From 3039597582c410d5d87311776a3da17340fa4062 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Tue, 27 Jul 2004 09:24:51 +0000 Subject: [PATCH] =?UTF-8?q?Modification=20de=20l'enregistrement=20des=20mo?= =?UTF-8?q?uvements=20de=20stock=20D=E9sormais=20l'enregistrement=20a=20li?= =?UTF-8?q?eu=20lors=20de=20la=20validation=20de=20l'expedition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/expedition/expedition.class.php | 31 +++++++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php index e304d2c5cb5..8489f2e5078 100644 --- a/htdocs/expedition/expedition.class.php +++ b/htdocs/expedition/expedition.class.php @@ -136,7 +136,6 @@ class Expedition Function create_line($transaction, $commande_ligne_id, $qty) { $error = 0; - $mouvS = new MouvementStock($this->db); $idprod = 0; $j = 0; @@ -149,11 +148,6 @@ class Expedition $j++; } - if (! $mouvS->livraison($this->user, $idprod, $this->entrepot_id, $qty, 0) ) - { - $error++; - } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet (fk_expedition, fk_commande_ligne, qty)"; $sql .= " VALUES ($this->id,".$commande_ligne_id.",".$qty.")"; @@ -213,6 +207,8 @@ class Expedition */ Function valid($user) { + require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php"; + $result = 0; if ($user->rights->expedition->valider) { @@ -223,6 +219,29 @@ class Expedition if ($this->db->query($sql) ) { $result = 1; + + /* + * Enregistrement d'un mouvement de stock + * pour chaque ligne produit de l'expedition + */ + + $sql = "SELECT cd.fk_product, ed.qty "; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql .= " WHERE ed.fk_expedition = $this->id AND cd.rowid = ed.fk_commande_ligne "; + + if ($this->db->query($sql)) + { + $num = $this->db->num_rows(); + $i=0; + while($i < $num) + { + $mouvS = new MouvementStock($this->db); + $obj = $this->db->fetch_object($i); + $mouvS->livraison($user, $obj->fk_product, $this->entrepot_id, $obj->qty, 0); + $i++; + } + } + } else {