29 require
'../main.inc.php';
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';
42 $langs->loadLangs(array(
"hrm",
"other",
'products'));
47 $action =
GETPOST(
'action',
'aZ09');
48 $confirm =
GETPOST(
'confirm',
'alpha');
49 $cancel =
GETPOST(
'cancel',
'aZ09');
50 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'evaluationcard';
51 $backtopage =
GETPOST(
'backtopage',
'alpha');
52 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
58 $diroutputmassaction = $conf->hrm->dir_output.
'/temp/massgeneration/'.$user->id;
59 $hookmanager->initHooks(array(
'evaluationcard',
'globalcard'));
62 $extrafields->fetch_name_optionals_label($object->table_element);
64 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
67 $search_all =
GETPOST(
"search_all",
'alpha');
69 foreach ($object->fields as $key => $val) {
70 if (
GETPOST(
'search_'.$key,
'alpha')) {
71 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
75 if (empty($action) && empty($id) && empty($ref)) {
80 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
83 $permissiontoread = $user->rights->hrm->evaluation->read;
84 $permissiontoadd = $user->rights->hrm->evaluation->write;
85 $permissiontovalidate = $user->rights->hrm->evaluation_advance->validate;
86 $permissiontoClose = $user->rights->hrm->evaluation->write;
87 $permissiontodelete = $user->rights->hrm->evaluation->delete;
88 $permissiondellink = $user->rights->hrm->evaluation->write;
89 $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1].
'/evaluation';
97 if (!$permissiontoread || ($action ===
'create' && !$permissiontoadd))
accessforbidden();
104 $parameters = array();
105 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
110 if (empty($reshook)) {
113 $backurlforlist =
dol_buildpath(
'/hrm/evaluation_list.php', 1);
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;
120 $backtopage =
dol_buildpath(
'/hrm/evaluation_card.php', 1).
'?id='.($id > 0 ? $id :
'__ID__');
125 $triggermodname =
'hrm_EVALUATION_MODIFY';
128 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
131 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
134 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
140 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
142 if ($action ==
'set_thirdparty' && $permissiontoadd) {
143 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
145 if ($action ==
'classin' && $permissiontoadd) {
146 $object->setProject(
GETPOST(
'projectid',
'int'));
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';
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);
166 if ($action ==
'close') {
169 $SkillrecordsForActiveUser = $sk->fetchAll(
'ASC',
'fk_skill', 0, 0, array(
"customsql"=>
"fk_object = ".$object->fk_user .
" AND objecttype ='".SkillRank::SKILLRANK_TYPE_USER.
"'"),
'AND');
173 foreach ($object->lines as $key => $line) {
175 if (count($SkillrecordsForActiveUser) == 0) {
177 $resCreate = $newSkill->cloneFromCurrentSkill($line, $object->fk_user);
179 if ($resCreate <= 0) {
181 setEventMessage($langs->trans(
'ErrorCreateUserSkill'), $line->fk_skill);
187 foreach ($SkillrecordsForActiveUser as $k => $sr) {
188 if ($sr->fk_skill == $line->fk_skill) {
196 $updSkill = $SkillrecordsForActiveUser[$k];
198 $updSkill->rankorder = $line->rankorder;
199 $updSkill->update($user);
202 $resCreate = $newSkill->cloneFromCurrentSkill($line, $object->fk_user);
206 if (empty($errors)) {
207 $object->setStatut(Evaluation::STATUS_CLOSED);
212 if ($action ==
'reopen' ) {
214 $object->setStatut(Evaluation::STATUS_VALIDATED);
231 $title = $langs->trans(
"Evaluation");
234 $css[] =
'/hrm/css/style.css';
237 print
'<script type="text/javascript" language="javascript">
238 $(document).ready(function() {
239 $("#btn_valid").click(function(){
240 var form = $("#form_save_rank");
245 url: form.attr("action"),
246 data: form.serialize(),
248 }).always(function() {
249 window.location.href = "'.dol_buildpath(
'/hrm/evaluation_card.php', 1).
'?id='.$id.
'&action=validate&token='.
newToken().
'";
258 if ($action ==
'create') {
259 print
load_fiche_titre($langs->trans(
"NewEval"),
'',
'object_' . $object->picto);
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">';
265 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
267 if ($backtopageforcancel) {
268 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
273 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
276 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
279 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
281 print
'</table>'.
"\n";
285 print
'<div class="center">';
286 print
'<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans(
"Create")).
'">';
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)"').
'>';
295 if (($id || $ref) && $action ==
'edit') {
296 print
load_fiche_titre($langs->trans(
"Evaluation"),
'',
'object_'.$object->picto);
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.
'">';
303 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
305 if ($backtopageforcancel) {
306 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
311 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
314 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
317 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
323 print
'<div class="center"><input type="submit" class="button button-save" name="save" value="'.$langs->trans(
"Save").
'">';
324 print
' <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
331 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
332 $res = $object->fetch_optionals();
335 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Workstation"), -1, $object->picto);
339 if ($action ==
'validate' && $permissiontovalidate) {
344 $ref = substr($object->ref, 1, 4);
345 if ($ref ==
'PROV') {
346 $numref = $object->getNextNumRef();
347 if (empty($numref)) {
352 $numref = $object->ref;
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);
360 $text .= $notify->confirmMessage(
'HRM_EVALUATION_VALIDATE', $object->socid, $object);
364 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ValidateEvaluation'), $text,
'confirm_validate',
'', 0, 1);
369 if ($action ==
'delete') {
370 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteEvaluation'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
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);
377 if ($action ==
'clone') {
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);
384 if ($action ==
'xxx') {
385 $formquestion = array();
387 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
391 $parameters = array(
'formConfirm' =>
$formconfirm,
'lineid' => $lineid);
392 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
393 if (empty($reshook)) {
395 } elseif ($reshook > 0) {
405 $linkback =
'<a href="'.dol_buildpath(
'/hrm/evaluation_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
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);
413 $job->fetch($object->fk_job);
414 $morehtmlref .=
'<br>'.$langs->trans(
'Job').
' : '.$job->getNomUrl(1);
415 $morehtmlref .=
'</div>';
419 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
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";
427 $object->fields[
'label'][
'visible']=0;
428 $object->fields[
'fk_user'][
'visible']=0;
429 $object->fields[
'fk_job'][
'visible']=0;
430 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
433 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
439 print
'<div class="clearboth"></div>';
448 if (!empty($object->table_element_line)) {
449 if ($object->status == Evaluation::STATUS_DRAFT) {
450 $result = $object->getLinesArray();
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.
'">
460 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
461 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
464 print
'<div class="div-table-responsive-no-min">';
475 if (!empty($object->lines)) {
476 $conf->modules_parts[
'tpl'][
'hrm']=
'/hrm/core/tpl/';
477 print
'<table id="tablelines" class="noborder noshadow">';
478 $object->printObjectLines($action, $mysoc,
null,
GETPOST(
'lineid',
'int'), 1,
'');
484 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
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').
'" >';
503 if ($object->status != Evaluation::STATUS_DRAFT) {
508 $sql .=
' e.date_creation,';
509 $sql .=
' e.fk_job,';
510 $sql .=
' j.label as "refjob",';
511 $sql .=
' ed.fk_skill,';
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"';
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)';
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);
533 $resql = $db->query($sql);
538 while ($obj = $db->fetch_object(
$resql)) {
539 $Tab[$num] =
new stdClass();
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>';
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');
559 $Tab[$num]->result =
'<span title="'.$title.
'" class="classfortooltip ' . $class .
' note"> </span>';
564 print
'<div class="underbanner clearboth"></div>';
565 print
'<table class="noborder centpercent">';
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>';
576 $sk =
new Skill($db);
577 foreach ($Tab as $t) {
578 $sk->fetch($t->skill_id);
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>';
595 $(document).ready(
function() {
596 $(
".radio_js_bloc_number").tooltip();
606 if ($action !=
'presend' && $action !=
'editline') {
607 print
'<div class="tabsAction">'.
"\n";
608 $parameters = array();
609 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
614 if (empty($reshook)) {
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');
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);
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);
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').
' '.$langs->trans(
'and').
' '.$langs->trans(
'Valid'),
'',
'default',
'#',
'btn_valid', $permissiontovalidate);
638 $langs->load(
"errors");
639 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
645 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=delete&token='.
newToken(),
'', $permissiontodelete);
653 if (
GETPOST(
'modelselected')) {
657 if ($action !=
'presend') {
658 print
'<div class="fichecenter"><div class="fichehalfleft">';
659 print
'<a name="builddoc"></a>';
661 $includedocgeneration = 0;
664 if ($includedocgeneration) {
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;
670 $delallowed = $user->rights->hrm->evaluation->write;
671 print $formfile->showdocuments(
'hrm:Evaluation', $object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
675 $linktoelem =
$form->showLinkToObjectBlock($object,
null, array(
'evaluation'));
676 $somethingshown =
$form->showLinkedObjectBlock($object, $linktoelem);
679 print
'</div><div class="fichehalfright">';
683 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/hrm/evaluation_agenda.php?id='.$object->id);
686 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
688 $somethingshown =
$formactions->showactions($object, $object->element.
'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
690 print
'</div></div>';
694 if (
GETPOST(
'modelselected')) {
699 $modelmail =
'evaluation';
700 $defaulttopic =
'InformationMessage';
701 $diroutput = $conf->hrm->dir_output;
702 $trackid =
'evaluation'.$object->id;
704 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';