dolibarr 20.0.2
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
3 * Copyright (C) 2013-2020 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2012-2016 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
6 * Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.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
29// Load Dolibarr environment
30require '../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
36require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
37require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
40
41// Load translation files required by the page
42$langs->loadLangs(array('users', 'other', 'holiday', 'hrm'));
43
44// Protection if external user
45if ($user->socid > 0) {
47}
48
49$action = GETPOST('action', 'aZ09'); // The action 'add', 'create', 'edit', 'update', 'view', ...
50$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
51$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
52$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
53$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
54$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
55$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'holidaylist'; // To manage different context of search
56$mode = GETPOST('mode', 'alpha'); // for switch mode view result
57$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
58$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
59
60$id = GETPOSTINT('id');
61
62$childids = $user->getAllChildIds(1);
63
64
65$diroutputmassaction = $conf->holiday->dir_output.'/temp/massgeneration/'.$user->id;
66
67
68// Load variable for pagination
69$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
70$sortfield = GETPOST('sortfield', 'aZ09comma');
71$sortorder = GETPOST('sortorder', 'aZ09comma');
72$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
73if (empty($page) || $page == -1) {
74 $page = 0;
75} // If $page is not defined, or '' or -1
76$offset = $limit * $page;
77$pageprev = $page - 1;
78$pagenext = $page + 1;
79if (!$sortorder) {
80 $sortorder = "DESC";
81}
82if (!$sortfield) {
83 $sortfield = "cp.ref";
84}
85
86$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
87$search_ref = GETPOST('search_ref', 'alphanohtml');
88$search_day_create = GETPOST('search_day_create', 'int');
89$search_month_create = GETPOST('search_month_create', 'int');
90$search_year_create = GETPOST('search_year_create', 'int');
91$search_day_start = GETPOST('search_day_start', 'int');
92$search_month_start = GETPOST('search_month_start', 'int');
93$search_year_start = GETPOST('search_year_start', 'int');
94$search_day_end = GETPOST('search_day_end', 'int');
95$search_month_end = GETPOST('search_month_end', 'int');
96$search_year_end = GETPOST('search_year_end', 'int');
97$search_employee = GETPOST('search_employee', 'intcomma');
98$search_valideur = GETPOST('search_valideur', 'intcomma');
99$search_status = GETPOST('search_status', 'intcomma');
100$search_type = GETPOST('search_type', 'intcomma');
101
102// Initialize technical objects
103$object = new Holiday($db);
104$extrafields = new ExtraFields($db);
105$hookmanager->initHooks(array('holidaylist')); // Note that conf->hooks_modules contains array
106
107// Fetch optionals attributes and labels
108$extrafields->fetch_name_optionals_label($object->table_element);
109
110$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
111
112// List of fields to search into when doing a "search in all"
113$fieldstosearchall = array(
114 'cp.ref' => 'Ref',
115 'cp.description' => 'Description',
116 'uu.lastname' => 'EmployeeLastname',
117 'uu.firstname' => 'EmployeeFirstname',
118 'uu.login' => 'Login'
119);
120
121$arrayfields = array(
122 'cp.ref' => array('label' => $langs->trans("Ref"), 'checked' => 1),
123 'cp.fk_user' => array('label' => $langs->trans("Employee"), 'checked' => 1, 'position' => 20),
124 'cp.fk_validator' => array('label' => $langs->trans("ValidatorCP"), 'checked' => 1, 'position' => 30),
125 'cp.fk_type' => array('label' => $langs->trans("Type"), 'checked' => 1, 'position' => 35),
126 'duration' => array('label' => $langs->trans("NbUseDaysCPShort"), 'checked' => 1, 'position' => 38),
127 'cp.date_debut' => array('label' => $langs->trans("DateStart"), 'checked' => 1, 'position' => 40),
128 'cp.date_fin' => array('label' => $langs->trans("DateEnd"), 'checked' => 1, 'position' => 42),
129 'cp.date_valid' => array('label' => $langs->trans("DateValidation"), 'checked' => 1, 'position' => 60),
130 'cp.date_approval' => array('label' => $langs->trans("DateApprove"), 'checked' => 1, 'position' => 70),
131 'cp.date_create' => array('label' => $langs->trans("DateCreation"), 'checked' => 0, 'position' => 500),
132 'cp.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => 0, 'position' => 501),
133 'cp.statut' => array('label' => $langs->trans("Status"), 'checked' => 1, 'position' => 1000),
134);
135// Extra fields
136include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
137
138
139// Security check
140$socid = 0;
141if ($user->socid > 0) { // Protection if external user
142 //$socid = $user->socid;
144}
145
146$permissiontoread = $user->hasRight('holiday', 'read');
147$permissiontodelete = $user->hasRight('holiday', 'delete');
148$permissiontoapprove = $user->hasRight('holiday', 'approve');
149
150if (!isModEnabled('holiday')) {
151 accessforbidden('Module holiday not enabled');
152}
153
154$result = restrictedArea($user, 'holiday', '', '');
155// If we are on the view of a specific user
156if ($id > 0) {
157 $canread = 0;
158 if ($id == $user->id) {
159 $canread = 1;
160 }
161 if ($user->hasRight('holiday', 'readall')) {
162 $canread = 1;
163 }
164 if ($user->hasRight('holiday', 'read') && in_array($id, $childids)) {
165 $canread = 1;
166 }
167 if (!$canread) {
169 }
170}
171
172
173
174/*
175 * Actions
176 */
177
178if (GETPOST('cancel', 'alpha')) {
179 $action = 'list';
180 $massaction = '';
181}
182if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
183 $massaction = '';
184}
185
186$parameters = array('socid' => $socid, 'arrayfields' => &$arrayfields);
187$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
188if ($reshook < 0) {
189 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
190}
191
192if (empty($reshook)) {
193 // Selection of new fields
194 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
195
196 // Purge search criteria
197 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
198 $search_ref = "";
199 $search_month_create = "";
200 $search_year_create = "";
201 $search_month_start = "";
202 $search_year_start = "";
203 $search_month_end = "";
204 $search_year_end = "";
205 $search_employee = "";
206 $search_valideur = "";
207 $search_status = "";
208 $search_type = '';
209 $toselect = array();
210 $search_array_options = array();
211 }
212 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
213 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
214 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
215 }
216
217 // Mass actions
218 $objectclass = 'Holiday';
219 $objectlabel = 'Holiday';
220 $uploaddir = $conf->holiday->dir_output;
221 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
222}
223
224
225/*
226 * View
227 */
228
229$form = new Form($db);
230$formother = new FormOther($db);
231$formfile = new FormFile($db);
232
233$fuser = new User($db);
234$holidaystatic = new Holiday($db);
235
236// Update sold
237$result = $object->updateBalance();
238
239$title = $langs->trans('CPTitreMenu');
240$help_url = '';
241
242llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist');
243
244$max_year = 5;
245$min_year = 10;
246
247// Get current user id
248$user_id = $user->id;
249
250if ($id > 0) {
251 // Charge utilisateur edite
252 $fuser->fetch($id, '', '', 1);
253 $fuser->getrights();
254 $user_id = $fuser->id;
255
256 $search_employee = $user_id;
257}
258
259// Récupération des congés payés de l'utilisateur ou de tous les users de sa hierarchy
260// Load array $object->holiday
261
262$sql = "SELECT";
263$sql .= " cp.rowid,";
264$sql .= " cp.ref,";
265
266$sql .= " cp.fk_user,";
267$sql .= " cp.fk_type,";
268$sql .= " cp.date_create,";
269$sql .= " cp.tms as date_modification,";
270$sql .= " cp.description,";
271$sql .= " cp.date_debut,";
272$sql .= " cp.date_fin,";
273$sql .= " cp.halfday,";
274$sql .= " cp.statut as status,";
275$sql .= " cp.fk_validator,";
276$sql .= " cp.date_valid,";
277$sql .= " cp.fk_user_valid,";
278$sql .= " cp.date_approval,";
279$sql .= " cp.fk_user_approve,";
280$sql .= " cp.date_refuse,";
281$sql .= " cp.fk_user_refuse,";
282$sql .= " cp.date_cancel,";
283$sql .= " cp.fk_user_cancel,";
284$sql .= " cp.detail_refuse,";
285
286$sql .= " uu.lastname as user_lastname,";
287$sql .= " uu.firstname as user_firstname,";
288$sql .= " uu.admin as user_admin,";
289$sql .= " uu.email as user_email,";
290$sql .= " uu.login as user_login,";
291$sql .= " uu.statut as user_status,";
292$sql .= " uu.photo as user_photo,";
293
294$sql .= " ua.lastname as validator_lastname,";
295$sql .= " ua.firstname as validator_firstname,";
296$sql .= " ua.admin as validator_admin,";
297$sql .= " ua.email as validator_email,";
298$sql .= " ua.login as validator_login,";
299$sql .= " ua.statut as validator_status,";
300$sql .= " ua.photo as validator_photo";
301// Add fields from extrafields
302if (!empty($extrafields->attributes[$object->table_element]['label'])) {
303 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
304 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
305 }
306}
307// Add fields from hooks
308$parameters = array();
309$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
310$sql .= $hookmanager->resPrint;
311$sql = preg_replace('/,\s*$/', '', $sql);
312
313$sqlfields = $sql; // $sql fields to remove for count total
314
315$sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp";
316if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
317 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cp.rowid = ef.fk_object)";
318}
319$sql .= ", ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua";
320$sql .= " WHERE cp.entity IN (".getEntity('holiday').")";
321$sql .= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau
322// Search all
323if (!empty($search_all)) {
324 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
325}
326// Ref
327if (!empty($search_ref)) {
328 $sql .= natural_search("cp.ref", $search_ref);
329}
330// Start date
331$sql .= dolSqlDateFilter("cp.date_debut", $search_day_start, $search_month_start, $search_year_start);
332// End date
333$sql .= dolSqlDateFilter("cp.date_fin", $search_day_end, $search_month_end, $search_year_end);
334// Create date
335$sql .= dolSqlDateFilter("cp.date_create", $search_day_create, $search_month_create, $search_year_create);
336// Employee
337if (!empty($search_employee) && $search_employee != -1) {
338 $sql .= " AND cp.fk_user = '".$db->escape($search_employee)."'\n";
339}
340// Validator
341if (!empty($search_valideur) && $search_valideur != -1) {
342 $sql .= " AND cp.fk_validator = '".$db->escape($search_valideur)."'\n";
343}
344// Type
345if (!empty($search_type) && $search_type != -1) {
346 $sql .= ' AND cp.fk_type IN ('.$db->sanitize($db->escape($search_type)).')';
347}
348// Status
349if (!empty($search_status) && $search_status != -1) {
350 $sql .= " AND cp.statut = '".$db->escape($search_status)."'\n";
351}
352
353if (!$user->hasRight('holiday', 'readall')) {
354 $sql .= ' AND cp.fk_user IN ('.$db->sanitize(implode(',', $childids)).')';
355}
356if ($id > 0) {
357 $sql .= " AND cp.fk_user IN (".$db->sanitize($id).")";
358}
359
360// Add where from extra fields
361include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
362// Add where from hooks
363$parameters = array();
364$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
365$sql .= $hookmanager->resPrint;
366
367// Count total nb of records
368$nbtotalofrecords = '';
369if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
370 /* The fast and low memory method to get and count full list converts the sql into a sql count */
371 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
372 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
373 $resql = $db->query($sqlforcount);
374 if ($resql) {
375 $objforcount = $db->fetch_object($resql);
376 $nbtotalofrecords = $objforcount->nbtotalofrecords;
377 } else {
378 dol_print_error($db);
379 }
380
381 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
382 $page = 0;
383 $offset = 0;
384 }
385 $db->free($resql);
386}
387
388// Complete request and execute it with limit
389$sql .= $db->order($sortfield, $sortorder);
390if ($limit) {
391 $sql .= $db->plimit($limit + 1, $offset);
392}
393
394//print $sql;
395$resql = $db->query($sql);
396if (!$resql) {
397 dol_print_error($db);
398 exit;
399}
400
401$num = $db->num_rows($resql);
402
403$arrayofselected = is_array($toselect) ? $toselect : array();
404
405$param = '';
406if (!empty($mode)) {
407 $param .= '&mode='.urlencode($mode);
408}
409if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
410 $param .= '&contextpage='.urlencode($contextpage);
411}
412if ($limit > 0 && $limit != $conf->liste_limit) {
413 $param .= '&limit='.((int) $limit);
414}
415if ($optioncss != '') {
416 $param .= '&optioncss='.urlencode($optioncss);
417}
418if ($search_ref) {
419 $param .= '&search_ref='.urlencode($search_ref);
420}
421if ($search_day_create) {
422 $param .= '&search_day_create='.urlencode($search_day_create);
423}
424if ($search_month_create) {
425 $param .= '&search_month_create='.urlencode($search_month_create);
426}
427if ($search_year_create) {
428 $param .= '&search_year_create='.urlencode($search_year_create);
429}
430if ($search_day_start) {
431 $param .= '&search_day_start='.urlencode($search_day_start);
432}
433if ($search_month_start) {
434 $param .= '&search_month_start='.urlencode($search_month_start);
435}
436if ($search_year_start) {
437 $param .= '&search_year_start='.urlencode($search_year_start);
438}
439if ($search_day_end) {
440 $param .= '&search_day_end='.urlencode($search_day_end);
441}
442if ($search_month_end) {
443 $param .= '&search_month_end='.urlencode($search_month_end);
444}
445if ($search_year_end) {
446 $param .= '&search_year_end='.urlencode($search_year_end);
447}
448if ($search_employee > 0) {
449 $param .= '&search_employee='.urlencode($search_employee);
450}
451if ($search_valideur > 0) {
452 $param .= '&search_valideur='.urlencode((string) ($search_valideur));
453}
454if ($search_type > 0) {
455 $param .= '&search_type='.urlencode((string) ($search_type));
456}
457if ($search_status > 0) {
458 $param .= '&search_status='.urlencode($search_status);
459}
460// Add $param from extra fields
461include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
462
463// List of mass actions available
464$arrayofmassactions = array(
465 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
466 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
467 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
468);
469if (!empty($permissiontodelete)) {
470 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
471}
472if (!empty($permissiontoapprove)) {
473 $arrayofmassactions['preapproveleave'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Approve");
474}
475if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
476 $arrayofmassactions = array();
477}
478$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
479
480print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
481if ($optioncss != '') {
482 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
483}
484print '<input type="hidden" name="token" value="'.newToken().'">';
485print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
486print '<input type="hidden" name="action" value="'.($action == 'edit' ? 'update' : 'list').'">';
487print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
488print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
489print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
490print '<input type="hidden" name="page" value="'.$page.'">';
491print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
492print '<input type="hidden" name="page_y" value="">';
493print '<input type="hidden" name="mode" value="'.$mode.'">';
494if ($id > 0) {
495 print '<input type="hidden" name="id" value="'.$id.'">';
496}
497
498if ($id > 0) { // For user tab
499 $title = $langs->trans("User");
500 $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
501 $head = user_prepare_head($fuser);
502
503 print dol_get_fiche_head($head, 'paidholidays', $title, -1, 'user');
504
505 dol_banner_tab($fuser, 'id', $linkback, $user->hasRight('user', 'user', 'lire') || $user->admin);
506
507 if (!getDolGlobalString('HOLIDAY_HIDE_BALANCE')) {
508 print '<div class="underbanner clearboth"></div>';
509
510 print '<br>';
511
512 print showMyBalance($object, $user_id);
513 }
514
515 print dol_get_fiche_end();
516
517 // Buttons for actions
518
519 print '<div class="tabsAction">';
520
521 $cancreate = 0;
522 if ($user->hasRight('holiday', 'writeall')) {
523 $cancreate = 1;
524 }
525 if ($user->hasRight('holiday', 'write') && in_array($user_id, $childids)) {
526 $cancreate = 1;
527 }
528
529 if ($cancreate) {
530 print '<a href="'.DOL_URL_ROOT.'/holiday/card.php?action=create&fuserid='.$user_id.'" class="butAction">'.$langs->trans("AddCP").'</a>';
531 }
532
533 print '</div>';
534} else {
535 $title = $langs->trans("ListeCP");
536
537
538 $newcardbutton = '';
539 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
540 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
541 $newcardbutton .= dolGetButtonTitleSeparator();
542 $newcardbutton .= dolGetButtonTitle($langs->trans('MenuAddCP'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/holiday/card.php?action=create', '', $user->hasRight('holiday', 'write'));
543
544 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_hrm', 0, $newcardbutton, '', $limit, 0, 0, 1);
545}
546
547$topicmail = "Information";
548$modelmail = "leaverequest";
549$objecttmp = new Holiday($db);
550$trackid = 'leav'.$object->id;
551include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
552
553if ($search_all) {
554 $setupstring = '';
555 foreach ($fieldstosearchall as $key => $val) {
556 $fieldstosearchall[$key] = $langs->trans($val);
557 $setupstring .= $key."=".$val.";";
558 }
559 print '<!-- Search done like if HOLIDAY_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
560 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
561}
562
563$moreforfilter = '';
564
565$parameters = array();
566$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
567if (empty($reshook)) {
568 $moreforfilter .= $hookmanager->resPrint;
569} else {
570 $moreforfilter = $hookmanager->resPrint;
571}
572
573if (!empty($moreforfilter)) {
574 print '<div class="liste_titre liste_titre_bydiv centpercent">';
575 print $moreforfilter;
576 print '</div>';
577}
578
579$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
580$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields with user setup
581$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
582$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
583
584$include = '';
585if (!$user->hasRight('holiday', 'readall')) {
586 $include = 'hierarchyme'; // Can see only its hierarchyl
587}
588
589print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
590print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
591
592// Fields title search
593// --------------------------------------------------------------------
594print '<tr class="liste_titre_filter">';
595// Action column
596if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
597 print '<td class="liste_titre center maxwidthsearch">';
598 $searchpicto = $form->showFilterButtons('left');
599 print $searchpicto;
600 print '</td>';
601}
602if (!empty($arrayfields['cp.ref']['checked'])) {
603 print '<td class="liste_titre">';
604 print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
605 print '</td>';
606}
607
608if (!empty($arrayfields['cp.fk_user']['checked'])) {
609 $morefilter = '';
610 if (getDolGlobalString('HOLIDAY_HIDE_FOR_NON_SALARIES')) {
611 $morefilter = 'AND employee = 1';
612 }
613
614 // User
615 $disabled = 0;
616 // If into the tab holiday of a user ($id is set in such a case)
617 if ($id && !GETPOSTISSET('search_employee')) {
618 $search_employee = $id;
619 $disabled = 1;
620 }
621
622 print '<td class="liste_titre maxwidthonsmartphone left">';
623 print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, $include, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth125');
624 print '</td>';
625}
626
627// Approver
628if (!empty($arrayfields['cp.fk_validator']['checked'])) {
629 if ($user->hasRight('holiday', 'readall')) {
630 print '<td class="liste_titre maxwidthonsmartphone left">';
631 $validator = new UserGroup($db);
632 $excludefilter = $user->admin ? '' : 'u.rowid <> '.((int) $user->id);
633 $valideurobjects = $validator->listUsersForGroup($excludefilter, 1);
634 $valideurarray = array();
635 foreach ($valideurobjects as $val) {
636 $valideurarray[$val] = $val;
637 }
638 print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth125');
639 print '</td>';
640 } else {
641 print '<td class="liste_titre">&nbsp;</td>';
642 }
643}
644
645// Type
646if (!empty($arrayfields['cp.fk_type']['checked'])) {
647 print '<td class="liste_titre">';
648 if (empty($mysoc->country_id)) {
649 setEventMessages(null, array($langs->trans("ErrorSetACountryFirst"), $langs->trans("CompanyFoundation")), 'errors');
650 } else {
651 $typeleaves = $holidaystatic->getTypes(1, -1);
652 $arraytypeleaves = array();
653 foreach ($typeleaves as $key => $val) {
654 $labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']);
655 //$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':'');
656 $arraytypeleaves[$val['rowid']] = $labeltoshow;
657 }
658 print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1);
659 }
660 print '</td>';
661}
662
663// Duration
664if (!empty($arrayfields['duration']['checked'])) {
665 print '<td class="liste_titre">&nbsp;</td>';
666}
667
668// Start date
669if (!empty($arrayfields['cp.date_debut']['checked'])) {
670 print '<td class="liste_titre center nowraponall">';
671 print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_start" value="'.dol_escape_htmltag($search_month_start).'">';
672 print $formother->selectyear($search_year_start, 'search_year_start', 1, $min_year, $max_year);
673 print '</td>';
674}
675
676// End date
677if (!empty($arrayfields['cp.date_fin']['checked'])) {
678 print '<td class="liste_titre center nowraponall">';
679 print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_end" value="'.dol_escape_htmltag($search_month_end).'">';
680 print $formother->selectyear($search_year_end, 'search_year_end', 1, $min_year, $max_year);
681 print '</td>';
682}
683
684// Date validation
685if (!empty($arrayfields['cp.date_valid']['checked'])) {
686 print '<td class="liste_titre center nowraponall">';
687 print '</td>';
688}
689
690// Date approval
691if (!empty($arrayfields['cp.date_approval']['checked'])) {
692 print '<td class="liste_titre center nowraponall">';
693 print '</td>';
694}
695
696// Extra fields
697include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
698
699// Fields from hook
700$parameters = array('arrayfields' => $arrayfields);
701$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
702print $hookmanager->resPrint;
703
704// Create date
705if (!empty($arrayfields['cp.date_create']['checked'])) {
706 print '<td class="liste_titre center width200">';
707 print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_create" value="'.dol_escape_htmltag($search_month_create).'">';
708 print $formother->selectyear($search_year_create, 'search_year_create', 1, $min_year, 0);
709 print '</td>';
710}
711
712// Create date
713if (!empty($arrayfields['cp.tms']['checked'])) {
714 print '<td class="liste_titre center width200">';
715 print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_update" value="'.dol_escape_htmltag($search_month_update).'">';
716 print $formother->selectyear($search_year_update, 'search_year_update', 1, $min_year, 0);
717 print '</td>';
718}
719
720// Status
721if (!empty($arrayfields['cp.statut']['checked'])) {
722 print '<td class="liste_titre center parentonrightofpage">';
723 print $object->selectStatutCP($search_status, 'search_status', 'search_status width100 onrightofpage');
724 print '</td>';
725}
726
727// Action column
728if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
729 print '<td class="liste_titre center maxwidthsearch">';
730 $searchpicto = $form->showFilterButtons();
731 print $searchpicto;
732 print '</td>';
733}
734
735print '</tr>'."\n";
736
737$totalarray = array();
738$totalarray['nbfield'] = 0;
739
740// Fields title label
741// --------------------------------------------------------------------
742print '<tr class="liste_titre">';
743if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
744 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
745 $totalarray['nbfield']++;
746}
747if (!empty($arrayfields['cp.ref']['checked'])) {
748 print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], "cp.ref", "", $param, '', $sortfield, $sortorder);
749 $totalarray['nbfield']++;
750}
751if (!empty($arrayfields['cp.fk_user']['checked'])) {
752 print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], "cp.fk_user", "", $param, '', $sortfield, $sortorder);
753 $totalarray['nbfield']++;
754}
755if (!empty($arrayfields['cp.fk_validator']['checked'])) {
756 print_liste_field_titre($arrayfields['cp.fk_validator']['label'], $_SERVER["PHP_SELF"], "cp.fk_validator", "", $param, '', $sortfield, $sortorder);
757 $totalarray['nbfield']++;
758}
759if (!empty($arrayfields['cp.fk_type']['checked'])) {
760 print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
761 $totalarray['nbfield']++;
762}
763if (!empty($arrayfields['duration']['checked'])) {
764 print_liste_field_titre($arrayfields['duration']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right maxwidth100');
765 $totalarray['nbfield']++;
766}
767if (!empty($arrayfields['cp.date_debut']['checked'])) {
768 print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], "cp.date_debut", "", $param, '', $sortfield, $sortorder, 'center ');
769 $totalarray['nbfield']++;
770}
771if (!empty($arrayfields['cp.date_fin']['checked'])) {
772 print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], "cp.date_fin", "", $param, '', $sortfield, $sortorder, 'center ');
773 $totalarray['nbfield']++;
774}
775if (!empty($arrayfields['cp.date_valid']['checked'])) {
776 print_liste_field_titre($arrayfields['cp.date_valid']['label'], $_SERVER["PHP_SELF"], "cp.date_valid", "", $param, '', $sortfield, $sortorder, 'center ');
777 $totalarray['nbfield']++;
778}
779if (!empty($arrayfields['cp.date_approval']['checked'])) {
780 print_liste_field_titre($arrayfields['cp.date_approval']['label'], $_SERVER["PHP_SELF"], "cp.date_approval", "", $param, '', $sortfield, $sortorder, 'center ');
781 $totalarray['nbfield']++;
782}
783// Extra fields
784include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
785// Hook fields
786$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
787$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
788print $hookmanager->resPrint;
789if (!empty($arrayfields['cp.date_create']['checked'])) {
790 print_liste_field_titre($arrayfields['cp.date_create']['label'], $_SERVER["PHP_SELF"], "cp.date_create", "", $param, '', $sortfield, $sortorder, 'center ');
791 $totalarray['nbfield']++;
792}
793if (!empty($arrayfields['cp.tms']['checked'])) {
794 print_liste_field_titre($arrayfields['cp.tms']['label'], $_SERVER["PHP_SELF"], "cp.tms", "", $param, '', $sortfield, $sortorder, 'center ');
795 $totalarray['nbfield']++;
796}
797if (!empty($arrayfields['cp.statut']['checked'])) {
798 print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cp.statut", "", $param, '', $sortfield, $sortorder, 'center ');
799 $totalarray['nbfield']++;
800}
801// Action column
802if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
803 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
804 $totalarray['nbfield']++;
805}
806print '</tr>'."\n";
807
808$listhalfday = array('morning' => $langs->trans("Morning"), "afternoon" => $langs->trans("Afternoon"));
809
810
811// Loop on record
812// --------------------------------------------------------------------
813
814// If we ask a dedicated card and not allow to see it, we force on user.
815if ($id && !$user->hasRight('holiday', 'readall') && !in_array($id, $childids)) {
816 $langs->load("errors");
817 print '<tr class="oddeven opacitymediuem"><td colspan="10">'.$langs->trans("NotEnoughPermissions").'</td></tr>';
818 $result = 0;
819} elseif ($num > 0 && !empty($mysoc->country_id)) {
820 // Lines
821 $userstatic = new User($db);
822 $approbatorstatic = new User($db);
823
824 $typeleaves = $object->getTypes(1, -1);
825
826 $i = 0;
827 $savnbfield = $totalarray['nbfield'];
828 $totalarray = array();
829 $totalarray['nbfield'] = 0;
830 $totalduration = 0;
831 $imaxinloop = ($limit ? min($num, $limit) : $num);
832 while ($i < $imaxinloop) {
833 $obj = $db->fetch_object($resql);
834 if (empty($obj)) {
835 break; // Should not happen
836 }
837
838 // Leave request
839 $holidaystatic->id = $obj->rowid;
840 $holidaystatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
841 $holidaystatic->status = $obj->status;
842 $holidaystatic->date_debut = $db->jdate($obj->date_debut);
843 $holidaystatic->date_fin = $db->jdate($obj->date_fin);
844
845 // User
846 $userstatic->id = $obj->fk_user;
847 $userstatic->lastname = $obj->user_lastname;
848 $userstatic->firstname = $obj->user_firstname;
849 $userstatic->admin = $obj->user_admin;
850 $userstatic->email = $obj->user_email;
851 $userstatic->login = $obj->user_login;
852 $userstatic->status = $obj->user_status;
853 $userstatic->photo = $obj->user_photo;
854
855 // Validator
856 $approbatorstatic->id = $obj->fk_validator;
857 $approbatorstatic->lastname = $obj->validator_lastname;
858 $approbatorstatic->firstname = $obj->validator_firstname;
859 $approbatorstatic->admin = $obj->validator_admin;
860 $approbatorstatic->email = $obj->validator_email;
861 $approbatorstatic->login = $obj->validator_login;
862 $approbatorstatic->status = $obj->validator_status;
863 $approbatorstatic->photo = $obj->validator_photo;
864
865 $date = $obj->date_create;
866 $date_modif = $obj->date_modification;
867
868 $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning';
869 $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon';
870
871 $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); // user jdate(..., 1) because num_open_day need UTC dates
872 $totalduration += $nbopenedday;
873
874 if ($mode == 'kanban') {
875 if ($i == 0) {
876 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
877 print '<div class="box-flex-container kanban">';
878 }
879
880 $holidaystatic->fk_type = empty($typeleaves[$obj->fk_type]['rowid']) ? 0 : $typeleaves[$obj->fk_type]['rowid'];
881
882 // Output Kanban
883 if ($massactionbutton || $massaction) {
884 $selected = 0;
885 if (in_array($object->id, $arrayofselected)) {
886 $selected = 1;
887 }
888 if (empty($typeleaves[$obj->fk_type])) {
889 $labeltypeleavetoshow = $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type);
890 } else {
891 $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']);
892 }
893
894 $arraydata = array('user' => $userstatic, 'labeltype' => $labeltypeleavetoshow, 'selected' => $selected, 'nbopenedday' => $nbopenedday);
895 }
896 print $holidaystatic->getKanbanView('', $arraydata);
897 if ($i == ($imaxinloop - 1)) {
898 print '</div>';
899 print '</td></tr>';
900 }
901 } else {
902 // Show here line of result
903 $j = 0;
904 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
905 // Action column
906 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
907 print '<td class="nowrap center">';
908 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
909 $selected = 0;
910 if (in_array($obj->rowid, $arrayofselected)) {
911 $selected = 1;
912 }
913 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
914 }
915 print '</td>';
916 if (!$i) {
917 $totalarray['nbfield']++;
918 }
919 }
920 if (!empty($arrayfields['cp.ref']['checked'])) {
921 print '<td class="nowraponall">';
922 print $holidaystatic->getNomUrl(1, 1);
923 print '</td>';
924 if (!$i) {
925 $totalarray['nbfield']++;
926 }
927 }
928 if (!empty($arrayfields['cp.fk_user']['checked'])) {
929 print '<td class="tdoverflowmax125">'.$userstatic->getNomUrl(-1, 'leave').'</td>';
930 if (!$i) {
931 $totalarray['nbfield']++;
932 }
933 }
934 if (!empty($arrayfields['cp.fk_validator']['checked'])) {
935 print '<td class="tdoverflowmax125">'.$approbatorstatic->getNomUrl(-1).'</td>';
936 if (!$i) {
937 $totalarray['nbfield']++;
938 }
939 }
940 if (!empty($arrayfields['cp.fk_type']['checked'])) {
941 if (empty($typeleaves[$obj->fk_type])) {
942 $labeltypeleavetoshow = $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type);
943 } else {
944 $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']);
945 }
946
947 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($labeltypeleavetoshow).'">';
948 print $labeltypeleavetoshow;
949 print '</td>';
950 if (!$i) {
951 $totalarray['nbfield']++;
952 }
953 }
954 if (!empty($arrayfields['duration']['checked'])) {
955 print '<td class="right">';
956 print $nbopenedday;
957 //print ' '.$langs->trans('DurationDays');
958 print '</td>';
959 if (!$i) {
960 $totalarray['nbfield']++;
961 }
962 }
963 if (!empty($arrayfields['cp.date_debut']['checked'])) {
964 print '<td class="center">';
965 print dol_print_date($db->jdate($obj->date_debut), 'day');
966 print ' <span class="opacitymedium nowraponall">('.$langs->trans($listhalfday[$starthalfday]).')</span>';
967 print '</td>';
968 if (!$i) {
969 $totalarray['nbfield']++;
970 }
971 }
972 if (!empty($arrayfields['cp.date_fin']['checked'])) {
973 print '<td class="center">';
974 print dol_print_date($db->jdate($obj->date_fin), 'day');
975 print ' <span class="opacitymedium nowraponall">('.$langs->trans($listhalfday[$endhalfday]).')</span>';
976 print '</td>';
977 if (!$i) {
978 $totalarray['nbfield']++;
979 }
980 }
981 // Date validation
982 if (!empty($arrayfields['cp.date_valid']['checked'])) { // date_valid is both date_valid but also date_approval
983 print '<td class="center" title="'.dol_print_date($db->jdate($obj->date_valid), 'dayhour').'">';
984 print dol_print_date($db->jdate($obj->date_valid), 'day');
985 print '</td>';
986 if (!$i) {
987 $totalarray['nbfield']++;
988 }
989 }
990 // Date approval
991 if (!empty($arrayfields['cp.date_approval']['checked'])) {
992 print '<td class="center" title="'.dol_print_date($db->jdate($obj->date_approval), 'dayhour').'">';
993 print dol_print_date($db->jdate($obj->date_approval), 'day');
994 print '</td>';
995 if (!$i) {
996 $totalarray['nbfield']++;
997 }
998 }
999
1000 // Extra fields
1001 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1002 // Fields from hook
1003 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1004 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1005 print $hookmanager->resPrint;
1006
1007 // Date creation
1008 if (!empty($arrayfields['cp.date_create']['checked'])) {
1009 print '<td style="text-align: center;">'.dol_print_date($date, 'dayhour').'</td>';
1010 if (!$i) {
1011 $totalarray['nbfield']++;
1012 }
1013 }
1014 if (!empty($arrayfields['cp.tms']['checked'])) {
1015 print '<td style="text-align: center;">'.dol_print_date($date_modif, 'dayhour').'</td>';
1016 if (!$i) {
1017 $totalarray['nbfield']++;
1018 }
1019 }
1020 // Status
1021 if (!empty($arrayfields['cp.statut']['checked'])) {
1022 print '<td class="center nowrap">'.$holidaystatic->getLibStatut(5).'</td>';
1023 if (!$i) {
1024 $totalarray['nbfield']++;
1025 }
1026 }
1027
1028 // Action column
1029 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1030 print '<td class="nowrap center">';
1031 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1032 $selected = 0;
1033 if (in_array($obj->rowid, $arrayofselected)) {
1034 $selected = 1;
1035 }
1036 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1037 }
1038 print '</td>';
1039 if (!$i) {
1040 $totalarray['nbfield']++;
1041 }
1042 }
1043
1044 print '</tr>'."\n";
1045 }
1046 $i++;
1047 }
1048
1049 // Add a line for total if there is a total to show
1050 if ($mode != 'kanban' && !empty($arrayfields['duration']['checked'])) {
1051 print '<tr class="total">';
1052 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1053 print '<td></td>';
1054 }
1055 foreach ($arrayfields as $key => $val) {
1056 if (!empty($val['checked'])) {
1057 if ($key == 'duration') {
1058 print '<td class="right">'.$totalduration.' '.$langs->trans('DurationDays').'</td>';
1059 } else {
1060 print '<td></td>';
1061 }
1062 }
1063 }
1064 // status
1065 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1066 print '<td></td>';
1067 }
1068 print '</tr>';
1069 }
1070}
1071
1072// If no record found
1073if ($num == 0) {
1074 $colspan = 1;
1075 foreach ($arrayfields as $key => $val) {
1076 if (!empty($val['checked'])) {
1077 $colspan++;
1078 }
1079 }
1080 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1081}
1082
1083$db->free($resql);
1084
1085$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1086$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1087print $hookmanager->resPrint;
1088
1089print '</table>'."\n";
1090print '</div>'."\n";
1091
1092print '</form>'."\n";
1093
1094// End of page
1095llxFooter();
1096$db->close();
1097
1098
1099
1100
1101
1109function showMyBalance($holiday, $user_id)
1110{
1111 global $langs;
1112
1113 //$alltypeleaves = $holiday->getTypes(1, -1); // To have labels
1114
1115 $out = '';
1116 $nb_holiday = 0;
1117 $typeleaves = $holiday->getTypes(1, 1);
1118 foreach ($typeleaves as $key => $val) {
1119 $nb_type = $holiday->getCPforUser($user_id, $val['rowid']);
1120 $nb_holiday += $nb_type;
1121 $out .= ' - '.$val['label'].': <strong>'.($nb_type ? price2num($nb_type) : 0).'</strong><br>';
1122 }
1123 $out = $langs->trans('SoldeCPUser', round($nb_holiday, 5)).'<br>'.$out;
1124
1125 return $out;
1126}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage standard extra fields.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class permettant la generation de composants html autre Only common components are here.
Class of the module paid holiday.
Class to manage user groups.
Class to manage Dolibarr users.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
Definition date.lib.php:378
num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0, $country_code='')
Function to return number of working days (and text of units) between two dates (working days)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
showMyBalance($holiday, $user_id)
Show balance of user.
Definition list.php:1109
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
user_prepare_head(User $object)
Prepare array with list of tabs.