Fix: Corrige bug sur methode fetch_lines de commande mal réinitialisé
This commit is contained in:
parent
c9628249a9
commit
ef82553324
@ -1118,6 +1118,8 @@ class Commande extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function fetch_lines($only_product=0)
|
function fetch_lines($only_product=0)
|
||||||
{
|
{
|
||||||
|
$this->lignes=array();
|
||||||
|
|
||||||
$sql = 'SELECT l.rowid, l.fk_product, l.fk_commande, l.description, l.price, l.qty, l.tva_tx,';
|
$sql = 'SELECT l.rowid, l.fk_product, l.fk_commande, l.description, l.price, l.qty, l.tva_tx,';
|
||||||
$sql.= ' l.fk_remise_except, l.remise_percent, l.subprice, l.marge_tx, l.marque_tx, l.rang, l.info_bits,';
|
$sql.= ' l.fk_remise_except, l.remise_percent, l.subprice, l.marge_tx, l.marque_tx, l.rang, l.info_bits,';
|
||||||
$sql.= ' l.total_ht, l.total_ttc, l.total_tva,';
|
$sql.= ' l.total_ht, l.total_ttc, l.total_tva,';
|
||||||
@ -1128,10 +1130,12 @@ class Commande extends CommonObject
|
|||||||
if ($only_product==1) $sql .= ' AND p.fk_product_type = 0';
|
if ($only_product==1) $sql .= ' AND p.fk_product_type = 0';
|
||||||
$sql .= ' ORDER BY l.rang';
|
$sql .= ' ORDER BY l.rang';
|
||||||
|
|
||||||
|
dolibarr_syslog("Commande::fetch_lines sql=".$sql,LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows($result);
|
$num = $this->db->num_rows($result);
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
@ -1195,17 +1199,21 @@ class Commande extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* \brief Charge tableau avec les expéditions par ligne
|
* \brief Charge tableau avec les expéditions par ligne
|
||||||
* \param filtre_statut Filtre sur statut
|
* \param filtre_statut Filtre sur statut
|
||||||
* \return int 0 si OK, <0 si KO
|
* \return int <0 if KO, Nb of records if OK
|
||||||
*/
|
*/
|
||||||
function loadExpeditions($filtre_statut=-1)
|
function loadExpeditions($filtre_statut=-1)
|
||||||
{
|
{
|
||||||
|
$num=0;
|
||||||
$this->expeditions = array();
|
$this->expeditions = array();
|
||||||
|
|
||||||
$sql = 'SELECT fk_product, sum(ed.qty)';
|
$sql = 'SELECT fk_product, sum(ed.qty)';
|
||||||
$sql.=' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed, '.MAIN_DB_PREFIX.'expedition as e, '.MAIN_DB_PREFIX.'commande as c, '.MAIN_DB_PREFIX.'commandedet as cd';
|
$sql.=' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed, '.MAIN_DB_PREFIX.'expedition as e, '.MAIN_DB_PREFIX.'commande as c, '.MAIN_DB_PREFIX.'commandedet as cd';
|
||||||
$sql.=' WHERE ed.fk_expedition = e.rowid AND ed.fk_commande_ligne = cd .rowid AND cd.fk_commande = c.rowid';
|
$sql.=' WHERE ed.fk_expedition = e.rowid AND ed.fk_commande_ligne = cd .rowid AND cd.fk_commande = c.rowid';
|
||||||
$sql.=' AND cd.fk_commande =' .$this->id;
|
$sql.=' AND cd.fk_commande =' .$this->id;
|
||||||
if ($filtre_statut >= 0) $sql.=' AND e.fk_statut = '.$filtre_statut;
|
if ($filtre_statut >= 0) $sql.=' AND e.fk_statut = '.$filtre_statut;
|
||||||
$sql .= ' GROUP BY fk_product ';
|
$sql .= ' GROUP BY fk_product ';
|
||||||
|
|
||||||
|
dolibarr_syslog("Commande::loadExpedition sql=".$sql,LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
@ -1218,9 +1226,14 @@ class Commande extends CommonObject
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$this->db->free();
|
$this->db->free();
|
||||||
|
return $num;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user