dolibarr 24.0.3
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
5 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
7 * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
8 * Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
9 * Copyright (C) 2019 Juanjo Menent <jmenent@2byte.es>
10 * Copyright (C) 2019-2026 Frédéric France <frederic.france@free.fr>
11 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 */
26
33// Load Dolibarr environment
34require '../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
44require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
45require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
46require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
47require_once DOL_DOCUMENT_ROOT.'/core/class/html.formexpensereport.class.php';
48require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
49require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_ik.class.php';
50
51
52// Load translation files required by the page
53$langs->loadLangs(array('companies', 'users', 'trips'));
54
55$action = GETPOST('action', 'aZ09');
56$massaction = GETPOST('massaction', 'alpha');
57$show_files = GETPOSTINT('show_files');
58$confirm = GETPOST('confirm', 'alpha');
59$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
60$toselect = GETPOST('toselect', 'array:int');
61$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'expensereportlist';
62$mode = GETPOST('mode', 'alpha');
63
64$childids = $user->getAllChildIds(1);
65
66$id = GETPOSTINT('id');
67// If we are on the view of a specific user
68if ($id > 0) {
69 $canread = 0;
70 if ($id == $user->id) {
71 $canread = 1;
72 }
73 if ($user->hasRight('expensereport', 'readall')) {
74 $canread = 1;
75 }
76 if ($user->hasRight('expensereport', 'lire') && in_array($id, $childids)) {
77 $canread = 1;
78 }
79 if (!$canread) {
81 }
82}
83
84$diroutputmassaction = $conf->expensereport->dir_output.'/temp/massgeneration/'.$user->id;
85
86
87// Load variable for pagination
88$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
89$sortfield = GETPOST('sortfield', 'aZ09comma');
90$sortorder = GETPOST('sortorder', 'aZ09comma');
91$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
92if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
93 // If $page is not defined, or '' or -1 or if we click on clear filters
94 $page = 0;
95}
96$offset = $limit * $page;
97$pageprev = $page - 1;
98$pagenext = $page + 1;
99if (!$sortorder) {
100 $sortorder = "DESC";
101}
102if (!$sortfield) {
103 $sortfield = "d.date_debut";
104}
105
106
107$search_all = trim(GETPOST('search_all', 'alphanohtml'));
108
109$search_ref = GETPOST('search_ref', 'alpha');
110$search_user = GETPOST('search_user', 'intcomma');
111$search_amount_ht = GETPOST('search_amount_ht', 'alpha');
112$search_amount_vat = GETPOST('search_amount_vat', 'alpha');
113$search_amount_ttc = GETPOST('search_amount_ttc', 'alpha');
114$search_status = (GETPOST('search_status', 'intcomma') != '' ? GETPOST('search_status', 'intcomma') : GETPOST('statut', 'intcomma'));
115
116$search_date_startday = GETPOSTINT('search_date_startday');
117$search_date_startmonth = GETPOSTINT('search_date_startmonth');
118$search_date_startyear = GETPOSTINT('search_date_startyear');
119$search_date_startendday = GETPOSTINT('search_date_startendday');
120$search_date_startendmonth = GETPOSTINT('search_date_startendmonth');
121$search_date_startendyear = GETPOSTINT('search_date_startendyear');
122$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
123$search_date_startend = dol_mktime(23, 59, 59, $search_date_startendmonth, $search_date_startendday, $search_date_startendyear);
124
125$search_date_endday = GETPOSTINT('search_date_endday');
126$search_date_endmonth = GETPOSTINT('search_date_endmonth');
127$search_date_endyear = GETPOSTINT('search_date_endyear');
128$search_date_endendday = GETPOSTINT('search_date_endendday');
129$search_date_endendmonth = GETPOSTINT('search_date_endendmonth');
130$search_date_endendyear = GETPOSTINT('search_date_endendyear');
131$search_date_end = dol_mktime(0, 0, 0, $search_date_endmonth, $search_date_endday, $search_date_endyear); // Use tzserver
132$search_date_endend = dol_mktime(23, 59, 59, $search_date_endendmonth, $search_date_endendday, $search_date_endendyear);
133
134$optioncss = GETPOST('optioncss', 'alpha');
135
136if ($search_status == '') {
137 $search_status = -1;
138}
139if ($search_user == '') {
140 $search_user = -1;
141}
142
143// Security check
144$socid = GETPOSTINT('socid');
145if ($user->isExternalUser()) {
146 $socid = $user->isExternalUser();
147}
148$hookmanager->initHooks(array('expensereportlist'));
149$result = restrictedArea($user, 'expensereport', '', '');
150
151// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
153$extrafields = new ExtraFields($db);
154
155// fetch optionals attributes and labels
156$extrafields->fetch_name_optionals_label($object->table_element);
157
158$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
159
160
161// List of fields to search into when doing a "search in all"
162$fieldstosearchall = array(
163 'd.ref' => 'Ref',
164 'd.note_public' => "NotePublic",
165 'u.lastname' => 'EmployeeLastname',
166 'u.firstname' => "EmployeeFirstname",
167 'u.login' => "Login",
168);
169if (empty($user->socid)) {
170 $fieldstosearchall["d.note_private"] = "NotePrivate";
171}
172
173$arrayfields = array(
174 'd.ref' => array('label' => $langs->trans("Ref"), 'checked' => '1'),
175 'user' => array('label' => $langs->trans("User"), 'checked' => '1'),
176 'd.date_debut' => array('label' => $langs->trans("DateStart"), 'checked' => '1'),
177 'd.date_fin' => array('label' => $langs->trans("DateEnd"), 'checked' => '1'),
178 'd.date_valid' => array('label' => $langs->trans("DateValidation"), 'checked' => '1'),
179 'd.date_approve' => array('label' => $langs->trans("DateApprove"), 'checked' => '1'),
180 'd.total_ht' => array('label' => $langs->trans("AmountHT"), 'checked' => '1'),
181 'd.total_vat' => array('label' => $langs->trans("AmountVAT"), 'checked' => '-1'),
182 'd.total_ttc' => array('label' => $langs->trans("AmountTTC"), 'checked' => '1'),
183 'd.date_create' => array('label' => $langs->trans("DateCreation"), 'checked' => '0', 'position' => 500),
184 'd.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => '0', 'position' => 500),
185 'd.fk_statut' => array('label' => $langs->trans("Status"), 'checked' => '1', 'position' => 1000),
186);
187// Extra fields
188include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
189// Add hook to complete $arrayfield
190$parameters = array('arrayfields' => &$arrayfields);
191$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
192
193$canedituser = (!empty($user->admin) || $user->hasRight('user', 'user', 'creer'));
194
195$permissiontoread = $user->hasRight('expensereport', 'lire');
196$permissiontodelete = $user->hasRight('expensereport', 'supprimer');
197
198$objectuser = new User($db);
199
200
201/*
202 * Actions
203 */
204
205if (GETPOST('cancel', 'alpha')) {
206 $action = 'list';
207 $massaction = '';
208}
209if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
210 $massaction = '';
211}
212
213$parameters = array('arrayfields' => &$arrayfields, 'socid' => $socid);
214$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
215if ($reshook < 0) {
216 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
217}
218
219if (empty($reshook)) {
220 // Selection of new fields
221 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
222
223 // Purge search criteria
224 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
225 $search_ref = "";
226 $search_user = "";
227 $search_amount_ht = "";
228 $search_amount_vat = "";
229 $search_amount_ttc = "";
230 $search_status = "";
231 $search_date_startday = '';
232 $search_date_startmonth = '';
233 $search_date_startyear = '';
234 $search_date_startendday = '';
235 $search_date_startendmonth = '';
236 $search_date_startendyear = '';
237 $search_date_start = '';
238 $search_date_startend = '';
239 $search_date_endday = '';
240 $search_date_endmonth = '';
241 $search_date_endyear = '';
242 $search_date_endendday = '';
243 $search_date_endendmonth = '';
244 $search_date_endendyear = '';
245 $search_date_end = '';
246 $search_date_endend = '';
247 $toselect = array();
248 $search_array_options = array();
249 }
250 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
251 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
252 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
253 }
254
255 // Mass actions
256 $objectclass = 'ExpenseReport';
257 $objectlabel = 'ExpenseReport';
258 $uploaddir = $conf->expensereport->dir_output;
259 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
260}
261
262
263/*
264 * View
265 */
266
267$form = new Form($db);
268$formother = new FormOther($db);
269$formfile = new FormFile($db);
270$formexpensereport = new FormExpenseReport($db);
271
272$fuser = new User($db);
273
274$title = $langs->trans("TripsAndExpenses");
275$help_url = '';
276$morejs = array();
277$morecss = array();
278
279$max_year = 5;
280$min_year = 10;
281
282// Get current user id
283$user_id = $user->id;
284
285if ($id > 0) {
286 // Load editing user
287 $fuser->fetch($id, '', '', 1);
288 $fuser->loadRights();
289 $user_id = $fuser->id;
290
291 $search_user = $user_id;
292}
293
294// Build and execute select
295// --------------------------------------------------------------------
296$sql = "SELECT d.rowid, d.ref, d.fk_user_author, d.total_ht, d.total_tva, d.total_ttc, d.fk_statut as status,";
297$sql .= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_valid, d.date_approve, d.note_private, d.note_public,";
298$sql .= " u.rowid as id_user, u.firstname, u.lastname, u.login, u.email, u.statut as user_status, u.photo";
299// Add fields from extrafields
300if (!empty($extrafields->attributes[$object->table_element]['label'])) {
301 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
302 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
303 }
304}
305// Add fields from hooks
306$parameters = array();
307$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
308$sql .= $hookmanager->resPrint;
309$sql = preg_replace('/,\s*$/', '', $sql);
310
311$sqlfields = $sql; // $sql fields to remove for count total
312
313$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as d";
314if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
315 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)";
316}
317$sql .= ", ".MAIN_DB_PREFIX."user as u";
318$sql .= " WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity('expensereport').")";
319// Search all
320if (!empty($search_all)) {
321 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
322}
323// Ref
324if (!empty($search_ref)) {
325 $sql .= natural_search('d.ref', $search_ref);
326}
327// Date Start
328if ($search_date_start) {
329 $sql .= " AND d.date_debut >= '".$db->idate($search_date_start)."'";
330}
331if ($search_date_startend) {
332 $sql .= " AND d.date_debut <= '".$db->idate($search_date_startend)."'";
333}
334// Date End
335if ($search_date_end) {
336 $sql .= " AND d.date_fin >= '".$db->idate($search_date_end)."'";
337}
338if ($search_date_endend) {
339 $sql .= " AND d.date_fin <= '".$db->idate($search_date_endend)."'";
340}
341
342if ($search_amount_ht != '') {
343 $sql .= natural_search('d.total_ht', $search_amount_ht, 1);
344}
345if ($search_amount_ttc != '') {
346 $sql .= natural_search('d.total_ttc', $search_amount_ttc, 1);
347}
348// User
349if ($search_user != '' && $search_user >= 0) {
350 $sql .= " AND u.rowid = '".$db->escape($search_user)."'";
351}
352// Status
353if ($search_status != '' && $search_status >= 0) {
354 $sql .= " AND d.fk_statut IN (".$db->sanitize($search_status).")";
355}
356// RESTRICT RIGHTS
357if (!$user->hasRight('expensereport', 'readall') && !$user->hasRight('expensereport', 'lire_tous')
358 && (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || !$user->hasRight('expensereport', 'writeall_advance'))) {
359 $sql .= " AND (d.fk_user_author IN (".$db->sanitize(implode(',', $childids)).")";
360 if ($user->hasRight('expensereport', 'approve')) {
361 $sql .= " OR d.fk_user_validator = ".((int) $user->id); // The user designated to approve the expense report
362 }
363 $sql .= ")\n";
364}
365// Add where from extra fields
366include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
367// Add where from hooks
368$parameters = array();
369$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
370$sql .= $hookmanager->resPrint;
371
372// Count total nb of records
373$nbtotalofrecords = '';
374if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
375 /* The fast and low memory method to get and count full list converts the sql into a sql count */
376 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
377 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
378 $resql = $db->query($sqlforcount);
379 if ($resql) {
380 $objforcount = $db->fetch_object($resql);
381 $nbtotalofrecords = $objforcount->nbtotalofrecords;
382 } else {
384 }
385
386 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
387 $page = 0;
388 $offset = 0;
389 }
390 $db->free($resql);
391}
392
393// Complete request and execute it with limit
394$sql .= $db->order($sortfield, $sortorder);
395if ($limit) {
396 $sql .= $db->plimit($limit + 1, $offset);
397}
398
399//print $sql;
400$resql = $db->query($sql);
401if (!$resql) {
403 exit;
404}
405
406$num = $db->num_rows($resql);
407
408// Direct jump if only one record found
409if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
410 $obj = $db->fetch_object($resql);
411 $id = $obj->rowid;
412 header("Location: ".DOL_URL_ROOT.'/expensereport/card.php?id='.$id);
413 exit;
414}
415
416// Output page
417// --------------------------------------------------------------------
418
419llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-expensereport page-list bodyforlist');
420
421$arrayofselected = is_array($toselect) ? $toselect : array();
422
423$param = '';
424if (!empty($mode)) {
425 $param .= '&mode='.urlencode($mode);
426}
427if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
428 $param .= '&contextpage='.urlencode($contextpage);
429}
430if ($limit > 0 && $limit != $conf->liste_limit) {
431 $param .= '&limit='.((int) $limit);
432}
433if ($optioncss != '') {
434 $param .= '&optioncss='.urlencode($optioncss);
435}
436if ($search_all) {
437 $param .= "&search_all=".urlencode($search_all);
438}
439if ($search_ref) {
440 $param .= "&search_ref=".urlencode($search_ref);
441}
442// Start date
443if ($search_date_startday) {
444 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
445}
446if ($search_date_startmonth) {
447 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
448}
449if ($search_date_startyear) {
450 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
451}
452if ($search_date_startendday) {
453 $param .= '&search_date_startendday='.urlencode((string) ($search_date_startendday));
454}
455if ($search_date_startendmonth) {
456 $param .= '&search_date_startendmonth='.urlencode((string) ($search_date_startendmonth));
457}
458if ($search_date_startendyear) {
459 $param .= '&search_date_startendyear='.urlencode((string) ($search_date_startendyear));
460}
461// End date
462if ($search_date_endday) {
463 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
464}
465if ($search_date_endmonth) {
466 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
467}
468if ($search_date_endyear) {
469 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
470}
471if ($search_date_endendday) {
472 $param .= '&search_date_endendday='.urlencode((string) ($search_date_endendday));
473}
474if ($search_date_endendmonth) {
475 $param .= '&search_date_endendmonth='.urlencode((string) ($search_date_endendmonth));
476}
477if ($search_date_endendyear) {
478 $param .= '&search_date_endendyear='.urlencode((string) ($search_date_endendyear));
479}
480if ($search_user) {
481 $param .= "&search_user=".urlencode($search_user);
482}
483if ($search_amount_ht) {
484 $param .= "&search_amount_ht=".urlencode($search_amount_ht);
485}
486if ($search_amount_ttc) {
487 $param .= "&search_amount_ttc=".urlencode($search_amount_ttc);
488}
489if ($search_status >= 0) {
490 $param .= "&search_status=".urlencode($search_status);
491}
492// Add $param from extra fields
493include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
494
495// List of mass actions available
496$arrayofmassactions = array(
497 'generate_doc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
498 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
499 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
500);
501if ($user->hasRight('expensereport', 'supprimer')) {
502 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
503}
504if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
505 $arrayofmassactions = array();
506}
507$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
508
509// Lines of title fields
510print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
511if ($optioncss != '') {
512 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
513}
514print '<input type="hidden" name="token" value="'.newToken().'">';
515print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
516print '<input type="hidden" name="action" value="'.($action == 'edit' ? 'update' : 'list').'">';
517print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
518print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
519print '<input type="hidden" name="page" value="'.$page.'">';
520print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
521print '<input type="hidden" name="page_y" value="">';
522print '<input type="hidden" name="mode" value="'.$mode.'">';
523if ($id > 0) {
524 print '<input type="hidden" name="id" value="'.$id.'">';
525}
526
527if ($id > 0) { // For user tab
528 $title = $langs->trans("User");
529 $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
530 $head = user_prepare_head($fuser);
531
532 print dol_get_fiche_head($head, 'expensereport', $title, -1, 'user');
533
534 dol_banner_tab($fuser, 'id', $linkback, $user->hasRight('user', 'user', 'lire') || $user->admin);
535
536 print dol_get_fiche_end();
537
538 if ($action != 'edit') {
539 print '<div class="tabsAction">';
540
541 $childids = $user->getAllChildIds(1);
542
543 $canedit = ((in_array($user_id, $childids) && $user->hasRight('expensereport', 'creer'))
544 || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('expensereport', 'writeall_advance')));
545
546 // Buttons for actions
547 if ($canedit) {
548 print '<a href="'.DOL_URL_ROOT.'/expensereport/card.php?action=create&fk_user_author='.$fuser->id.'" class="butAction">'.$langs->trans("AddTrip").'</a>';
549 } else {
550 print '<a href="#" class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddTrip").'</a>';
551 }
552
553 print '</div>';
554 } else {
555 print $form->buttonsSaveCancel("Save", '');
556 }
557} else {
558 $title = $langs->trans("ListTripsAndExpenses");
559
560 $url = DOL_URL_ROOT.'/expensereport/card.php?action=create';
561 if (!empty($socid)) {
562 $url .= '&socid='.$socid;
563 }
564 $newcardbutton = '';
565 $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'));
566 $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'));
567 $newcardbutton .= dolGetButtonTitle($langs->trans('Statistics'), '', 'fa fa-chart-bar imgforviewmode', DOL_URL_ROOT.'/expensereport/stats/index.php?mode=statistics&objecttype=expensereport@expensereport'.preg_replace('/(&|\?)*(mode|groupby)=[^&]+/', '', $param), '', ($mode == 'statistics' ? 2 : 1), array('morecss' => 'reposition'));
568 $newcardbutton .= dolGetButtonTitleSeparator();
569 $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('expensereport', 'creer'));
570
571 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'expensereport', 0, $newcardbutton, '', $limit, 0, 0, 1);
572}
573
574// Add code for pre mass action (confirmation or email presend form)
575$topicmail = "SendExpenseReport";
576$modelmail = "expensereport";
577$objecttmp = new ExpenseReport($db);
578$trackid = 'exp'.$object->id;
579include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
580
581if ($search_all) {
582 $setupstring = '';
583 foreach ($fieldstosearchall as $key => $val) {
584 $fieldstosearchall[$key] = $langs->trans($val);
585 $setupstring .= $key."=".$val.";";
586 }
587 print '<!-- Search done like if EXPENSEREPORT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
588 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
589}
590
591$moreforfilter = '';
592
593$parameters = array();
594$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
595if (empty($reshook)) {
596 $moreforfilter .= $hookmanager->resPrint;
597} else {
598 $moreforfilter = $hookmanager->resPrint;
599}
600
601if (!empty($moreforfilter)) {
602 print '<div class="liste_titre liste_titre_bydiv centpercent">';
603 print $moreforfilter;
604 print '</div>';
605}
606
607$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
608$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
609$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
610$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
611
612print '<div class="div-table-responsive">';
613print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
614
615// Fields title search
616// --------------------------------------------------------------------
617print '<tr class="liste_titre_filter">';
618// Action column
619if ($conf->main_checkbox_left_column) {
620 print '<td class="liste_titre center maxwidthsearch">';
621 $searchpicto = $form->showFilterButtons('left');
622 print $searchpicto;
623 print '</td>';
624}
625if (!empty($arrayfields['d.ref']['checked'])) {
626 print '<td class="liste_titre">';
627 print '<input class="flat width100" type="text" name="search_ref" value="'.dolPrintHTMLForAttribute($search_ref).'">';
628 print '</td>';
629}
630// User
631if (!empty($arrayfields['user']['checked'])) {
632 if ($user->hasRight('expensereport', 'readall') || $user->hasRight('expensereport', 'lire_tous')) {
633 print '<td class="liste_titre maxwidthonsmartphone" align="left">';
634 print $form->select_dolusers($search_user, 'search_user', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth200');
635 print '</td>';
636 } else {
637 print '<td class="liste_titre">&nbsp;</td>';
638 }
639}
640// Date start
641if (!empty($arrayfields['d.date_debut']['checked'])) {
642 print '<td class="liste_titre" align="center">';
643 print '<div class="nowrapfordate">';
644 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
645 print '</div>';
646 print '<div class="nowrapfordate">';
647 print $form->selectDate($search_date_startend ? $search_date_startend : -1, 'search_date_startend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
648 print '</div>';
649 print '</td>';
650}
651// Date end
652if (!empty($arrayfields['d.date_fin']['checked'])) {
653 print '<td class="liste_titre" align="center">';
654 print '<div class="nowrapfordate">';
655 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
656 print '</div>';
657 print '<div class="nowrapfordate">';
658 print $form->selectDate($search_date_endend ? $search_date_endend : -1, 'search_date_endend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
659 print '</div>';
660 print '</td>';
661}
662// Date valid
663if (!empty($arrayfields['d.date_valid']['checked'])) {
664 print '<td class="liste_titre" align="center">';
665 //print '<input class="flat" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">';
666 //print $formother->selectyear($year_end,'year_end',1, $min_year, $max_year);
667 print '</td>';
668}
669// Date approve
670if (!empty($arrayfields['d.date_approve']['checked'])) {
671 print '<td class="liste_titre" align="center">';
672 //print '<input class="flat" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">';
673 //print $formother->selectyear($year_end,'year_end',1, $min_year, $max_year);
674 print '</td>';
675}
676// Amount with no tax
677if (!empty($arrayfields['d.total_ht']['checked'])) {
678 print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ht" value="'.$search_amount_ht.'"></td>';
679}
680if (!empty($arrayfields['d.total_vat']['checked'])) {
681 print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_vat" value="'.$search_amount_vat.'"></td>';
682}
683// Amount with all taxes
684if (!empty($arrayfields['d.total_ttc']['checked'])) {
685 print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ttc" value="'.$search_amount_ttc.'"></td>';
686}
687// Extra fields
688include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
689
690// Fields from hook
691$parameters = array('arrayfields' => $arrayfields);
692$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
693print $hookmanager->resPrint;
694// Date creation
695if (!empty($arrayfields['d.date_create']['checked'])) {
696 print '<td class="liste_titre">';
697 print '</td>';
698}
699// Date modification
700if (!empty($arrayfields['d.tms']['checked'])) {
701 print '<td class="liste_titre">';
702 print '</td>';
703}
704// Status
705if (!empty($arrayfields['d.fk_statut']['checked'])) {
706 print '<td class="liste_titre center parentonrightofpage">';
707 print $formexpensereport->selectExpensereportStatus($search_status, 'search_status', 1, 1, 'search_status width100 onrightofpage');
708 print '</td>';
709}
710// Action column
711if (!$conf->main_checkbox_left_column) {
712 print '<td class="liste_titre center maxwidthsearch">';
713 $searchpicto = $form->showFilterButtons();
714 print $searchpicto;
715 print '</td>';
716}
717
718print '</tr>'."\n";
719
720$totalarray = array();
721$totalarray['nbfield'] = 0;
722
723// Fields title label
724// --------------------------------------------------------------------
725print '<tr class="liste_titre">';
726if ($conf->main_checkbox_left_column) {
727 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ');
728 $totalarray['nbfield']++;
729}
730if (!empty($arrayfields['d.ref']['checked'])) {
731 print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "d.ref", "", $param, '', $sortfield, $sortorder);
732 $totalarray['nbfield']++;
733}
734if (!empty($arrayfields['user']['checked'])) {
735 print_liste_field_titre($arrayfields['user']['label'], $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder);
736 $totalarray['nbfield']++;
737}
738if (!empty($arrayfields['d.date_debut']['checked'])) {
739 print_liste_field_titre($arrayfields['d.date_debut']['label'], $_SERVER["PHP_SELF"], "d.date_debut", "", $param, '', $sortfield, $sortorder, 'center ');
740 $totalarray['nbfield']++;
741}
742if (!empty($arrayfields['d.date_fin']['checked'])) {
743 print_liste_field_titre($arrayfields['d.date_fin']['label'], $_SERVER["PHP_SELF"], "d.date_fin", "", $param, '', $sortfield, $sortorder, 'center ');
744 $totalarray['nbfield']++;
745}
746if (!empty($arrayfields['d.date_valid']['checked'])) {
747 print_liste_field_titre($arrayfields['d.date_valid']['label'], $_SERVER["PHP_SELF"], "d.date_valid", "", $param, '', $sortfield, $sortorder, 'center ');
748 $totalarray['nbfield']++;
749}
750if (!empty($arrayfields['d.date_approve']['checked'])) {
751 print_liste_field_titre($arrayfields['d.date_approve']['label'], $_SERVER["PHP_SELF"], "d.date_approve", "", $param, '', $sortfield, $sortorder, 'center ');
752 $totalarray['nbfield']++;
753}
754if (!empty($arrayfields['d.total_ht']['checked'])) {
755 print_liste_field_titre($arrayfields['d.total_ht']['label'], $_SERVER["PHP_SELF"], "d.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
756 $totalarray['nbfield']++;
757}
758if (!empty($arrayfields['d.total_vat']['checked'])) {
759 print_liste_field_titre($arrayfields['d.total_vat']['label'], $_SERVER["PHP_SELF"], "d.total_tva", "", $param, '', $sortfield, $sortorder, 'right ');
760 $totalarray['nbfield']++;
761}
762if (!empty($arrayfields['d.total_ttc']['checked'])) {
763 print_liste_field_titre($arrayfields['d.total_ttc']['label'], $_SERVER["PHP_SELF"], "d.total_ttc", "", $param, '', $sortfield, $sortorder, 'right ');
764 $totalarray['nbfield']++;
765}
766// Extra fields
767include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
768// Hook fields
769$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
770$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
771print $hookmanager->resPrint;
772if (!empty($arrayfields['d.date_create']['checked'])) {
773 print_liste_field_titre($arrayfields['d.date_create']['label'], $_SERVER["PHP_SELF"], "d.date_create", "", $param, '', $sortfield, $sortorder, 'nowraponall center');
774 $totalarray['nbfield']++;
775}
776if (!empty($arrayfields['d.tms']['checked'])) {
777 print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, '', $sortfield, $sortorder, 'nowraponall center');
778 $totalarray['nbfield']++;
779}
780if (!empty($arrayfields['d.fk_statut']['checked'])) {
781 print_liste_field_titre($arrayfields['d.fk_statut']['label'], $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
782 $totalarray['nbfield']++;
783}
784if (!$conf->main_checkbox_left_column) {
785 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
786 $totalarray['nbfield']++;
787}
788print '</tr>'."\n";
789
790
791// Loop on record
792// --------------------------------------------------------------------
793
794$total_total_ht = 0;
795$total_total_ttc = 0;
796$total_total_tva = 0;
797
798$expensereportstatic = new ExpenseReport($db);
799$usertmp = new User($db);
800
801if ($num > 0) {
802 $i = 0;
803 $savnbfield = $totalarray['nbfield'];
804 $totalarray = array();
805 $totalarray['nbfield'] = 0;
806 $totalarray['val'] = array();
807 $totalarray['val']['d.total_ht'] = 0;
808 $totalarray['val']['d.total_tva'] = 0;
809 $totalarray['val']['d.total_ttc'] = 0;
810 $totalarray['totalizable'] = array();
811
812 $imaxinloop = ($limit ? min($num, $limit) : $num);
813 while ($i < $imaxinloop) {
814 $obj = $db->fetch_object($resql);
815 if (empty($obj)) {
816 break; // Should not happen
817 }
818
819 $expensereportstatic->id = $obj->rowid;
820 $expensereportstatic->ref = $obj->ref;
821 $expensereportstatic->status = $obj->status;
822 $expensereportstatic->date_debut = $db->jdate($obj->date_debut);
823 $expensereportstatic->date_fin = $db->jdate($obj->date_fin);
824 $expensereportstatic->date_create = $db->jdate($obj->date_create);
825 $expensereportstatic->date_modif = $db->jdate($obj->date_modif);
826 $expensereportstatic->date_valid = $db->jdate($obj->date_valid);
827 $expensereportstatic->date_approve = $db->jdate($obj->date_approve);
828 $expensereportstatic->note_private = $obj->note_private;
829 $expensereportstatic->note_public = $obj->note_public;
830 $expensereportstatic->fk_user = $obj->id_user;
831
832 $usertmp->id = $obj->id_user;
833 $usertmp->lastname = $obj->lastname;
834 $usertmp->firstname = $obj->firstname;
835 $usertmp->login = $obj->login;
836 $usertmp->statut = $obj->user_status;
837 $usertmp->status = $obj->user_status;
838 $usertmp->photo = $obj->photo;
839 $usertmp->email = $obj->email;
840
841 if ($mode == 'kanban') {
842 if ($i == 0) {
843 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
844 print '<div class="box-flex-container kanban">';
845 }
846 // TODO Use a cache on user
847 $usertmp->fetch($obj->id_user);
848
849 // Output Kanban
850 if ($massactionbutton || $massaction) {
851 $selected = 0;
852
853 print $expensereportstatic->getKanbanView('', array('userauthor' => $usertmp, 'selected' => in_array($expensereportstatic->id, $arrayofselected)));
854 }
855 if ($i == ($imaxinloop - 1)) {
856 print '</div>';
857 print '</td></tr>';
858 }
859 } else {
860 // Show line of result
861 $j = 0;
862 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
863
864 // Action column
865 if ($conf->main_checkbox_left_column) {
866 print '<td class="nowrap center">';
867 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
868 $selected = 0;
869 if (in_array($obj->rowid, $arrayofselected)) {
870 $selected = 1;
871 }
872 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
873 }
874 print '</td>';
875 if (!$i) {
876 $totalarray['nbfield']++;
877 }
878 }
879 // Ref
880 if (!empty($arrayfields['d.ref']['checked'])) {
881 print '<td class="tdoverflowmax150">';
882 print $expensereportstatic->getNomUrl(1);
883 // Warning late icon and note
884 if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay('toapprove')) {
885 print img_warning($langs->trans("Late"));
886 }
887 if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay('topay')) {
888 print img_warning($langs->trans("Late"));
889 }
890 if (!empty($obj->note_private) || !empty($obj->note_public)) {
891 print ' <span class="note">';
892 print '<a href="'.DOL_URL_ROOT.'/expensereport/note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>';
893 print '</span>';
894 }
895 $filename = dol_sanitizeFileName($obj->ref);
896 $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($obj->ref);
897 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
898 print $formfile->getDocumentsLink($expensereportstatic->element, $filename, $filedir);
899 print '</td>';
900 if (!$i) {
901 $totalarray['nbfield']++;
902 }
903 }
904 // User
905 if (!empty($arrayfields['user']['checked'])) {
906 print '<td class="left">';
907 print $usertmp->getNomUrl(-1);
908 print '</td>';
909 if (!$i) {
910 $totalarray['nbfield']++;
911 }
912 }
913 // Start date
914 if (!empty($arrayfields['d.date_debut']['checked'])) {
915 print '<td class="center">'.($obj->date_debut > 0 ? dol_print_date($db->jdate($obj->date_debut), 'day') : '').'</td>';
916 if (!$i) {
917 $totalarray['nbfield']++;
918 }
919 }
920 // End date
921 if (!empty($arrayfields['d.date_fin']['checked'])) {
922 print '<td class="center">'.($obj->date_fin > 0 ? dol_print_date($db->jdate($obj->date_fin), 'day') : '').'</td>';
923 if (!$i) {
924 $totalarray['nbfield']++;
925 }
926 }
927 // Date validation
928 if (!empty($arrayfields['d.date_valid']['checked'])) {
929 print '<td class="center">'.($obj->date_valid > 0 ? dol_print_date($db->jdate($obj->date_valid), 'day') : '').'</td>';
930 if (!$i) {
931 $totalarray['nbfield']++;
932 }
933 }
934 // Date approval
935 if (!empty($arrayfields['d.date_approve']['checked'])) {
936 print '<td class="center">'.($obj->date_approve > 0 ? dol_print_date($db->jdate($obj->date_approve), 'day') : '').'</td>';
937 if (!$i) {
938 $totalarray['nbfield']++;
939 }
940 }
941 // Amount HT
942 if (!empty($arrayfields['d.total_ht']['checked'])) {
943 print '<td class="right">'.price($obj->total_ht)."</td>\n";
944 if (!$i) {
945 $totalarray['nbfield']++;
946 }
947 if (!$i) {
948 $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ht';
949 }
950 $totalarray['val']['d.total_ht'] += $obj->total_ht;
951 }
952 // Amount VAT
953 if (!empty($arrayfields['d.total_vat']['checked'])) {
954 print '<td class="right">'.price($obj->total_tva)."</td>\n";
955 if (!$i) {
956 $totalarray['nbfield']++;
957 }
958 if (!$i) {
959 $totalarray['pos'][$totalarray['nbfield']] = 'd.total_tva';
960 }
961 $totalarray['val']['d.total_tva'] += $obj->total_tva;
962 }
963 // Amount TTC
964 if (!empty($arrayfields['d.total_ttc']['checked'])) {
965 print '<td class="right">'.price($obj->total_ttc)."</td>\n";
966 if (!$i) {
967 $totalarray['nbfield']++;
968 }
969 if (!$i) {
970 $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ttc';
971 }
972 $totalarray['val']['d.total_ttc'] += $obj->total_ttc;
973 }
974
975 // Extra fields
976 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
977 // Fields from hook
978 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
979 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
980 print $hookmanager->resPrint;
981
982 // Date creation
983 if (!empty($arrayfields['d.date_create']['checked'])) {
984 print '<td class="nowrap center">';
985 print dol_print_date($db->jdate($obj->date_create), 'dayhour');
986 print '</td>';
987 if (!$i) {
988 $totalarray['nbfield']++;
989 }
990 }
991 // Date modification
992 if (!empty($arrayfields['d.tms']['checked'])) {
993 print '<td class="nowrap center">';
994 print dol_print_date($db->jdate($obj->date_modif), 'dayhour');
995 print '</td>';
996 if (!$i) {
997 $totalarray['nbfield']++;
998 }
999 }
1000 // Status
1001 if (!empty($arrayfields['d.fk_statut']['checked'])) {
1002 print '<td class="nowrap center">'.$expensereportstatic->getLibStatut(5).'</td>';
1003 if (!$i) {
1004 $totalarray['nbfield']++;
1005 }
1006 }
1007 // Action column
1008 if (!$conf->main_checkbox_left_column) {
1009 print '<td class="nowrap center">';
1010 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1011 $selected = 0;
1012 if (in_array($obj->rowid, $arrayofselected)) {
1013 $selected = 1;
1014 }
1015 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1016 }
1017 print '</td>';
1018 if (!$i) {
1019 $totalarray['nbfield']++;
1020 }
1021 }
1022
1023 print '</tr>'."\n";
1024 }
1025
1026 $total_total_ht += $obj->total_ht;
1027 $total_total_tva += $obj->total_tva;
1028 $total_total_ttc += $obj->total_ttc;
1029
1030 $i++;
1031 }
1032}
1033
1034// Show total line
1035include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1036
1037// If no record found
1038if ($num == 0) {
1039 $colspan = 1;
1040 foreach ($arrayfields as $key => $val) {
1041 if (!empty($val['checked'])) {
1042 $colspan++;
1043 }
1044 }
1045 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1046}
1047
1048$db->free($resql);
1049
1050$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1051$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1052print $hookmanager->resPrint;
1053
1054print '</table>'."\n";
1055print '</div>'."\n";
1056
1057print '</form>'."\n";
1058
1059if (empty($id)) {
1060 $hidegeneratedfilelistifempty = 1;
1061 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1062 $hidegeneratedfilelistifempty = 0;
1063 }
1064
1065 // Show list of available documents
1066 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1067 $urlsource .= str_replace('&amp;', '&', $param);
1068
1069 $filedir = $diroutputmassaction;
1070 $genallowed = $user->hasRight('expensereport', 'lire');
1071 $delallowed = $user->hasRight('expensereport', 'creer');
1072
1073 print $formfile->showdocuments('massfilesarea_expensereport', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1074}
1075
1076// End of page
1077llxFooter();
1078$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:501
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage Trips and Expenses.
Class to manage standard extra fields.
Class to manage generation of HTML components for contract module.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to help generate other html components Only common components are here.
Class to manage Dolibarr users.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
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)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
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.