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