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'), '', null, '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] == "NA" ? -1 : $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 '@phan-var-force SkillRank[] $SkillrecordsForActiveUser';
175
176 $errors = 0;
177 // we go through the evaldets of the eval
178 foreach ($object->lines as $key => $line) {
179 // no reference .. we add the line to use it
180 if (count($SkillrecordsForActiveUser) == 0) {
181 $newSkill = new SkillRank($db);
182 $resCreate = $newSkill->cloneFromCurrentSkill($line, $object->fk_user);
183
184 if ($resCreate <= 0) {
185 $errors++;
186 setEventMessage($langs->trans('ErrorCreateUserSkill', $line->fk_skill));
187 }
188 } else {
189 //check if the skill is present to use it
190 $find = false;
191 $keyFind = 0;
192 foreach ($SkillrecordsForActiveUser as $k => $sr) {
193 if ($sr->fk_skill == $line->fk_skill) {
194 $keyFind = $k;
195 $find = true;
196 break;
197 }
198 }
199 //we update the skill user
200 if ($find) {
201 $updSkill = $SkillrecordsForActiveUser[$k];
202
203 $updSkill->rankorder = $line->rankorder;
204 $updSkill->update($user);
205 } else { // sinon on ajoute la skill
206 $newSkill = new SkillRank($db);
207 $resCreate = $newSkill->cloneFromCurrentSkill($line, $object->fk_user);
208 }
209 }
210 }
211 if (empty($errors)) {
212 $object->setStatut(Evaluation::STATUS_CLOSED);
213 setEventMessage('EmployeeSkillsUpdated');
214 }
215 }
216
217 if ($action == 'reopen' && $permissiontoadd) {
218 // no update here we just change the evaluation status
219 $object->setStatut(Evaluation::STATUS_VALIDATED);
220 }
221
222 // Action to build doc
223 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
224
225 // action to remove file
226 if ($action == 'remove_file_comfirm' && $permissiontoadd) {
227 // Delete file in doc form
228 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
229
230 $upload_dir = $conf->hrm->dir_output;
231 $file = $upload_dir.'/'.GETPOST('file');
232 $ret = dol_delete_file($file, 0, 0, 0, $object);
233 if ($ret) {
234 setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
235 } else {
236 setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
237 }
238 }
239}
240
241
242
243
244/*
245 * View
246 *
247 * Put here all code to build page
248 */
249
250$form = new Form($db);
251$formfile = new FormFile($db);
252$formproject = new FormProjets($db);
253
254$title = $langs->trans("Evaluation");
255$help_url = '';
256$css = array();
257$css[] = '/hrm/css/style.css';
258llxHeader('', $title, $help_url, '', 0, 0, '', $css);
259
260print '<script type="text/javascript" language="javascript">
261 $(document).ready(function() {
262 $("#btn_valid").click(function(){
263 var form = $("#form_save_rank");
264
265 $.ajax({
266
267 type: "POST",
268 url: form.attr("action"),
269 data: form.serialize(),
270 dataType: "json"
271 }).always(function() {
272 window.location.href = "'.dol_buildpath('/hrm/evaluation_card.php', 1).'?id='.$id.'&action=validate&token='.newToken().'";
273 return false;
274 });
275
276 });
277 });
278</script>';
279
280// Part to create
281if ($action == 'create') {
282 print load_fiche_titre($langs->trans("NewEval"), '', 'object_' . $object->picto);
283
284 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
285 print '<input type="hidden" name="token" value="'.newToken().'">';
286 print '<input type="hidden" name="action" value="add">';
287 if ($backtopage) {
288 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
289 }
290 if ($backtopageforcancel) {
291 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
292 }
293
294 print dol_get_fiche_head(array(), '');
295
296 print '<table class="border centpercent tableforfieldcreate">'."\n";
297
298 // Common attributes
299 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
300
301 // Other attributes
302 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
303
304 print '</table>'."\n";
305
306 print dol_get_fiche_end();
307
308 print $form->buttonsSaveCancel("Create", "Cancel");
309
310 print '</form>';
311}
312
313// Part to edit record
314if (($id || $ref) && $action == 'edit') {
315 print load_fiche_titre($langs->trans("Evaluation"), '', 'object_'.$object->picto);
316
317 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
318 print '<input type="hidden" name="token" value="'.newToken().'">';
319 print '<input type="hidden" name="action" value="update">';
320 print '<input type="hidden" name="id" value="'.$object->id.'">';
321 if ($backtopage) {
322 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
323 }
324 if ($backtopageforcancel) {
325 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
326 }
327
328 print dol_get_fiche_head();
329
330 print '<table class="border centpercent tableforfieldedit">'."\n";
331
332 // Common attributes
333 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
334
335 // Other attributes
336 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
337
338 print '</table>';
339
340 print dol_get_fiche_end();
341
342 print $form->buttonsSaveCancel();
343
344 print '</form>';
345}
346
347// Part to show record
348if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
349 $res = $object->fetch_optionals();
350
351 $head = evaluationPrepareHead($object);
352 print dol_get_fiche_head($head, 'card', $langs->trans("Workstation"), -1, $object->picto);
353
354 $formconfirm = '';
355
356 if ($action == 'validate' && $permissiontovalidate) {
357 // Confirm validate proposal
358 $error = 0;
359
360 // We verify whether the object is provisionally numbering
361 $ref = substr($object->ref, 1, 4);
362 if ($ref == 'PROV') {
363 $numref = $object->getNextNumRef();
364 if (empty($numref)) {
365 $error++;
366 setEventMessages($object->error, $object->errors, 'errors');
367 }
368 } else {
369 $numref = $object->ref;
370 }
371
372 $text = $langs->trans('ConfirmValidateEvaluation', $numref);
373 if (isModEnabled('notification')) {
374 require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
375 $notify = new Notify($db);
376 $text .= '<br>';
377 $text .= $notify->confirmMessage('HRM_EVALUATION_VALIDATE', 0, $object);
378 }
379
380 if (!$error) {
381 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateEvaluation'), $text, 'confirm_validate', '', 0, 1);
382 }
383 }
384
385 // Confirmation to delete
386 if ($action == 'delete') {
387 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteEvaluation'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
388 }
389 // Confirmation to delete line
390 if ($action == 'deleteline') {
391 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
392 }
393 // Clone confirmation
394 if ($action == 'clone') {
395 // Create an array for form
396 $formquestion = array();
397 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
398 }
399
400 // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...)
401 if ($action == 'xxx') {
402 $text = $langs->trans('ConfirmActionMyObject', $object->ref);
403
404 $formquestion = array();
405
406 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
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 == -1) {
584 $title = $langs->trans('NA');
585 $class .= 'veryhappy diffnote';
586 } elseif ($obj->userRankForSkill > $obj->required_rank) {
587 $title = $langs->trans('MaxlevelGreaterThanShort');
588 $class .= 'veryhappy diffnote';
589 } elseif ($obj->userRankForSkill == $obj->required_rank) {
590 $title = $langs->trans('MaxLevelEqualToShort');
591 $class .= 'happy diffnote';
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'), 'default', $_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
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.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
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.