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