diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 1f8808bacf9..3efad393732 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -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[] = '
'.$langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'),$langs->transnoentitiesnoconv('Qty')).'
';
- $result = -1 ;
+ setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), 'errors');
+ $error = true;
}
if (! GETPOST('idprod') && GETPOST('type') < 0)
{
- $mesgs[] = ''.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')).'
';
- $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[] = ''.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice')).'
';
- $result = -1 ;
+ setEventMessage($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice'))), 'errors');
+ $error = true;
}
if (! GETPOST('qty') && GETPOST('qty') == '')
{
- $mesgs[] = ''.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')).'
';
- $result = -1 ;
+ setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors');
+ $error = true;
}
if (! GETPOST('idprod') && (GETPOST('np_desc') == '') && (GETPOST('dp_desc') == ''))
{
- $mesgs[] = ''.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')).'
';
- $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' : '';
diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index 3e962449326..88af4e5ada6 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -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[]=''.$langs->trans("ErrorBothFieldCantBeNegative",$langs->transnoentitiesnoconv("UnitPriceHT"),$langs->transnoentitiesnoconv("Qty")).'
';
- $result = -1 ;
+ setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), 'errors');
+ $error = true;
}
if (empty($_POST['idprodfournprice']) && $_POST['type'] < 0)
{
- $mesgs[]=''.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'
';
- $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[]=''.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPrice")).'
';
- $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[]=''.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Description")).'
';
- $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[]=''.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv('Qty')).'
';
- $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();