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