Fix: uniformize code

Fix: services do not stock
This commit is contained in:
Regis Houssin 2010-01-30 07:45:57 +00:00
parent a54e98ed23
commit 7d10f8533e
8 changed files with 190 additions and 159 deletions

View File

@ -80,7 +80,7 @@ $com->note = 'A comment';
$com->source = 1;
$com->remise_percent = 0;
$orderline1=new CommandeLigne($db);
$orderline1=new OrderLine($db);
$orderline1->tva_tx=10.0;
$orderline1->remise_percent=0;
$orderline1->qty=1;

View File

@ -120,19 +120,21 @@ class Commande extends CommonObject
$this->source = 0;
for ($i = 0 ; $i < sizeof($propal->lignes) ; $i++)
{
$CommLigne = new CommandeLigne($this->db);
$CommLigne->libelle = $propal->lignes[$i]->libelle;
$CommLigne->desc = $propal->lignes[$i]->desc;
$CommLigne->price = $propal->lignes[$i]->price;
$CommLigne->subprice = $propal->lignes[$i]->subprice;
$CommLigne->tva_tx = $propal->lignes[$i]->tva_tx;
$CommLigne->qty = $propal->lignes[$i]->qty;
$CommLigne->fk_remise_except = $propal->lignes[$i]->fk_remise_except;
$CommLigne->remise_percent = $propal->lignes[$i]->remise_percent;
$CommLigne->fk_product = $propal->lignes[$i]->fk_product;
$CommLigne->info_bits = $propal->lignes[$i]->info_bits;
$CommLigne->product_type = $propal->lignes[$i]->product_type;
$this->lines[$i] = $CommLigne;
$line = new OrderLine($this->db);
$line->libelle = $propal->lignes[$i]->libelle;
$line->desc = $propal->lignes[$i]->desc;
$line->price = $propal->lignes[$i]->price;
$line->subprice = $propal->lignes[$i]->subprice;
$line->tva_tx = $propal->lignes[$i]->tva_tx;
$line->qty = $propal->lignes[$i]->qty;
$line->fk_remise_except = $propal->lignes[$i]->fk_remise_except;
$line->remise_percent = $propal->lignes[$i]->remise_percent;
$line->fk_product = $propal->lignes[$i]->fk_product;
$line->info_bits = $propal->lignes[$i]->info_bits;
$line->product_type = $propal->lignes[$i]->product_type;
$this->lines[$i] = $line;
}
$this->socid = $propal->socid;
@ -797,31 +799,31 @@ class Commande extends CommonObject
}
// Insert line
$ligne=new CommandeLigne($this->db);
$line=new OrderLine($this->db);
$ligne->fk_commande=$commandeid;
$ligne->desc=$desc;
$ligne->qty=$qty;
$ligne->tva_tx=$txtva;
$ligne->fk_product=$fk_product;
$ligne->fk_remise_except=$fk_remise_except;
$ligne->remise_percent=$remise_percent;
$ligne->subprice=$pu_ht;
$ligne->rang=-1;
$ligne->info_bits=$info_bits;
$ligne->total_ht=$total_ht;
$ligne->total_tva=$total_tva;
$ligne->total_ttc=$total_ttc;
$ligne->product_type=$type;
$line->fk_commande=$commandeid;
$line->desc=$desc;
$line->qty=$qty;
$line->tva_tx=$txtva;
$line->fk_product=$fk_product;
$line->fk_remise_except=$fk_remise_except;
$line->remise_percent=$remise_percent;
$line->subprice=$pu_ht;
$line->rang=-1;
$line->info_bits=$info_bits;
$line->total_ht=$total_ht;
$line->total_tva=$total_tva;
$line->total_ttc=$total_ttc;
$line->product_type=$type;
// \TODO Ne plus utiliser
$ligne->price=$price;
$ligne->remise=$remise;
$line->price=$price;
$line->remise=$remise;
$ligne->date_start=$date_start;
$ligne->date_end=$date_end;
$line->date_start=$date_start;
$line->date_end=$date_end;
$result=$ligne->insert();
$result=$line->insert();
if ($result > 0)
{
// Mise a jour informations denormalisees au niveau de la commande meme
@ -840,7 +842,7 @@ class Commande extends CommonObject
}
else
{
$this->error=$ligne->error;
$this->error=$line->error;
dol_syslog("Commande::addline error=".$this->error, LOG_ERR);
$this->db->rollback();
return -2;
@ -879,7 +881,8 @@ class Commande extends CommonObject
else
$price = $prod->price;
$line=new CommandeLigne($this->db);
$line=new OrderLine($this->db);
$line->fk_product=$idproduct;
$line->desc=$prod->description;
$line->qty=$qty;
@ -1063,25 +1066,26 @@ class Commande extends CommonObject
return -5;
}
$comligne=new CommandeLigne($this->db);
$comligne->fk_commande=$this->id;
$comligne->fk_remise_except=$remise->id;
$comligne->desc=$remise->description; // Description ligne
$comligne->tva_tx=$remise->tva_tx;
$comligne->subprice=-$remise->amount_ht;
$comligne->price=-$remise->amount_ht;
$comligne->fk_product=0; // Id produit predefini
$comligne->qty=1;
$comligne->remise=0;
$comligne->remise_percent=0;
$comligne->rang=-1;
$comligne->info_bits=2;
$line = new OrderLine($this->db);
$line->fk_commande=$this->id;
$line->fk_remise_except=$remise->id;
$line->desc=$remise->description; // Description ligne
$line->tva_tx=$remise->tva_tx;
$line->subprice=-$remise->amount_ht;
$line->price=-$remise->amount_ht;
$line->fk_product=0; // Id produit predefini
$line->qty=1;
$line->remise=0;
$line->remise_percent=0;
$line->rang=-1;
$line->info_bits=2;
$comligne->total_ht = -$remise->amount_ht;
$comligne->total_tva = -$remise->amount_tva;
$comligne->total_ttc = -$remise->amount_ttc;
$line->total_ht = -$remise->amount_ht;
$line->total_tva = -$remise->amount_tva;
$line->total_ttc = -$remise->amount_ttc;
$result=$comligne->insert();
$result=$line->insert();
if ($result > 0)
{
$result=$this->update_price();
@ -1098,7 +1102,7 @@ class Commande extends CommonObject
}
else
{
$this->error=$comligne->error;
$this->error=$line->error;
$this->db->rollback();
return -2;
}
@ -1114,7 +1118,7 @@ class Commande extends CommonObject
/**
* \brief Reinitialize array lignes
* \param only_product Return only physical products
* \return array Array of CommandeLigne
* \return array Array of OrderLine
*/
function fetch_lines($only_product=0)
{
@ -1142,38 +1146,39 @@ class Commande extends CommonObject
{
$objp = $this->db->fetch_object($result);
$ligne = new CommandeLigne($this->db);
$ligne->rowid = $objp->rowid; // \deprecated
$ligne->id = $objp->rowid;
$ligne->fk_commande = $objp->fk_commande;
$ligne->commande_id = $objp->fk_commande; // \deprecated
$ligne->desc = $objp->description; // Description ligne
$ligne->product_type = $objp->product_type;
$ligne->qty = $objp->qty;
$ligne->tva_tx = $objp->tva_tx;
$ligne->total_ht = $objp->total_ht;
$ligne->total_ttc = $objp->total_ttc;
$ligne->total_tva = $objp->total_tva;
$ligne->subprice = $objp->subprice;
$ligne->fk_remise_except = $objp->fk_remise_except;
$ligne->remise_percent = $objp->remise_percent;
$ligne->price = $objp->price;
$ligne->fk_product = $objp->fk_product;
$ligne->marge_tx = $objp->marge_tx;
$ligne->marque_tx = $objp->marque_tx;
$ligne->rang = $objp->rang;
$ligne->info_bits = $objp->info_bits;
$line = new OrderLine($this->db);
$line->rowid = $objp->rowid; // \deprecated
$line->id = $objp->rowid;
$line->fk_commande = $objp->fk_commande;
$line->commande_id = $objp->fk_commande; // \deprecated
$line->desc = $objp->description; // Description ligne
$line->product_type = $objp->product_type;
$line->qty = $objp->qty;
$line->tva_tx = $objp->tva_tx;
$line->total_ht = $objp->total_ht;
$line->total_ttc = $objp->total_ttc;
$line->total_tva = $objp->total_tva;
$line->subprice = $objp->subprice;
$line->fk_remise_except = $objp->fk_remise_except;
$line->remise_percent = $objp->remise_percent;
$line->price = $objp->price;
$line->fk_product = $objp->fk_product;
$line->marge_tx = $objp->marge_tx;
$line->marque_tx = $objp->marque_tx;
$line->rang = $objp->rang;
$line->info_bits = $objp->info_bits;
$ligne->ref = $objp->product_ref;
$ligne->libelle = $objp->label;
$ligne->product_desc = $objp->product_desc; // Description produit
$ligne->fk_product_type = $objp->fk_product_type; // Produit ou service
$line->ref = $objp->product_ref;
$line->libelle = $objp->label;
$line->product_desc = $objp->product_desc; // Description produit
$line->fk_product_type = $objp->fk_product_type; // Produit ou service
$ligne->date_start = $this->db->jdate($objp->date_start);
$ligne->date_end = $this->db->jdate($objp->date_end);
$line->date_start = $this->db->jdate($objp->date_start);
$line->date_end = $this->db->jdate($objp->date_end);
$this->lignes[$i] = $ligne; // For backward compatibility
$this->lines[$i] = $ligne;
$this->lignes[$i] = $line; // For backward compatibility
$this->lines[$i] = $line;
$i++;
}
$this->db->free($result);
@ -1348,10 +1353,12 @@ class Commande extends CommonObject
$product->id = $obj->fk_product;
// Supprime ligne
$ligne = new CommandeLigne($this->db);
$ligne->id = $idligne;
$ligne->fk_commande = $this->id; // On en a besoin dans les triggers
$result=$ligne->delete($user);
$line = new OrderLine($this->db);
$line->id = $idligne;
$line->fk_commande = $this->id; // On en a besoin dans les triggers
$result=$line->delete($user);
if ($result > 0)
{
@ -1794,7 +1801,8 @@ class Commande extends CommonObject
$subprice = price2num($subprice);
$LigneOld = new CommandeLigne($this->db);
// TODO: utile ?
$LigneOld = new OrderLine($this->db);
$LigneOld->fetch($rowid);
// Mise a jour ligne en base
@ -2219,19 +2227,24 @@ class Commande extends CommonObject
$xnbp = 0;
while ($xnbp < $nbp)
{
$ligne=new CommandeLigne($this->db);
$ligne->desc=$langs->trans("Description")." ".$xnbp;
$ligne->qty=1;
$ligne->subprice=100;
$ligne->price=100;
$ligne->tva_tx=19.6;
$ligne->total_ht=100;
$ligne->total_ttc=119.6;
$ligne->total_tva=19.6;
$line=new OrderLine($this->db);
$prodid = rand(1, $num_prods);
$ligne->produit_id=$prodids[$prodid];
$ligne->fk_product=$prodids[$prodid];
$this->lignes[$xnbp]=$ligne;
$line->desc=$langs->trans("Description")." ".$xnbp;
$line->qty=1;
$line->subprice=100;
$line->price=100;
$line->tva_tx=19.6;
$line->total_ht=100;
$line->total_ttc=119.6;
$line->total_tva=19.6;
$line->produit_id=$prodids[$prodid];
$line->fk_product=$prodids[$prodid];
$this->lignes[$xnbp]=$line; // TODO: deprecated
$this->lines[$xnbp]=$line;
$xnbp++;
}
@ -2286,10 +2299,10 @@ class Commande extends CommonObject
/**
* \class CommandeLigne
* \class OrderLine
* \brief Classe de gestion des lignes de commande
*/
class CommandeLigne
class OrderLine
{
var $db;
var $error;
@ -2333,7 +2346,7 @@ class CommandeLigne
* \brief Constructeur d'objets ligne de commande
* \param DB handler d'acces base de donnee
*/
function CommandeLigne($DB)
function OrderLine($DB)
{
$this->db= $DB;
}
@ -2405,7 +2418,7 @@ class CommandeLigne
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid='".$this->id."';";
dol_syslog("CommandeLigne::delete sql=".$sql);
dol_syslog("OrderLine::delete sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
@ -2421,7 +2434,7 @@ class CommandeLigne
else
{
$this->error=$this->db->lasterror();
dol_syslog("CommandeLigne::delete ".$this->error, LOG_ERR);
dol_syslog("OrderLine::delete ".$this->error, LOG_ERR);
return -1;
}
}
@ -2435,7 +2448,7 @@ class CommandeLigne
{
global $langs, $conf, $user;
dol_syslog("CommandeLigne::insert rang=".$this->rang);
dol_syslog("OrderLine::insert rang=".$this->rang);
$this->db->begin();
@ -2497,7 +2510,7 @@ class CommandeLigne
else { $sql.='null'; }
$sql.= ')';
dol_syslog("CommandeLigne::insert sql=".$sql);
dol_syslog("OrderLine::insert sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
@ -2519,7 +2532,7 @@ class CommandeLigne
else
{
$this->error=$this->db->error();
dol_syslog("CommandeLigne::insert Error ".$this->error, LOG_ERR);
dol_syslog("OrderLine::insert Error ".$this->error, LOG_ERR);
$this->db->rollback();
return -2;
}
@ -2541,7 +2554,7 @@ class CommandeLigne
$sql.= ",total_ttc='".price2num($this->total_ttc)."'";
$sql.= " WHERE rowid = ".$this->rowid;
dol_syslog("CommandeLigne::update_total sql=$sql");
dol_syslog("OrderLine::update_total sql=$sql");
$resql=$this->db->query($sql);
if ($resql)
@ -2552,7 +2565,7 @@ class CommandeLigne
else
{
$this->error=$this->db->error();
dol_syslog("CommandeLigne::update_total Error ".$this->error, LOG_ERR);
dol_syslog("OrderLine::update_total Error ".$this->error, LOG_ERR);
$this->db->rollback();
return -2;
}

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -497,7 +497,7 @@ if ($id > 0 || ! empty($ref))
$product->fetch($objp->fk_product);
}
if ($objp->fk_product > 0 && $conf->stock->enabled)
if ($objp->fk_product > 0 && $type == 0 && $conf->stock->enabled)
{
print '<td align="center">';
print $product->stock_reel;

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
@ -383,11 +383,13 @@ class Expedition extends CommonObject
require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php";
// Loop on each product line to add a stock movement
// TODO possibilite d'expedier a partir d'une propale ou autre origine
$sql = "SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot";
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
$sql.= ", ".MAIN_DB_PREFIX."expeditiondet as ed";
$sql.= " WHERE ed.fk_expedition = ".$this->id;
$sql.= " AND cd.rowid = ed.fk_origin_line";
dol_syslog("Expedition::valid select details sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
@ -403,7 +405,7 @@ class Expedition extends CommonObject
{
$mouvS = new MouvementStock($this->db);
// We decrement stock of product (and sub-products)
$entrepot_id = "1"; // TODO ajouter possibilit<EFBFBD> de choisir l'entrepot
$entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot
$result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice);
if ($result < 0) { $error++; }
}

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -388,39 +388,48 @@ if ($_GET["action"] == 'create')
{
$product = new Product($db);
$ligne = $object->lignes[$indiceAsked];
$line = $object->lines[$indiceAsked];
$var=!$var;
print "<tr ".$bc[$var].">\n";
// Desc
if ($ligne->fk_product > 0)
if ($line->fk_product > 0)
{
$product->fetch($ligne->fk_product);
$product->fetch($line->fk_product);
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$ligne->fk_product.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.$product->libelle;
if ($ligne->desc) print '<br>'.dol_nl2br(dol_htmlcleanlastbr($ligne->desc),1);
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$line->fk_product.'">';
if ($line->product_type == 1)
{
print img_object($langs->trans("ShowService"),"service");
}
else
{
print img_object($langs->trans("ShowProduct"),"product");
}
print ' '.$product->ref.'</a> - '.$product->libelle;
if ($line->desc) print '<br>'.dol_nl2br(dol_htmlcleanlastbr($line->desc),1);
print '</td>';
}
else
{ //var_dump($ligne);
print "<td>".nl2br($ligne->desc)."</td>\n";
print "<td>".nl2br($line->desc)."</td>\n";
}
// Qty
print '<td align="center">'.$ligne->qty.'</td>';
$qtyProdCom=$ligne->qty;
print '<td align="center">'.$line->qty.'</td>';
$qtyProdCom=$line->qty;
// Sendings
print '<td align="center">';
$quantityDelivered = $object->expeditions[$ligne->id];
$quantityDelivered = $object->expeditions[$line->id];
print $quantityDelivered;
print '</td>';
$quantityAsked = $ligne->qty;
$quantityAsked = $line->qty;
$quantityToBeDelivered = $quantityAsked - $quantityDelivered;
if ($conf->stock->enabled)
if ($conf->stock->enabled && $line->product_type == 0)
{
$defaultqty=0;
if ($_GET["entrepot_id"])
@ -433,8 +442,8 @@ if ($_GET["action"] == 'create')
// Quantity
print '<td align="center">';
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$ligne->id.'">';
print '<input name="qtyl'.$indiceAsked.'" type="text" size="4" value="'.$defaultqty.'">';
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">';
print '<input name="qtyl'.$indiceAsked.'" type="text" size="6" value="'.$defaultqty.'">';
print '</td>';
// Stock
@ -453,8 +462,11 @@ if ($_GET["action"] == 'create')
$array=array();
$sql = "SELECT e.rowid, e.label, ps.reel";
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."entrepot as e";
$sql.= " WHERE ps.fk_entrepot = e.rowid AND fk_product = '".$product->id."'";
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
$sql.= ", ".MAIN_DB_PREFIX."entrepot as e";
$sql.= " WHERE ps.fk_entrepot = e.rowid";
$sql.= " AND fk_product = '".$product->id."'";
$result = $db->query($sql) ;
if ($result)
{
@ -486,16 +498,17 @@ if ($_GET["action"] == 'create')
else
{
// Quantity
print '<td align="center">';
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$ligne->id.'">';
print '<td align="center" '.$colspan.'>';
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">';
print '<input name="qtyl'.$indiceAsked.'" type="text" size="6" value="'.$quantityToBeDelivered.'">';
print '</td>';
if ($line->product_type == 1) print '<td>&nbsp;</td>';
}
print "</tr>\n";
// Show subproducts of product
if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $ligne->fk_product > 0)
if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0)
{
$product->get_sousproduits_arbo ();
$prods_arbo = $product->get_arbo_each_prod($qtyProdCom);

View File

@ -1462,7 +1462,7 @@ class CommandeFournisseur extends Commande
* \class CommandeFournisseurLigne
* \brief Classe de gestion des lignes de commande
*/
class CommandeFournisseurLigne extends CommandeLigne
class CommandeFournisseurLigne extends OrderLine
{
// From llx_commandedet
var $qty;

View File

@ -231,8 +231,8 @@ class InterfaceEcotax
else
{
// Insertion dans base de la ligne
// See class CommandeLigne
// we don't use the class CommandeLigne for insert, because
// See class OrderLine
// we don't use the class OrderLine for insert, because
// then the trigger would be called again ... and again ... and ...
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commandedet";
$sql.= " (fk_commande, description, qty, tva_tx,";

View File

@ -89,6 +89,8 @@ class Propal extends CommonObject
var $adresse;
var $products=array();
var $lines = array();
var $labelstatut=array();
var $labelstatut_short=array();
@ -887,33 +889,34 @@ class Propal extends CommonObject
{
$objp = $this->db->fetch_object($result);
$ligne = new PropaleLigne($this->db);
$line = new PropaleLigne($this->db);
$ligne->product_type = $objp->product_type;
$ligne->desc = $objp->description; // Description ligne
$ligne->qty = $objp->qty;
$ligne->tva_tx = $objp->tva_tx;
$ligne->subprice = $objp->subprice;
$ligne->fk_remise_except = $objp->fk_remise_except;
$ligne->remise_percent = $objp->remise_percent;
$ligne->price = $objp->price; // deprecated
$line->product_type = $objp->product_type;
$line->desc = $objp->description; // Description ligne
$line->qty = $objp->qty;
$line->tva_tx = $objp->tva_tx;
$line->subprice = $objp->subprice;
$line->fk_remise_except = $objp->fk_remise_except;
$line->remise_percent = $objp->remise_percent;
$line->price = $objp->price; // deprecated
$ligne->info_bits = $objp->info_bits;
$ligne->total_ht = $objp->total_ht;
$ligne->total_tva = $objp->total_tva;
$ligne->total_ttc = $objp->total_ttc;
$ligne->marge_tx = $objp->marge_tx;
$ligne->marque_tx = $objp->marque_tx;
$ligne->special_code = $objp->special_code;
$ligne->rang = $objp->rang;
$line->info_bits = $objp->info_bits;
$line->total_ht = $objp->total_ht;
$line->total_tva = $objp->total_tva;
$line->total_ttc = $objp->total_ttc;
$line->marge_tx = $objp->marge_tx;
$line->marque_tx = $objp->marque_tx;
$line->special_code = $objp->special_code;
$line->rang = $objp->rang;
$ligne->fk_product = $objp->fk_product;
$line->fk_product = $objp->fk_product;
$ligne->libelle = $objp->label; // Label produit
$ligne->product_desc = $objp->product_desc; // Description produit
$ligne->ref = $objp->ref;
$line->libelle = $objp->label; // Label produit
$line->product_desc = $objp->product_desc; // Description produit
$line->ref = $objp->ref;
$this->lignes[$i] = $ligne;
$this->lignes[$i] = $line; // TODO: deprecated
$this->lines[$i] = $line;
//dol_syslog("1 ".$ligne->fk_product);
//print "xx $i ".$this->lignes[$i]->fk_product;
$i++;