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