2
0
forked from Wavyzz/dolibarr

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

View File

@@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* 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) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.fr> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.fr>
* *
@@ -218,13 +218,25 @@ if ($_GET['action'] == 'del_ligne')
} }
// Modification d'une 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 if ($_REQUEST['etat'] == '1' && ! $_REQUEST['cancel']) // si on valide la modification
{ {
$facfou = new FactureFournisseur($db,'',$_GET['facid']); $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 '<tr><td valign="top">'.$langs->trans('Ref').'</td><td valign="top">';
print '<input name="facnumber" type="text" value="'.$fac->ref.'"></td>'; print '<input name="facnumber" type="text" value="'.$fac->ref.'"></td>';
$rownb=8; $rownb=9;
print '<td rowspan="'.$rownb.'" valign="top">'; 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 $fac->note;
print '</textarea></td></tr>'; 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"); 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 '</td></tr>';
print '<tr><td>'.$langs->trans('AmountHT').'</td>'; print '<tr><td>'.$langs->trans('AmountHT').'</td><td nowrap="nowrap"><b>'.price($fac->total_ht).'</b></td></tr>';
print '<td nowrap="nowrap">'.price($fac->total_ht).'</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('AmountTTC').'</td>';
print '<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>'.$langs->trans('Status').'</td><td>'.$fac->getLibStatut(4).'</td></tr>';
print '<tr><td colspan="2" align="center">'; print '<tr><td colspan="2" align="center">';
@@ -556,7 +566,7 @@ else
print "</tr>\n"; print "</tr>\n";
// Societe // 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 '<td align="right"><a href="index.php?socid='.$fac->socid.'">'.$langs->trans('OtherBills').'</a></td>';
print '</tr>'; print '</tr>';
@@ -688,14 +698,23 @@ else
// Ligne en modification // Ligne en modification
if ($fac->statut == 0 && $_GET['action'] == 'mod_ligne' && $_GET['etat'] == '0' && $_GET['ligne_id'] == $fac->lignes[$i]->rowid) 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 '<form action="fiche.php?facid='.$fac->id.'&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 '<input type="hidden" name="action" value="change_line">';
print '<tr '.$bc[$var].'>'; 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"><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"><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">'; print '<td align="right">';
$html->select_tva('tauxtva',$fac->lignes[$i]->tva_taux,$societe,$mysoc); $html->select_tva('tauxtva',$fac->lignes[$i]->tva_taux,$societe,$mysoc);
print '</td>'; print '</td>';
@@ -756,7 +775,7 @@ else
print '<td align="right">'; print '<td align="right">';
print '<input size="1" name="qty" type="text" value="1">'; print '<input size="1" name="qty" type="text" value="1">';
print '</td>'; print '</td>';
print '<td align="center">-</td>'; print '<td align="right">&nbsp;</td>';
print '<td align="right">'; print '<td align="right">';
$html->select_tva('tauxtva','',$societe,$mysoc); $html->select_tva('tauxtva','',$societe,$mysoc);
print '</td><td align="center" colspan="2">'; print '</td><td align="center" colspan="2">';

View File

@@ -305,7 +305,7 @@ if ($resql)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print "<td>".$langs->trans("Company")."</td>\n"; print "<td>".$langs->trans("Company")."</td>\n";
print "<td>".$langs->trans("SupplierCode")."</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"; print "</tr>\n";
$var=True; $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 '<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 "&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="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 "</tr>\n";
} }
print "</table>\n"; print "</table>\n";

View File

@@ -904,63 +904,68 @@ class Form
} }
/** /**
\brief Retourne la liste des produits de fournisseurs \brief Retourne la liste des produits de fournisseurs
\param socid Id soci<63>t<EFBFBD> (0 pour aucun filtre) \param socid Id soci<63>t<EFBFBD> (0 pour aucun filtre)
\param selected Produit pr<70>s<EFBFBD>lectionn<6E> \param selected Produit pr<70>s<EFBFBD>lectionn<6E>
\param htmlname Nom de la zone select \param htmlname Nom de la zone select
\param filtretype Pour filtre sur type de produit \param filtretype Pour filtre sur type de produit
\param limit Limite sur le nombre de lignes retourn<72>es \param limit Limite sur le nombre de lignes retourn<72>es
\param filtre Pour filtre \param filtre Pour filtre
*/ */
function select_produits_fournisseurs($socid,$selected='',$htmlname='productid',$filtretype='',$filtre='') function select_produits_fournisseurs($socid,$selected='',$htmlname='productid',$filtretype='',$filtre='')
{ {
global $langs,$conf; global $langs,$conf;
$sql = "SELECT p.rowid, p.label, p.ref, p.price, pf.price as fprice, pf.quantity, p.duration"; $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.= " 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.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pf ON p.rowid = pf.fk_product";
$sql.= " WHERE p.envente = 1"; $sql.= " WHERE p.envente = 1";
if ($socid) $sql.= " AND pf.fk_soc = ".$socid; if ($socid) $sql.= " AND pf.fk_soc = ".$socid;
if ($filtretype && $filtretype != '') $sql.=" AND p.fk_product_type=".$filtretype; if ($filtretype && $filtretype != '') $sql.=" AND p.fk_product_type=".$filtretype;
if ($filtre) $sql.="$filtre"; if ($filtre) $sql.="$filtre";
$sql.= " ORDER BY p.ref DESC"; $sql.= " ORDER BY p.ref DESC";
dolibarr_syslog("Form::select_produits_fournisseurs sql=$sql",LOG_DEBUG); dolibarr_syslog("Form::select_produits_fournisseurs sql=$sql",LOG_DEBUG);
$result=$this->db->query($sql); $result=$this->db->query($sql);
if ($result) if ($result)
{ {
print '<select class="flat" name="'.$htmlname.'">'; print '<select class="flat" name="'.$htmlname.'">';
print "<option value=\"0\" selected=\"true\">&nbsp;</option>"; 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; $num = $this->db->num_rows($result);
while ($i < $num) $i = 0;
{ while ($i < $num)
$objp = $this->db->fetch_object($result); {
$opt = '<option value="'.$objp->rowid.'">'.$objp->ref.' - '; $objp = $this->db->fetch_object($result);
$opt.= dolibarr_trunc($objp->label,24).' - ';
$opt.= $objp->fprice.$langs->trans("Currency".$conf->monnaie)."/".$objp->quantity.$langs->trans("Units"); $opt = '<option value="'.$objp->rowid.'"';
if ($objp->quantity > 1) if ($selected == $objp->rowid) $opt.= ' selected="true"';
{ $opt.= '>'.$objp->ref.' - ';
$opt.=" - "; $opt.= dolibarr_trunc($objp->label,24).' - ';
$opt.= round($objp->fprice/$objp->quantity,4).$langs->trans("Currency".$conf->monnaie)."/".$langs->trans("Unit"); $opt.= $objp->fprice.$langs->trans("Currency".$conf->monnaie)."/".$objp->quantity.$langs->trans("Units");
} if ($objp->quantity > 1)
if ($objp->duration) $opt .= " - ".$objp->duration; {
$opt .= "</option>\n"; $opt.=" - ";
print $opt; $opt.= round($objp->fprice/$objp->quantity,4).$langs->trans("Currency".$conf->monnaie)."/".$langs->trans("Unit");
$i++; }
} if ($objp->duration) $opt .= " - ".$objp->duration;
print '</select>'; $opt .= "</option>\n";
$this->db->free($result); print $opt;
} $i++;
else }
{ print '</select>';
dolibarr_print_error($db);
} $this->db->free($result);
} }
else
{
dolibarr_print_error($db);
}
}
/** /**
* \brief Retourne la liste d<>roulante des adresses de livraison * \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<6F>taire format<61> * \brief Fonction qui retourne un montant mon<6F>taire format<61>
\remarks Fonction utilis<69>e dans les pdf et les pages html * \remarks Fonction utilis<69>e dans les pdf et les pages html
\param amount Montant a formater * \param amount Montant a formater
\param html Formatage html ou pas (0 par defaut) * \param html Formatage html ou pas (0 par defaut)
\param outlangs Objet langs pour formatage * \param outlangs Objet langs pour formatage
\seealso price2num Fonction inverse de price * \return string Chaine avec montant format<61>
* \seealso price2num Fonction inverse de price
*/ */
function price($amount, $html=0, $outlangs='') function price($amount, $html=0, $outlangs='')
{ {
global $langs; global $langs,$conf;
// Separateurs par defaut // Separateurs par defaut
$dec='.'; $thousand=' '; $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;
// On pose par defaut 2 decimales // Si $outlangs non force, on prend langue utilisateur
$decimal = 2; if (! is_object($outlangs)) $outlangs=$langs;
//print "xx".$amount."-";
$amount = ereg_replace(',','.',$amount);
//print $amount."-";
$datas = split("\.",$amount);
$decpart = $datas[1];
//print $datas[1]."<br>";
// On augmente au besoin si il y a plus de 2 d<>cimales if ($outlangs->trans("SeparatorDecimal") != "SeparatorDecimal") $dec=$outlangs->trans("SeparatorDecimal");
if (strlen($decpart) > 2) $decimal=strlen($decpart); if ($outlangs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$outlangs->trans("SeparatorThousand");
//print "dec=".$dec." thousand=".$thousand;
// Formate nombre //print "xx".$amount."-";
if ($html) $amount = ereg_replace(',','.',$amount);
{ //print $amount."-";
return ereg_replace(' ','&nbsp;',number_format($amount, $decimal, $dec, $thousand)); $datas = split("\.",$amount);
} $decpart = $datas[1];
else //print $datas[1]."<br>";
{
return number_format($amount, $decimal, $dec, $thousand); // 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<75>rique depuis un montant format<61> \brief Fonction qui retourne un num<75>rique depuis un montant format<61>
\remarks Fonction <20> appeler sur montants saisi avant un insert \remarks Fonction <20> appeler sur montants saisi avant un insert