diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index d95816a1511..efc59943a23 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1272,7 +1272,7 @@ class CommandeFournisseur extends CommonOrder * @param string $batch Lot number * @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 +1292,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 4421ad032eb..7199cd8ebf3 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 @@ -1155,3 +1155,5 @@ ALTER TABLE llx_resource MODIFY COLUMN entity integer DEFAULT 1 NOT NULL; -- This request make mysql drop (mysql bug, so we add it at end): ALTER TABLE llx_product ADD CONSTRAINT fk_product_barcode_type FOREIGN KEY (fk_barcode_type) REFERENCES llx_c_barcode_type(rowid); +-- 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; \ No newline at end of file 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,