diff --git a/htdocs/conf/conf.class.php b/htdocs/conf/conf.class.php index 1a047e90a2a..1d5969b9bec 100644 --- a/htdocs/conf/conf.class.php +++ b/htdocs/conf/conf.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Xavier Dutoit - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2006 Jean Heimburger * * 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 diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index cd1e33e5393..98b0713a20a 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005 Marc Barilley / Ocebo * @@ -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 ''.$langs->trans('Ref').''; print ''; - $rownb=8; + $rownb=9; print ''; - print ''; @@ -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 ''; - print ''.$langs->trans('AmountHT').''; - print ''.price($fac->total_ht).''; - - print ''.$langs->trans('AmountTTC').''; - print ''.price($fac->total_ttc).''; + print ''.$langs->trans('AmountHT').''.price($fac->total_ht).''; + print ''.$langs->trans('AmountVAT').''.price($fac->total_tva).''; + print ''.$langs->trans('AmountTTC').''.price($fac->total_ttc).''; print ''.$langs->trans('Status').''.$fac->getLibStatut(4).''; print ''; @@ -556,7 +566,7 @@ else print "\n"; // Societe - print ''.$langs->trans('Company').''.$societe->getNomUrl(1).''; + print ''.$langs->trans('Company').''.$societe->getNomUrl(1).''; print ''.$langs->trans('OtherBills').''; print ''; @@ -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 '
'; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; + if ($conf->produit->enabled && $fac->lignes[$i]->fk_product) + { + $html->select_produits_fournisseurs($fac->socid,$fac->lignes[$i]->fk_product,'idprod',$filtre); + } + else + { + print ''; + } + print ''; print ''; - print ' '; + print ''; print ''; - print ''; + print ' '; print ''; $html->select_tva('tauxtva',$fac->lignes[$i]->tva_taux,$societe,$mysoc); print ''; @@ -756,7 +775,7 @@ else print ''; print ''; print ''; - print '-'; + print ' '; print ''; $html->select_tva('tauxtva','',$societe,$mysoc); print ''; diff --git a/htdocs/fourn/index.php b/htdocs/fourn/index.php index 22d70e2c4c1..528331e0fcd 100644 --- a/htdocs/fourn/index.php +++ b/htdocs/fourn/index.php @@ -305,7 +305,7 @@ if ($resql) print ''; print "".$langs->trans("Company")."\n"; print "".$langs->trans("SupplierCode")."\n"; - print ''.$langs->trans("DateCreation")."\n"; + print ''.$langs->trans("DateCreation")."\n"; print "\n"; $var=True; @@ -318,7 +318,7 @@ if ($resql) print ''.img_object($langs->trans("ShowSupplier"),"company").''; print " idp\">$obj->nom\n"; print ''.$obj->code_fournisseur.' '; - print ''.dolibarr_print_date($obj->datec).''; + print ''.dolibarr_print_date($obj->datec,'day').''; print "\n"; } print "\n"; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index d7e9f03e446..31b063e2b35 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -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 ''; - - $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 ''; + + $this->db->free($result); + } + else + { + dolibarr_print_error($db); + } + } /** * \brief Retourne la liste déroulante des adresses de livraison diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 969c016444e..98abeeed1c3 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -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]."
"; + // 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(' ',' ',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]."
"; + + // 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(' ',' ',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