New: Ajout constante MAIN_MAX_DECIMALS_SHOWN pour grer le nombre max de dcimal affichs (5 par dfaut).

Si le nb de dcimal dpasse, on limite  5 et on affiche ...  la suite.
This commit is contained in:
Laurent Destailleur 2007-04-01 23:04:24 +00:00
parent c95bdfa581
commit ad0e1f2c15
5 changed files with 155 additions and 112 deletions

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Jean Heimburger <jean@tiaris.info>
*
* This program is free software; you can redistribute it and/or modify
@ -25,6 +25,7 @@
/**
\file htdocs/conf/conf.class.php
\brief Fichier de la classe de stockage de la config courante
\remarks La config est stockée dans le fichier conf/conf.php
\version $Revision$
*/
@ -447,6 +448,12 @@ class Conf
$this->format_date_short_java="dd/MM/yyyy";
// Format montant affichés
if (! isset($this->global->MAIN_MAX_DECIMALS_SHOWN))
{
$this->global->MAIN_MAX_DECIMALS_SHOWN=5;
}
/* \todo Ajouter une option Gestion de la TVA dans le module compta qui permet de désactiver la fonction TVA
* (pour particuliers ou libéraux en franchise)
* En attendant, valeur forcée à 1

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.fr>
*
@ -218,13 +218,25 @@ if ($_GET['action'] == 'del_ligne')
}
// Modification d'une ligne
if ($_REQUEST['action'] == 'mod_ligne')
if ($_REQUEST['action'] == 'change_line')
{
if ($_REQUEST['etat'] == '1' && ! $_REQUEST['cancel']) // si on valide la modification
{
$facfou = new FactureFournisseur($db,'',$_GET['facid']);
$facfou->updateline($_GET['ligne_id'], $_POST['label'], $_POST['puht'], $_POST['tauxtva'], $_POST['qty']);
if ($_POST['idprod'])
{
$prod = new Product($db);
$prod->fetch($_POST['idprod']);
$label = $prod->libelle;
$facfou->updateline($_GET['ligne_id'], $label, $_POST['puht'], $_POST['tauxtva'], $_POST['qty'], $_POST['idprod']);
}
else
{
$facfou->updateline($_GET['ligne_id'], $_POST['label'], $_POST['puht'], $_POST['tauxtva'], $_POST['qty']);
}
}
}
@ -435,9 +447,9 @@ else
print '<tr><td valign="top">'.$langs->trans('Ref').'</td><td valign="top">';
print '<input name="facnumber" type="text" value="'.$fac->ref.'"></td>';
$rownb=8;
$rownb=9;
print '<td rowspan="'.$rownb.'" valign="top">';
print '<textarea name="note" wrap="soft" cols="60" rows="'.ROWS_8.'">';
print '<textarea name="note" wrap="soft" cols="60" rows="'.ROWS_9.'">';
print $fac->note;
print '</textarea></td></tr>';
@ -453,11 +465,9 @@ else
if (($fac->paye == 0) && ($fac->statut > 0) && $fac->date_echeance < (time() - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning");
print '</td></tr>';
print '<tr><td>'.$langs->trans('AmountHT').'</td>';
print '<td nowrap="nowrap">'.price($fac->total_ht).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountTTC').'</td>';
print '<td nowrap="nowrap">'.price($fac->total_ttc).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountHT').'</td><td nowrap="nowrap"><b>'.price($fac->total_ht).'</b></td></tr>';
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td nowrap="nowrap">'.price($fac->total_tva).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td nowrap="nowrap">'.price($fac->total_ttc).'</td></tr>';
print '<tr><td>'.$langs->trans('Status').'</td><td>'.$fac->getLibStatut(4).'</td></tr>';
print '<tr><td colspan="2" align="center">';
@ -556,7 +566,7 @@ else
print "</tr>\n";
// Societe
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.$societe->getNomUrl(1).'</a></td>';
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.$societe->getNomUrl(1).'</td>';
print '<td align="right"><a href="index.php?socid='.$fac->socid.'">'.$langs->trans('OtherBills').'</a></td>';
print '</tr>';
@ -688,14 +698,23 @@ else
// Ligne en modification
if ($fac->statut == 0 && $_GET['action'] == 'mod_ligne' && $_GET['etat'] == '0' && $_GET['ligne_id'] == $fac->lignes[$i]->rowid)
{
print '<form action="fiche.php?facid='.$fac->id.'&amp;action=mod_ligne&amp;etat=1&amp;ligne_id='.$fac->lignes[$i]->rowid.'" method="post">';
print '<input type="hidden" name="tauxtva" value="'.$fac->lignes[$i]->tva_taux.'">';
print '<form action="fiche.php?facid='.$fac->id.'&amp;etat=1&amp;ligne_id='.$fac->lignes[$i]->rowid.'" method="post">';
print '<input type="hidden" name="action" value="change_line">';
print '<tr '.$bc[$var].'>';
print '<td><input size="30" name="label" type="text" value="'.$fac->lignes[$i]->description.'"></td>';
print '<td>';
if ($conf->produit->enabled && $fac->lignes[$i]->fk_product)
{
$html->select_produits_fournisseurs($fac->socid,$fac->lignes[$i]->fk_product,'idprod',$filtre);
}
else
{
print '<input size="30" name="label" type="text" value="'.$fac->lignes[$i]->description.'">';
}
print '</td>';
print '<td align="right" nowrap="nowrap"><input size="6" name="puht" type="text" value="'.price($fac->lignes[$i]->pu_ht).'"></td>';
print '<td align="right" nowrap="nowrap">&nbsp;</td>';
print '<td align="right" nowrap="nowrap"><input size="6" name="amountttc" type="text" value=""></td>';
print '<td align="right"><input size="1" name="qty" type="text" value="'.$fac->lignes[$i]->qty.'"></td>';
print '<td align="right" nowrap="nowrap"><input size="6" name="totalht" type="text" value="'.price($fac->lignes[$i]->total_ht).'"></td>';
print '<td align="right" nowrap="nowrap">&nbsp;</td>';
print '<td align="right">';
$html->select_tva('tauxtva',$fac->lignes[$i]->tva_taux,$societe,$mysoc);
print '</td>';
@ -756,7 +775,7 @@ else
print '<td align="right">';
print '<input size="1" name="qty" type="text" value="1">';
print '</td>';
print '<td align="center">-</td>';
print '<td align="right">&nbsp;</td>';
print '<td align="right">';
$html->select_tva('tauxtva','',$societe,$mysoc);
print '</td><td align="center" colspan="2">';

View File

@ -305,7 +305,7 @@ if ($resql)
print '<tr class="liste_titre">';
print "<td>".$langs->trans("Company")."</td>\n";
print "<td>".$langs->trans("SupplierCode")."</td>\n";
print '<td align="center">'.$langs->trans("DateCreation")."</td>\n";
print '<td align="right">'.$langs->trans("DateCreation")."</td>\n";
print "</tr>\n";
$var=True;
@ -318,7 +318,7 @@ if ($resql)
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowSupplier"),"company").'</a>';
print "&nbsp;<a href=\"fiche.php?socid=$obj->idp\">$obj->nom</a></td>\n";
print '<td align="left">'.$obj->code_fournisseur.'&nbsp;</td>';
print '<td align="center">'.dolibarr_print_date($obj->datec).'</td>';
print '<td align="right">'.dolibarr_print_date($obj->datec,'day').'</td>';
print "</tr>\n";
}
print "</table>\n";

View File

@ -904,63 +904,68 @@ class Form
}
/**
\brief Retourne la liste des produits de fournisseurs
\param socid Id société (0 pour aucun filtre)
\param selected Produit présélectionné
\param htmlname Nom de la zone select
\param filtretype Pour filtre sur type de produit
\param limit Limite sur le nombre de lignes retournées
\param filtre Pour filtre
*/
function select_produits_fournisseurs($socid,$selected='',$htmlname='productid',$filtretype='',$filtre='')
{
global $langs,$conf;
$sql = "SELECT p.rowid, p.label, p.ref, p.price, pf.price as fprice, pf.quantity, p.duration";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pf ON p.rowid = pf.fk_product";
$sql.= " WHERE p.envente = 1";
if ($socid) $sql.= " AND pf.fk_soc = ".$socid;
if ($filtretype && $filtretype != '') $sql.=" AND p.fk_product_type=".$filtretype;
if ($filtre) $sql.="$filtre";
$sql.= " ORDER BY p.ref DESC";
dolibarr_syslog("Form::select_produits_fournisseurs sql=$sql",LOG_DEBUG);
$result=$this->db->query($sql);
if ($result)
{
print '<select class="flat" name="'.$htmlname.'">';
print "<option value=\"0\" selected=\"true\">&nbsp;</option>";
$num = $this->db->num_rows($result);
$i = 0;
while ($i < $num)
{
$objp = $this->db->fetch_object($result);
$opt = '<option value="'.$objp->rowid.'">'.$objp->ref.' - ';
$opt.= dolibarr_trunc($objp->label,24).' - ';
$opt.= $objp->fprice.$langs->trans("Currency".$conf->monnaie)."/".$objp->quantity.$langs->trans("Units");
if ($objp->quantity > 1)
{
$opt.=" - ";
$opt.= round($objp->fprice/$objp->quantity,4).$langs->trans("Currency".$conf->monnaie)."/".$langs->trans("Unit");
}
if ($objp->duration) $opt .= " - ".$objp->duration;
$opt .= "</option>\n";
print $opt;
$i++;
}
print '</select>';
$this->db->free($result);
}
else
{
dolibarr_print_error($db);
}
}
/**
\brief Retourne la liste des produits de fournisseurs
\param socid Id société (0 pour aucun filtre)
\param selected Produit présélectionné
\param htmlname Nom de la zone select
\param filtretype Pour filtre sur type de produit
\param limit Limite sur le nombre de lignes retournées
\param filtre Pour filtre
*/
function select_produits_fournisseurs($socid,$selected='',$htmlname='productid',$filtretype='',$filtre='')
{
global $langs,$conf;
$sql = "SELECT p.rowid, p.label, p.ref, p.price, pf.price as fprice, pf.quantity, p.duration";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pf ON p.rowid = pf.fk_product";
$sql.= " WHERE p.envente = 1";
if ($socid) $sql.= " AND pf.fk_soc = ".$socid;
if ($filtretype && $filtretype != '') $sql.=" AND p.fk_product_type=".$filtretype;
if ($filtre) $sql.="$filtre";
$sql.= " ORDER BY p.ref DESC";
dolibarr_syslog("Form::select_produits_fournisseurs sql=$sql",LOG_DEBUG);
$result=$this->db->query($sql);
if ($result)
{
print '<select class="flat" name="'.$htmlname.'">';
if (! $selected) print '<option value="0" selected="true">&nbsp;</option>';
else print '<option value="0">&nbsp;</option>';
$num = $this->db->num_rows($result);
$i = 0;
while ($i < $num)
{
$objp = $this->db->fetch_object($result);
$opt = '<option value="'.$objp->rowid.'"';
if ($selected == $objp->rowid) $opt.= ' selected="true"';
$opt.= '>'.$objp->ref.' - ';
$opt.= dolibarr_trunc($objp->label,24).' - ';
$opt.= $objp->fprice.$langs->trans("Currency".$conf->monnaie)."/".$objp->quantity.$langs->trans("Units");
if ($objp->quantity > 1)
{
$opt.=" - ";
$opt.= round($objp->fprice/$objp->quantity,4).$langs->trans("Currency".$conf->monnaie)."/".$langs->trans("Unit");
}
if ($objp->duration) $opt .= " - ".$objp->duration;
$opt .= "</option>\n";
print $opt;
$i++;
}
print '</select>';
$this->db->free($result);
}
else
{
dolibarr_print_error($db);
}
}
/**
* \brief Retourne la liste déroulante des adresses de livraison

View File

@ -1819,49 +1819,61 @@ function print_fleche_navigation($page,$file,$options='',$nextpage)
/**
\brief Fonction qui retourne un montant monétaire formaté
\remarks Fonction utilisée dans les pdf et les pages html
\param amount Montant a formater
\param html Formatage html ou pas (0 par defaut)
\param outlangs Objet langs pour formatage
\seealso price2num Fonction inverse de price
* \brief Fonction qui retourne un montant monétaire formaté
* \remarks Fonction utilisée dans les pdf et les pages html
* \param amount Montant a formater
* \param html Formatage html ou pas (0 par defaut)
* \param outlangs Objet langs pour formatage
* \return string Chaine avec montant formaté
* \seealso price2num Fonction inverse de price
*/
function price($amount, $html=0, $outlangs='')
{
global $langs;
global $langs,$conf;
// Separateurs par defaut
$dec='.'; $thousand=' ';
// Si $outlangs non force, on prend langue utilisateur
if (! is_object($outlangs)) $outlangs=$langs;
if ($outlangs->trans("SeparatorDecimal") != "SeparatorDecimal") $dec=$outlangs->trans("SeparatorDecimal");
if ($outlangs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$outlangs->trans("SeparatorThousand");
//print "dec=".$dec." thousand=".$thousand;
// Separateurs par defaut
$dec='.'; $thousand=' ';
// On pose par defaut 2 decimales
$decimal = 2;
//print "xx".$amount."-";
$amount = ereg_replace(',','.',$amount);
//print $amount."-";
$datas = split("\.",$amount);
$decpart = $datas[1];
//print $datas[1]."<br>";
// Si $outlangs non force, on prend langue utilisateur
if (! is_object($outlangs)) $outlangs=$langs;
// On augmente au besoin si il y a plus de 2 décimales
if (strlen($decpart) > 2) $decimal=strlen($decpart);
if ($outlangs->trans("SeparatorDecimal") != "SeparatorDecimal") $dec=$outlangs->trans("SeparatorDecimal");
if ($outlangs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$outlangs->trans("SeparatorThousand");
//print "dec=".$dec." thousand=".$thousand;
// Formate nombre
if ($html)
{
return ereg_replace(' ','&nbsp;',number_format($amount, $decimal, $dec, $thousand));
}
else
{
return number_format($amount, $decimal, $dec, $thousand);
}
//print "xx".$amount."-";
$amount = ereg_replace(',','.',$amount);
//print $amount."-";
$datas = split("\.",$amount);
$decpart = $datas[1];
//print $datas[1]."<br>";
// On pose par defaut 2 decimales
$decimal = 2;
$end='';
// On augmente au besoin si il y a plus de 2 décimales
if (strlen($decpart) > $decimal) $decimal=strlen($decpart);
// Si on depasse max
if ($decimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN)
{
$decimal=$conf->global->MAIN_MAX_DECIMALS_SHOWN;
$end='...';
}
// Formate nombre
if ($html)
{
$output=ereg_replace(' ','&nbsp;',number_format($amount, $decimal, $dec, $thousand));
}
else
{
$output=number_format($amount, $decimal, $dec, $thousand);
}
$output.=$end;
return $output;
}
/**
\brief Fonction qui retourne un numérique depuis un montant formaté
\remarks Fonction à appeler sur montants saisi avant un insert