Fix: bug #16894 overview: Problème avec les lignes produits libre de propal vers commande

This commit is contained in:
Laurent Destailleur 2006-06-20 22:49:10 +00:00
parent e39a795a8d
commit 7ce4375fc9
2 changed files with 25 additions and 5 deletions

View File

@ -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) function add_product($idproduct, $qty, $remise_percent=0)
{ {
global $conf; global $conf;
if (!$qty) $qty = 1 ; if (!$qty) $qty = 1;
if ($idproduct > 0) 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=new CommandeLigne($this->db);
$ligne->fk_product=$idproduct; $ligne->fk_product=$idproduct;
$ligne->desc=$prod->description;
$ligne->qty=$qty; $ligne->qty=$qty;
$ligne->price=$price;
$ligne->remise_percent=$remise_percent; $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); $i = sizeof($this->lines);
$this->lines[$i] = $ligne; $this->lines[$i] = $ligne;
@ -1825,13 +1844,12 @@ class CommandeLigne
var $rowid; var $rowid;
var $fk_facture; var $fk_facture;
var $desc; // Description ligne var $desc; // Description ligne
var $qty; var $qty;
var $tva_tx; var $tva_tx;
var $price;
var $subprice; var $subprice;
var $remise; var $remise;
var $remise_percent; var $remise_percent;
var $price;
var $rang; var $rang;
var $coef; var $coef;

View File

@ -103,6 +103,8 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
$commande->date_livraison = $datelivraison; $commande->date_livraison = $datelivraison;
$commande->adresse_livraison_id = $_POST['adresse_livraison_id']; $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['idprod1'],$_POST['qty1'],$_POST['remise_percent1']);
$commande->add_product($_POST['idprod2'],$_POST['qty2'],$_POST['remise_percent2']); $commande->add_product($_POST['idprod2'],$_POST['qty2'],$_POST['remise_percent2']);
$commande->add_product($_POST['idprod3'],$_POST['qty3'],$_POST['remise_percent3']); $commande->add_product($_POST['idprod3'],$_POST['qty3'],$_POST['remise_percent3']);