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