From 1a41232181e9d7802f0edabe4e9285fd9f2b6c07 Mon Sep 17 00:00:00 2001 From: Atm-Gregr Date: Wed, 16 Feb 2022 15:24:35 +0100 Subject: [PATCH 1/5] add vacant position option --- htdocs/hrm/class/position.class.php | 77 ++++++++++++++++++++++++++++- htdocs/hrm/position_list.php | 4 ++ htdocs/langs/fr_FR/hrm.lang | 2 + 3 files changed, 81 insertions(+), 2 deletions(-) diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index 2401791bb5f..f3cc82f92fe 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -109,7 +109,7 @@ class Position extends CommonObject 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), 'fk_contrat' => array('type'=>'integer:Contrat:contrat/class/contrat.class.php', 'label'=>'fk_contrat', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>0,), - 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Employee', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>1,), + 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Employee', 'enabled'=>'1', 'position'=>55, 'notnull'=>1, 'visible'=>1, 'default'=>0), 'fk_job' => array('type'=>'integer:Job:/hrm/class/job.class.php', 'label'=>'Job', 'enabled'=>'1', 'position'=>56, 'notnull'=>1, 'visible'=>1,), 'date_start' => array('type'=>'date', 'label'=>'DateStart', 'enabled'=>'1', 'position'=>51, 'notnull'=>1, 'visible'=>1,), 'date_end' => array('type'=>'date', 'label'=>'DateEnd', 'enabled'=>'1', 'position'=>52, 'notnull'=>0, 'visible'=>1,), @@ -842,7 +842,80 @@ class Position extends CommonObject return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } - /** + /** + * Return HTML string to put an input field into a page + * Code very similar with showInputField of extra fields + * + * @param array $val Array of properties for field to show + * @param string $key Key of attribute + * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) + * @param string $moreparam To add more parameters on html input tag + * @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names) + * @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names) + * @param string|int $morecss Value for css to define style/length of field. May also be a numeric. + * @return string + */ + public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0, $nonewbutton = 0) + { + global $langs; + + if($key == 'fk_user') + { + $vacantId = $keyprefix.$key.'vacant'.$keysuffix; + + $out = parent::showInputField($val, $key, $value, $moreparam, $keysuffix, $keyprefix, $morecss); + $out.= ''; + + ?> + + fk_user == 0) + { + return $langs->trans("VacantPosition"); + } + return parent::showOutputField($val, $key, $value, $moreparam, $keysuffix, $keyprefix, $morecss); + } + + + /** * Load the info information in the object * * @param int $id Id of object diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index d6ed72c2612..0e0f561ebb2 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -270,6 +270,10 @@ foreach ($search as $key => $val) { } } } +$vacant = GETPOST('vacant', 'alphanohtml') === 'on'; +if($vacant) { + $sql .= ' AND t.fk_user = 0'; +} if ($search_all) { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } diff --git a/htdocs/langs/fr_FR/hrm.lang b/htdocs/langs/fr_FR/hrm.lang index d47596fe95e..fd0bddcc2eb 100644 --- a/htdocs/langs/fr_FR/hrm.lang +++ b/htdocs/langs/fr_FR/hrm.lang @@ -79,3 +79,5 @@ NoEval=Aucune évaluation effectuée pour cet employé HowManyUserWithThisMaxNote=Nombre d'employés avec ce niveau HighestRank=Plus haut niveau SkillComparison=Comparaison des compétences +VacantPosition=Poste vacant +VacantCheckboxHelper=Cocher cette option affichera le(s) poste(s) comme non pourvu(s) From 7868aa305b8e0cea98f4dc01101f10107b9c5d57 Mon Sep 17 00:00:00 2001 From: Atm-Gregr Date: Wed, 16 Feb 2022 15:48:23 +0100 Subject: [PATCH 2/5] fix filter --- htdocs/hrm/position_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index 0e0f561ebb2..11e6d3c9abf 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -270,7 +270,7 @@ foreach ($search as $key => $val) { } } } -$vacant = GETPOST('vacant', 'alphanohtml') === 'on'; +$vacant = GETPOST('search_fk_uservacant', 'alphanohtml') === 'on'; if($vacant) { $sql .= ' AND t.fk_user = 0'; } From dbcbda642a3531f3c115a8f0e26fef5aa725d658 Mon Sep 17 00:00:00 2001 From: Atm-Gregr Date: Wed, 16 Feb 2022 15:53:06 +0100 Subject: [PATCH 3/5] fix sticker 1 --- htdocs/hrm/class/position.class.php | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index f3cc82f92fe..bc74f96cee9 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -855,22 +855,20 @@ class Position extends CommonObject * @param string|int $morecss Value for css to define style/length of field. May also be a numeric. * @return string */ - public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0, $nonewbutton = 0) - { + public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0, $nonewbutton = 0) { global $langs; - if($key == 'fk_user') - { + if($key == 'fk_user') { $vacantId = $keyprefix.$key.'vacant'.$keysuffix; $out = parent::showInputField($val, $key, $value, $moreparam, $keysuffix, $keyprefix, $morecss); - $out.= ''; + $out .= ''; ?> fk_user == 0) - { + if($key == 'fk_user' && $this->fk_user == 0) { return $langs->trans("VacantPosition"); } return parent::showOutputField($val, $key, $value, $moreparam, $keysuffix, $keyprefix, $morecss); From 30d3a782dea288fe7dcc305e3e2cf49841e0fb64 Mon Sep 17 00:00:00 2001 From: Atm-Gregr Date: Wed, 16 Feb 2022 16:30:54 +0100 Subject: [PATCH 4/5] precommit stickler --- htdocs/hrm/class/position.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index bc74f96cee9..2bba18c131a 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -1141,7 +1141,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobjectline.class.php'; class PositionLine extends CommonObjectLine { // To complete with content of an object PositionLine - // We should have a field rowid, fk_position and position + // We should have a field rowid , fk_position and position /** * @var int Does object support extrafields ? 0=No, 1=Yes From 30cde100ffd55c0f513434cb06f79c515cd18a0b Mon Sep 17 00:00:00 2001 From: Atm-Gregr Date: Fri, 18 Feb 2022 14:41:29 +0100 Subject: [PATCH 5/5] trad us --- htdocs/langs/en_US/hrm.lang | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/langs/en_US/hrm.lang b/htdocs/langs/en_US/hrm.lang index c571ec6ca8a..ab3628026c5 100644 --- a/htdocs/langs/en_US/hrm.lang +++ b/htdocs/langs/en_US/hrm.lang @@ -79,3 +79,6 @@ NoEval=No evaluation done for this employee HowManyUserWithThisMaxNote=Number of users with this rank HighestRank=Highest rank SkillComparison=Skill comparison +ActionsOnJob=Events on this job +VacantPosition=job vacancy +VacantCheckboxHelper=Checking this option will show unfilled positions (job vacancy)