From 2f4fe2b898c445f44dfbb7efcc37033c7b5a323e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 3 Dec 2021 10:59:47 +0100 Subject: [PATCH] error message --- htdocs/hrm/class/skill.class.php | 8 ++++++- htdocs/hrm/lib/hrm_skillrank.lib.php | 36 +++++++++++++++------------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 0b247e7f5f4..ebf568e68fe 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -410,7 +410,13 @@ class Skill extends CommonObject $skilldet = new Skilldet($this->db); $this->lines = $skilldet->fetchAll('ASC', '', '', '', array('fk_skill' => $this->id), ''); - return (count($this->lines) > 0 ) ? $this->lines : array(); + if (is_array($this->lines)) { + return (count($this->lines) > 0) ? $this->lines : array(); + } elseif ($this->lines < 0) { + $this->errors = array_merge($this->errors, $skilldet->errors); + $this->error = $skilldet->error; + return $this->lines; + } } diff --git a/htdocs/hrm/lib/hrm_skillrank.lib.php b/htdocs/hrm/lib/hrm_skillrank.lib.php index 2aca41504ad..78a53823c2d 100644 --- a/htdocs/hrm/lib/hrm_skillrank.lib.php +++ b/htdocs/hrm/lib/hrm_skillrank.lib.php @@ -115,44 +115,48 @@ function displayRankInfos($selected_rank, $fk_skill, $inputname = 'TNote', $mode $skilldet = new Skilldet($db); $Lines = $skilldet->fetchAll('ASC', 'rank', 0, 0, array('customsql'=>'fk_skill = '.$fk_skill)); + if (!is_array($Lines) && $Lines<0) { + setEventMessages($skilldet->error, $skilldet->errors, 'errors'); + } if (empty($Lines)) return $langs->trans('SkillHasNoLines'); $ret = '0'; + if (is_array($Lines) && !empty($Lines)) { + foreach ($Lines as $line) { + $MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL; + if ($line->rank > $MaxNumberSkill) { + continue; + } - foreach ($Lines as $line) { - $MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL; - if ($line->rank > $MaxNumberSkill) { - continue; + $ret .= '' . $line->rank . ''; } - $ret.= ''.$line->rank.''; - } - - if ($mode == 'edit') { - $ret.= ' - + if ($mode == 'edit') { + $ret .= ' + '; + } } return $ret;