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