From e9cfb9b69c17678e9eca50ddb19da5d10cce0fcb Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 25 Apr 2022 11:24:09 +0200 Subject: [PATCH] Improve error handling confirm_billcreate --- htdocs/commande/list.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 4859412f692..38d79aa9698 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -368,7 +368,7 @@ if (empty($reshook)) { $TFactThirdNbLines[$cmd->socid] = 0; //init nblines to have lines ordered by expedition and rang } else { $langs->load("errors"); - $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->error); + $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]); $error++; } } @@ -377,7 +377,7 @@ if (empty($reshook)) { $res = $objecttmp->add_object_linked($objecttmp->origin, $id_order); if ($res == 0) { - $errors[] = $objecttmp->error; + $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]); $error++; } @@ -640,7 +640,11 @@ if (empty($reshook)) { $action = 'create'; $_GET["origin"] = $_POST["origin"]; $_GET["originid"] = $_POST["originid"]; - setEventMessages("Error", null, 'errors'); + if (!empty($errors)) { + setEventMessages(null, $errors, 'errors'); + } else { + setEventMessages("Error", null, 'errors'); + } $error++; } }