diff --git a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN index d3abf17501df62b5ebb282af1676777a7b4f39ab..0a65a74c4c8a8f7058cf7693f048b269da1d1ec5 100644 --- a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN +++ b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN @@ -134,6 +134,7 @@ class InterfaceDemo extends DolibarrTriggers case 'ORDER_SUPPLIER_REFUSE': case 'ORDER_SUPPLIER_CANCEL': case 'ORDER_SUPPLIER_SENTBYMAIL': + case 'ORDER_SUPPLIER_DISPATCH': case 'LINEORDER_SUPPLIER_DISPATCH': case 'LINEORDER_SUPPLIER_CREATE': case 'LINEORDER_SUPPLIER_UPDATE': diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 95c8c1801a75b550d021606f043e17228b5fddd8..e4f69572c0d5261e3237c71b503cf7d284483e63 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1275,9 +1275,10 @@ class CommandeFournisseur extends CommonOrder * @param date $sellby sell-by date * @param string $batch Lot number * @param int $fk_commandefourndet Id of supplier order line + * @param int $notrigger 1 = notrigger * @return int <0 if KO, >0 if OK */ - function DispatchProduct($user, $product, $qty, $entrepot, $price=0, $comment='', $eatby='', $sellby='', $batch='', $fk_commandefourndet='') + function DispatchProduct($user, $product, $qty, $entrepot, $price=0, $comment='', $eatby='', $sellby='', $batch='', $fk_commandefourndet=0, $notrigger=0) { global $conf; $error = 0; diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 9874f80967385859fa496952c521d0bd402b9aef..e62402feabb50cc691f35b6ad2c68ba80ec60694 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -81,7 +81,7 @@ if ($_POST["action"] == 'dispatch' && $user->rights->fournisseur->commande->rece $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"), '', '', '', GETPOST($fk_commandefourndet, 'int')); + $result = $commande->DispatchProduct($user, GETPOST($prod,'int'),GETPOST($qty), GETPOST($ent,'int'), GETPOST($pu), GETPOST("comment"), '', '', '', GETPOST($fk_commandefourndet, 'int'), $notrigger); } else { @@ -98,35 +98,37 @@ if ($_POST["action"] == 'dispatch' && $user->rights->fournisseur->commande->rece $lot = "lot_number_".$reg[1]."_".$reg[2]; $dDLUO = dol_mktime(12, 0, 0, $_POST['dluo_'.$reg[1]."_".$reg[2].'month'], $_POST['dluo_'.$reg[1]."_".$reg[2].'day'], $_POST['dluo_'.$reg[1]."_".$reg[2].'year']); $dDLC = dol_mktime(12, 0, 0, $_POST['dlc_'.$reg[1]."_".$reg[2].'month'], $_POST['dlc_'.$reg[1]."_".$reg[2].'day'], $_POST['dlc_'.$reg[1]."_".$reg[2].'year']); - + $fk_commandefourndet = "fk_commandefourndet_".$reg[1]."_".$reg[2]; if (! (GETPOST($ent,'int') > 0)) { dol_syslog('No dispatch for line '.$key.' as no warehouse choosed'); $text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').'' .($reg[1]-1); setEventMessage($langs->trans('ErrorFieldRequired',$text), 'errors'); - } + } if (!((GETPOST($qty) > 0 ) && ( $_POST[$lot] or $dDLUO or $dDLC) )) { dol_syslog('No dispatch for line '.$key.' as qty is not set or eat-by date are not set'); $text = $langs->transnoentities('atleast1batchfield').', '.$langs->transnoentities('Line').'' .($reg[1]-1); setEventMessage($langs->trans('ErrorFieldRequired',$text), 'errors'); - } else { - $result = $commande->DispatchProduct($user, GETPOST($prod,'int'),GETPOST($qty), GETPOST($ent,'int'), GETPOST($pu), GETPOST("comment"), $dDLC, $dDLUO, GETPOST($lot)); - } + } + else + { + $result = $commande->DispatchProduct($user, GETPOST($prod,'int'),GETPOST($qty), GETPOST($ent,'int'), GETPOST($pu), GETPOST("comment"), $dDLC, $dDLUO, GETPOST($lot), GETPOST($fk_commandefourndet, 'int'), $notrigger); + } } } - if (! $notrigger) + if (! $notrigger && ($result >= 0)) { global $conf, $langs, $user; - // Call trigger - $result=$commande->call_trigger('ORDER_SUPPLIER_DISPATCH',$user); + // Call trigger + $result = $commande->call_trigger('ORDER_SUPPLIER_DISPATCH', $user); // End call triggers } - if ($result > 0) + if ($result >= 0) { $db->commit(); @@ -138,6 +140,7 @@ if ($_POST["action"] == 'dispatch' && $user->rights->fournisseur->commande->rece $db->rollback(); $mesg='<div class="error">'.$langs->trans($commande->error).'</div>'; + setEventMessage($mesg); } }