dolibarr 25.0.0-alpha
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
66$object = new Evaluation($db);
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 $maxrank = getDolGlobalInt('HRM_MAXRANK', Skill::DEFAULT_MAX_RANK_PER_SKILL);
142 foreach ($object->lines as $line) {
143 if (!isset($TNote[$line->fk_skill])) {
144 continue; // No rank received for this skill, we keep the current one
145 }
146 $newrank = ($TNote[$line->fk_skill] == "NA" ? -1 : (int) $TNote[$line->fk_skill]);
147 if ($newrank < -1 || $newrank > $maxrank) {
148 // A rank can only be "not applicable" (-1) or a level between 0 and the maximum number of levels
149 $langs->load("errors");
150 setEventMessages($langs->trans("ErrorBadValueForParameter", $TNote[$line->fk_skill], 'TNote['.$line->fk_skill.']'), null, 'errors');
151 continue;
152 }
153 $line->rankorder = $newrank;
154 $result = $line->update($user);
155 if ($result < 0) {
156 setEventMessages($line->error, $line->errors, 'errors');
157 }
158 }
159 //setEventMessage($langs->trans("SaveLevelSkill"));
160 }
161
162 $action = 'validate';
163 }
164
165 if ($action == "validate" && $permissiontoadd) {
166 // Levels are saved in database as soon as they are clicked (see core/ajax/objectfield.php)
167 $emptyTNote = true;
168 foreach ($object->lines as $line) {
169 if ($line->rankorder != "") {
170 $emptyTNote = false;
171 break;
172 }
173 }
174 if ($emptyTNote) {
175 setEventMessage($langs->trans("WarningEvaluationEmptyValidate"), 'errors');
176 $action = '';
177 }
178 }
179
180 $triggermodname = 'HRM_EVALUATION_MODIFY'; // Name of trigger action code to execute when we modify record
181
182 // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
183 include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
184
185 // Actions when linking object each other
186 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
187
188 // Actions when printing a doc from card
189 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
190
191 // Action to move up and down lines of object
192 //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
193
194
195 if ($action == 'set_thirdparty' && $permissiontoadd) {
196 $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', null, 'date', '', $user, $triggermodname);
197 }
198 if ($action == 'classin' && $permissiontoadd) {
199 $object->setProject(GETPOSTINT('projectid'));
200 }
201
202 // Actions to send emails
203 $triggersendname = 'HRM_EVALUATION_SENTBYMAIL';
204 $autocopy = 'MAIN_MAIL_AUTOCOPY_EVALUATION_TO';
205 $trackid = 'evaluation'.$object->id;
206 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
207
208 if ($action == 'close' && $permissiontoadd && $object->status == Evaluation::STATUS_VALIDATED) { // Only a validated assessment can be closed
209 // save evaldet lines to user;
210 $sk = new SkillRank($db);
211 $SkillrecordsForActiveUser = $sk->fetchAll('ASC', 'fk_skill', 0, 0, "(fk_object:=:".((int) $object->fk_user).") AND (objecttype:=:'".$db->escape(SkillRank::SKILLRANK_TYPE_USER)."')", 'AND');
212 '@phan-var-force SkillRank[] $SkillrecordsForActiveUser';
213
214 $errors = 0;
215 // we go through the evaldets of the eval
216 foreach ($object->lines as $key => $line) {
217 // no reference .. we add the line to use it
218 if (count($SkillrecordsForActiveUser) == 0) {
219 $newSkill = new SkillRank($db);
220 $resCreate = $newSkill->cloneFromCurrentSkill($line, $object->fk_user);
221
222 if ($resCreate <= 0) {
223 $errors++;
224 setEventMessage($langs->trans('ErrorCreateUserSkill', $line->fk_skill));
225 }
226 } else {
227 //check if the skill is present to use it
228 $keyFind = 0;
229 foreach ($SkillrecordsForActiveUser as $k => $sr) {
230 if ($sr->fk_skill == $line->fk_skill) {
231 $keyFind = $k;
232 break;
233 }
234 }
235 //we update the skill user
236 if ($keyFind) {
237 $updSkill = $SkillrecordsForActiveUser[$keyFind];
238
239 $updSkill->rankorder = $line->rankorder;
240 $result = $updSkill->update($user);
241 if ($result < 0) {
242 $errors++;
243 setEventMessages($updSkill->error, $updSkill->errors, 'errors');
244 }
245 } else { // else we create the skill
246 $newSkill = new SkillRank($db);
247 $resCreate = $newSkill->cloneFromCurrentSkill($line, $object->fk_user);
248
249 if ($resCreate <= 0) {
250 $errors++;
251 setEventMessage($langs->trans('ErrorCreateUserSkill', $line->fk_skill), 'errors');
252 }
253 }
254 }
255 }
256 if (empty($errors)) {
257 $object->setStatut(Evaluation::STATUS_CLOSED);
258 setEventMessage('EmployeeSkillsUpdated');
259 }
260 }
261
262 if ($action == 'reopen' && $permissiontoadd && $object->status == Evaluation::STATUS_CLOSED) { // Only a closed assessment can be reopened
263 // no update here we just change the evaluation status
264 $object->setStatut(Evaluation::STATUS_VALIDATED);
265 }
266
267 // Action to build doc
268 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
269
270 // action to remove file
271 if ($action == 'remove_file_comfirm' && $permissiontoadd) {
272 // Delete file in doc form
273 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
274
275 $upload_dir = $conf->hrm->dir_output;
276 $file = $upload_dir.'/'.GETPOST('file');
277 $ret = dol_delete_file($file, 1, 0, 0, $object);
278 if ($ret) {
279 setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
280 } else {
281 setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
282 }
283 }
284}
285
286
287/*
288 * View
289 */
290
291$form = new Form($db);
292$formfile = new FormFile($db);
293
294$title = $langs->trans("Evaluation");
295$help_url = '';
296$css = array();
297$css[] = '/hrm/css/style.css';
298llxHeader('', $title, $help_url, '', 0, 0, '', $css);
299
300$urltopost = DOL_URL_ROOT.'/core/ajax/objectfield.php';
301?>
302<script>
303 $(document).ready(function() {
304 // Save the level of a skill as soon as it is clicked, so it is not lost when leaving the page
305 $("#form_save_rank").on("change", "input[name^=TNote]", function() {
306 var lineid = $(this).closest("tr").attr("id").replace(/^row-/, "");
307 var rank = $(this).val();
308 if (rank == "NA") {
309 rank = -1; /* Not applicable */
310 }
311 console.log("Save rank "+rank+" for evaluation line "+lineid);
312 $.post('<?php echo dol_escape_js($urltopost); ?>', {
313 token: '<?php echo currentToken(); ?>',
314 element: "evaluationdet",
315 id: lineid,
316 field: "rankorder",
317 ajaxfield_rankorder: rank
318 }).fail(async function(xhr) {
319 let msg = (xhr.responseJSON && xhr.responseJSON.msg) ? xhr.responseJSON.msg : '';
320 if (!msg) {
321 await Dolibarr.tools.langs.load('main');
322 msg = Dolibarr.tools.langs.trans('ErrorFailedToUpdateRecord');
323 }
324 $.jnotify(msg, 'error', true);
325 });
326 });
327 });
328</script>
329<?php
330
331// Part to create
332if ($action == 'create') {
333 print load_fiche_titre($langs->trans("NewEval"), '', 'object_' . $object->picto);
334
335 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
336 print '<input type="hidden" name="token" value="'.newToken().'">';
337 print '<input type="hidden" name="action" value="add">';
338 if ($backtopage) {
339 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
340 }
341 if ($backtopageforcancel) {
342 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
343 }
344
345 print dol_get_fiche_head(array(), '');
346
347 print '<table class="border centpercent tableforfieldcreate">'."\n";
348
349 // Common attributes
350 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
351
352 // Other attributes
353 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
354
355 print '</table>'."\n";
356
357 print dol_get_fiche_end();
358
359 print $form->buttonsSaveCancel("Create", "Cancel");
360
361 print '</form>';
362}
363
364// Part to edit record
365if (($id || $ref) && $action == 'edit') {
366 print load_fiche_titre($langs->trans("Evaluation"), '', 'object_'.$object->picto);
367
368 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
369 print '<input type="hidden" name="token" value="'.newToken().'">';
370 print '<input type="hidden" name="action" value="update">';
371 print '<input type="hidden" name="id" value="'.$object->id.'">';
372 if ($backtopage) {
373 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
374 }
375 if ($backtopageforcancel) {
376 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
377 }
378
379 print dol_get_fiche_head();
380
381 print '<table class="border centpercent tableforfieldedit">'."\n";
382
383 // Common attributes
384 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
385
386 // Other attributes
387 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
388
389 print '</table>';
390
391 print dol_get_fiche_end();
392
393 print $form->buttonsSaveCancel();
394
395 print '</form>';
396}
397
398// Part to show record
399if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
400 $res = $object->fetch_optionals();
401
402 $head = evaluationPrepareHead($object);
403 print dol_get_fiche_head($head, 'card', $langs->trans("Workstation"), -1, $object->picto, 0, '', '', 0, '', 1);
404
405 $formconfirm = '';
406
407 if ($action == 'validate' && $permissiontovalidate) {
408 // Confirm validate proposal
409 $error = 0;
410
411 // We verify whether the object is provisionally numbering
412 $ref = substr($object->ref, 1, 4);
413 if ($ref == 'PROV') {
414 $numref = $object->getNextNumRef();
415 if (empty($numref)) {
416 $error++;
417 setEventMessages($object->error, $object->errors, 'errors');
418 }
419 } else {
420 $numref = (string) $object->ref;
421 }
422
423 $text = $langs->trans('ConfirmValidateEvaluation', $numref);
424 if (isModEnabled('notification')) {
425 require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
426 $notify = new Notify($db);
427 $text .= '<br>';
428 $text .= $notify->confirmMessage('HRM_EVALUATION_VALIDATE', 0, $object);
429 }
430
431 if (!$error) {
432 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateEvaluation'), $text, 'confirm_validate', '', 0, 1);
433 }
434 }
435
436 // Confirmation to delete
437 if ($action == 'delete') {
438 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteEvaluation'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
439 }
440 // Confirmation to delete line
441 if ($action == 'deleteline') {
442 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
443 }
444 // Clone confirmation
445 if ($action == 'clone') {
446 // Create an array for form
447 $formquestion = array();
448 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
449 }
450
451 // Call Hook formConfirm
452 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
453 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
454 if (empty($reshook)) {
455 $formconfirm .= $hookmanager->resPrint;
456 } elseif ($reshook > 0) {
457 $formconfirm = $hookmanager->resPrint;
458 }
459
460 // Print form confirm
461 print $formconfirm;
462
463
464 // Object card
465 // ------------------------------------------------------------
466 $linkback = '<a href="'.dol_buildpath('/hrm/evaluation_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
467
468 $morehtmlref = '<div class="refidno">';
469 $morehtmlref .= $langs->trans('Label').' : '.$object->label;
470 $u_position = new User(($db));
471 $u_position->fetch($object->fk_user);
472 $morehtmlref .= '<br>'.$u_position->getNomUrl(1);
473 $job = new Job($db);
474 $job->fetch($object->fk_job);
475 $morehtmlref .= '<br>'.$langs->trans('JobProfile').' : '.$job->getNomUrl(1);
476 $morehtmlref .= '</div>';
477
478
479
480 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
481
482
483 print '<div class="fichecenter">';
484 print '<div class="fichehalfleft">';
485 print '<div class="underbanner clearboth"></div>';
486 print '<table class="border centpercent tableforfield">'."\n";
487
488 $object->fields['label']['visible'] = 0; // Already in banner
489 $object->fields['fk_user']['visible'] = 0; // Already in banner
490 $object->fields['fk_job']['visible'] = 0; // Already in banner
491 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
492
493 // Other attributes. Fields from hook formObjectOptions and Extrafields.
494 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
495
496 print '</table>';
497 print '</div>';
498 print '</div>';
499
500 print '<div class="clearboth"></div>';
501
502 print dol_get_fiche_end();
503
504
505 // Lines when evaluation is in edit mode
506
507 if (!empty($object->table_element_line) && $object->status == Evaluation::STATUS_DRAFT) {
508 // Show object lines
509 $result = $object->getLinesArray();
510 if ($result < 0) {
511 dol_print_error($db, $object->error, $object->errors);
512 }
513
514 print '<br>';
515
516 print ' <form name="form_save_rank" id="form_save_rank" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '' : '#line_'.GETPOSTINT('lineid')).'" method="POST">
517 <input type="hidden" name="token" value="' . newToken().'">
518 <input type="hidden" name="action" value="saveSkill">
519 <input type="hidden" name="mode" value="">
520 <input type="hidden" name="page_y" value="">
521 <input type="hidden" name="id" value="' . $object->id.'">
522 ';
523
524 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
525 include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
526 }
527
528 $conf->modules_parts['tpl']['hrm'] = '/hrm/core/tpl/'; // To use the hrm tpl on this screen
529
530 print '<div class="div-table-responsive-no-min">';
531 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
532 print '<table id="tablelines" class="noborder noshadow centpercent">';
533 }
534
535 // Lines of evaluated skills
536 // $object is Evaluation
537 $object->printObjectLines($action, $mysoc, null, GETPOSTINT('lineid'), 1);
538
539 if (empty($object->lines)) {
540 print '<tr><td colspan="4"><span class="opacitymedium">'.img_warning().' '.$langs->trans("TheJobProfileHasNoSkillsDefinedFixBefore").'</td></tr>';
541 }
542
543 // Form to add new line
544 /*
545 if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
546 if ($action != 'editline') {
547 // Add products/services form
548
549 $parameters = array();
550 $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
551 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
552 if (empty($reshook))
553 $object->formAddObjectLine(1, $mysoc, $soc);
554 }
555 }
556 */
557
558 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
559 print '</table>';
560 }
561 print '</div>';
562
563 print "</form>\n";
564
565 print "<br>";
566 }
567
568 // Lines when evaluation is validated
569
570 if ($object->status != Evaluation::STATUS_DRAFT) {
571 // Recovery of skills related to this evaluation
572
573 $sql = 'select';
574 $sql .= ' e.ref,';
575 $sql .= ' e.date_creation,';
576 $sql .= ' e.fk_job,';
577 $sql .= ' j.label as "refjob",';
578 $sql .= ' ed.fk_skill,';
579
580 $sql .= ' sk.label as "skilllabel",';
581 $sql .= ' sk.skill_type,';
582 $sql .= ' sk.description,';
583 $sql .= ' ed.rankorder,';
584 $sql .= ' ed.required_rank,';
585 $sql .= ' ed.rankorder as "userRankForSkill",';
586 $sql .= ' skdet_user.description as "userRankForSkillDesc",';
587 $sql .= ' skdet_required.description as "required_rank_desc"';
588
589 $sql .= ' FROM ' . MAIN_DB_PREFIX . 'hrm_evaluation as e';
590 $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'hrm_evaluationdet as ed ON e.rowid = ed.fk_evaluation';
591 $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'hrm_job as j ON e.fk_job = j.rowid';
592 $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'hrm_skill as sk ON ed.fk_skill = sk.rowid';
593 $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'hrm_skilldet as skdet_user ON (skdet_user.fk_skill = sk.rowid AND skdet_user.rankorder = ed.rankorder)';
594 //$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')";
595 $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)';
596 $sql .= " WHERE e.rowid =" . ((int) $object->id);
597
598 // echo $sql;
599
600 $resql = $db->query($sql);
601 $Tab = array();
602
603 if ($resql) {
604 $num = 0;
605 while ($obj = $db->fetch_object($resql)) {
606 $Tab[$num] = new stdClass();
607 $class = '';
608 $Tab[$num]->skill_type = $obj->skill_type;
609 $Tab[$num]->skill_id = $obj->fk_skill;
610 $Tab[$num]->skilllabel = $obj->skilllabel;
611 $Tab[$num]->description = $obj->description;
612
613 $rank = $obj->userRankForSkill;
614 $rank_desc = $obj->userRankForSkillDesc;
615 if ($obj->userRankForSkill < 0) {
616 $rank = $langs->trans('NA');
617 $rank_desc = $langs->trans("NA");
618 }
619 if ($obj->userRankForSkill == 0) {
620 $rank = "-";
621 }
622 $Tab[$num]->userRankForSkill = '<span title="'.$rank_desc.'" class="radio_js_bloc_number TNote_1">' . $rank . '</span>';
623
624 $required_rank = $obj->required_rank;
625 $required_rank_desc = $obj->required_rank_desc;
626 if ($required_rank == "-1") {
627 $required_rank = $langs->trans("NA");
628 $required_rank_desc = $langs->trans("NA");
629 } elseif ($required_rank == "0") {
630 $required_rank_desc = $langs->trans('SkillNotRequired');
631 }
632
633 $Tab[$num]->required_rank = '<span title="'.$required_rank_desc.'" class="radio_js_bloc_number TNote_1">' . $required_rank . '</span>';
634
635 if ($obj->userRankForSkill < 0 || $obj->required_rank < 0) {
636 $title = $langs->trans('NA');
637 $class .= 'na';
638 } elseif ($obj->userRankForSkill > $obj->required_rank) {
639 $title = $langs->trans('MaxlevelGreaterThanShort');
640 $class .= 'veryhappy';
641 } elseif ($obj->userRankForSkill == $obj->required_rank) {
642 $title = $langs->trans('MaxLevelEqualToShort');
643 $class .= 'happy';
644 } elseif ($obj->userRankForSkill < $obj->required_rank) {
645 $title = $langs->trans('MaxLevelLowerThanShort');
646 $class .= 'sad';
647 }
648
649 $Tab[$num]->result = '<span title="'.$title.'" class="classfortooltip ' . $class . ' note">&nbsp;</span>';
650
651 $num++;
652 }
653
654 print '<br>';
655
656 print '<div class="div-table-responsive-no-min">';
657 print '<table id="tablelines" class="noborder noshadow centpercent">';
658
659 print '<tr class="liste_titre">';
660 print '<th style="width:auto;text-align:auto" class="liste_titre">' . $langs->trans("TypeSkill") . ' </th>';
661 print '<th style="width:auto;text-align:auto" class="liste_titre">' . $langs->trans("Label") . '</th>';
662 print '<th style="width:auto;text-align:auto" class="liste_titre">' . $langs->trans("Description") . '</th>';
663 print '<th style="width:auto;text-align:center" class="liste_titre">' . $langs->trans("EmployeeRank") . '</th>';
664 print '<th style="width:auto;text-align:center" class="liste_titre">' . $langs->trans("RequiredRank") . '</th>';
665 print '<th style="width:auto;text-align:auto" class="liste_titre">' . $langs->trans("Result") . ' ' .$form->textwithpicto('', GetLegendSkills(), 1) .'</th>';
666 print '</tr>';
667
668 $sk = new Skill($db);
669 foreach ($Tab as $t) {
670 $sk->fetch($t->skill_id);
671
672 print '<tr>';
673 print ' <td>' . dolPrintHTML(Skill::typeCodeToLabel($t->skill_type)) . '</td>';
674 print ' <td class="tdoverflowmax200">' . $sk->getNomUrl(1) . '</td>';
675 print ' <td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($t->description).'">' . dolPrintHTML($t->description) . '</td>';
676 print ' <td class="center">' . $t->userRankForSkill . '</td>';
677 print ' <td class="center">' . $t->required_rank . '</td>';
678 print ' <td>' . $t->result . '</td>';
679 print '</tr>';
680 }
681
682 print '</table>';
683 print '</div>'; ?>
684
685 <script>
686
687 $(document).ready(function() {
688 $(".radio_js_bloc_number").tooltip();
689 });
690
691 </script>
692
693 <?php
694 }
695 }
696
697 // Buttons for actions
698 if ($action != 'presend' && $action != 'editline') {
699 print '<div class="tabsAction">'."\n";
700 $parameters = array();
701 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
702 if ($reshook < 0) {
703 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
704 }
705
706 if (empty($reshook)) {
707 // Send
708 if (empty($user->socid)) {
709 print dolGetButtonAction('', $langs->trans('SendMail'), 'email', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init&token='.newToken().'#formmailbeforetitle');
710 }
711
712 // Back to draft
713 if ($object->status == $object::STATUS_VALIDATED) {
714 print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd);
715 print dolGetButtonAction('', $langs->trans('Close'), 'close', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_CLOSED && $permissiontoclose));
716 } elseif ($object->status != $object::STATUS_CLOSED) {
717 print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
718 }
719
720 if ($object->status == $object::STATUS_CLOSED) {
721 print dolGetButtonAction($langs->trans('ReOpen'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken(), '', $permissiontoadd);
722 }
723
724
725 // Validate
726 if ($object->status == $object::STATUS_DRAFT) {
727 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
728 print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=validate&token='.newToken(), 'btn_valid', $permissiontovalidate);
729 } else {
730 $langs->load("errors");
731 print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0);
732 }
733 }
734
735
736 // Delete (need delete permission, or if draft, just need create/modify permission)
737 print dolGetButtonAction($langs->trans('Delete'), $langs->trans('Delete'), 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete, array('attr' => array('class' => 'reposition')))."\n";
738 }
739
740
741 print '</div>'."\n";
742 }
743
744 // Select mail models is same action as presend
745 if (GETPOST('modelselected')) {
746 $action = 'presend';
747 }
748
749 if ($action != 'presend') {
750 print '<div class="fichecenter"><div class="fichehalfleft">';
751 print '<a name="builddoc"></a>'; // ancre
752
753 $includedocgeneration = 1;
754
755 // Documents
756 if ($user->hasRight('hrm', 'evaluation', 'read')) {
757 $objref = dol_sanitizeFileName($object->ref);
758 $relativepath = $objref.'/'.$objref.'.pdf';
759 $filedir = $conf->hrm->dir_output.'/'.$object->element.'/'.$objref;
760 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
761 $genallowed = $user->hasRight('hrm', 'evaluation', 'read'); // If you can read, you can build the PDF to read content
762 $delallowed = $user->hasRight('hrm', 'evaluation', 'write'); // If you can create/edit, you can remove a file on card
763 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');
764 }
765
766 // Show links to link elements
767 $tmparray = $form->showLinkToObjectBlock($object, array(), array('evaluation'), 1);
768 $linktoelem = $tmparray['linktoelem'];
769 $htmltoenteralink = $tmparray['htmltoenteralink'];
770 print $htmltoenteralink;
771
772 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
773
774
775 print '</div><div class="fichehalfright">';
776
777 $MAXEVENT = 10;
778
779 $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/hrm/evaluation_agenda.php?id='.$object->id);
780
781 // List of actions on element
782 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
783 $formactions = new FormActions($db);
784 $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
785
786 print '</div></div>';
787 }
788
789 //Select mail models is same action as presend
790 /*if (GETPOST('modelselected')) {
791 // $action = 'presend';
792 }*/ // To delete.
793
794 // Presend form
795 $modelmail = 'evaluation';
796 $defaulttopic = 'InformationMessage';
797 $diroutput = $conf->hrm->dir_output.'/evaluation';
798 $trackid = 'evaluation'.$object->id;
799
800 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
801}
802
803// End of page
804llxFooter();
805$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
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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()
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:542
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:740
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
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.
if(empty( $takeposterminal)) fail($message)
Abort invoice creation with a given error message.
Definition invoice.php:125