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