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