From 51c2103c3ef2fb9c9fa10bf6e15b58de895eafc8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Oct 2025 02:25:05 +0200 Subject: [PATCH] Close #35754 - Better fix in 1 POST. --- htdocs/hrm/evaluation_card.php | 58 +++++++++++++++++++--------------- htdocs/langs/en_US/errors.lang | 1 + 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/htdocs/hrm/evaluation_card.php b/htdocs/hrm/evaluation_card.php index 4f26a4dcc44..e08b10435ee 100644 --- a/htdocs/hrm/evaluation_card.php +++ b/htdocs/hrm/evaluation_card.php @@ -110,7 +110,6 @@ if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) { accessforbidden(); } - /* * Actions */ @@ -136,6 +135,34 @@ if (empty($reshook)) { } } + if ($action == 'saveSkill' && $permissiontoadd) { + $TNote = GETPOST('TNote', 'array'); + if (!empty($TNote)) { + foreach ($object->lines as $line) { + $line->rankorder = ($TNote[$line->fk_skill] == "NA" ? -1 : $TNote[$line->fk_skill]); + $line->update($user); + } + //setEventMessage($langs->trans("SaveLevelSkill")); + } + + $action = 'validate'; + } + + if ($action == "validate" && $permissiontoadd) { + $TNote = GETPOST('TNote', 'array'); + $emptyTNote = true; + foreach ($object->lines as $line) { + if (!in_array($TNote[$line->fk_skill], array("0", ""))) { + $emptyTNote = false; + break; + } + } + if ($emptyTNote) { + setEventMessage($langs->trans("WarningEvaluationEmptyValidate"), 'errors'); + $action = ''; + } + } + $triggermodname = 'HRM_EVALUATION_MODIFY'; // Name of trigger action code to execute when we modify record // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen @@ -164,17 +191,6 @@ if (empty($reshook)) { $trackid = 'evaluation'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - if ($action == 'saveSkill' && $permissiontoadd) { - $TNote = GETPOST('TNote', 'array'); - if (!empty($TNote)) { - foreach ($object->lines as $line) { - $line->rankorder = ($TNote[$line->fk_skill] == "NA" ? -1 : $TNote[$line->fk_skill]); - $line->update($user); - } - setEventMessage($langs->trans("SaveLevelSkill")); - } - } - if ($action == 'close' && $permissiontoadd) { // save evaldet lines to user; $sk = new SkillRank($db); @@ -253,7 +269,6 @@ if (empty($reshook)) { $form = new Form($db); $formfile = new FormFile($db); -$formproject = new FormProjets($db); $title = $langs->trans("Evaluation"); $help_url = ''; @@ -263,20 +278,11 @@ llxHeader('', $title, $help_url, '', 0, 0, '', $css); print ''; diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 8fce2c611e6..6622b68edd2 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -451,3 +451,4 @@ ThisIdNotDefined=Id not defined OperNotDefined=Payment method not defined EmptyMessageNotAllowedError=Empty message is not allowed SomeShipmentExists=Error, there is some shipment linked to the order. Deletion refused. +WarningEvaluationEmptyValidate=Can't validate evaluation, levels on skills not defined