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