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)