diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 6ba464b0a18..9051ab0bb27 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1261,18 +1261,19 @@ class CommandeFournisseur extends CommonOrder /** * Add a product into a stock warehouse. * - * @param User $user User object making change - * @param int $product Id of product to dispatch - * @param double $qty Qty to dispatch - * @param int $entrepot Id of warehouse to add product - * @param double $price Unit Price for PMP value calculation (Unit price without Tax and taking into account discount) - * @param string $comment Comment for stock movement - * @param date $eatby eat-by date - * @param date $sellby sell-by date - * @param string $batch Lot number + * @param User $user User object making change + * @param int $product Id of product to dispatch + * @param double $qty Qty to dispatch + * @param int $entrepot Id of warehouse to add product + * @param double $price Unit Price for PMP value calculation (Unit price without Tax and taking into account discount) + * @param string $comment Comment for stock movement + * @param date $eatby eat-by date + * @param date $sellby sell-by date + * @param string $batch Lot number + * @param int $fk_commandefourndet Id of supplier order line * @return int <0 if KO, >0 if OK */ - function DispatchProduct($user, $product, $qty, $entrepot, $price=0, $comment='', $eatby='', $sellby='', $batch='') + function DispatchProduct($user, $product, $qty, $entrepot, $price=0, $comment='', $eatby='', $sellby='', $batch='', $fk_commandefourndet='') { global $conf; $error = 0; @@ -1292,8 +1293,8 @@ class CommandeFournisseur extends CommonOrder $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur_dispatch "; - $sql.= " (fk_commande,fk_product, qty, fk_entrepot, fk_user, datec) VALUES "; - $sql.= " ('".$this->id."','".$product."','".$qty."',".($entrepot>0?"'".$entrepot."'":"null").",'".$user->id."','".$this->db->idate($now)."')"; + $sql.= " (fk_commande,fk_product, qty, fk_entrepot, fk_user, datec, fk_commandefourndet) VALUES "; + $sql.= " ('".$this->id."','".$product."','".$qty."',".($entrepot>0?"'".$entrepot."'":"null").",'".$user->id."','".$this->db->idate($now)."','".$fk_commandefourndet."')"; dol_syslog(get_class($this)."::DispatchProduct", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index bea467340e6..d5ace69a09f 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -78,9 +78,10 @@ if ($_POST["action"] == 'dispatch' && $user->rights->fournisseur->commande->rece $qty = "qty_".$reg[1]; $ent = "entrepot_".$reg[1]; $pu = "pu_".$reg[1]; // This is unit price including discount + $fk_commandefourndet = "fk_commandefourndet_".$reg[1]; if (GETPOST($ent,'int') > 0) { - $result = $commande->DispatchProduct($user, GETPOST($prod,'int'),GETPOST($qty), GETPOST($ent,'int'), GETPOST($pu), GETPOST("comment")); + $result = $commande->DispatchProduct($user, GETPOST($prod,'int'),GETPOST($qty), GETPOST($ent,'int'), GETPOST($pu), GETPOST("comment"), '', '', '', GETPOST($fk_commandefourndet, 'int')); } else { @@ -251,22 +252,23 @@ if ($id > 0 || ! empty($ref)) print ''; print '
| '.$objp->qty.' | '; - print ''.$products_dispatched[$objp->fk_product].' | '; + print ''.$products_dispatched[$objp->rowid].' | '; if ( !(empty($conf->productbatch->enabled)) && $objp->tobatch==1) { print ''.img_picto_common($langs->trans('AddDispatchBatchLine'),'treemenu/plustop2.gif','onClick="AddLineBatch('.$i.')"').' | '; @@ -361,6 +363,7 @@ if ($id > 0 || ! empty($ref)) print '  | '; } else { print ''; + print ''; print ''; } diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index 0a9213a3d73..dc912be4286 100755 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -1160,3 +1160,5 @@ ALTER TABLE llx_product ADD CONSTRAINT fk_product_barcode_type FOREIGN KEY (fk_b -- this update change the old formated url on llx_bank_url UPDATE llx_bank_url set url = REPLACE( url, 'fiche.php', 'card.php'); +-- Add id commandefourndet in llx_commande_fournisseur_dispatch to correct /fourn/commande/dispatch.php display when several times same product in supplier order +ALTER TABLE llx_commande_fournisseur_dispatch ADD COLUMN fk_commandefourndet INT(11) NOT NULL DEFAULT '0' AFTER fk_product; diff --git a/htdocs/install/mysql/tables/llx_commande_fournisseur_dispatch.sql b/htdocs/install/mysql/tables/llx_commande_fournisseur_dispatch.sql index 7eeb02ab5cf..1c2cd348a74 100644 --- a/htdocs/install/mysql/tables/llx_commande_fournisseur_dispatch.sql +++ b/htdocs/install/mysql/tables/llx_commande_fournisseur_dispatch.sql @@ -21,6 +21,7 @@ create table llx_commande_fournisseur_dispatch rowid integer AUTO_INCREMENT PRIMARY KEY, fk_commande integer, fk_product integer, + fk_commandefourndet integer, qty float, -- qty fk_entrepot integer, fk_user integer,