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