Fix error management

This commit is contained in:
Laurent Destailleur 2015-04-09 15:14:50 +02:00
parent f6c2472d92
commit ed6f2e9386
2 changed files with 36 additions and 9 deletions

View File

@ -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;
}

View File

@ -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 '<a class="button buttonRefused" href="#">'.$langs->trans("Check").'</a>';
print '<a class="button buttonRefused" href="#">'.$langs->trans("Approve").'</a>';
print '<a class="button buttonRefused" href="#">'.$langs->trans("Deny").'</a>';
}
else
{
print '<a class="button buttonRefused" href="#">'.$langs->trans("Uncheck").'</a>';
print '<a class="button buttonRefused" href="#">'.$langs->trans("Disapprove").'</a>';
print '<a class="button buttonRefused" href="#">'.$langs->trans("Deny").'</a>';
}
}
else
@ -656,11 +675,13 @@ if ($id > 0 || ! empty($ref))
if ($commande->statut == 5) $disabled=1;
if (empty($objp->status))
{
print '<a class="button'.($disabled?' buttonRefused':'').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=checkdispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Check").'</a>';
print '<a class="button'.($disabled?' buttonRefused':'').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=checkdispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Approve").'</a>';
print '<a class="button'.($disabled?' buttonRefused':'').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=denydispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Deny").'</a>';
}
else
{
print '<a class="button'.($disabled?' buttonRefused':'').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=uncheckdispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Uncheck").'</a>';
print '<a class="button'.($disabled?' buttonRefused':'').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=uncheckdispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Disapprove").'</a>';
print '<a class="button'.($disabled?' buttonRefused':'').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=denydispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Deny").'</a>';
}
}
print '</td>';