From b4471a4bd755ea871be2c346563bfcb469910e31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a?= Date: Wed, 15 Aug 2012 15:52:51 +0200 Subject: [PATCH 1/4] Added missing error messages in supplier & customer's orders --- htdocs/commande/fiche.php | 25 ++++++++++++++++++---- htdocs/fourn/commande/fiche.php | 38 +++++++++++++++++++++++++++++---- 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index f37cb5c78ac..1f8808bacf9 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,18 +518,34 @@ else if ($action == 'setnote' && $user->rights->commande->creer) */ else if ($action == 'addline' && $user->rights->commande->creer) { - $result=0; + $langs->load('errors'); + $result = 0; + if ((GETPOST('np_price') < 0) && (GETPOST('qty') < 0)) + { + $mesgs[] = '
'.$langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'),$langs->transnoentitiesnoconv('Qty')).'
'; + $result = -1 ; + } if (! GETPOST('idprod') && GETPOST('type') < 0) { - $mesg = '
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'
'; + $mesgs[] = '
'.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')).'
'; $result = -1 ; } - 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")).'
'; + $mesgs[] = '
'.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice')).'
'; $result = -1 ; } + if (! GETPOST('qty') && GETPOST('qty') == '') + { + $mesgs[] = '
'.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')).'
'; + $result = -1 ; + } + if (! GETPOST('idprod') && (GETPOST('np_desc') == '') && (GETPOST('dp_desc') == '')) + { + $mesgs[] = '
'.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')).'
'; + $result = -1 ; + } if ($result >= 0 && GETPOST('qty') && ((GETPOST('np_price') != '' && (GETPOST('np_desc') || GETPOST('dp_desc'))) || GETPOST('idprod'))) { diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 613d7272a75..2d83b209b01 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'); + $result = 0; + + if ($_POST['pu'] < 0 && $_POST['qty'] < 0) + { + $mesgs[]='
'.$langs->trans("ErrorBothFieldCantBeNegative",$langs->transnoentitiesnoconv("UnitPriceHT"),$langs->transnoentitiesnoconv("Qty")).'
'; + $result = -1 ; + } + if (empty($_POST['idprodfournprice']) && $_POST['type'] < 0) + { + $mesgs[]='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'
'; + $result = -1 ; + } + 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 ; + } + if (empty($_POST['idprodfournprice']) && empty($_POST["np_desc"]) && empty($_POST["dp_desc"])) + { + $mesgs[]='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Description")).'
'; + $result = -1 ; + } + if ((empty($_POST['idprodfournprice']) && (! isset($_POST['qty']) || $_POST['qty']=='')) || (empty($_POST['idprodfournprice']) && (! isset($_POST['pqty']) || $_POST['qty'] == ''))) + { + $mesgs[]='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv('Qty')).'
'; + $result = -1 ; + } + + if ($result >= 0 && (($_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.'
'; } } } @@ -1787,6 +1816,7 @@ if ($id > 0 || ! empty($ref)) } } +dol_htmloutput_mesg('', $mesgs); // End of page llxFooter(); From a9c868a17be89dea79eb07e5656d07b6fc17b144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a?= Date: Wed, 15 Aug 2012 16:01:16 +0200 Subject: [PATCH 2/4] Added modification to ChangeLog --- ChangeLog | 1 + 1 file changed, 1 insertion(+) 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. From 3941466cd32978a59f8624a27387d0de70183735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a?= Date: Thu, 16 Aug 2012 03:55:41 +0200 Subject: [PATCH 3/4] Removed duplicated code --- htdocs/fourn/commande/fiche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 2d83b209b01..3e962449326 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -193,7 +193,7 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer) $mesgs[]='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Description")).'
'; $result = -1 ; } - if ((empty($_POST['idprodfournprice']) && (! isset($_POST['qty']) || $_POST['qty']=='')) || (empty($_POST['idprodfournprice']) && (! isset($_POST['pqty']) || $_POST['qty'] == ''))) + if ((! isset($_POST['qty']) || $_POST['qty']=='')) { $mesgs[]='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv('Qty')).'
'; $result = -1 ; From db5d046ee7efe43a764e778d560fc28b17993cd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a?= Date: Thu, 16 Aug 2012 13:10:14 +0200 Subject: [PATCH 4/4] Applied 3.3 error management as @hregis requested --- htdocs/commande/fiche.php | 24 ++++++++++++------------ htdocs/fourn/commande/fiche.php | 30 ++++++++++++++---------------- 2 files changed, 26 insertions(+), 28 deletions(-) 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();