dolibarr 19.0.3
hrm_evaluation.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
3 * Copyright (C) 2021 Greg Rastklan <greg.rastklan@atm-consulting.fr>
4 * Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
5 * Copyright (C) 2021 Grégory BLEMAND <gregory.blemand@atm-consulting.fr>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
33function evaluationPrepareHead($object)
34{
35 global $db, $langs, $conf;
36
37 $langs->load("hrm");
38
39 $h = 0;
40 $head = array();
41
42 $head[$h][0] = dol_buildpath("/hrm/evaluation_card.php", 1).'?id='.$object->id;
43 $head[$h][1] = $langs->trans("EvaluationCard");
44 $head[$h][2] = 'card';
45 $h++;
46
47 if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
48 $nbNote = 0;
49 if (!empty($object->note_private)) {
50 $nbNote++;
51 }
52 if (!empty($object->note_public)) {
53 $nbNote++;
54 }
55 $head[$h][0] = dol_buildpath('/hrm/evaluation_note.php', 1).'?id='.$object->id;
56 $head[$h][1] = $langs->trans('Notes');
57 if ($nbNote > 0) {
58 $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
59 }
60 $head[$h][2] = 'note';
61 $h++;
62 }
63
64 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
65 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
66 $upload_dir = $conf->hrm->dir_output."/evaluation/".dol_sanitizeFileName($object->ref);
67 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
68 $nbLinks = Link::count($db, $object->element, $object->id);
69 $head[$h][0] = dol_buildpath("/hrm/evaluation_document.php", 1).'?id='.$object->id;
70 $head[$h][1] = $langs->trans('Documents');
71 if (($nbFiles + $nbLinks) > 0) {
72 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
73 }
74 $head[$h][2] = 'document';
75 $h++;
76
77 $head[$h][0] = dol_buildpath("/hrm/evaluation_agenda.php", 1).'?id='.$object->id;
78 $head[$h][1] = $langs->trans("Events");
79 $head[$h][2] = 'agenda';
80 $h++;
81
82 // Show more tabs from modules
83 // Entries must be declared in modules descriptor with line
84 //$this->tabs = array(
85 // 'entity:+tabname:Title:@hrm:/hrm/mypage.php?id=__ID__'
86 //); // to add new tab
87 //$this->tabs = array(
88 // 'entity:-tabname:Title:@hrm:/hrm/mypage.php?id=__ID__'
89 //); // to remove a tab
90 complete_head_from_modules($conf, $langs, $object, $head, $h, 'evaluation@hrm');
91
92 complete_head_from_modules($conf, $langs, $object, $head, $h, 'evaluation@hrm', 'remove');
93
94 return $head;
95}
96
101{
102 global $langs;
103 $legendSkills = '<div style="font-style:italic;">
104 ' . $langs->trans('legend') . '
105 <table class="border" width="100%">
106 <tr>
107 <td><span style="vertical-align:middle" class="toohappy diffnote little"></span>
108 ' . $langs->trans('CompetenceAcquiredByOneOrMore') . '</td>
109 </tr>
110 <tr>
111 <td><span style="vertical-align:middle" class="veryhappy diffnote little"></span>
112 ' . $langs->trans('MaxlevelGreaterThan') . '</td>
113 </tr>
114 <tr>
115 <td><span style="vertical-align:middle" class="happy diffnote little"></span>
116 ' . $langs->trans('MaxLevelEqualTo') . '</td>
117 </tr>
118 <tr>
119 <td><span style="vertical-align:middle" class="sad diffnote little"></span>
120 ' . $langs->trans('MaxLevelLowerThan') . '</td>
121 </tr>
122 <tr>
123 <td><span style="vertical-align:middle" class="toosad diffnote little"></span>
124 ' . $langs->trans('SkillNotAcquired') . '</td>
125 </tr>
126 </table>
127</div>';
128 return $legendSkills;
129}
130
136{
137 global $langs;
138 $results = array(
139 'greater' => array(
140 'title' => $langs->trans('MaxlevelGreaterThanShort'),
141 'style' => 'background-color: #c3e6cb; border:5px solid #3097D1; color: #555; font-weight: 700;'
142 ),
143 'equal' => array(
144 'title' => $langs->trans('MaxLevelEqualToShort'),
145 'style' => 'background-color: #c3e6cb; color: #555; font-weight: 700;'
146 ),
147 'lesser' => array(
148 'title' => $langs->trans('MaxLevelLowerThanShort'),
149 'style' => 'background-color: #bd4147; color: #FFFFFF; font-weight: 700;'
150 )
151 );
152 $key = '';
153 if ($obj->rankorder > $obj->required_rank) {
154 $key = 'greater';
155 } elseif ($obj->rankorder == $obj->required_rank) {
156 $key = 'equal';
157 } elseif ($obj->rankorder < $obj->required_rank) {
158 $key = 'lesser';
159 }
160 return '<span title="'.strtoupper($obj->label).': ' .$results[$key]['title']. '" class="radio_js_bloc_number TNote_1" style="' . htmlspecialchars($results[$key]['style'], ENT_QUOTES) . '">' . strtoupper(substr($obj->label, 0, 3)) .(strlen($obj->label) > 3 ? '..' : '').'</span>';
161}
162
168function getGroupedEval($objects)
169{
170 if (count($objects) < 0 || !is_array($objects)) {
171 return -1;
172 }
173 // grouped $object by ref
174 $grouped = [];
175 foreach ($objects as $object) {
176 $ref = $object->ref;
177 if (!isset($grouped[$ref])) {
178 $grouped[$ref] = [];
179 }
180 $grouped[$ref][] = $object;
181 }
182 $newArray = [];
183 foreach ($grouped as $refs => $objects) {
184 if (count($objects) > 1) {
185 $newArray[$refs] = $objects;
186 }
187 }
188 $combinedArray = [];
189 foreach ($grouped as $refs => $objects) {
190 if (count($objects) == 1) {
191 $combinedArray[] = $objects[0];
192 }
193 }
194 $resultArray = array_merge($combinedArray, array_values($newArray));
195 return $resultArray;
196}
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:62
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.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
evaluationPrepareHead($object)
Prepare array of tabs for Evaluation.
GetLegendSkills()
getRankOrderResults($obj)
getGroupedEval($objects)
Grouped rows with same ref in array.