diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index b1d5ee46ec9..1da32dc9b43 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -63,10 +63,10 @@ if ($HTTP_POST_VARS["action"] == 'add') if (!$HTTP_POST_VARS["propalid"]) { - $facture->add_product($HTTP_POST_VARS["idprod1"],$HTTP_POST_VARS["qty1"]); - $facture->add_product($HTTP_POST_VARS["idprod2"],$HTTP_POST_VARS["qty2"]); - $facture->add_product($HTTP_POST_VARS["idprod3"],$HTTP_POST_VARS["qty3"]); - $facture->add_product($HTTP_POST_VARS["idprod4"],$HTTP_POST_VARS["qty4"]); + $facture->add_product($HTTP_POST_VARS["idprod1"],$HTTP_POST_VARS["qty1"],$HTTP_POST_VARS["remise_percent1"]); + $facture->add_product($HTTP_POST_VARS["idprod2"],$HTTP_POST_VARS["qty2"],$HTTP_POST_VARS["remise_percent2"]); + $facture->add_product($HTTP_POST_VARS["idprod3"],$HTTP_POST_VARS["qty3"],$HTTP_POST_VARS["remise_percent3"]); + $facture->add_product($HTTP_POST_VARS["idprod4"],$HTTP_POST_VARS["qty4"],$HTTP_POST_VARS["remise_percent4"]); $facid = $facture->create($user); } @@ -428,11 +428,12 @@ if ($action == 'create') } print ''; - + print ''; for ($i = 1 ; $i < 5 ; $i++) { print ''; - print ''; + print ''; + print ''; } print '
ProduitQuan.Remise
%
'; diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 6640a738029..681bd70fa04 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -136,10 +136,16 @@ class Facture $prod = new Product($this->db, $this->products[$i]); $prod->fetch($this->products[$i]); - $sql = "INSERT INTO llx_facturedet (fk_facture, fk_product, qty, price, tva_taux, description) VALUES "; - $sql .= " ($this->id,".$this->products[$i].",".$this->products_qty[$i].",$prod->price,$prod->tva_tx,'".addslashes($prod->libelle)."');"; - - if (! $this->db->query($sql) ) + $result_insert = $this->addline($this->id, + $prod->libelle, + $prod->price, + $this->products_qty[$i], + $prod->tva_tx, + $this->products[$i], + $this->products_remise_percent[$i]); + + + if ( $result_insert < 0) { print $sql . '
' . $this->db->error() .'
'; } @@ -402,7 +408,7 @@ class Facture * Ajoute un produit dans la facture * */ - Function add_product($idproduct, $qty) + Function add_product($idproduct, $qty, $remise_percent) { if ($idproduct > 0) { @@ -413,6 +419,7 @@ class Facture $qty = 1 ; } $this->products_qty[$i] = $qty; + $this->products_remise_percent[$i] = $remise_percent; } } /**