From 7ce4375fc959734ad18f7d540076a28a15b21271 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2006 22:49:10 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20bug=20#16894=20overview:=20Probl=E8me=20?= =?UTF-8?q?avec=20les=20lignes=20produits=20libre=20de=20propal=20vers=20c?= =?UTF-8?q?ommande?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/commande/commande.class.php | 28 +++++++++++++++++++++++----- htdocs/commande/fiche.php | 2 ++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index b324092ebd7..0435e5c403e 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -547,21 +547,40 @@ class Commande extends CommonObject /** - * Ajoute un produit dans la commande - * + * \brief Ajoute une ligne produit prédéfini dans tableau lines + * \param idproduct Id du produit à ajouter + * \param qty Quantité + * \remise_percent remise_percent Remise ligne en pourcentage + * \remarks $this->client doit etre chargé */ function add_product($idproduct, $qty, $remise_percent=0) { global $conf; - if (!$qty) $qty = 1 ; + if (!$qty) $qty = 1; if ($idproduct > 0) { + $prod=new Product($this->db); + $prod->fetch($idproduct); + + $tva_tx = get_default_tva($mysoc,$this->client,$prod->tva_tx); + // multiprix + if($conf->global->PRODUIT_MULTIPRICES == 1) + $price = $prod->multiprices[$this->client->price_level]; + else + $price = $prod->price; + $ligne=new CommandeLigne($this->db); $ligne->fk_product=$idproduct; + $ligne->desc=$prod->description; $ligne->qty=$qty; + $ligne->price=$price; $ligne->remise_percent=$remise_percent; + $ligne->tva_tx=$tva_tx; + $ligne->ref=$prod->ref; + $ligne->libelle=$prod->libelle; + $ligne->product_desc=$prod->description; $i = sizeof($this->lines); $this->lines[$i] = $ligne; @@ -1825,13 +1844,12 @@ class CommandeLigne var $rowid; var $fk_facture; var $desc; // Description ligne - var $qty; var $tva_tx; + var $price; var $subprice; var $remise; var $remise_percent; - var $price; var $rang; var $coef; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index b8249add356..d969221eb8b 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -103,6 +103,8 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer) $commande->date_livraison = $datelivraison; $commande->adresse_livraison_id = $_POST['adresse_livraison_id']; + $commande->fetch_client(); + $commande->add_product($_POST['idprod1'],$_POST['qty1'],$_POST['remise_percent1']); $commande->add_product($_POST['idprod2'],$_POST['qty2'],$_POST['remise_percent2']); $commande->add_product($_POST['idprod3'],$_POST['qty3'],$_POST['remise_percent3']);