From 7e7c3b4f47146f083a19c57fe4a36ee7dd428445 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 6 Sep 2005 01:20:13 +0000 Subject: [PATCH] =?UTF-8?q?Qual:=20Nettoyage=20des=20param=E8tres=20avant?= =?UTF-8?q?=20traitement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/facture.class.php | 52 ++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 27e6e88a17a..33ed8453b5c 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -896,33 +896,17 @@ class Facture */ function addline($facid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $datestart='', $dateend='', $ventil = 0) { + dolibarr_syslog("facture.class.php::addline($facid,$desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$datestart,$dateend,$ventil)"); if ($this->brouillon) { - - /* Lecture du rang max de la facture */ - - $sql = "SELECT max(rang) FROM ".MAIN_DB_PREFIX."facturedet"; - $sql .= " WHERE fk_facture =".$facid; - $resql = $this->db->query($sql); - - if ($resql) - { - $row = $this->db->fetch_row($resql); - $rangmax = $row[0]; - } - - /* -- */ - - if (strlen(trim($qty))==0) - { - $qty=1; - } + // Nettoyage paramètres + if (strlen(trim($qty))==0) $qty=1; $remise = 0; $_price = $pu; $subprice = $pu; - + $remise_percent = trim($remise_percent); - + if ($this->socidp) { $soc = new Societe($this->db); @@ -933,29 +917,39 @@ class Facture $remise_percent = $remise_client ; } } - + if ($remise_percent > 0) { $remise = ($pu * $remise_percent / 100); $_price = ($pu - $remise); } - - /* Formatage des prix */ + + // Lecture du rang max de la facture + $sql = "SELECT max(rang) FROM ".MAIN_DB_PREFIX."facturedet"; + $sql .= " WHERE fk_facture =".$facid; + $resql = $this->db->query($sql); + if ($resql) + { + $row = $this->db->fetch_row($resql); + $rangmax = $row[0]; + } + + // Formatage des prix $_price = ereg_replace(",",".",$_price); $subprice = ereg_replace(",",".",$subprice); - + $sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet "; $sql .= " (fk_facture,description,price,qty,tva_taux, fk_product, remise_percent, subprice, remise, date_start, date_end, fk_code_ventilation, rang)"; $sql .= " VALUES ($facid, '".addslashes($desc)."','$_price','$qty','$txtva',$fk_product,'$remise_percent','$subprice','$remise', "; - + if ($datestart) { $sql.= "'$datestart', "; } else { $sql.=" null, "; } if ($dateend) { $sql.= "'$dateend' "; } else { $sql.=" null "; } - - $sql .= ",".$ventil; + + $sql .= ",".$ventil; $sql .=",".($rangmax + 1).")"; - + if ( $this->db->query( $sql) ) { $this->updateprice($facid);