dolibarr 24.0.0-beta
evaluation_card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
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 MDW <mdeweerd@users.noreply.github.com>
8 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30// Load Dolibarr environment
31require '../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
43require_once DOL_DOCUMENT_ROOT.'/hrm/class/evaluation.class.php';
44require_once DOL_DOCUMENT_ROOT.'/hrm/class/job.class.php';
45require_once DOL_DOCUMENT_ROOT.'/hrm/class/skill.class.php';
46require_once DOL_DOCUMENT_ROOT.'/hrm/class/skillrank.class.php';
47require_once DOL_DOCUMENT_ROOT.'/hrm/lib/hrm_evaluation.lib.php';
48require_once DOL_DOCUMENT_ROOT.'/hrm/lib/hrm_skillrank.lib.php';
49
50
51// Load translation files required by the page
52$langs->loadLangs(array('hrm', 'other', 'products')); // why products?
53
54// Get parameters
55$id = GETPOSTINT('id');
56$ref = GETPOST('ref', 'alpha');
57$action = GETPOST('action', 'aZ09');
58$confirm = GETPOST('confirm', 'alpha');
59$cancel = GETPOST('cancel');
60$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'evaluationcard'; // To manage different context of search
61$backtopage = GETPOST('backtopage', 'alpha');
62$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
63$lineid = GETPOSTINT('lineid');
64
65// Initialize a technical objects
67$extrafields = new ExtraFields($db);
68$diroutputmassaction = $conf->hrm->dir_output.'/temp/massgeneration/'.$user->id;
69$hookmanager->initHooks(array('evaluationcard', 'globalcard')); // Note that conf->hooks_modules contains array
70
71// Fetch optionals attributes and labels
72$extrafields->fetch_name_optionals_label($object->table_element);
73
74$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
75
76// Initialize array of search criteria
77$search_all = GETPOST("search_all", 'alpha');
78$search = array();
79foreach ($object->fields as $key => $val) {
80 if (GETPOST('search_'.$key, 'alpha')) {
81 $search[$key] = GETPOST('search_'.$key, 'alpha');
82 }
83}
84
85if (empty($action) && empty($id) && empty($ref)) {
86 $action = 'view';
87}
88
89// Load object
90include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
91
92// Permissions
93$permissiontoread = $user->hasRight('hrm', 'evaluation', 'read');
94$permissiontoadd = $user->hasRight('hrm', 'evaluation', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
95$permissiontovalidate = (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('hrm', 'evaluation_advance', 'validate')) || (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $permissiontoadd);
96$permissiontoclose = $user->hasRight('hrm', 'evaluation', 'write');
97$permissiontodelete = $user->hasRight('hrm', 'evaluation', 'delete')/* || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT)*/;
98$permissiondellink = $user->hasRight('hrm', 'evaluation', 'write'); // Used by the include of actions_dellink.inc.php
99$upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1].'/evaluation';
100
101// Security check (enable the most restrictive one)
102//if ($user->socid > 0) accessforbidden();
103//if ($user->socid > 0) $socid = $user->socid;
104$isdraft = ($object->status == Evaluation::STATUS_DRAFT) ? 1 : 0;
105restrictedArea($user, $object->element, $object, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
106if (!isModEnabled("hrm")) {
108}
109if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) {
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_buildpath('/hrm/evaluation_list.php', 1);
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)) { // Test on permission not required
131 $backtopage = $backurlforlist;
132 } else {
133 $backtopage = dol_buildpath('/hrm/evaluation_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
134 }
135 }
136 }
137
138 if ($action == 'saveSkill' && $permissiontoadd) {
139 $TNote = GETPOST('TNote', 'array');
140 if (!empty($TNote)) {
141 foreach ($object->lines as $line) {
142 $line->rankorder = ($TNote[$line->fk_skill] == "NA" ? -1 : $TNote[$line->fk_skill]);
143 $line->update($user);
144 }
145 //setEventMessage($langs->trans("SaveLevelSkill"));
146 }
147
148 $action = 'validate';
149 }
150
151 if ($action == "validate" && $permissiontoadd) {
152 $TNote = GETPOST('TNote', 'array');
153 $emptyTNote = true;
154 foreach ($object->lines as $line) {
155 if (!in_array($TNote[$line->fk_skill], array("0", ""))) {
156 $emptyTNote = false;
157 break;
158 }
159 }
160 if ($emptyTNote) {
161 setEventMessage($langs->trans("WarningEvaluationEmptyValidate"), 'errors');
162 $action = '';
163 }
164 }
165
166 $triggermodname = 'HRM_EVALUATION_MODIFY'; // Name of trigger action code to execute when we modify record
167
168 // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
169 include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
170
171 // Actions when linking object each other
172 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
173
174 // Actions when printing a doc from card
175 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
176
177 // Action to move up and down lines of object
178 //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
179
180
181 if ($action == 'set_thirdparty' && $permissiontoadd) {
182 $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', null, 'date', '', $user, $triggermodname);
183 }
184 if ($action == 'classin' && $permissiontoadd) {
185 $object->setProject(GETPOSTINT('projectid'));
186 }
187
188 // Actions to send emails
189 $triggersendname = 'HRM_EVALUATION_SENTBYMAIL';
190 $autocopy = 'MAIN_MAIL_AUTOCOPY_EVALUATION_TO';
191 $trackid = 'evaluation'.$object->id;
192 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
193
194 if ($action == 'close' && $permissiontoadd) {
195 // save evaldet lines to user;
196 $sk = new SkillRank($db);
197 $SkillrecordsForActiveUser = $sk->fetchAll('ASC', 'fk_skill', 0, 0, "(fk_object:=:".((int) $object->fk_user).") AND (objecttype:=:'".$db->escape(SkillRank::SKILLRANK_TYPE_USER)."')", 'AND');
198 '@phan-var-force SkillRank[] $SkillrecordsForActiveUser';
199
200 $errors = 0;
201 // we go through the evaldets of the eval
202 foreach ($object->lines as $key => $line) {
203 // no reference .. we add the line to use it
204 if (count($SkillrecordsForActiveUser) == 0) {
205 $newSkill = new SkillRank($db);
206 $resCreate = $newSkill->cloneFromCurrentSkill($line, $object->fk_user);
207
208 if ($resCreate <= 0) {
209 $errors++;
210 setEventMessage($langs->trans('ErrorCreateUserSkill', $line->fk_skill));
211 }
212 } else {
213 //check if the skill is present to use it
214 $keyFind = 0;
215 foreach ($SkillrecordsForActiveUser as $k => $sr) {
216 if ($sr->fk_skill == $line->fk_skill) {
217 $keyFind = $k;
218 break;
219 }
220 }
221 //we update the skill user
222 if ($keyFind) {
223 $updSkill = $SkillrecordsForActiveUser[$keyFind];
224
225 $updSkill->rankorder = $line->rankorder;
226 $updSkill->update($user);
227 } else { // else we create the skill
228 $newSkill = new SkillRank($db);
229 $resCreate = $newSkill->cloneFromCurrentSkill($line, $object->fk_user);
230 }
231 }
232 }
233 if (empty($errors)) {
234 $object->setStatut(Evaluation::STATUS_CLOSED);
235 setEventMessage('EmployeeSkillsUpdated');
236 }
237 }
238
239 if ($action == 'reopen' && $permissiontoadd) {
240 // no update here we just change the evaluation status
241 $object->setStatut(Evaluation::STATUS_VALIDATED);
242 }
243
244 // Action to build doc
245 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
246
247 // action to remove file
248 if ($action == 'remove_file_comfirm' && $permissiontoadd) {
249 // Delete file in doc form
250 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
251
252 $upload_dir = $conf->hrm->dir_output;
253 $file = $upload_dir.'/'.GETPOST('file');
254 $ret = dol_delete_file($file, 0, 0, 0, $object);
255 if ($ret) {
256 setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
257 } else {
258 setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
259 }
260 }
261}
262
263
264/*
265 * View
266 */
267
268$form = new Form($db);
269$formfile = new FormFile($db);
270
271$title = $langs->trans("Evaluation");
272$help_url = '';
273$css = array();
274$css[] = '/hrm/css/style.css';
275llxHeader('', $title, $help_url, '', 0, 0, '', $css);
276?>
277<script>
278 $(document).ready(function() {
279 $("#btn_valid").click(function() {
280 console.log("Click on btn_valid");
281 var form = $("#form_save_rank");
282 form.submit();
283 return true;
284 });
285 });
286</script>
287<?php
288
289// Part to create
290if ($action == 'create') {
291 print load_fiche_titre($langs->trans("NewEval"), '', 'object_' . $object->picto);
292
293 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
294 print '<input type="hidden" name="token" value="'.newToken().'">';
295 print '<input type="hidden" name="action" value="add">';
296 if ($backtopage) {
297 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
298 }
299 if ($backtopageforcancel) {
300 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
301 }
302
303 print dol_get_fiche_head(array(), '');
304
305 print '<table class="border centpercent tableforfieldcreate">'."\n";
306
307 // Common attributes
308 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
309
310 // Other attributes
311 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
312
313 print '</table>'."\n";
314
315 print dol_get_fiche_end();
316
317 print $form->buttonsSaveCancel("Create", "Cancel");
318
319 print '</form>';
320}
321
322// Part to edit record
323if (($id || $ref) && $action == 'edit') {
324 print load_fiche_titre($langs->trans("Evaluation"), '', 'object_'.$object->picto);
325
326 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
327 print '<input type="hidden" name="token" value="'.newToken().'">';
328 print '<input type="hidden" name="action" value="update">';
329 print '<input type="hidden" name="id" value="'.$object->id.'">';
330 if ($backtopage) {
331 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
332 }
333 if ($backtopageforcancel) {
334 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
335 }
336
337 print dol_get_fiche_head();
338
339 print '<table class="border centpercent tableforfieldedit">'."\n";
340
341 // Common attributes
342 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
343
344 // Other attributes
345 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
346
347 print '</table>';
348
349 print dol_get_fiche_end();
350
351 print $form->buttonsSaveCancel();
352
353 print '</form>';
354}
355
356// Part to show record
357if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
358 $res = $object->fetch_optionals();
359
360 $head = evaluationPrepareHead($object);
361 print dol_get_fiche_head($head, 'card', $langs->trans("Workstation"), -1, $object->picto);
362
363 $formconfirm = '';
364
365 if ($action == 'validate' && $permissiontovalidate) {
366 // Confirm validate proposal
367 $error = 0;
368
369 // We verify whether the object is provisionally numbering
370 $ref = substr($object->ref, 1, 4);
371 if ($ref == 'PROV') {
372 $numref = $object->getNextNumRef();
373 if (empty($numref)) {
374 $error++;
375 setEventMessages($object->error, $object->errors, 'errors');
376 }
377 } else {
378 $numref = (string) $object->ref;
379 }
380
381 $text = $langs->trans('ConfirmValidateEvaluation', $numref);
382 if (isModEnabled('notification')) {
383 require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
384 $notify = new Notify($db);
385 $text .= '<br>';
386 $text .= $notify->confirmMessage('HRM_EVALUATION_VALIDATE', 0, $object);
387 }
388
389 if (!$error) {
390 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateEvaluation'), $text, 'confirm_validate', '', 0, 1);
391 }
392 }
393
394 // Confirmation to delete
395 if ($action == 'delete') {
396 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteEvaluation'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
397 }
398 // Confirmation to delete line
399 if ($action == 'deleteline') {
400 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
401 }
402 // Clone confirmation
403 if ($action == 'clone') {
404 // Create an array for form
405 $formquestion = array();
406 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
407 }
408
409 // Call Hook formConfirm
410 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
411 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
412 if (empty($reshook)) {
413 $formconfirm .= $hookmanager->resPrint;
414 } elseif ($reshook > 0) {
415 $formconfirm = $hookmanager->resPrint;
416 }
417
418 // Print form confirm
419 print $formconfirm;
420
421
422 // Object card
423 // ------------------------------------------------------------
424 $linkback = '<a href="'.dol_buildpath('/hrm/evaluation_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
425
426 $morehtmlref = '<div class="refidno">';
427 $morehtmlref .= $langs->trans('Label').' : '.$object->label;
428 $u_position = new User(($db));
429 $u_position->fetch($object->fk_user);
430 $morehtmlref .= '<br>'.$u_position->getNomUrl(1);
431 $job = new Job($db);
432 $job->fetch($object->fk_job);
433 $morehtmlref .= '<br>'.$langs->trans('JobProfile').' : '.$job->getNomUrl(1);
434 $morehtmlref .= '</div>';
435
436
437
438 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
439
440
441 print '<div class="fichecenter">';
442 print '<div class="fichehalfleft">';
443 print '<div class="underbanner clearboth"></div>';
444 print '<table class="border centpercent tableforfield">'."\n";
445
446 $object->fields['label']['visible'] = 0; // Already in banner
447 $object->fields['fk_user']['visible'] = 0; // Already in banner
448 $object->fields['fk_job']['visible'] = 0; // Already in banner
449 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
450
451 // Other attributes. Fields from hook formObjectOptions and Extrafields.
452 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
453
454 print '</table>';
455 print '</div>';
456 print '</div>';
457
458 print '<div class="clearboth"></div>';
459
460 print dol_get_fiche_end();
461
462
463 // Lines when evaluation is in edit mode
464
465 if (!empty($object->table_element_line) && $object->status == Evaluation::STATUS_DRAFT) {
466 // Show object lines
467 $result = $object->getLinesArray();
468 if ($result < 0) {
469 dol_print_error($db, $object->error, $object->errors);
470 }
471
472 print '<br>';
473
474 print ' <form name="form_save_rank" id="form_save_rank" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '' : '#line_'.GETPOSTINT('lineid')).'" method="POST">
475 <input type="hidden" name="token" value="' . newToken().'">
476 <input type="hidden" name="action" value="saveSkill">
477 <input type="hidden" name="mode" value="">
478 <input type="hidden" name="page_y" value="">
479 <input type="hidden" name="id" value="' . $object->id.'">
480 ';
481
482 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
483 include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
484 }
485
486 $conf->modules_parts['tpl']['hrm'] = '/hrm/core/tpl/'; // Pour utilisation du tpl hrm sur cet écran
487
488 print '<div class="div-table-responsive-no-min">';
489 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
490 print '<table id="tablelines" class="noborder noshadow centpercent">';
491 }
492
493 // Lines of evaluated skills
494 // $object is Evaluation
495 $object->printObjectLines($action, $mysoc, null, GETPOSTINT('lineid'), 1);
496
497 if (empty($object->lines)) {
498 print '<tr><td colspan="4"><span class="opacitymedium">'.img_warning().' '.$langs->trans("TheJobProfileHasNoSkillsDefinedFixBefore").'</td></tr>';
499 }
500
501 // Form to add new line
502 /*
503 if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
504 if ($action != 'editline') {
505 // Add products/services form
506
507 $parameters = array();
508 $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
509 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
510 if (empty($reshook))
511 $object->formAddObjectLine(1, $mysoc, $soc);
512 }
513 }
514 */
515
516 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
517 print '</table>';
518 }
519 print '</div>';
520
521 print "</form>\n";
522
523 print "<br>";
524 }
525
526 // Lines when evaluation is validated
527
528 if ($object->status != Evaluation::STATUS_DRAFT) {
529 // Recovery of skills related to this evaluation
530
531 $sql = 'select';
532 $sql .= ' e.ref,';
533 $sql .= ' e.date_creation,';
534 $sql .= ' e.fk_job,';
535 $sql .= ' j.label as "refjob",';
536 $sql .= ' ed.fk_skill,';
537
538 $sql .= ' sk.label as "skilllabel",';
539 $sql .= ' sk.skill_type,';
540 $sql .= ' sk.description,';
541 $sql .= ' ed.rankorder,';
542 $sql .= ' ed.required_rank,';
543 $sql .= ' ed.rankorder as "userRankForSkill",';
544 $sql .= ' skdet_user.description as "userRankForSkillDesc",';
545 $sql .= ' skdet_required.description as "required_rank_desc"';
546
547 $sql .= ' FROM ' . MAIN_DB_PREFIX . 'hrm_evaluation as e';
548 $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'hrm_evaluationdet as ed ON e.rowid = ed.fk_evaluation';
549 $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'hrm_job as j ON e.fk_job = j.rowid';
550 $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'hrm_skill as sk ON ed.fk_skill = sk.rowid';
551 $sql .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'hrm_skilldet as skdet_user ON (skdet_user.fk_skill = sk.rowid AND skdet_user.rankorder = ed.rankorder)';
552 //$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "hrm_skillrank as skr ON (j.rowid = skr.fk_object AND skr.fk_skill = ed.fk_skill AND skr.objecttype = 'job')";
553 $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'hrm_skilldet as skdet_required ON (skdet_required.fk_skill = sk.rowid AND skdet_required.rankorder = ed.required_rank)';
554 $sql .= " WHERE e.rowid =" . ((int) $object->id);
555
556 // echo $sql;
557
558 $resql = $db->query($sql);
559 $Tab = array();
560
561 if ($resql) {
562 $num = 0;
563 while ($obj = $db->fetch_object($resql)) {
564 $Tab[$num] = new stdClass();
565 $class = '';
566 $Tab[$num]->skill_type = $obj->skill_type;
567 $Tab[$num]->skill_id = $obj->fk_skill;
568 $Tab[$num]->skilllabel = $obj->skilllabel;
569 $Tab[$num]->description = $obj->description;
570 $Tab[$num]->userRankForSkill = '<span title="'.$obj->userRankForSkillDesc.'" class="radio_js_bloc_number TNote_1">' . $obj->userRankForSkill . '</span>';
571
572 $required_rank = $obj->required_rank;
573 $required_rank_desc = $obj->required_rank_desc;
574 if ($required_rank == "-1") {
575 $required_rank = $langs->trans("NA");
576 $required_rank_desc = $langs->trans("NA");
577 } elseif ($required_rank == "0") {
578 $required_rank_desc = $langs->trans('SkillNotRequired');
579 }
580
581 $Tab[$num]->required_rank = '<span title="'.$required_rank_desc.'" class="radio_js_bloc_number TNote_1">' . $required_rank . '</span>';
582
583 if ($obj->userRankForSkill < 0 || $obj->required_rank < 0) {
584 $title = $langs->trans('NA');
585 $class .= 'na';
586 } elseif ($obj->userRankForSkill > $obj->required_rank) {
587 $title = $langs->trans('MaxlevelGreaterThanShort');
588 $class .= 'veryhappy';
589 } elseif ($obj->userRankForSkill == $obj->required_rank) {
590 $title = $langs->trans('MaxLevelEqualToShort');
591 $class .= 'happy';
592 } elseif ($obj->userRankForSkill < $obj->required_rank) {
593 $title = $langs->trans('MaxLevelLowerThanShort');
594 $class .= 'sad';
595 }
596
597 $Tab[$num]->result = '<span title="'.$title.'" class="classfortooltip ' . $class . ' note">&nbsp;</span>';
598
599 $num++;
600 }
601
602 print '<br>';
603
604 print '<div class="div-table-responsive-no-min">';
605 print '<table id="tablelines" class="noborder noshadow centpercent">';
606
607 print '<tr class="liste_titre">';
608 print '<th style="width:auto;text-align:auto" class="liste_titre">' . $langs->trans("TypeSkill") . ' </th>';
609 print '<th style="width:auto;text-align:auto" class="liste_titre">' . $langs->trans("Label") . '</th>';
610 print '<th style="width:auto;text-align:auto" class="liste_titre">' . $langs->trans("Description") . '</th>';
611 print '<th style="width:auto;text-align:center" class="liste_titre">' . $langs->trans("EmployeeRank") . '</th>';
612 print '<th style="width:auto;text-align:center" class="liste_titre">' . $langs->trans("RequiredRank") . '</th>';
613 print '<th style="width:auto;text-align:auto" class="liste_titre">' . $langs->trans("Result") . ' ' .$form->textwithpicto('', GetLegendSkills(), 1) .'</th>';
614 print '</tr>';
615
616 $sk = new Skill($db);
617 foreach ($Tab as $t) {
618 $sk->fetch($t->skill_id);
619
620 print '<tr>';
621 print ' <td>' . dolPrintHTML(Skill::typeCodeToLabel($t->skill_type)) . '</td>';
622 print ' <td class="tdoverflowmax200">' . $sk->getNomUrl(1) . '</td>';
623 print ' <td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($t->description).'">' . dolPrintHTML($t->description) . '</td>';
624 print ' <td class="center">' . $t->userRankForSkill . '</td>';
625 print ' <td class="center">' . $t->required_rank . '</td>';
626 print ' <td>' . $t->result . '</td>';
627 print '</tr>';
628 }
629
630 print '</table>';
631 print '</div>'; ?>
632
633 <script>
634
635 $(document).ready(function() {
636 $(".radio_js_bloc_number").tooltip();
637 });
638
639 </script>
640
641 <?php
642 }
643 }
644
645 // Buttons for actions
646 if ($action != 'presend' && $action != 'editline') {
647 print '<div class="tabsAction">'."\n";
648 $parameters = array();
649 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
650 if ($reshook < 0) {
651 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
652 }
653
654 if (empty($reshook)) {
655 // Send
656 if (empty($user->socid)) {
657 print dolGetButtonAction('', $langs->trans('SendMail'), 'email', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init&token='.newToken().'#formmailbeforetitle');
658 }
659
660 // Back to draft
661 if ($object->status == $object::STATUS_VALIDATED) {
662 print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd);
663 print dolGetButtonAction('', $langs->trans('Close'), 'close', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_CLOSED && $permissiontoclose));
664 } elseif ($object->status != $object::STATUS_CLOSED) {
665 print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
666 }
667
668 if ($object->status == $object::STATUS_CLOSED) {
669 print dolGetButtonAction($langs->trans('ReOpen'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken(), '', $permissiontoadd);
670 }
671
672
673 // Validate
674 if ($object->status == $object::STATUS_DRAFT) {
675 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
676 print dolGetButtonAction($langs->trans('Save').'&nbsp;'.$langs->trans('and').'&nbsp;'.$langs->trans('Valid'), '', 'default', '#', 'btn_valid', $permissiontovalidate);
677 } else {
678 $langs->load("errors");
679 print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0);
680 }
681 }
682
683
684 // Delete (need delete permission, or if draft, just need create/modify permission)
685 print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete);
686 }
687
688
689 print '</div>'."\n";
690 }
691
692 // Select mail models is same action as presend
693 if (GETPOST('modelselected')) {
694 $action = 'presend';
695 }
696
697 if ($action != 'presend') {
698 print '<div class="fichecenter"><div class="fichehalfleft">';
699 print '<a name="builddoc"></a>'; // ancre
700
701 $includedocgeneration = 1;
702
703 // Documents
704 if ($user->hasRight('hrm', 'evaluation', 'read')) {
705 $objref = dol_sanitizeFileName($object->ref);
706 $relativepath = $objref.'/'.$objref.'.pdf';
707 $filedir = $conf->hrm->dir_output.'/'.$object->element.'/'.$objref;
708 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
709 $genallowed = $user->hasRight('hrm', 'evaluation', 'read'); // If you can read, you can build the PDF to read content
710 $delallowed = $user->hasRight('hrm', 'evaluation', 'write'); // If you can create/edit, you can remove a file on card
711 print $formfile->showdocuments('hrm:Evaluation', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang, '', $object, 0, 'remove_file_comfirm');
712 }
713
714 // Show links to link elements
715 $tmparray = $form->showLinkToObjectBlock($object, array(), array('evaluation'), 1);
716 $linktoelem = $tmparray['linktoelem'];
717 $htmltoenteralink = $tmparray['htmltoenteralink'];
718 print $htmltoenteralink;
719
720 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
721
722
723 print '</div><div class="fichehalfright">';
724
725 $MAXEVENT = 10;
726
727 $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/hrm/evaluation_agenda.php?id='.$object->id);
728
729 // List of actions on element
730 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
731 $formactions = new FormActions($db);
732 $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
733
734 print '</div></div>';
735 }
736
737 //Select mail models is same action as presend
738 /*if (GETPOST('modelselected')) {
739 // $action = 'presend';
740 }*/ // To delete.
741
742 // Presend form
743 $modelmail = 'evaluation';
744 $defaulttopic = 'InformationMessage';
745 $diroutput = $conf->hrm->dir_output;
746 $trackid = 'evaluation'.$object->id;
747
748 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
749}
750
751// End of page
752llxFooter();
753$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 to manage standard extra fields.
Class to manage building of HTML components.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class for Job.
Definition job.class.php:38
Class to manage the table of subscription to notifications.
Class for Skill.
static typeCodeToLabel($code)
Class for SkillRank.
Class to manage Dolibarr users.
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
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.
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_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
evaluationPrepareHead($object)
Prepare array of tabs for Evaluation.
GetLegendSkills()
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.