diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php index a6bdf99179d..6ec8ab3603d 100644 --- a/htdocs/expedition/expedition.class.php +++ b/htdocs/expedition/expedition.class.php @@ -555,29 +555,26 @@ class Expedition $resql = $this->db->query($sql); if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $ligne = new ExpeditionLigne(); - - $obj = $this->db->fetch_object($resql); - - $ligne->product_id = $obj->fk_product; - $ligne->qty_commande = $obj->qtycom; - $ligne->qty_expedition = $obj->qtyexp; - $ligne->description = stripslashes($obj->description); - - $this->lignes[$i] = $ligne; - $i++; - } - $this->db->free($resql); + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $ligne = new ExpeditionLigne(); + $obj = $this->db->fetch_object($resql); + + $ligne->product_id = $obj->fk_product; + $ligne->qty_commande = $obj->qtycom; + $ligne->qty_expedition = $obj->qtyexp; + $ligne->description = stripslashes($obj->description); + + $this->lignes[$i] = $ligne; + $i++; + } + $this->db->free($resql); } - return $this->lignes; } - } diff --git a/htdocs/livraison/livraison.class.php b/htdocs/livraison/livraison.class.php index af183037fe6..c2f01092848 100644 --- a/htdocs/livraison/livraison.class.php +++ b/htdocs/livraison/livraison.class.php @@ -172,29 +172,29 @@ class Livraison function create_line($transaction, $commande_ligne_id, $qty) { $error = 0; - $idprod = 0; $j = 0; + while (($j < sizeof($this->commande->lignes)) && idprod == 0) { - if ($this->commande->lignes[$j]->id == $commande_ligne_id) - { - $idprod = $this->commande->lignes[$j]->product_id; - } - $j++; + if ($this->commande->lignes[$j]->id == $commande_ligne_id) + { + $idprod = $this->commande->lignes[$j]->product_id; + } + $j++; } - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."livraisondet (fk_livraison, fk_commande_ligne, qty)"; - $sql .= " VALUES ($this->id,".$commande_ligne_id.",".$qty.")"; - - if (! $this->db->query($sql) ) + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."livraisondet (fk_livraison, fk_commande_ligne, qty)"; + $sql .= " VALUES ($this->id,".$commande_ligne_id.",".$qty.")"; + + if (! $this->db->query($sql) ) { - $error++; + $error++; } - - if ($error == 0 ) + + if ($error == 0 ) { - return 1; + return 1; } }