From 126356f87c560691634d578be02fa1c53b03622a Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Wed, 8 Oct 2003 22:59:52 +0000 Subject: [PATCH] =?UTF-8?q?Gestion=20des=20remises=20dans=20l'ajout=20des?= =?UTF-8?q?=20produits=20g=E9n=E9riques?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/propal.class.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php index e2c1bc3e3b5..ad99bce0ab9 100644 --- a/htdocs/propal.class.php +++ b/htdocs/propal.class.php @@ -108,13 +108,27 @@ class Propal * * */ - Function insert_product_generic($p_desc, $p_price, $p_qty, $p_tva_tx=19.6) + Function insert_product_generic($p_desc, $p_price, $p_qty, $p_tva_tx=19.6, $remise_percent=0) { if ($this->statut == 0) { + if (strlen(trim($p_qty)) == 0) + { + $p_qty = 1; + } + $p_price = ereg_replace(",",".",$p_price); - $sql = "INSERT INTO llx_propaldet (fk_propal, fk_product, qty, price, tva_tx, description) VALUES "; - $sql .= " (".$this->id.", 0,". $p_qty.",". $p_price.",".$p_tva_tx.",'".$p_desc."') ; "; + + $price = $p_price; + $subprice = $p_price; + if ($remise_percent > 0) + { + $remise = round(($p_price * $remise_percent / 100), 2); + $price = $p_price - $remise; + } + + $sql = "INSERT INTO llx_propaldet (fk_propal, fk_product, qty, price, tva_tx, description, remise_percent, subprice) VALUES "; + $sql .= " (".$this->id.", 0,". $p_qty.",". $price.",".$p_tva_tx.",'".$p_desc."',$remise_percent, $subprice) ; "; if ($this->db->query($sql) ) {