Applied 3.3 error management as @hregis requested
This commit is contained in:
parent
3941466cd3
commit
db5d046ee7
@ -519,35 +519,35 @@ else if ($action == 'setnote' && $user->rights->commande->creer)
|
||||
else if ($action == 'addline' && $user->rights->commande->creer)
|
||||
{
|
||||
$langs->load('errors');
|
||||
$result = 0;
|
||||
$error = false;
|
||||
|
||||
if ((GETPOST('np_price') < 0) && (GETPOST('qty') < 0))
|
||||
{
|
||||
$mesgs[] = '<div class="error">'.$langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'),$langs->transnoentitiesnoconv('Qty')).'</div>';
|
||||
$result = -1 ;
|
||||
setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), 'errors');
|
||||
$error = true;
|
||||
}
|
||||
if (! GETPOST('idprod') && GETPOST('type') < 0)
|
||||
{
|
||||
$mesgs[] = '<div class="error">'.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')).'</div>';
|
||||
$result = -1 ;
|
||||
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors');
|
||||
$error = true;
|
||||
}
|
||||
if (! GETPOST('idprod') && GETPOST('np_price') == '') // Unit price can be 0 but not ''
|
||||
{
|
||||
$mesgs[] = '<div class="error">'.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice')).'</div>';
|
||||
$result = -1 ;
|
||||
setEventMessage($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice'))), 'errors');
|
||||
$error = true;
|
||||
}
|
||||
if (! GETPOST('qty') && GETPOST('qty') == '')
|
||||
{
|
||||
$mesgs[] = '<div class="error">'.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')).'</div>';
|
||||
$result = -1 ;
|
||||
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors');
|
||||
$error = true;
|
||||
}
|
||||
if (! GETPOST('idprod') && (GETPOST('np_desc') == '') && (GETPOST('dp_desc') == ''))
|
||||
{
|
||||
$mesgs[] = '<div class="error">'.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')).'</div>';
|
||||
$result = -1 ;
|
||||
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors');
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if ($result >= 0 && GETPOST('qty') && ((GETPOST('np_price') != '' && (GETPOST('np_desc') || GETPOST('dp_desc'))) || GETPOST('idprod')))
|
||||
if (!$error && GETPOST('qty') && ((GETPOST('np_price') != '' && (GETPOST('np_desc') || GETPOST('dp_desc'))) || GETPOST('idprod')))
|
||||
{
|
||||
// Clean parameters
|
||||
$suffixe = GETPOST('idprod') ? '_predef' : '';
|
||||
|
||||
@ -171,35 +171,35 @@ else if ($action == 'reopen' && $user->rights->fournisseur->commande->approuver)
|
||||
else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
|
||||
{
|
||||
$langs->load('errors');
|
||||
$result = 0;
|
||||
$error = false;
|
||||
|
||||
if ($_POST['pu'] < 0 && $_POST['qty'] < 0)
|
||||
{
|
||||
$mesgs[]='<div class="error">'.$langs->trans("ErrorBothFieldCantBeNegative",$langs->transnoentitiesnoconv("UnitPriceHT"),$langs->transnoentitiesnoconv("Qty")).'</div>';
|
||||
$result = -1 ;
|
||||
setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), 'errors');
|
||||
$error = true;
|
||||
}
|
||||
if (empty($_POST['idprodfournprice']) && $_POST['type'] < 0)
|
||||
{
|
||||
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
|
||||
$result = -1 ;
|
||||
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors');
|
||||
$error = true;
|
||||
}
|
||||
if (empty($_POST['idprodfournprice']) && (! isset($_POST['pu']) || $_POST['pu']=='')) // Unit price can be 0 but not ''
|
||||
{
|
||||
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPrice")).'</div>';
|
||||
$result = -1 ;
|
||||
setEventMessage($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice'))), 'errors');
|
||||
$error = true;
|
||||
}
|
||||
if (empty($_POST['idprodfournprice']) && empty($_POST["np_desc"]) && empty($_POST["dp_desc"]))
|
||||
if (empty($_POST['idprodfournprice']) && empty($_POST['np_desc']) && empty($_POST['dp_desc']))
|
||||
{
|
||||
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Description")).'</div>';
|
||||
$result = -1 ;
|
||||
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors');
|
||||
$error = true;
|
||||
}
|
||||
if ((! isset($_POST['qty']) || $_POST['qty']==''))
|
||||
if ((! isset($_POST['qty']) || $_POST['qty'] == ''))
|
||||
{
|
||||
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv('Qty')).'</div>';
|
||||
$result = -1 ;
|
||||
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors');
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if ($result >= 0 && (($_POST['qty'] || $_POST['pqty']) && (($_POST['pu'] && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprodfournprice'])))
|
||||
if (!$error && (($_POST['qty'] || $_POST['pqty']) && (($_POST['pu'] && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprodfournprice'])))
|
||||
{
|
||||
if ($object->fetch($id) < 0) dol_print_error($db,$object->error);
|
||||
if ($object->fetch_thirdparty() < 0) dol_print_error($db,$object->error);
|
||||
@ -1816,8 +1816,6 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
}
|
||||
|
||||
dol_htmloutput_mesg('', $mesgs);
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user