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
* @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;

View File

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

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';
// 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 '<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>';
}
}
@ -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').'&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 {
$langs->load("errors");
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');
// Load translation files required by the page
$langs->loadLangs(array("hrm", "other"));
$langs->loadLangs(array("hrm", "other", 'products'));
// Get parameters
$id = GETPOST('id', 'int');

View File

@ -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 = '';

View File

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

View File

@ -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 '<div class="fichecenter">';
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 '<div class="div-table-responsive-no-min">';
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>';
foreach ($skill->fields as $key => $infos) {
if ($key == 'fk_skill') {
print '<td>' . $skill->showInputField($infos, $key, $$key) . '</td>';
}
}
print '<td>' . $form->multiselectarray('fk_skill', array_diff_key($TAllSkillsFormatted, $TAlreadyUsedSkill), array(), 0, 0, '', 0, '100%') . '</td>';
print '<td><input class="button reposition" type="submit" value="' . $langs->trans('Add') . '"></td>';
print '</tr>';
print '</table>';
@ -335,11 +345,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<th class="linecoldelete"></th>';
}
print '</tr>';
if (!is_array($TSkills) || empty($TSkills)) {
if (!is_array($TSkillsJob) || empty($TSkillsJob)) {
print '<tr><td>' . $langs->trans("NoRecordFound") . '</td></tr>';
} else {
$sk = new Skill($db);
foreach ($TSkills as $skillElement) {
foreach ($TSkillsJob as $skillElement) {
$sk->fetch($skillElement->fk_skill);
print '<tr>';
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
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

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