dolibarr  17.0.4
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/job.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/hrm/class/skill.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/hrm/class/skillrank.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/hrm/lib/hrm_evaluation.lib.php';
39 require_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();
70 foreach ($object->fields as $key => $val) {
71  if (GETPOST('search_'.$key, 'alpha')) {
72  $search[$key] = GETPOST('search_'.$key, 'alpha');
73  }
74 }
75 
76 if (empty($action) && empty($id) && empty($ref)) {
77  $action = 'view';
78 }
79 
80 // Load object
81 include 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 = (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->hrm->evaluation_advance->validate) || (empty($conf->global->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);
97 if (!isModEnabled("hrm")) {
99 }
100 if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) accessforbidden();
101 
102 
103 /*
104  * Actions
105  */
106 
107 $parameters = array();
108 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
109 if ($reshook < 0) {
110  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
111 }
112 
113 if (empty($reshook)) {
114  $error = 0;
115 
116  $backurlforlist = dol_buildpath('/hrm/evaluation_list.php', 1);
117 
118  if (empty($backtopage) || ($cancel && empty($id))) {
119  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
120  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
121  $backtopage = $backurlforlist;
122  } else {
123  $backtopage = dol_buildpath('/hrm/evaluation_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
124  }
125  }
126  }
127 
128  $triggermodname = 'hrm_EVALUATION_MODIFY'; // Name of trigger action code to execute when we modify record
129 
130  // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
131  include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
132 
133  // Actions when linking object each other
134  include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
135 
136  // Actions when printing a doc from card
137  include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
138 
139  // Action to move up and down lines of object
140  //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
141 
142  // Action to build doc
143  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
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 
221 
222 
223 
224 /*
225  * View
226  *
227  * Put here all code to build page
228  */
229 
230 $form = new Form($db);
231 $formfile = new FormFile($db);
232 $formproject = new FormProjets($db);
233 
234 $title = $langs->trans("Evaluation");
235 $help_url = '';
236 $css = array();
237 $css[] = '/hrm/css/style.css';
238 llxHeader('', $title, $help_url, '', 0, 0, '', $css);
239 
240 print '<script type="text/javascript" language="javascript">
241  $(document).ready(function() {
242  $("#btn_valid").click(function(){
243  var form = $("#form_save_rank");
244 
245  $.ajax({
246 
247  type: "POST",
248  url: form.attr("action"),
249  data: form.serialize(),
250  dataType: "json"
251  }).always(function() {
252  window.location.href = "'.dol_buildpath('/hrm/evaluation_card.php', 1).'?id='.$id.'&action=validate&token='.newToken().'";
253  return false;
254  });
255 
256  });
257  });
258 </script>';
259 
260 // Part to create
261 if ($action == 'create') {
262  print load_fiche_titre($langs->trans("NewEval"), '', 'object_' . $object->picto);
263 
264  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
265  print '<input type="hidden" name="token" value="'.newToken().'">';
266  print '<input type="hidden" name="action" value="add">';
267  if ($backtopage) {
268  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
269  }
270  if ($backtopageforcancel) {
271  print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
272  }
273 
274  print dol_get_fiche_head(array(), '');
275 
276  print '<table class="border centpercent tableforfieldcreate">'."\n";
277 
278  // Common attributes
279  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
280 
281  // Other attributes
282  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
283 
284  print '</table>'."\n";
285 
286  print dol_get_fiche_end();
287 
288  print $form->buttonsSaveCancel("Create", "Cancel");
289 
290  print '</form>';
291 }
292 
293 // Part to edit record
294 if (($id || $ref) && $action == 'edit') {
295  print load_fiche_titre($langs->trans("Evaluation"), '', 'object_'.$object->picto);
296 
297  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
298  print '<input type="hidden" name="token" value="'.newToken().'">';
299  print '<input type="hidden" name="action" value="update">';
300  print '<input type="hidden" name="id" value="'.$object->id.'">';
301  if ($backtopage) {
302  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
303  }
304  if ($backtopageforcancel) {
305  print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
306  }
307 
308  print dol_get_fiche_head();
309 
310  print '<table class="border centpercent tableforfieldedit">'."\n";
311 
312  // Common attributes
313  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
314 
315  // Other attributes
316  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
317 
318  print '</table>';
319 
320  print dol_get_fiche_end();
321 
322  print $form->buttonsSaveCancel();
323 
324  print '</form>';
325 }
326 
327 // Part to show record
328 if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
329  $res = $object->fetch_optionals();
330 
331  $head = evaluationPrepareHead($object);
332  print dol_get_fiche_head($head, 'card', $langs->trans("Workstation"), -1, $object->picto);
333 
334  $formconfirm = '';
335 
336  if ($action == 'validate' && $permissiontovalidate) {
337  // Confirm validate proposal
338  $error = 0;
339 
340  // We verify whether the object is provisionally numbering
341  $ref = substr($object->ref, 1, 4);
342  if ($ref == 'PROV') {
343  $numref = $object->getNextNumRef();
344  if (empty($numref)) {
345  $error++;
346  setEventMessages($object->error, $object->errors, 'errors');
347  }
348  } else {
349  $numref = $object->ref;
350  }
351 
352  $text = $langs->trans('ConfirmValidateEvaluation', $numref);
353  if (isModEnabled('notification')) {
354  require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
355  $notify = new Notify($db);
356  $text .= '<br>';
357  $text .= $notify->confirmMessage('HRM_EVALUATION_VALIDATE', $object->socid, $object);
358  }
359 
360  if (!$error) {
361  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateEvaluation'), $text, 'confirm_validate', '', 0, 1);
362  }
363  }
364 
365  // Confirmation to delete
366  if ($action == 'delete') {
367  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteEvaluation'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
368  }
369  // Confirmation to delete line
370  if ($action == 'deleteline') {
371  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
372  }
373  // Clone confirmation
374  if ($action == 'clone') {
375  // Create an array for form
376  $formquestion = array();
377  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
378  }
379 
380  // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...)
381  if ($action == 'xxx') {
382  $text = $langs->trans('ConfirmActionMyObject', $object->ref);
383 
384  $formquestion = array();
385 
386  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
387  }
388 
389  // Call Hook formConfirm
390  $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
391  $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
392  if (empty($reshook)) {
393  $formconfirm .= $hookmanager->resPrint;
394  } elseif ($reshook > 0) {
395  $formconfirm = $hookmanager->resPrint;
396  }
397 
398  // Print form confirm
399  print $formconfirm;
400 
401 
402  // Object card
403  // ------------------------------------------------------------
404  $linkback = '<a href="'.dol_buildpath('/hrm/evaluation_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
405 
406  $morehtmlref = '<div class="refidno">';
407  $morehtmlref .= $langs->trans('Label').' : '.$object->label;
408  $u_position = new User(($db));
409  $u_position->fetch($object->fk_user);
410  $morehtmlref .= '<br>'.$u_position->getNomUrl(1);
411  $job = new Job($db);
412  $job->fetch($object->fk_job);
413  $morehtmlref .= '<br>'.$langs->trans('JobProfile').' : '.$job->getNomUrl(1);
414  $morehtmlref .= '</div>';
415 
416 
417 
418  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
419 
420 
421  print '<div class="fichecenter">';
422  print '<div class="fichehalfleft">';
423  print '<div class="underbanner clearboth"></div>';
424  print '<table class="border centpercent tableforfield">'."\n";
425 
426  $object->fields['label']['visible']=0; // Already in banner
427  $object->fields['fk_user']['visible']=0; // Already in banner
428  $object->fields['fk_job']['visible']=0; // Already in banner
429  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
430 
431  // Other attributes. Fields from hook formObjectOptions and Extrafields.
432  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
433 
434  print '</table>';
435  print '</div>';
436  print '</div>';
437 
438  print '<div class="clearboth"></div>';
439 
440  print dol_get_fiche_end();
441 
442 
443  /*
444  * Lines
445  */
446 
447  if (!empty($object->table_element_line) && $object->status == Evaluation::STATUS_DRAFT) {
448  // Show object lines
449  $result = $object->getLinesArray();
450  if ($result < 0) {
451  dol_print_error($db, $object->error, $object->errors);
452  }
453 
454  print '<br>';
455 
456  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">
457  <input type="hidden" name="token" value="' . newToken().'">
458  <input type="hidden" name="action" value="saveSkill">
459  <input type="hidden" name="mode" value="">
460  <input type="hidden" name="page_y" value="">
461  <input type="hidden" name="id" value="' . $object->id.'">
462  ';
463 
464  if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
465  include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
466  }
467 
468  $conf->modules_parts['tpl']['hrm']='/hrm/core/tpl/'; // Pour utilisation du tpl hrm sur cet écran
469 
470  print '<div class="div-table-responsive-no-min">';
471  if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
472  print '<table id="tablelines" class="noborder noshadow" width="100%">';
473  }
474 
475  //if (!empty($object->lines)) {
476  $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
477  //}
478 
479  // Form to add new line
480  /*
481  if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
482  if ($action != 'editline') {
483  // Add products/services form
484 
485  $parameters = array();
486  $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
487  if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
488  if (empty($reshook))
489  $object->formAddObjectLine(1, $mysoc, $soc);
490  }
491  }
492  */
493 
494  if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
495  print '</table>';
496  }
497  print '</div>';
498 
499  print "</form>\n";
500 
501  print "<br>";
502  }
503 
504  // list of comparison
505  if ($object->status != Evaluation::STATUS_DRAFT) {
506  // Recovery of skills related to this evaluation
507 
508  $sql = 'select';
509  $sql .= ' e.ref,';
510  $sql .= ' e.date_creation,';
511  $sql .= ' e.fk_job,';
512  $sql .= ' j.label as "refjob",';
513  $sql .= ' ed.fk_skill,';
514 
515  $sql .= ' sk.label as "skilllabel",';
516  $sql .= ' sk.skill_type,';
517  $sql .= ' sk.description,';
518  $sql .= ' ed.rankorder,';
519  $sql .= ' ed.required_rank,';
520  $sql .= ' ed.rankorder as "userRankForSkill",';
521  $sql .= ' skdet_user.description as "userRankForSkillDesc",';
522  $sql .= ' skdet_required.description as "required_rank_desc"';
523 
524  $sql .= ' FROM ' . MAIN_DB_PREFIX . 'hrm_evaluation as e';
525  $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'hrm_evaluationdet as ed ON e.rowid = ed.fk_evaluation';
526  $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'hrm_job as j ON e.fk_job = j.rowid';
527  $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'hrm_skill as sk ON ed.fk_skill = sk.rowid';
528  $sql .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'hrm_skilldet as skdet_user ON (skdet_user.fk_skill = sk.rowid AND skdet_user.rankorder = ed.rankorder)';
529  //$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')";
530  $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)';
531  $sql .= " WHERE e.rowid =" . ((int) $object->id);
532 
533  // echo $sql;
534 
535  $resql = $db->query($sql);
536  $Tab = array();
537 
538  if ($resql) {
539  $num = 0;
540  while ($obj = $db->fetch_object($resql)) {
541  $Tab[$num] = new stdClass();
542  $class = '';
543  $Tab[$num]->skill_type = $obj->skill_type;
544  $Tab[$num]->skill_id = $obj->fk_skill;
545  $Tab[$num]->skilllabel = $obj->skilllabel;
546  $Tab[$num]->description = $obj->description;
547  $Tab[$num]->userRankForSkill = '<span title="'.$obj->userRankForSkillDesc.'" class="radio_js_bloc_number TNote_1">' . $obj->userRankForSkill . '</span>';
548  $Tab[$num]->required_rank = '<span title="'.$obj->required_rank_desc.'" class="radio_js_bloc_number TNote_1">' . $obj->required_rank . '</span>';
549 
550  if ($obj->userRankForSkill > $obj->required_rank) {
551  $title=$langs->trans('MaxlevelGreaterThanShort');
552  $class .= 'veryhappy diffnote';
553  } elseif ($obj->userRankForSkill == $obj->required_rank) {
554  $title=$langs->trans('MaxLevelEqualToShort');
555  $class .= 'happy diffnote';
556  } elseif ($obj->userRankForSkill < $obj->required_rank) {
557  $title=$langs->trans('MaxLevelLowerThanShort');
558  $class .= 'sad';
559  }
560 
561  $Tab[$num]->result = '<span title="'.$title.'" class="classfortooltip ' . $class . ' note">&nbsp;</span>';
562 
563  $num++;
564  }
565 
566  print '<div class="underbanner clearboth"></div>';
567  print '<table class="noborder centpercent">';
568 
569  print '<tr class="liste_titre">';
570  print '<th style="width:auto;text-align:auto" class="liste_titre">' . $langs->trans("TypeSkill") . ' </th>';
571  print '<th style="width:auto;text-align:auto" class="liste_titre">' . $langs->trans("Label") . '</th>';
572  print '<th style="width:auto;text-align:auto" class="liste_titre">' . $langs->trans("Description") . '</th>';
573  print '<th style="width:auto;text-align:center" class="liste_titre">' . $langs->trans("EmployeeRank") . '</th>';
574  print '<th style="width:auto;text-align:center" class="liste_titre">' . $langs->trans("RequiredRank") . '</th>';
575  print '<th style="width:auto;text-align:auto" class="liste_titre">' . $langs->trans("Result") . ' ' .$form->textwithpicto('', GetLegendSkills(), 1) .'</th>';
576  print '</tr>';
577 
578  $sk = new Skill($db);
579  foreach ($Tab as $t) {
580  $sk->fetch($t->skill_id);
581  print '<tr>';
582  print ' <td>' . Skill::typeCodeToLabel($t->skill_type) . '</td>';
583  print ' <td>' . $sk->getNomUrl(1) . '</td>';
584  print ' <td>' . $t->description . '</td>';
585  print ' <td align="center">' . $t->userRankForSkill . '</td>';
586  print ' <td align="center">' . $t->required_rank . '</td>';
587  print ' <td>' . $t->result . '</td>';
588  print '</tr>';
589  }
590 
591  print '</table>';
592 
593  ?>
594 
595  <script>
596 
597  $(document).ready(function() {
598  $(".radio_js_bloc_number").tooltip();
599  });
600 
601  </script>
602 
603  <?php
604  }
605  }
606 
607  // Buttons for actions
608  if ($action != 'presend' && $action != 'editline') {
609  print '<div class="tabsAction">'."\n";
610  $parameters = array();
611  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
612  if ($reshook < 0) {
613  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
614  }
615 
616  if (empty($reshook)) {
617  // Send
618  if (empty($user->socid)) {
619  print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init&token='.newToken().'#formmailbeforetitle');
620  }
621 
622  // Back to draft
623  if ($object->status == $object::STATUS_VALIDATED) {
624  print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd);
625  print dolGetButtonAction('', $langs->trans('Close'), 'close', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_CLOSED && $permissiontoclose));
626  } elseif ($object->status != $object::STATUS_CLOSED) {
627  print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
628  }
629 
630  if ($object->status == $object::STATUS_CLOSED) {
631  print dolGetButtonAction($langs->trans('ReOpen'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken(), '', $permissiontoadd);
632  }
633 
634 
635  // Validate
636  if ($object->status == $object::STATUS_DRAFT) {
637  if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
638  print dolGetButtonAction($langs->trans('Save').'&nbsp;'.$langs->trans('and').'&nbsp;'.$langs->trans('Valid'), '', 'default', '#', 'btn_valid', $permissiontovalidate);
639  } else {
640  $langs->load("errors");
641  print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0);
642  }
643  }
644 
645 
646  // Delete (need delete permission, or if draft, just need create/modify permission)
647  print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete);
648  }
649 
650 
651  print '</div>'."\n";
652  }
653 
654  // Select mail models is same action as presend
655  if (GETPOST('modelselected')) {
656  $action = 'presend';
657  }
658 
659  if ($action != 'presend') {
660  print '<div class="fichecenter"><div class="fichehalfleft">';
661  print '<a name="builddoc"></a>'; // ancre
662 
663  $includedocgeneration = 0;
664 
665  // Documents
666  if ($includedocgeneration) {
667  $objref = dol_sanitizeFileName($object->ref);
668  $relativepath = $objref.'/'.$objref.'.pdf';
669  $filedir = $conf->hrm->dir_output.'/'.$object->element.'/'.$objref;
670  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
671  $genallowed = $user->rights->hrm->evaluation->read; // If you can read, you can build the PDF to read content
672  $delallowed = $user->rights->hrm->evaluation->write; // If you can create/edit, you can remove a file on card
673  print $formfile->showdocuments('hrm:Evaluation', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
674  }
675 
676  // Show links to link elements
677  $linktoelem = $form->showLinkToObjectBlock($object, null, array('evaluation'));
678  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
679 
680 
681  print '</div><div class="fichehalfright">';
682 
683  $MAXEVENT = 10;
684 
685  $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/hrm/evaluation_agenda.php?id='.$object->id);
686 
687  // List of actions on element
688  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
689  $formactions = new FormActions($db);
690  $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
691 
692  print '</div></div>';
693  }
694 
695  //Select mail models is same action as presend
696  if (GETPOST('modelselected')) {
697  $action = 'presend';
698  }
699 
700  // Presend form
701  $modelmail = 'evaluation';
702  $defaulttopic = 'InformationMessage';
703  $diroutput = $conf->hrm->dir_output;
704  $trackid = 'evaluation'.$object->id;
705 
706  include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
707 }
708 
709 // End of page
710 llxFooter();
711 $db->close();
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:118
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:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class for Evaluation.
Class to manage standard extra fields.
Class to manage building of HTML components.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage building of HTML components.
Class for Job.
Definition: job.class.php:37
Class to manage notifications.
Class for Skill.
Definition: skill.class.php:37
static typeCodeToLabel($code)
Class for SkillRank.
Class to manage Dolibarr users.
Definition: user.class.php:47
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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='')
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages 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.
setEventMessage($mesgs, $style='mesgs')
Set event message 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.
isModEnabled($module)
Is Dolibarr module enabled.
evaluationPrepareHead($object)
Prepare array of tabs for Evaluation.
GetLegendSkills()
$formconfirm
if ($action == 'delbookkeepingyear') {
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.