diff --git a/ChangeLog b/ChangeLog index 7c180afdb68..b84c24045a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -39,6 +39,7 @@ For users: - Fix: No images into product description lines as PDF generation does not work with this. - New: [ task #326 ]: Add a numbering module to suggest automatically a product ref +- Fix: Errors weren't being shown in customer's & supplier's orders For developers: - New: Add webservice for thirdparty creation and list. diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index f37cb5c78ac..3efad393732 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -7,6 +7,7 @@ * Copyright (C) 2010-2012 Juanjo Menent * Copyright (C) 2011 Philippe Grand * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012 Marcos García * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -517,20 +518,36 @@ else if ($action == 'setnote' && $user->rights->commande->creer) */ else if ($action == 'addline' && $user->rights->commande->creer) { - $result=0; + $langs->load('errors'); + $error = false; + if ((GETPOST('np_price') < 0) && (GETPOST('qty') < 0)) + { + setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), 'errors'); + $error = true; + } if (! GETPOST('idprod') && GETPOST('type') < 0) { - $mesg = '
'.$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 '' + if (! GETPOST('idprod') && GETPOST('np_price') == '') // Unit price can be 0 but not '' { - $mesg = '
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")).'
'; - $result = -1 ; + setEventMessage($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice'))), 'errors'); + $error = true; } + if (! GETPOST('qty') && GETPOST('qty') == '') + { + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); + $error = true; + } + if (! GETPOST('idprod') && (GETPOST('np_desc') == '') && (GETPOST('dp_desc') == '')) + { + 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 03b54bcdc67..793e3f67504 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2012 Juanjo Menent * Copyright (C) 2011 Philippe Grand + * Copyright (C) 2012 Marcos García * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -169,7 +170,36 @@ else if ($action == 'reopen' && $user->rights->fournisseur->commande->approuver) */ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer) { - if (($_POST['qty'] || $_POST['pqty']) && (($_POST['pu'] && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprodfournprice'])) + $langs->load('errors'); + $error = false; + + if ($_POST['pu'] < 0 && $_POST['qty'] < 0) + { + setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), 'errors'); + $error = true; + } + if (empty($_POST['idprodfournprice']) && $_POST['type'] < 0) + { + 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 '' + { + setEventMessage($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice'))), 'errors'); + $error = true; + } + if (empty($_POST['idprodfournprice']) && empty($_POST['np_desc']) && empty($_POST['dp_desc'])) + { + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); + $error = true; + } + if ((! isset($_POST['qty']) || $_POST['qty'] == '')) + { + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); + $error = true; + } + + 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); @@ -223,7 +253,6 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer) if ($idprod == -1) { // Quantity too low - $langs->load("errors"); $mesg='
'.$langs->trans("ErrorQtyTooLowForThisSupplier").'
'; } } @@ -288,9 +317,9 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer) unset($localtax1_tx); unset($localtax2_tx); } - else if (empty($mesg)) + else { - $mesg='
'.$object->error.'
'; + $mesgs[] ='
'.$object->error.'
'; } } } @@ -1803,7 +1832,6 @@ if ($id > 0 || ! empty($ref)) } } - // End of page llxFooter();