FIX : several fixes + travis

This commit is contained in:
Gauthier PC portable 024 2021-10-05 11:14:08 +02:00
parent 35e7a473f4
commit 5d179beaac
9 changed files with 51 additions and 43 deletions

View File

@ -659,24 +659,21 @@ class Evaluation extends CommonObject
* @param int $fk_user ID of user we need to get last eval * @param int $fk_user ID of user we need to get last eval
* @return Evaluation|null * @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 = "SELECT rowid FROM ".MAIN_DB_PREFIX."hrm_evaluation ";
$sql.= "WHERE fk_user=".$fk_user." "; $sql.= "WHERE fk_user=".$fk_user." ";
$sql.= "ORDER BY date_eval DESC "; $sql.= "ORDER BY date_eval DESC ";
$sql.= "LIMIT 1 "; $sql.= "LIMIT 1 ";
$res = $db->query($sql); $res = $this->db->query($sql);
if (!$res) { dol_print_error($db);} if (!$res) { dol_print_error($this->db);}
$Tab = $db->fetch_object($res); $Tab = $this->db->fetch_object($res);
if (empty($Tab)) return null; if (empty($Tab)) return null;
else { else {
$evaluation = new Evaluation($db); $evaluation = new Evaluation($this->db);
$evaluation->fetch($Tab->rowid); $evaluation->fetch($Tab->rowid);
return $evaluation; return $evaluation;

View File

@ -436,7 +436,8 @@ function displayUsersListWithPicto(&$TUser, $fk_usergroup = 0, $namelist = 'list
$job = Job::getLastJobForUser($user->id); $job = Job::getLastJobForUser($user->id);
$desc .= $job; $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)) { if (!empty($evaluation) && !empty($evaluation->date_eval)) {
$desc .= $langs->trans('DateLastEval') . ' : ' . dol_print_date($evaluation->date_eval); $desc .= $langs->trans('DateLastEval') . ' : ' . dol_print_date($evaluation->date_eval);

View File

@ -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'; require_once DOL_DOCUMENT_ROOT . '/hrm/class/job.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("hrm", "other")); $langs->loadLangs(array("hrm", "other", 'products'));
// Get parameters // Get parameters
$id = GETPOST('id', 'int'); $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) { if ($object->status == $object::STATUS_DRAFT && $permissiontoadd) {
print '<br><div class="center">'; print '<br><div class="center">';
print '<input class="button pll-right" type="submit" value="'.$langs->trans('SaveRank').'" >'; print '<input class="button pll-right" type="submit" value="'.$langs->trans('Save').'" >';
print '</div>'; print '</div>';
} }
} }
@ -579,14 +579,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
} }
if ($object->status == $object::STATUS_CLOSED) { 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 // Validate
if ($object->status == $object::STATUS_DRAFT) { if ($object->status == $object::STATUS_DRAFT) {
if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
print dolGetButtonAction($langs->trans('SaveRank').'&nbsp;'.$langs->trans('and').'&nbsp;'.$langs->trans('Valid'), '', 'default', '#', 'btn_valid', $permissiontovalidate); print dolGetButtonAction($langs->trans('Save').'&nbsp;'.$langs->trans('and').'&nbsp;'.$langs->trans('Valid'), '', 'default', '#', 'btn_valid', $permissiontovalidate);
} else { } else {
$langs->load("errors"); $langs->load("errors");
print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0); print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0);

View File

@ -88,7 +88,7 @@ dol_include_once('/hrm/class/job.class.php');
dol_include_once('/hrm/lib/hrm_job.lib.php'); dol_include_once('/hrm/lib/hrm_job.lib.php');
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("hrm", "other")); $langs->loadLangs(array("hrm", "other", 'products'));
// Get parameters // Get parameters
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');

View File

@ -184,7 +184,7 @@ if (empty($reshook)) {
} }
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("hrm", "other")); $langs->loadLangs(array("hrm", "other", 'products'));
$title = $langs->trans("Position"); $title = $langs->trans("Position");
$help_url = ''; $help_url = '';

View File

@ -89,7 +89,7 @@ dol_include_once('/hrm/lib/hrm_skill.lib.php');
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("hrm", "other")); $langs->loadLangs(array("hrm", "other", 'products'));
// Get parameters // Get parameters
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');

View File

@ -93,7 +93,7 @@ dol_include_once('/hrm/lib/hrm_skill.lib.php');
$langs->loadLangs(array("hrm", "other")); $langs->loadLangs(array("hrm", "other"));
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$fk_skill = GETPOST('fk_skill', 'int'); $TSkillsToAdd = GETPOST('fk_skill', 'array');
$objecttype = GETPOST('objecttype', 'alpha'); $objecttype = GETPOST('objecttype', 'alpha');
$TNote = GETPOST('TNote', 'array'); $TNote = GETPOST('TNote', 'array');
$lineid = GETPOST('lineid', 'int'); $lineid = GETPOST('lineid', 'int');
@ -159,19 +159,21 @@ if (empty($reshook)) {
if ($action == 'addSkill') { if ($action == 'addSkill') {
$error = 0; $error = 0;
if ($fk_skill <= 0) { if (empty($TSkillsToAdd)) {
setEventMessage('ErrNoSkillSelected', 'errors'); setEventMessage('ErrNoSkillSelected', 'errors');
$error++; $error++;
} }
if (!$error) { if (!$error) {
foreach ($TSkillsToAdd as $k=>$v) {
$skillAdded = new SkillRank($db); $skillAdded = new SkillRank($db);
$skillAdded->fk_skill = $fk_skill; $skillAdded->fk_skill = $v;
$skillAdded->fk_object = $id; $skillAdded->fk_object = $id;
$skillAdded->objecttype = $objecttype; $skillAdded->objecttype = $objecttype;
$ret = $skillAdded->create($user); $ret = $skillAdded->create($user);
if ($ret < 0) setEventMessage($skillAdded->error, 'errors'); if ($ret < 0) setEventMessage($skillAdded->error, 'errors');
else unset($fk_skill); //else unset($TSkillsToAdd);
}
} }
} else if ($action == 'saveSkill') { } else if ($action == 'saveSkill') {
if (!empty($TNote)) { 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); dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref, '&objecttype='.$objecttype);
// table of skillRank linked to current object // Get all available skills
$TSkills = $skill->fetchAll('ASC', 't.rowid', 0, 0, array('customsql' => 'fk_object=' . $id . ' AND objecttype="' . $objecttype . '"')); $static_skill = new Skill($db);
$TAllSkills = $static_skill->fetchAll();
// $TAlreadyUsedSkill = array(); // Array format for multiselectarray function
// if (is_array($TSkills) && !empty($TSkills)) { $TAllSkillsFormatted=array();
// foreach ($TSkills as $skillElement) { if(!empty($TAllSkills)) {
// $TAlreadyUsedSkill[] = $skillElement->fk_skill; 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 '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="fichehalfleft">'; print '<div class="fichehalfleft">';
@ -298,13 +312,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<input type="hidden" name="action" value="addSkill">'; print '<input type="hidden" name="action" value="addSkill">';
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table id="tablelines" class="noborder noshadow" width="100%">'; print '<table id="tablelines" class="noborder noshadow" width="100%">';
print '<tr><td>' . $langs->trans('AddSkill') . '</td><td></td></tr>'; print '<tr><td style="width:90%">' . $langs->trans('AddSkill') . '</td><td style="width:10%"></td></tr>';
print '<tr>'; print '<tr>';
foreach ($skill->fields as $key => $infos) { print '<td>' . $form->multiselectarray('fk_skill', array_diff_key($TAllSkillsFormatted, $TAlreadyUsedSkill), array(), 0, 0, '', 0, '100%') . '</td>';
if ($key == 'fk_skill') {
print '<td>' . $skill->showInputField($infos, $key, $$key) . '</td>';
}
}
print '<td><input class="button reposition" type="submit" value="' . $langs->trans('Add') . '"></td>'; print '<td><input class="button reposition" type="submit" value="' . $langs->trans('Add') . '"></td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
@ -335,11 +345,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<th class="linecoldelete"></th>'; print '<th class="linecoldelete"></th>';
} }
print '</tr>'; print '</tr>';
if (!is_array($TSkills) || empty($TSkills)) { if (!is_array($TSkillsJob) || empty($TSkillsJob)) {
print '<tr><td>' . $langs->trans("NoRecordFound") . '</td></tr>'; print '<tr><td>' . $langs->trans("NoRecordFound") . '</td></tr>';
} else { } else {
$sk = new Skill($db); $sk = new Skill($db);
foreach ($TSkills as $skillElement) { foreach ($TSkillsJob as $skillElement) {
$sk->fetch($skillElement->fk_skill); $sk->fetch($skillElement->fk_skill);
print '<tr>'; print '<tr>';
print '<td>'; print '<td>';

View File

@ -65,7 +65,7 @@ MaxLevelLowerThan= Max level lower than that demand
SkillNotAcquired=Skill not acquired by all users and requested by the second comparator SkillNotAcquired=Skill not acquired by all users and requested by the second comparator
legend=Legend legend=Legend
TypeSkill=Skill type TypeSkill=Skill type
AddSkill=Add skill to job AddSkill=Add skills to job
RequiredSkills=Required skills for this job RequiredSkills=Required skills for this job
UserRank=User Rank UserRank=User Rank
SkillList=Skill list SkillList=Skill list

View File

@ -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 SkillNotAcquired=Compétence non acquise par tous les utilisateur et requise par le second élément de comparaison
legend=Légende legend=Légende
TypeSkill=Type de compétence 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 RequiredSkills=Compétences requises pour ce métier
UserRank=Note utilisateur UserRank=Note utilisateur
SkillList=Liste des compétences SkillList=Liste des compétences