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