From 5d179beaac8a1065a3a52eb9fc32586d3a85ac54 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 5 Oct 2021 11:14:08 +0200 Subject: [PATCH] FIX : several fixes + travis --- htdocs/hrm/class/evaluation.class.php | 13 +++--- htdocs/hrm/compare.php | 3 +- htdocs/hrm/evaluation_card.php | 8 ++-- htdocs/hrm/job_card.php | 2 +- htdocs/hrm/position.php | 2 +- htdocs/hrm/skill_card.php | 2 +- htdocs/hrm/skill_tab.php | 60 ++++++++++++++++----------- htdocs/langs/en_US/hrm.lang | 2 +- htdocs/langs/fr_FR/hrm.lang | 2 +- 9 files changed, 51 insertions(+), 43 deletions(-) diff --git a/htdocs/hrm/class/evaluation.class.php b/htdocs/hrm/class/evaluation.class.php index 237b4740641..ae30c900338 100644 --- a/htdocs/hrm/class/evaluation.class.php +++ b/htdocs/hrm/class/evaluation.class.php @@ -659,24 +659,21 @@ class Evaluation extends CommonObject * @param int $fk_user ID of user we need to get last eval * @return Evaluation|null */ - public static function getLastEvaluationForUser($fk_user) + public function getLastEvaluationForUser($fk_user) { - global $db; - - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."hrm_evaluation "; $sql.= "WHERE fk_user=".$fk_user." "; $sql.= "ORDER BY date_eval DESC "; $sql.= "LIMIT 1 "; - $res = $db->query($sql); - if (!$res) { dol_print_error($db);} + $res = $this->db->query($sql); + if (!$res) { dol_print_error($this->db);} - $Tab = $db->fetch_object($res); + $Tab = $this->db->fetch_object($res); if (empty($Tab)) return null; else { - $evaluation = new Evaluation($db); + $evaluation = new Evaluation($this->db); $evaluation->fetch($Tab->rowid); return $evaluation; diff --git a/htdocs/hrm/compare.php b/htdocs/hrm/compare.php index 44462791961..f47eec79997 100644 --- a/htdocs/hrm/compare.php +++ b/htdocs/hrm/compare.php @@ -436,7 +436,8 @@ function displayUsersListWithPicto(&$TUser, $fk_usergroup = 0, $namelist = 'list $job = Job::getLastJobForUser($user->id); $desc .= $job; - $evaluation = Evaluation::getLastEvaluationForUser($user->id); + $static_eval = new Evaluation($db); + $evaluation = $static_eval->getLastEvaluationForUser($user->id); if (!empty($evaluation) && !empty($evaluation->date_eval)) { $desc .= $langs->trans('DateLastEval') . ' : ' . dol_print_date($evaluation->date_eval); diff --git a/htdocs/hrm/evaluation_card.php b/htdocs/hrm/evaluation_card.php index 156ee79518e..172956fc379 100644 --- a/htdocs/hrm/evaluation_card.php +++ b/htdocs/hrm/evaluation_card.php @@ -88,7 +88,7 @@ require_once DOL_DOCUMENT_ROOT.'/hrm/lib/hrm_skillrank.lib.php'; require_once DOL_DOCUMENT_ROOT . '/hrm/class/job.class.php'; // Load translation files required by the page -$langs->loadLangs(array("hrm", "other")); +$langs->loadLangs(array("hrm", "other", 'products')); // Get parameters $id = GETPOST('id', 'int'); @@ -540,7 +540,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($object->status == $object::STATUS_DRAFT && $permissiontoadd) { print '
'; - print ''; + print ''; print '
'; } } @@ -579,14 +579,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } if ($object->status == $object::STATUS_CLOSED) { - print dolGetButtonAction($langs->trans('reopen'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken(), '', $permissiontoadd); + print dolGetButtonAction($langs->trans('ReOpen'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken(), '', $permissiontoadd); } // Validate if ($object->status == $object::STATUS_DRAFT) { if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { - print dolGetButtonAction($langs->trans('SaveRank').' '.$langs->trans('and').' '.$langs->trans('Valid'), '', 'default', '#', 'btn_valid', $permissiontovalidate); + print dolGetButtonAction($langs->trans('Save').' '.$langs->trans('and').' '.$langs->trans('Valid'), '', 'default', '#', 'btn_valid', $permissiontovalidate); } else { $langs->load("errors"); print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0); diff --git a/htdocs/hrm/job_card.php b/htdocs/hrm/job_card.php index 8cb8d0fceee..728c288d6cc 100644 --- a/htdocs/hrm/job_card.php +++ b/htdocs/hrm/job_card.php @@ -88,7 +88,7 @@ dol_include_once('/hrm/class/job.class.php'); dol_include_once('/hrm/lib/hrm_job.lib.php'); // Load translation files required by the page -$langs->loadLangs(array("hrm", "other")); +$langs->loadLangs(array("hrm", "other", 'products')); // Get parameters $id = GETPOST('id', 'int'); diff --git a/htdocs/hrm/position.php b/htdocs/hrm/position.php index 9a3b1e364ff..7fc5cc777b6 100644 --- a/htdocs/hrm/position.php +++ b/htdocs/hrm/position.php @@ -184,7 +184,7 @@ if (empty($reshook)) { } // Load translation files required by the page -$langs->loadLangs(array("hrm", "other")); +$langs->loadLangs(array("hrm", "other", 'products')); $title = $langs->trans("Position"); $help_url = ''; diff --git a/htdocs/hrm/skill_card.php b/htdocs/hrm/skill_card.php index 12602a46c0a..e3dbf63e160 100644 --- a/htdocs/hrm/skill_card.php +++ b/htdocs/hrm/skill_card.php @@ -89,7 +89,7 @@ dol_include_once('/hrm/lib/hrm_skill.lib.php'); // Load translation files required by the page -$langs->loadLangs(array("hrm", "other")); +$langs->loadLangs(array("hrm", "other", 'products')); // Get parameters $id = GETPOST('id', 'int'); diff --git a/htdocs/hrm/skill_tab.php b/htdocs/hrm/skill_tab.php index ae5ee4371a0..4694d27679a 100644 --- a/htdocs/hrm/skill_tab.php +++ b/htdocs/hrm/skill_tab.php @@ -93,7 +93,7 @@ dol_include_once('/hrm/lib/hrm_skill.lib.php'); $langs->loadLangs(array("hrm", "other")); $id = GETPOST('id', 'int'); -$fk_skill = GETPOST('fk_skill', 'int'); +$TSkillsToAdd = GETPOST('fk_skill', 'array'); $objecttype = GETPOST('objecttype', 'alpha'); $TNote = GETPOST('TNote', 'array'); $lineid = GETPOST('lineid', 'int'); @@ -159,19 +159,21 @@ if (empty($reshook)) { if ($action == 'addSkill') { $error = 0; - if ($fk_skill <= 0) { + if (empty($TSkillsToAdd)) { setEventMessage('ErrNoSkillSelected', 'errors'); $error++; } if (!$error) { - $skillAdded = new SkillRank($db); - $skillAdded->fk_skill = $fk_skill; - $skillAdded->fk_object = $id; - $skillAdded->objecttype = $objecttype; - $ret = $skillAdded->create($user); - if ($ret < 0) setEventMessage($skillAdded->error, 'errors'); - else unset($fk_skill); + foreach ($TSkillsToAdd as $k=>$v) { + $skillAdded = new SkillRank($db); + $skillAdded->fk_skill = $v; + $skillAdded->fk_object = $id; + $skillAdded->objecttype = $objecttype; + $ret = $skillAdded->create($user); + if ($ret < 0) setEventMessage($skillAdded->error, 'errors'); + //else unset($TSkillsToAdd); + } } } else if ($action == 'saveSkill') { if (!empty($TNote)) { @@ -268,15 +270,27 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref, '&objecttype='.$objecttype); - // table of skillRank linked to current object - $TSkills = $skill->fetchAll('ASC', 't.rowid', 0, 0, array('customsql' => 'fk_object=' . $id . ' AND objecttype="' . $objecttype . '"')); + // Get all available skills + $static_skill = new Skill($db); + $TAllSkills = $static_skill->fetchAll(); -// $TAlreadyUsedSkill = array(); -// if (is_array($TSkills) && !empty($TSkills)) { -// foreach ($TSkills as $skillElement) { -// $TAlreadyUsedSkill[] = $skillElement->fk_skill; -// } -// } + // Array format for multiselectarray function + $TAllSkillsFormatted=array(); + if(!empty($TAllSkills)) { + foreach ($TAllSkills as $k=>$v) { + $TAllSkillsFormatted[$k] = $v->label; + } + } + + // table of skillRank linked to current object + $TSkillsJob = $skill->fetchAll('ASC', 't.rowid', 0, 0, array('customsql' => 'fk_object=' . $id . ' AND objecttype="' . $objecttype . '"')); + + $TAlreadyUsedSkill = array(); + if (is_array($TSkillsJob) && !empty($TSkillsJob)) { + foreach ($TSkillsJob as $skillElement) { + $TAlreadyUsedSkill[$skillElement->fk_skill] = $skillElement->fk_skill; + } + } print '
'; print '
'; @@ -298,13 +312,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print '
'; print ''; - print ''; + print ''; print ''; - foreach ($skill->fields as $key => $infos) { - if ($key == 'fk_skill') { - print ''; - } - } + print ''; print ''; print ''; print '
' . $langs->trans('AddSkill') . '
' . $langs->trans('AddSkill') . '
' . $skill->showInputField($infos, $key, $$key) . '' . $form->multiselectarray('fk_skill', array_diff_key($TAllSkillsFormatted, $TAlreadyUsedSkill), array(), 0, 0, '', 0, '100%') . '
'; @@ -335,11 +345,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; } print ''; - if (!is_array($TSkills) || empty($TSkills)) { + if (!is_array($TSkillsJob) || empty($TSkillsJob)) { print '' . $langs->trans("NoRecordFound") . ''; } else { $sk = new Skill($db); - foreach ($TSkills as $skillElement) { + foreach ($TSkillsJob as $skillElement) { $sk->fetch($skillElement->fk_skill); print ''; print ''; diff --git a/htdocs/langs/en_US/hrm.lang b/htdocs/langs/en_US/hrm.lang index cb6d860bb8c..6a578aab50d 100644 --- a/htdocs/langs/en_US/hrm.lang +++ b/htdocs/langs/en_US/hrm.lang @@ -65,7 +65,7 @@ MaxLevelLowerThan= Max level lower than that demand SkillNotAcquired=Skill not acquired by all users and requested by the second comparator legend=Legend TypeSkill=Skill type -AddSkill=Add skill to job +AddSkill=Add skills to job RequiredSkills=Required skills for this job UserRank=User Rank SkillList=Skill list diff --git a/htdocs/langs/fr_FR/hrm.lang b/htdocs/langs/fr_FR/hrm.lang index c2a787cecb2..ceb86bab497 100644 --- a/htdocs/langs/fr_FR/hrm.lang +++ b/htdocs/langs/fr_FR/hrm.lang @@ -76,7 +76,7 @@ MaxLevelLowerThan= Niveau maximal inférieur au niveau requis SkillNotAcquired=Compétence non acquise par tous les utilisateur et requise par le second élément de comparaison legend=Légende TypeSkill=Type de compétence -AddSkill=Ajouter une compétence à ce métier +AddSkill=Ajouter des compétences à ce métier RequiredSkills=Compétences requises pour ce métier UserRank=Note utilisateur SkillList=Liste des compétences