dolibarr 25.0.0-alpha
skill_tab.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2021 Grégory Blémand <contact@atm-consulting.fr>
3 * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
4 * Copyright (C) 2021 Greg Rastklan <greg.rastklan@atm-consulting.fr>
5 * Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
6 * Copyright (C) 2021 Grégory BLEMAND <gregory.blemand@atm-consulting.fr>
7 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
9 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
32// Load Dolibarr environment
33require '../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
37require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
38require_once DOL_DOCUMENT_ROOT.'/hrm/class/job.class.php';
39require_once DOL_DOCUMENT_ROOT.'/hrm/class/skill.class.php';
40require_once DOL_DOCUMENT_ROOT.'/hrm/class/skillrank.class.php';
41require_once DOL_DOCUMENT_ROOT.'/hrm/lib/hrm_skill.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/hrm/class/evaluation.class.php';
43require_once DOL_DOCUMENT_ROOT.'/hrm/lib/hrm_evaluation.lib.php';
44require_once DOL_DOCUMENT_ROOT.'/hrm/class/evaluationdet.class.php';
45
55// Load translation files required by the page
56$langs->loadLangs(array('hrm', 'companies', 'other'));
57
58// Get Parameters
59$action = GETPOST('action', 'aZ09');
60$confirm = GETPOST('confirm', 'alpha');
61$cancel = GETPOST('cancel');
62$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'skillcard'; // To manage different context of search
63$backtopage = GETPOST('backtopage', 'alpha');
64$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
65
66$id = GETPOSTINT('id');
67$TSkillsToAdd = GETPOST('fk_skill', 'array');
68$objecttype = GETPOST('objecttype', 'alpha');
69$TNote = GETPOST('TNote', 'array');
70$lineid = GETPOSTINT('lineid');
71
72if (empty($objecttype)) {
73 $objecttype = 'job';
74}
75
76$TAuthorizedObjects = array('job', 'user');
77$skill = new SkillRank($db);
78
79// Initialize a technical objects
80$object = null;
81if (in_array($objecttype, $TAuthorizedObjects)) {
82 if ($objecttype == 'job') {
83 $object = new Job($db);
84 } elseif ($objecttype == 'user') {
85 $object = new User($db);
86 } else {
87 accessforbidden('ErrorBadObjectType');
88 }
89} else {
90 accessforbidden('ErrorBadObjectType');
91}
92
93$hookmanager->initHooks(array('skilltab', 'globalcard')); // Note that conf->hooks_modules contains array
94
95// Load object
96include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
97if (method_exists($object, 'loadPersonalConf')) {
98 $object->loadPersonalConf();
99}
100
101// Permissions
102$permissiontoread = $user->hasRight('hrm', 'all', 'read');
103$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
104
105// Security check (enable the most restrictive one)
106if ($user->socid > 0) {
108}
109if (!isModEnabled('hrm')) {
111}
112if (!$permissiontoread) {
114}
115
116
117/*
118 * Actions
119 */
120
121$parameters = array();
122$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
123if ($reshook < 0) {
124 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
125}
126
127if (empty($reshook)) {
128 $error = 0;
129
130 $backurlforlist = DOL_URL_ROOT.'/hrm/skill_list.php';
131
132 if (empty($backtopage) || ($cancel && empty($id))) {
133 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
134 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
135 $backtopage = $backurlforlist;
136 } else {
137 $backtopage = DOL_URL_ROOT.'/hrm/skill_list.php?id=' . ($id > 0 ? $id : '__ID__');
138 }
139 }
140 }
141
142 // update national_registration_number
143 if ($action == 'setnational_registration_number' && $permissiontoadd) {
144 $object->national_registration_number = (string) GETPOST('national_registration_number', 'alphanohtml');
145 $result = $object->update($user);
146 if ($result < 0) {
147 setEventMessages($object->error, $object->errors, 'errors');
148 }
149 }
150
151 if ($action == 'addSkill' && $permissiontoadd) {
152 $db->begin();
153 $error = 0;
154
155 if (empty($TSkillsToAdd)) {
156 setEventMessage('ErrNoSkillSelected', 'errors');
157 $error++;
158 }
159 if (!$error) {
160 $ret = -1;
161 foreach ($TSkillsToAdd as $k => $v) {
162 $skillAdded = new SkillRank($db);
163 $skillAdded->fk_skill = (int) $v;
164 $skillAdded->fk_object = $id;
165 $skillAdded->objecttype = $objecttype;
166 $ret = $skillAdded->create($user);
167 if ($ret < 0) {
168 $error++;
169 setEventMessages($skillAdded->error, null, 'errors');
170 break;
171 } elseif ($objecttype == 'job') {
172 // Create new EvaluationLine for each Skill to add in draft evaluation (the id is the one of a job only in this case)
173 $sql_eval = "SELECT e.rowid FROM ".MAIN_DB_PREFIX."hrm_evaluation as e";
174 $sql_eval .= " WHERE e.status = 0 ";
175 $sql_eval .= " AND e.entity = ".(int) getEntity($object->element);
176 $sql_eval .= " AND e.fk_job = ".(int) $object->id;
177 $result = $db->query($sql_eval);
178 $numEvals = $db->num_rows($result);
179 $i = 0;
180 while ($i < $numEvals) {
181 $objEval = $db->fetch_object($result);
182 $line = new EvaluationLine($db);
183 $line->fk_evaluation = $objEval->rowid;
184 $line->fk_skill = (int) $v;
185 $line->required_rank = 0;
186 $line->fk_rank = 0;
187
188 $res = $line->create($user);
189 if ($res < 0) {
190 $error++;
191 setEventMessages($line->error, null, 'errors');
192 break;
193 }
194 $i++;
195 }
196 }
197 }
198 if (!$error) {
199 setEventMessages($langs->trans("SaveAddSkill"), null);
200 $db->commit();
201 } else {
202 $db->rollback();
203 }
204 }
205 } elseif ($action == 'saveSkill' && $permissiontoadd) {
206 if (!empty($TNote)) {
207 $db->begin();
208 $error = 0;
209 $maxrank = getDolGlobalInt('HRM_MAXRANK', Skill::DEFAULT_MAX_RANK_PER_SKILL);
210 foreach ($TNote as $skillId => $rank) {
211 $newrank = ($rank == "NA" ? -1 : (int) $rank);
212 if ($newrank < -1 || $newrank > $maxrank) {
213 // A rank can only be "not applicable" (-1) or a level between 0 and the maximum number of levels
214 $langs->load("errors");
215 setEventMessages($langs->trans("ErrorBadValueForParameter", $rank, 'TNote['.((int) $skillId).']'), null, 'errors');
216 $error++;
217 break;
218 }
219 $rank = $newrank;
220 $TSkills = $skill->fetchAll('ASC', 't.rowid', 0, 0, '(fk_object:=:'.((int) $id).") AND (objecttype:=:'".$db->escape($objecttype)."') AND (fk_skill:=:".((int) $skillId).')');
221 '@phan-var-force SkillRank[] $tSkills';
222 if (is_array($TSkills) && !empty($TSkills)) {
223 foreach ($TSkills as $tmpObj) {
224 $tmpObj->rankorder = $rank;
225 $ret = $tmpObj->update($user);
226 if ($ret < 0) {
227 $error++;
228 setEventMessages($tmpObj->error, null, 'errors');
229 break;
230 }
231 if (!$error && $objecttype == 'job') {
232 // Update draft Evaluations using this Skill (the id is the one of a job only in this case)
233 $sql_eval = "SELECT e.rowid FROM ".MAIN_DB_PREFIX."hrm_evaluation as e";
234 $sql_eval .= " WHERE e.status = 0 ";
235 $sql_eval .= " AND e.entity = ".getEntity($object->element);
236 $sql_eval .= " AND e.fk_job = ".(int) $object->id;
237 $result = $db->query($sql_eval);
238 $numEvals = $db->num_rows($result);
239 $i = 0;
240 while ($i < $numEvals) {
241 $objEval = $db->fetch_object($result);
242 $line = new EvaluationLine($db);
243 $lines = $line->fetchAll('', '', 0, 0, '((fk_skill:=:'.((int) $tmpObj->fk_skill).') AND (fk_evaluation:=:'.((int) $objEval->rowid).'))');
244 if (is_array($lines)) {
245 foreach ($lines as $key => $evalline) {
246 // Verify if fetchAll gave the right object
247 if (is_object($evalline) && $evalline instanceof EvaluationLine) {
248 $evalline->required_rank = $rank;
249 $ret = $evalline->update($user);
250 if ($ret <= 0) {
251 $error++;
252 setEventMessages($evalline->error, null, 'errors');
253 break;
254 }
255 }
256 }
257 } else {
258 $error++;
259 setEventMessages($line->error, null, 'errors');
260 break;
261 }
262 $i++;
263 }
264 }
265 }
266 } else {
267 $error++;
268 setEventMessages($skill->error, null, 'errors');
269 break;
270 }
271 }
272 if (!$error) {
273 setEventMessages($langs->trans("SaveLevelSkill"), null);
274 $db->commit();
275 } else {
276 $db->rollback();
277 }
278 header("Location: " . DOL_URL_ROOT.'/hrm/skill_tab.php?id=' . $id. '&objecttype='.urlencode($objecttype));
279 exit;
280 }
281 } elseif ($action == 'confirm_deleteskill' && $confirm == 'yes' && $permissiontoadd) {
282 $db->begin();
283 $error = 0;
284 $skillToDelete = new SkillRank($db);
285 $ret = $skillToDelete->fetch($lineid);
286 if ($ret > 0) {
287 // Remove EvaluationLine foreach draft Evaluations using this Skill
288 $sql_eval = "SELECT e.rowid FROM ".MAIN_DB_PREFIX."hrm_evaluation as e";
289 $sql_eval .= " WHERE e.status = 0 ";
290 $sql_eval .= " AND e.entity = ".getEntity($object->element);
291 $sql_eval .= " AND e.fk_job = ".(int) $object->id;
292 $result = $db->query($sql_eval);
293 $numEvals = $db->num_rows($result);
294 $i = 0;
295 while ($i < $numEvals) {
296 $objEval = $db->fetch_object($result);
297 $line = new EvaluationLine($db);
298 $lines = $line->fetchAll('', '', 0, 0, '((fk_skill:=:'.((int) $skillToDelete->fk_skill).') AND (fk_evaluation:=:'.((int) $objEval->rowid).'))');
299 if (is_array($lines)) {
300 foreach ($lines as $key => $evalline) {
301 // Verify if fetchAll gave the right object
302 if (is_object($evalline) && $evalline instanceof EvaluationLine) {
303 $ret = $evalline->delete($user);
304 if ($ret <= 0) {
305 $error++;
306 setEventMessages($evalline->error, null, 'errors');
307 break;
308 }
309 }
310 }
311 } else {
312 $error++;
313 setEventMessages($line->error, null, 'errors');
314 break;
315 }
316 $i++;
317 }
318 } else {
319 $error++;
320 setEventMessages($skillToDelete->error, null, 'errors');
321 }
322 if (!$error) {
323 $ret = $skillToDelete->delete($user);
324 if ($ret <= 0) {
325 $error++;
326 setEventMessages($skillToDelete->error, null, 'errors');
327 }
328 }
329 if (!$error) {
330 setEventMessages($langs->trans("DeleteSkill"), null);
331 $db->commit();
332 } else {
333 $db->rollback();
334 }
335 }
336}
337
338
339/*
340 * View
341 */
342
343$form = new Form($db);
344$formfile = new FormFile($db);
345$formproject = new FormProjets($db);
346
347$title = $langs->trans("RequiredSkills");
348$help_url = '';
349llxHeader('', $title, $help_url);
350
351$listLink = '';
352// Part to show record
353if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
354 $res = $object->fetch_optionals();
355
356 // view configuration
357 if ($objecttype == 'job') {
358 require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm_job.lib.php';
359 $head = jobPrepareHead($object);
360 $listLink = dol_buildpath('/hrm/job_list.php', 1);
361 } elseif ($objecttype == "user") { // Always true - @phpstan-ignore equal.alwaysTrue
362 require_once DOL_DOCUMENT_ROOT . "/core/lib/usergroups.lib.php";
363 $head = user_prepare_head($object);
364 $listLink = dol_buildpath('/user/list.php', 1);
365 } else {
366 $head = [];
367 }
368
369 print dol_get_fiche_head($head, 'skill_tab', $langs->trans("Workstation"), -1, $object->picto);
370
371 $formconfirm = '';
372
373 // Confirmation to delete
374 // Confirmation to delete line
375 if ($action == 'ask_deleteskill') {
376 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&objecttype=' . $objecttype . '&lineid=' . $lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteskill', '', 0, 1);
377 }
378 // Clone confirmation
379 /*if ($action == 'clone' && $permissiontoadd) {
380 // Create an array for form
381 $formquestion = array();
382 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
383 }*/
384
385 // Call Hook formConfirm
386 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
387 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
388 if (empty($reshook)) {
389 $formconfirm .= $hookmanager->resPrint;
390 } elseif ($reshook > 0) {
391 $formconfirm = $hookmanager->resPrint;
392 }
393
394 // Print form confirm
395 print $formconfirm;
396
397
398 // Object card
399 // ------------------------------------------------------------
400 if ($objecttype == 'job') {
401 $linkback = '<a href="' . dol_buildpath('/hrm/job_list.php', 1) . '?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
402
403 $morehtmlref = '<div class="refid">';
404 $morehtmlref .= $object->label;
405 $morehtmlref .= '</div>';
406
407 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref);
408 } elseif ($listLink !== null) {
409 $linkback = '<a href="' . $listLink . '?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
410
411 $morehtmlref = '<a href="'.DOL_URL_ROOT.'/user/vcard.php?id='.$object->id.'&output=file&file='.urlencode(dol_sanitizeFileName($object->getFullName($langs).'.vcf')).'" class="refid" tabindex="-1" rel="noopener">';
412 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard', 'class="valignmiddle marginleftonly paddingrightonly"');
413 $morehtmlref .= '</a>';
414
415 $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id);
416 $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->trans("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover');
417
418 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref, '&objecttype='.$objecttype);
419 }
420
421 // Get all available skills
422 $static_skill = new Skill($db);
423 $TAllSkills = $static_skill->fetchAll();
424
425 // Array format for multiselectarray function
426 $TAllSkillsFormatted = array();
427 if (!empty($TAllSkills)) {
428 foreach ($TAllSkills as $k => $v) {
429 $TAllSkillsFormatted[$k] = $v->label;
430 }
431 }
432
433 // table of skillRank linked to current object
434 //$TSkillsJob = $skill->fetchAll('ASC', 't.rowid', 0, 0);
435 $sql_skill = "SELECT sr.fk_object, sr.rowid, s.label,s.skill_type, sr.rankorder, sr.fk_skill";
436 $sql_skill .= " FROM ".MAIN_DB_PREFIX."hrm_skillrank AS sr";
437 $sql_skill .= " JOIN ".MAIN_DB_PREFIX."hrm_skill AS s ON sr.fk_skill = s.rowid";
438 $sql_skill .= " AND sr.fk_object = ".((int) $id);
439 $result = $db->query($sql_skill);
440 $numSkills = $db->num_rows($result);
441 $TSkillsJob = array();
442 for ($i = 0; $i < $numSkills; $i++) {
443 $objSkillRank = $db->fetch_object($result);
444 $TSkillsJob[] = $objSkillRank;
445 }
446
447 $TAlreadyUsedSkill = array();
448 if (is_array($TSkillsJob) && !empty($TSkillsJob)) {
449 foreach ($TSkillsJob as $skillElement) {
450 $TAlreadyUsedSkill[$skillElement->fk_skill] = $skillElement->fk_skill;
451 }
452 }
453
454 print '<div class="fichecenter">';
455 print '<div class="fichehalfleft">';
456
457 print '<div class="underbanner clearboth"></div>';
458 print '<table class="border centpercent tableforfield">'."\n";
459
460 if ($objecttype == 'job') {
461 // Common attributes
462 //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
463 //unset($object->fields['fk_project']); // Hide field already shown in banner
464 //unset($object->fields['fk_soc']); // Hide field already shown in banner
465 $object->fields['label']['visible'] = 0; // Already in banner
466 include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
467
468 // Other attributes. Fields from hook formObjectOptions and Extrafields.
469 include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
470 } else {
471 // Login
472 print '<tr><td class="titlefieldmiddle">'.$langs->trans("Login").'</td>';
473 if (!empty($object->ldap_sid) && $object->statut == 0) {
474 print '<td class="error">';
475 print $langs->trans("LoginAccountDisableInDolibarr");
476 print '</td>';
477 } else {
478 print '<td>';
479 $addadmin = '';
480 if (property_exists($object, 'admin')) {
481 if (isModEnabled('multicompany') && !empty($object->admin) && empty($object->entity)) {
482 $addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "superadmin", 'class="paddingleft valignmiddle"');
483 } elseif (!empty($object->admin)) {
484 $addadmin .= img_picto($langs->trans("AdministratorDesc"), "admin", 'class="paddingleft valignmiddle"');
485 }
486 }
487 print showValueWithClipboardCPButton(!empty($object->login) ? $object->login : '').$addadmin;
488 print '</td>';
489 }
490 print '</tr>'."\n";
491
492 $object->fields['label']['visible'] = 0; // Already in banner
493 $object->fields['firstname']['visible'] = 0; // Already in banner
494 $object->fields['lastname']['visible'] = 0; // Already in banner
495 //include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
496
497 // Ref employee
498 print '<tr><td class="titlefield">'.$langs->trans("RefEmployee").'</td>';
499 print '<td class="error">';
500 print showValueWithClipboardCPButton(!empty($object->ref_employee) ? $object->ref_employee : '');
501 print '</td>';
502 print '</tr>'."\n";
503
504 // National Registration Number
505 print '<tr><td class="titlefield">'.$langs->trans("NationalRegistrationNumber").' <a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&objecttype=user&action=editnational_registration_number&token='.newToken().'">'.img_picto($langs->trans("Edit"), 'edit').'</a></td>';
506 print '<td>';
507 if ($action == 'editnational_registration_number') {
508 $ret = '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&objecttype=user">';
509 $ret .= '<input type="hidden" name="action" value="setnational_registration_number">';
510 $ret .= '<input type="hidden" name="token" value="'.newToken().'">';
511 $ret .= '<input type="hidden" name="id" value="'.$object->id.'">';
512 $ret .= '<input type="text" name="national_registration_number" value="'.$object->national_registration_number.'">';
513 $ret .= '<input type="submit" class="button smallpaddingimp" name="modify" value="'.$langs->trans("Modify").'"> ';
514 $ret .= '<input type="submit" class="button smallpaddingimp button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
515 $ret .= '</form>';
516 print $ret;
517 } else {
518 print showValueWithClipboardCPButton(!empty($object->national_registration_number) ? $object->national_registration_number : '');
519 }
520 print '</td>';
521 print '</tr>'."\n";
522 }
523
524 print '</table>';
525
526 print '</div>';
527 print '</div>';
528
529
530 print '<div class="clearboth"></div><br>';
531
532 if ($objecttype != 'user' && $permissiontoadd) {
533 // form to add new skills
534 print '<br>';
535 print '<form name="addSkill" method="post" action="' . $_SERVER['PHP_SELF'] . '">';
536 print '<input type="hidden" name="objecttype" value="' . $objecttype . '">';
537 print '<input type="hidden" name="id" value="' . $id . '">';
538 print '<input type="hidden" name="action" value="addSkill">';
539 print '<input type="hidden" name="token" value="'.newToken().'">';
540 print '<div class="div-table-responsive-no-min">';
541 print '<table id="tablelines" class="noborder noshadow" width="100%">';
542 print '<tr><td style="width:90%">' . $langs->trans('AddSkill') . '</td><td style="width:10%"></td></tr>';
543 print '<tr>';
544 print '<td>';
545 print img_picto('', 'shapes', 'class="pictofixedwidth"');
546 print $form->multiselectarray('fk_skill', array_diff_key($TAllSkillsFormatted, $TAlreadyUsedSkill), array(), 0, 0, 'widthcentpercentminusx') . '</td>';
547 print '<td><input class="button reposition" type="submit" value="' . $langs->trans('Add') . '"></td>';
548 print '</tr>';
549 print '</table>';
550 print '</div>';
551 print '</form>';
552 }
553 print '<br>';
554
555 print '<div class="clearboth"></div>';
556
557 if ($objecttype != 'user' && $permissiontoadd) {
558 print '<form name="saveSkill" method="post" action="' . $_SERVER['PHP_SELF'] . '">';
559 print '<input type="hidden" name="objecttype" value="' . $objecttype . '">';
560 print '<input type="hidden" name="id" value="' . $id . '">';
561 print '<input type="hidden" name="token" value="'.newToken().'">';
562 print '<input type="hidden" name="action" value="saveSkill">';
563 }
564 if ($objecttype != 'user') {
565 print '<div class="div-table-responsive-no-min">';
566 print '<table id="tablelines" class="noborder centpercent" width="100%">';
567 print '<tr class="liste_titre">';
568 print '<th>'.$langs->trans('SkillType').'</th>';
569 print '<th>'.$langs->trans('Label').'</th>';
570 print '<th>'.$langs->trans('Description').'</th>';
571 print '<th>'.$langs->trans($objecttype === 'job' ? 'RequiredRank' : 'EmployeeRank').'</th>'; // Always true - @phpstan-ignore identical.alwaysTrue
572 if ($objecttype === 'job') { // Always true - @phpstan-ignore identical.alwaysTrue
573 print '<th class="linecoledit"></th>';
574 print '<th class="linecoldelete"></th>';
575 }
576 print '</tr>';
577 if (!is_array($TSkillsJob) || empty($TSkillsJob)) {
578 print '<tr><td><span class="opacitymedium">' . $langs->trans("NoRecordFound") . '</span></td></tr>';
579 } else {
580 $sk = new Skill($db);
581 foreach ($TSkillsJob as $skillElement) {
582 $sk->fetch((int) $skillElement->fk_skill);
583 print '<tr>';
584 print '<td>';
585 print Skill::typeCodeToLabel($sk->skill_type);
586 print '</td><td class="linecolfk_skill">';
587 print $sk->getNomUrl(1);
588 print '</td>';
589 print '<td>';
590 print $sk->description;
591 print '</td><td class="linecolrank">';
592 print displayRankInfos($skillElement->rankorder, $skillElement->fk_skill, 'TNote', $objecttype == 'job' && $permissiontoadd ? 'edit' : 'view'); // Always true - @phpstan-ignore equal.alwaysTrue
593 print '</td>';
594 if ($objecttype != 'user' && $permissiontoadd) { // Always true - @phpstan-ignore notEqual.alwaysTrue
595 print '<td class="linecoledit"></td>';
596 print '<td class="linecoldelete">';
597 print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $skillElement->fk_object . '&amp;objecttype=' . $objecttype . '&amp;action=ask_deleteskill&amp;lineid=' . $skillElement->rowid . '&amp;token='.newToken().'">';
598 print img_delete();
599 print '</a>';
600 }
601 print '</td>';
602 print '</tr>';
603 }
604 }
605
606 print '</table>';
607 if ($objecttype != 'user' && $permissiontoadd) { // Left always true - @phpstan-ignore notEqual.alwaysTrue
608 print '<td><input class="button pull-right" type="submit" value="' . $langs->trans('SaveRank') . '"></td>';
609 }
610 print '</div>';
611 if ($objecttype != 'user' && $permissiontoadd) { // Left always true - @phpstan-ignore notEqual.alwaysTrue
612 print '</form>';
613 }
614 }
615
616
617 // list of linked evaluations
618 if ($objecttype == 'user' && $permissiontoadd) {
619 $evaltmp = new Evaluation($db);
620 $job = new Job($db);
621 $sql = "select e.rowid,e.ref,e.fk_user,e.fk_job,e.date_eval,ed.rankorder,ed.required_rank,ed.fk_skill,s.label";
622 $sql .= " FROM ".MAIN_DB_PREFIX."hrm_evaluation as e";
623 $sql .= ", ".MAIN_DB_PREFIX."hrm_evaluationdet as ed";
624 $sql .= ", ".MAIN_DB_PREFIX."hrm_skill as s";
625 $sql .= " WHERE e.rowid = ed.fk_evaluation";
626 $sql .= " AND s.rowid = ed.fk_skill";
627 $sql .= " AND e.fk_user = ".((int) $id);
628
629 $resql = $db->query($sql);
630 $num = $db->num_rows($resql);
631
632 //num of evaluations for each user
633 $sqlEval = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."hrm_evaluation as e";
634 $sqlEval .= " WHERE e.fk_user = ".((int) $id);
635 $rslt = $db->query($sqlEval);
636 $tmpobj = $db->fetch_object($rslt);
637 $numEval = 0;
638 if ($tmpobj) {
639 $numEval = $tmpobj->nb;
640 }
641
642 $page = 0;
643 print_barre_liste($langs->trans("Evaluations"), $page, $_SERVER["PHP_SELF"], '', '', '', '', $numEval, $numEval, $evaltmp->picto, 0);
644
645 print '<div class="div-table-responsive-no-min">';
646 print '<table id="tablelines" class="noborder centpercent">';
647 print '<tr class="liste_titre">';
648 print '<th>'.$langs->trans('Label').'</th>';
649 print '<th>'.$langs->trans('Description').'</th>';
650 print '<th>'.$langs->trans('DateEval').'</th>';
651 print '<th>'.$langs->trans('Status').'</th>';
652 print '<th>'.$langs->trans("Result").' ' .$form->textwithpicto('', GetLegendSkills(), 1) .'</th>';
653 print '</tr>';
654 if (!$resql) {
655 print '<tr><td><span class="opacitymedium">' . $langs->trans("NoRecordFound") . '</span></td></tr>';
656 } else {
657 $i = 0;
658 $sameRef = array();
660 $objects = array();
661 while ($i < $num) {
662 $obj = $db->fetch_object($resql);
663 $obj->result = getRankOrderResults($obj);
664 $objects[$i] = $obj;
665 $i++;
666 }
667
668 //grouped skills by evaluation
669 $resultArray = getGroupedEval($objects);
670 foreach ($resultArray as $object) {
671 if (is_array($object)) {
672 $evaltmp->fetch($object[0]->rowid);
673 $evaltmp->id = $object[0]->rowid;
674 $evaltmp->ref = $object[0]->ref;
675 $job->fetch($object[0]->fk_job);
676 } else {
677 $evaltmp->ref = $object->ref;
678 $evaltmp->fetch($object->rowid);
679 $evaltmp->id = $object->rowid;
680 $job->fetch($object->fk_job);
681 }
682
683 print '<tr>';
684 print '<td class="nowraponall">';
685 print $evaltmp->getNomUrl(1);
686 print '</td><td class="linecolfk_skill">';
687 print $job->getNomUrl(1);
688 print '</td>';
689 print '<td>';
690 print dol_print_date((!is_array($object) ? $object->date_eval : $object[0]->date_eval), 'day', 'tzserver');
691 print '</td><td>';
692 print $evaltmp->getLibStatut(2);
693 print '</td>';
694 print '<td class="linecolrank tdoverflowmax300">';
695 if ($job->status == $job::STATUS_VALIDATED) {
696 if (!is_array($object)) {
697 print $object->result;
698 } else {
699 foreach ($object as $skill) {
700 print $skill->result;
701 }
702 }
703 }
704 print '</td>';
705 print '</tr>';
706 }
707 }
708 print '</table>';
709 }
710
711 print dol_get_fiche_end();
712}
713
714llxFooter();
715$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class for Evaluation.
Class for EvaluationLine.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage building of HTML components.
Class for Job.
Definition job.class.php:38
Class for Skill.
static typeCodeToLabel($code)
Class for SkillRank.
Class to manage Dolibarr users.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
isModEnabled($module)
Is Dolibarr module enabled.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
GetLegendSkills()
getRankOrderResults($obj)
getGroupedEval($objects)
Grouped rows with same ref in array.
jobPrepareHead($object)
Prepare array of tabs for Job.
displayRankInfos($selected_rank, $fk_skill, $inputname='TNote', $mode='view')
Used to print ranks of a skill into several case, view or edit pour js necessary to select a rank.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:542
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $jsonclose='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
Definition html.lib.php:437
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:740
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
user_prepare_head(User $object)
Prepare array with list of tabs.