From 73b04deb19b7a2d2a0a4a2681441587f0dbfeced Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Feb 2022 00:17:49 +0100 Subject: [PATCH] Fix error management. --- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index c96f24760c0..63f2977acdb 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1944,7 +1944,7 @@ if ($action == 'create') { // We verify whether the object is provisionally numbering $ref = substr($object->ref, 1, 4); - if ($ref == 'PROV') { + if ($ref == 'PROV' || $ref == '') { $numref = $object->getNextNumRef($soc); if (empty($numref)) { $error++; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index ba96725ddbd..3ed5ede556c 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1877,8 +1877,12 @@ if ($action == 'create' && $usercancreate) { if ($action == 'validate') { // We check that object has a temporary ref $ref = substr($object->ref, 1, 4); - if ($ref == 'PROV') { + if ($ref == 'PROV' || $ref == '') { $numref = $object->getNextNumRef($soc); + if (empty($numref)) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } } else { $numref = $object->ref; } @@ -1915,7 +1919,9 @@ if ($action == 'create' && $usercancreate) { ); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); + if (!$error) { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); + } } // Confirm back to draft status