dolibarr 18.0.6
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
3 * Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2012-2014 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
6 * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
7 * Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
30// Load Dolibarr environment
31require '../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
38require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
39
40if (isModEnabled('deplacement')) {
41 require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
42}
43if (isModEnabled('expensereport')) {
44 require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
45}
46if (isModEnabled('recruitment')) {
47 require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php';
48 require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
49}
50if (isModEnabled('holiday')) {
51 require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
52}
53
54
55// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
56$hookmanager = new HookManager($db);
57
58$hookmanager->initHooks('hrmindex');
59
60// Load translation files required by the page
61$langs->loadLangs(array('users', 'holiday', 'trips', 'boxes'));
62
63// Get Parameters
64$socid = GETPOST("socid", "int");
65
66// Protection if external user
67if ($user->socid > 0) {
69}
70
71if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) {
72 $setupcompanynotcomplete = 1;
73}
74
75$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
76
77
78/*
79 * Actions
80 */
81
82// Update sold
83if (isModEnabled('holiday') && !empty($setupcompanynotcomplete)) {
84 $holidaystatic = new Holiday($db);
85 $result = $holidaystatic->updateBalance();
86}
87
88
89/*
90 * View
91 */
92
93$childids = $user->getAllChildIds();
94$childids[] = $user->id;
95
96$title = $langs->trans('HRMArea');
97
98llxHeader('', $title, '');
99
100print load_fiche_titre($langs->trans("HRMArea"), '', 'hrm');
101
102
103if (!empty($setupcompanynotcomplete)) {
104 $langs->load("errors");
105 $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"));
106 print '<br><div class="warning"><a href="'.DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit&token='.newToken()).'">'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").'</a></div>';
107
108 llxFooter();
109 exit;
110}
111
112
113print '<div class="fichecenter"><div class="fichethirdleft">';
114
115if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo
116 if (isModEnabled('holiday') && $user->rights->holiday->read) {
117 $langs->load("holiday");
118 $listofsearchfields['search_holiday'] = array('text'=>'TitreRequestCP');
119 }
120 if (isModEnabled('deplacement') && $user->rights->deplacement->lire) {
121 $langs->load("trips");
122 $listofsearchfields['search_deplacement'] = array('text'=>'ExpenseReport');
123 }
124 if (isModEnabled('expensereport') && $user->rights->expensereport->lire) {
125 $langs->load("trips");
126 $listofsearchfields['search_expensereport'] = array('text'=>'ExpenseReport');
127 }
128 if (count($listofsearchfields)) {
129 print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
130 print '<input type="hidden" name="token" value="'.newToken().'">';
131 print '<div class="div-table-responsive-no-min">';
132 print '<table class="noborder nohover centpercent">';
133 $i = 0;
134 foreach ($listofsearchfields as $key => $value) {
135 if ($i == 0) {
136 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
137 }
138 print '<tr>';
139 print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
140 if ($i == 0) {
141 print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
142 }
143 print '</tr>';
144 $i++;
145 }
146 print '</table>';
147 print '</div>';
148 print '</form>';
149 print '<br>';
150 }
151}
152
153
154if (isModEnabled('holiday')) {
155 if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) {
156 $holidaystatic = new Holiday($db);
157 $user_id = $user->id;
158
159 print '<div class="div-table-responsive-no-min">';
160 print '<table class="noborder nohover centpercent">';
161 print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("Holidays").'</th></tr>';
162 print '<tr class="oddeven">';
163 print '<td>';
164
165 $out = '';
166 $nb_holiday = 0;
167 $typeleaves = $holidaystatic->getTypes(1, 1);
168 foreach ($typeleaves as $key => $val) {
169 $nb_type = $holidaystatic->getCPforUser($user->id, $val['rowid']);
170 $nb_holiday += $nb_type;
171 $out .= ' - '.($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']).': <strong>'.($nb_type ? price2num($nb_type) : 0).'</strong><br>';
172 }
173 $balancetoshow = $langs->trans('SoldeCPUser', '{s1}');
174 print '<div class="valignmiddle div-balanceofleave">'.str_replace('{s1}', img_picto('', 'holiday', 'class="paddingleft pictofixedwidth"').'<span class="balanceofleave valignmiddle'.($nb_holiday > 0 ? ' amountpaymentcomplete' : ($nb_holiday < 0 ? ' amountremaintopay' : ' amountpaymentneutral')).'">'.round($nb_holiday, 5).'</span>', $balancetoshow).'</div>';
175 print '<span class="opacitymedium">'.$out.'</span>';
176
177 print '</td>';
178 print '</tr>';
179 print '</table></div><br>';
180 } elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) {
181 print $langs->trans($conf->global->HOLIDAY_HIDE_BALANCE).'<br>';
182 }
183}
184
185
186print '</div><div class="fichetwothirdright">';
187
188
189
190// Latest leave requests
191if (isModEnabled('holiday') && $user->hasRight('holiday', 'read')) {
192 $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.photo, u.statut as user_status,";
193 $sql .= " x.rowid, x.ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status";
194 $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u";
195 $sql .= " WHERE u.rowid = x.fk_user";
196 $sql .= " AND x.entity = ".$conf->entity;
197 if (empty($user->rights->holiday->readall)) {
198 $sql .= ' AND x.fk_user IN ('.$db->sanitize(join(',', $childids)).')';
199 }
200 //if (empty($user->rights->societe->client->voir) && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
201 //if (!empty($socid)) $sql.= " AND x.fk_soc = ".((int) $socid);
202 $sql .= $db->order("x.tms", "DESC");
203 $sql .= $db->plimit($max, 0);
204
205 $result = $db->query($sql);
206 if ($result) {
207 $var = false;
208 $num = $db->num_rows($result);
209
210 $holidaystatic = new Holiday($db);
211 $userstatic = new User($db);
212
213 $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon"));
214 $typeleaves = $holidaystatic->getTypes(1, -1);
215
216 $i = 0;
217
218 print '<div class="div-table-responsive-no-min">';
219 print '<table class="noborder centpercent">';
220 print '<tr class="liste_titre">';
221 print '<th colspan="3">'.$langs->trans("BoxTitleLastLeaveRequests", min($max, $num)).'</th>';
222 print '<th>'.$langs->trans("from").'</th>';
223 print '<th>'.$langs->trans("to").'</th>';
224 print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/holiday/list.php?sortfield=cp.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
225 print '</tr>';
226 if ($num) {
227 while ($i < $num && $i < $max) {
228 $obj = $db->fetch_object($result);
229
230 $holidaystatic->id = $obj->rowid;
231 $holidaystatic->ref = $obj->ref;
232 $holidaystatic->statut = $obj->status;
233 $holidaystatic->date_debut = $db->jdate($obj->date_start);
234
235 $userstatic->id = $obj->uid;
236 $userstatic->lastname = $obj->lastname;
237 $userstatic->firstname = $obj->firstname;
238 $userstatic->login = $obj->login;
239 $userstatic->photo = $obj->photo;
240 $userstatic->email = $obj->email;
241 $userstatic->statut = $obj->user_status;
242 $userstatic->status = $obj->user_status;
243
244 print '<tr class="oddeven">';
245 print '<td class="nowraponall">'.$holidaystatic->getNomUrl(1).'</td>';
246 print '<td class="tdoverflowmax100">'.$userstatic->getNomUrl(-1, 'leave').'</td>';
247
248 $leavecode = empty($typeleaves[$obj->fk_type]) ? 'Undefined' : $typeleaves[$obj->fk_type]['code'];
249 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($langs->trans($leavecode)).'">'.dol_escape_htmltag($langs->trans($leavecode)).'</td>';
250
251 $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning';
252 $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon';
253
254 print '<td class="tdoverflowmax125">'.dol_print_date($db->jdate($obj->date_start), 'day').' <span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).'</span>';
255 print '<td class="tdoverflowmax125">'.dol_print_date($db->jdate($obj->date_end), 'day').' <span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).'</span>';
256 print '<td class="right">'.dol_print_date($db->jdate($obj->dm), 'day').'</td>';
257 print '<td class="right nowrap" width="16">'.$holidaystatic->LibStatut($obj->status, 3, $holidaystatic->date_debut).'</td>';
258 print '</tr>';
259
260 $i++;
261 }
262 } else {
263 print '<tr class="oddeven"><td colspan="7"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
264 }
265 print '</table>';
266 print '</div>';
267 print '<br>';
268 } else {
269 dol_print_error($db);
270 }
271}
272
273
274// Latest expense report
275if (isModEnabled('expensereport') && $user->hasRight('expensereport', 'read')) {
276 $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut as user_status, u.photo,";
277 $sql .= " x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status";
278 $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u";
279 //if (empty($user->rights->societe->client->voir) && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
280 $sql .= " WHERE u.rowid = x.fk_user_author";
281 $sql .= " AND x.entity = ".$conf->entity;
282 if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) {
283 $sql .= ' AND x.fk_user_author IN ('.$db->sanitize(join(',', $childids)).')';
284 }
285 //if (empty($user->rights->societe->client->voir) && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
286 //if (!empty($socid)) $sql.= " AND x.fk_soc = ".((int) $socid);
287 $sql .= $db->order("x.tms", "DESC");
288 $sql .= $db->plimit($max, 0);
289
290 $result = $db->query($sql);
291 if ($result) {
292 $num = $db->num_rows($result);
293
294 $i = 0;
295
296 print '<div class="div-table-responsive-no-min">';
297 print '<table class="noborder centpercent">';
298 print '<tr class="liste_titre">';
299 print '<th colspan="2">'.$langs->trans("BoxTitleLastModifiedExpenses", min($max, $num)).'</th>';
300 print '<th class="right">'.$langs->trans("TotalTTC").'</th>';
301 print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/expensereport/list.php?sortfield=d.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
302 print '</tr>';
303 if ($num) {
304 $total_ttc = $totalam = $total = 0;
305
306 $expensereportstatic = new ExpenseReport($db);
307 $userstatic = new User($db);
308 while ($i < $num && $i < $max) {
309 $obj = $db->fetch_object($result);
310
311 $expensereportstatic->id = $obj->rowid;
312 $expensereportstatic->ref = $obj->ref;
313 $expensereportstatic->statut = $obj->status;
314 $expensereportstatic->status = $obj->status;
315
316 $userstatic->id = $obj->uid;
317 $userstatic->lastname = $obj->lastname;
318 $userstatic->firstname = $obj->firstname;
319 $userstatic->email = $obj->email;
320 $userstatic->login = $obj->login;
321 $userstatic->statut = $obj->user_status;
322 $userstatic->photo = $obj->photo;
323
324 print '<tr class="oddeven">';
325 print '<td class="tdoverflowmax200">'.$expensereportstatic->getNomUrl(1).'</td>';
326 print '<td class="tdoverflowmax150">'.$userstatic->getNomUrl(-1).'</td>';
327 print '<td class="right amount">'.price($obj->total_ttc).'</td>';
328 print '<td class="right">'.dol_print_date($db->jdate($obj->dm), 'day').'</td>';
329 print '<td class="right nowraponall" width="16">'.$expensereportstatic->LibStatut($obj->status, 3).'</td>';
330 print '</tr>';
331
332 $i++;
333 }
334 } else {
335 print '<tr class="oddeven"><td colspan="5"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
336 }
337 print '</table>';
338 print '</div>';
339 print '<br>';
340 } else {
341 dol_print_error($db);
342 }
343}
344
345
346// Last modified job position
347if (isModEnabled('recruitment') && $user->hasRight('recruitment', 'recruitmentjobposition', 'read')) {
348 $staticrecruitmentcandidature = new RecruitmentCandidature($db);
349 $staticrecruitmentjobposition = new RecruitmentJobPosition($db);
350 $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status,";
351 $sql.= " rp.rowid as jobid, rp.ref as jobref, rp.label";
352 $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc";
353 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as rp ON rc.fk_recruitmentjobposition = rp.rowid";
354 if (isModEnabled('societe') && empty($user->rights->societe->client->voir) && !$socid) {
355 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
356 }
357 $sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentcandidature->element).")";
358 if (isModEnabled('societe') && empty($user->rights->societe->client->voir) && !$socid) {
359 $sql .= " AND rp.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
360 }
361 if ($socid) {
362 $sql .= " AND rp.fk_soc = $socid";
363 }
364 $sql .= $db->order("rc.tms", "DESC");
365 $sql .= $db->plimit($max, 0);
366
367 $resql = $db->query($sql);
368 if ($resql) {
369 $num = $db->num_rows($resql);
370 $i = 0;
371
372 print '<div class="div-table-responsive-no-min">';
373 print '<table class="noborder centpercent">';
374 print '<tr class="liste_titre">';
375 print '<th colspan="3">';
376 print $langs->trans("BoxTitleLatestModifiedCandidatures", min($max, $num));
377 print '</th>';
378 print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentcandidature_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
379 print '</tr>';
380 if ($num) {
381 while ($i < $num) {
382 $objp = $db->fetch_object($resql);
383 $staticrecruitmentcandidature->id = $objp->rowid;
384 $staticrecruitmentcandidature->ref = $objp->ref;
385 $staticrecruitmentcandidature->email = $objp->email;
386 $staticrecruitmentcandidature->status = $objp->status;
387 $staticrecruitmentcandidature->date_creation = $objp->date_creation;
388 $staticrecruitmentcandidature->firstname = $objp->firstname;
389 $staticrecruitmentcandidature->lastname = $objp->lastname;
390
391 $staticrecruitmentjobposition->id = $objp->jobid;
392 $staticrecruitmentjobposition->ref = $objp->jobref;
393 $staticrecruitmentjobposition->label = $objp->label;
394
395 print '<tr class="oddeven">';
396 print '<td class="nowraponall">'.$staticrecruitmentcandidature->getNomUrl(1, '').'</td>';
397 print '<td class="tdoverflowmax150">'.$staticrecruitmentcandidature->getFullName($langs).'</td>';
398 print '<td class="nowraponall">'.$staticrecruitmentjobposition->getNomUrl(1).'</td>';
399 print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day').'</td>';
400 print '<td class="right nowrap" width="16">';
401 print $staticrecruitmentcandidature->getLibStatut(3);
402 print "</td>";
403 print '</tr>';
404 $i++;
405 }
406
407 $db->free($resql);
408 } else {
409 print '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
410 }
411 print "</table>";
412 print "</div>";
413 print "<br>";
414 } else {
415 dol_print_error($db);
416 }
417}
418
419print '</div></div>';
420
421// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
422$parameters = array('user' => $user);
423$reshook = $hookmanager->executeHooks('dashboardHRM', $parameters, $object); // Note that $action and $object may have been modified by hook
424
425// End of page
426llxFooter();
427$db->close();
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 to manage Trips and Expenses.
Class of the module paid holiday.
Class to manage hooks.
Class for RecruitmentCandidature.
Class for RecruitmentJobPosition.
Class to manage Dolibarr users.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.