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