add vacant position option

This commit is contained in:
Atm-Gregr 2022-02-16 15:24:35 +01:00
parent 9173eec8ac
commit 1a41232181
3 changed files with 81 additions and 2 deletions

View File

@ -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.= '<label class="nowrap position-fk-user classfortooltip" title="'.dol_escape_js($langs->trans('VacantCheckboxHelper')).'"><input type="checkbox" id="'.$vacantId.'" name="'.$vacantId.'" />&nbsp;' . $langs->trans("Vacant") . '</label>';
?>
<script type="text/javascript">
$(document).ready(function() {
var checkbox = $('#<?php print $vacantId; ?>')
var searchfkuser = $('#<?php print $keyprefix.$key.$keysuffix; ?>')
checkbox.click(function () {
if (checkbox.prop('checked')) {
searchfkuser.val(0).trigger('change');
searchfkuser.prop('disabled', 1);
} else {
searchfkuser.prop('disabled', 0);
}
})
})
</script>
<?php
}
else{
$out = parent::showInputField($val, $key, $value, $moreparam, $keysuffix, $keyprefix, $morecss);
}
return $out;
}
/**
* Return HTML string to show a field into a page
* Code very similar with showOutputField of extra fields
*
* @param array $val Array of properties of 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 parametes 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 mixed $morecss Value for css to define size. May also be a numeric.
* @return string
*/
public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '')
{
global $langs;
if($key == 'fk_user' && $this->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

View File

@ -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);
}

View File

@ -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)