diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 22ac415b511..732a381694d 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -1392,13 +1392,19 @@ class CommandeFournisseur extends CommonOrder
function dispatchProduct($user, $product, $qty, $entrepot, $price=0, $comment='', $eatby='', $sellby='', $batch='', $fk_commandefourndet=0, $notrigger=0)
{
global $conf;
+
$error = 0;
require_once DOL_DOCUMENT_ROOT .'/product/stock/class/mouvementstock.class.php';
- // Check parameters
- if ($entrepot <= 0 || $qty <= 0)
+ // Check parameters (if test are wrong here, there is bug into caller)
+ if ($entrepot <= 0)
{
- $this->error='BadValueForParameterWarehouseOrQty';
+ $this->error='ErrorBadValueForParameterWarehouse';
+ return -1;
+ }
+ if ($qty <= 0)
+ {
+ $this->error='ErrorBadValueForParameterQty';
return -1;
}
diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php
index 84b03f1953a..1da5f5eb29a 100644
--- a/htdocs/fourn/commande/dispatch.php
+++ b/htdocs/fourn/commande/dispatch.php
@@ -101,6 +101,23 @@ if ($action == 'uncheckdispatchline' &&
}
}
+if ($action == 'denydispatchline' &&
+ ! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner))
+ || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))
+)
+{
+ $supplierorderdispatch = new CommandeFournisseurDispatch($db);
+ $result=$supplierorderdispatch->fetch($lineid);
+ if (! $result) dol_print_error($db);
+ $result=$supplierorderdispatch->setStatut(-1);
+ if ($result < 0)
+ {
+ setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
+ $error++;
+ $action='';
+ }
+}
+
if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
{
$commande = new CommandeFournisseur($db);
@@ -123,7 +140,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
if (GETPOST($qty) > 0) // We ask to move a qty
{
- if (! GETPOST($ent,'int') > 0)
+ if (! (GETPOST($ent,'int') > 0))
{
dol_syslog('No dispatch for line '.$key.' as no warehouse choosed');
$text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' ' .($numline);
@@ -133,7 +150,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
if (! $error)
{
- $result = $commande->DispatchProduct($user, GETPOST($prod,'int'),GETPOST($qty), GETPOST($ent,'int'), GETPOST($pu), GETPOST("comment"), '', '', '', GETPOST($fk_commandefourndet, 'int'), $notrigger);
+ $result = $commande->DispatchProduct($user, GETPOST($prod,'int'), GETPOST($qty), GETPOST($ent,'int'), GETPOST($pu), GETPOST("comment"), '', '', '', GETPOST($fk_commandefourndet, 'int'), $notrigger);
if ($result < 0)
{
setEventMessages($commande->error, $commande->errors, 'errors');
@@ -643,11 +660,13 @@ if ($id > 0 || ! empty($ref))
{
if (empty($objp->status))
{
- print ''.$langs->trans("Check").'';
+ print ''.$langs->trans("Approve").'';
+ print ''.$langs->trans("Deny").'';
}
else
{
- print ''.$langs->trans("Uncheck").'';
+ print ''.$langs->trans("Disapprove").'';
+ print ''.$langs->trans("Deny").'';
}
}
else
@@ -656,11 +675,13 @@ if ($id > 0 || ! empty($ref))
if ($commande->statut == 5) $disabled=1;
if (empty($objp->status))
{
- print 'dispatchlineid.'">'.$langs->trans("Check").'';
+ print 'dispatchlineid.'">'.$langs->trans("Approve").'';
+ print 'dispatchlineid.'">'.$langs->trans("Deny").'';
}
else
{
- print 'dispatchlineid.'">'.$langs->trans("Uncheck").'';
+ print 'dispatchlineid.'">'.$langs->trans("Disapprove").'';
+ print 'dispatchlineid.'">'.$langs->trans("Deny").'';
}
}
print '';