dolibarr 25.0.0-alpha
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)).")\n";
360}
361// Add where from extra fields
362include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
363// Add where from hooks
364$parameters = array();
365$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
366$sql .= $hookmanager->resPrint;
367
368// Count total nb of records
369$nbtotalofrecords = '';
370if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
371 /* The fast and low memory method to get and count full list converts the sql into a sql count */
372 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
373 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
374 $resql = $db->query($sqlforcount);
375 if ($resql) {
376 $objforcount = $db->fetch_object($resql);
377 $nbtotalofrecords = $objforcount->nbtotalofrecords;
378 } else {
380 }
381
382 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
383 $page = 0;
384 $offset = 0;
385 }
386 $db->free($resql);
387}
388
389// Complete request and execute it with limit
390$sql .= $db->order($sortfield, $sortorder);
391if ($limit) {
392 $sql .= $db->plimit($limit + 1, $offset);
393}
394
395//print $sql;
396$resql = $db->query($sql);
397if (!$resql) {
399 exit;
400}
401
402$num = $db->num_rows($resql);
403
404// Direct jump if only one record found
405if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
406 $obj = $db->fetch_object($resql);
407 $id = $obj->rowid;
408 header("Location: ".DOL_URL_ROOT.'/expensereport/card.php?id='.$id);
409 exit;
410}
411
412// Output page
413// --------------------------------------------------------------------
414
415llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-expensereport page-list bodyforlist');
416
417$arrayofselected = is_array($toselect) ? $toselect : array();
418
419$param = '';
420if (!empty($mode)) {
421 $param .= '&mode='.urlencode($mode);
422}
423if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
424 $param .= '&contextpage='.urlencode($contextpage);
425}
426if ($limit > 0 && $limit != $conf->liste_limit) {
427 $param .= '&limit='.((int) $limit);
428}
429if ($optioncss != '') {
430 $param .= '&optioncss='.urlencode($optioncss);
431}
432if ($search_all) {
433 $param .= "&search_all=".urlencode($search_all);
434}
435if ($search_ref) {
436 $param .= "&search_ref=".urlencode($search_ref);
437}
438// Start date
439if ($search_date_startday) {
440 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
441}
442if ($search_date_startmonth) {
443 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
444}
445if ($search_date_startyear) {
446 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
447}
448if ($search_date_startendday) {
449 $param .= '&search_date_startendday='.urlencode((string) ($search_date_startendday));
450}
451if ($search_date_startendmonth) {
452 $param .= '&search_date_startendmonth='.urlencode((string) ($search_date_startendmonth));
453}
454if ($search_date_startendyear) {
455 $param .= '&search_date_startendyear='.urlencode((string) ($search_date_startendyear));
456}
457// End date
458if ($search_date_endday) {
459 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
460}
461if ($search_date_endmonth) {
462 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
463}
464if ($search_date_endyear) {
465 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
466}
467if ($search_date_endendday) {
468 $param .= '&search_date_endendday='.urlencode((string) ($search_date_endendday));
469}
470if ($search_date_endendmonth) {
471 $param .= '&search_date_endendmonth='.urlencode((string) ($search_date_endendmonth));
472}
473if ($search_date_endendyear) {
474 $param .= '&search_date_endendyear='.urlencode((string) ($search_date_endendyear));
475}
476if ($search_user) {
477 $param .= "&search_user=".urlencode($search_user);
478}
479if ($search_amount_ht) {
480 $param .= "&search_amount_ht=".urlencode($search_amount_ht);
481}
482if ($search_amount_ttc) {
483 $param .= "&search_amount_ttc=".urlencode($search_amount_ttc);
484}
485if ($search_status >= 0) {
486 $param .= "&search_status=".urlencode($search_status);
487}
488// Add $param from extra fields
489include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
490
491// List of mass actions available
492$arrayofmassactions = array(
493 'generate_doc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
494 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
495 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
496);
497if ($user->hasRight('expensereport', 'supprimer')) {
498 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
499}
500if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
501 $arrayofmassactions = array();
502}
503$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
504
505// Lines of title fields
506print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
507if ($optioncss != '') {
508 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
509}
510print '<input type="hidden" name="token" value="'.newToken().'">';
511print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
512print '<input type="hidden" name="action" value="'.($action == 'edit' ? 'update' : 'list').'">';
513print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
514print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
515print '<input type="hidden" name="page" value="'.$page.'">';
516print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
517print '<input type="hidden" name="page_y" value="">';
518print '<input type="hidden" name="mode" value="'.$mode.'">';
519if ($id > 0) {
520 print '<input type="hidden" name="id" value="'.$id.'">';
521}
522
523if ($id > 0) { // For user tab
524 $title = $langs->trans("User");
525 $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
526 $head = user_prepare_head($fuser);
527
528 print dol_get_fiche_head($head, 'expensereport', $title, -1, 'user');
529
530 dol_banner_tab($fuser, 'id', $linkback, $user->hasRight('user', 'user', 'lire') || $user->admin);
531
532 print dol_get_fiche_end();
533
534 if ($action != 'edit') {
535 print '<div class="tabsAction">';
536
537 $childids = $user->getAllChildIds(1);
538
539 $canedit = ((in_array($user_id, $childids) && $user->hasRight('expensereport', 'creer'))
540 || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('expensereport', 'writeall_advance')));
541
542 // Buttons for actions
543 if ($canedit) {
544 print '<a href="'.DOL_URL_ROOT.'/expensereport/card.php?action=create&fk_user_author='.$fuser->id.'" class="butAction">'.$langs->trans("AddTrip").'</a>';
545 } else {
546 print '<a href="#" class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddTrip").'</a>';
547 }
548
549 print '</div>';
550 } else {
551 print $form->buttonsSaveCancel("Save", '');
552 }
553} else {
554 $title = $langs->trans("ListTripsAndExpenses");
555
556 $url = DOL_URL_ROOT.'/expensereport/card.php?action=create';
557 if (!empty($socid)) {
558 $url .= '&socid='.$socid;
559 }
560 $newcardbutton = '';
561 $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'));
562 $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'));
563 $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'));
564 $newcardbutton .= dolGetButtonTitleSeparator();
565 $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('expensereport', 'creer'));
566
567 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'expensereport', 0, $newcardbutton, '', $limit, 0, 0, 1);
568}
569
570// Add code for pre mass action (confirmation or email presend form)
571$topicmail = "SendExpenseReport";
572$modelmail = "expensereport";
573$objecttmp = new ExpenseReport($db);
574$trackid = 'exp'.$object->id;
575include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
576
577if ($search_all) {
578 $setupstring = '';
579 foreach ($fieldstosearchall as $key => $val) {
580 $fieldstosearchall[$key] = $langs->trans($val);
581 $setupstring .= $key."=".$val.";";
582 }
583 print '<!-- Search done like if EXPENSEREPORT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
584 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
585}
586
587$moreforfilter = '';
588
589$parameters = array();
590$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
591if (empty($reshook)) {
592 $moreforfilter .= $hookmanager->resPrint;
593} else {
594 $moreforfilter = $hookmanager->resPrint;
595}
596
597if (!empty($moreforfilter)) {
598 print '<div class="liste_titre liste_titre_bydiv centpercent">';
599 print $moreforfilter;
600 print '</div>';
601}
602
603$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
604$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
605$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
606$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
607
608print '<div class="div-table-responsive">';
609print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
610
611// Fields title search
612// --------------------------------------------------------------------
613print '<tr class="liste_titre_filter">';
614// Action column
615if ($conf->main_checkbox_left_column) {
616 print '<td class="liste_titre center maxwidthsearch">';
617 $searchpicto = $form->showFilterButtons('left');
618 print $searchpicto;
619 print '</td>';
620}
621if (!empty($arrayfields['d.ref']['checked'])) {
622 print '<td class="liste_titre">';
623 print '<input class="flat width100" type="text" name="search_ref" value="'.dolPrintHTMLForAttribute($search_ref).'">';
624 print '</td>';
625}
626// User
627if (!empty($arrayfields['user']['checked'])) {
628 if ($user->hasRight('expensereport', 'readall') || $user->hasRight('expensereport', 'lire_tous')) {
629 print '<td class="liste_titre maxwidthonsmartphone" align="left">';
630 print $form->select_dolusers($search_user, 'search_user', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth200');
631 print '</td>';
632 } else {
633 print '<td class="liste_titre">&nbsp;</td>';
634 }
635}
636// Date start
637if (!empty($arrayfields['d.date_debut']['checked'])) {
638 print '<td class="liste_titre" align="center">';
639 print '<div class="nowrapfordate">';
640 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
641 print '</div>';
642 print '<div class="nowrapfordate">';
643 print $form->selectDate($search_date_startend ? $search_date_startend : -1, 'search_date_startend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
644 print '</div>';
645 print '</td>';
646}
647// Date end
648if (!empty($arrayfields['d.date_fin']['checked'])) {
649 print '<td class="liste_titre" align="center">';
650 print '<div class="nowrapfordate">';
651 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
652 print '</div>';
653 print '<div class="nowrapfordate">';
654 print $form->selectDate($search_date_endend ? $search_date_endend : -1, 'search_date_endend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
655 print '</div>';
656 print '</td>';
657}
658// Date valid
659if (!empty($arrayfields['d.date_valid']['checked'])) {
660 print '<td class="liste_titre" align="center">';
661 //print '<input class="flat" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">';
662 //print $formother->selectyear($year_end,'year_end',1, $min_year, $max_year);
663 print '</td>';
664}
665// Date approve
666if (!empty($arrayfields['d.date_approve']['checked'])) {
667 print '<td class="liste_titre" align="center">';
668 //print '<input class="flat" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">';
669 //print $formother->selectyear($year_end,'year_end',1, $min_year, $max_year);
670 print '</td>';
671}
672// Amount with no tax
673if (!empty($arrayfields['d.total_ht']['checked'])) {
674 print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ht" value="'.$search_amount_ht.'"></td>';
675}
676if (!empty($arrayfields['d.total_vat']['checked'])) {
677 print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_vat" value="'.$search_amount_vat.'"></td>';
678}
679// Amount with all taxes
680if (!empty($arrayfields['d.total_ttc']['checked'])) {
681 print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ttc" value="'.$search_amount_ttc.'"></td>';
682}
683// Extra fields
684include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
685
686// Fields from hook
687$parameters = array('arrayfields' => $arrayfields);
688$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
689print $hookmanager->resPrint;
690// Date creation
691if (!empty($arrayfields['d.date_create']['checked'])) {
692 print '<td class="liste_titre">';
693 print '</td>';
694}
695// Date modification
696if (!empty($arrayfields['d.tms']['checked'])) {
697 print '<td class="liste_titre">';
698 print '</td>';
699}
700// Status
701if (!empty($arrayfields['d.fk_statut']['checked'])) {
702 print '<td class="liste_titre center parentonrightofpage">';
703 print $formexpensereport->selectExpensereportStatus($search_status, 'search_status', 1, 1, 'search_status width100 onrightofpage');
704 print '</td>';
705}
706// Action column
707if (!$conf->main_checkbox_left_column) {
708 print '<td class="liste_titre center maxwidthsearch">';
709 $searchpicto = $form->showFilterButtons();
710 print $searchpicto;
711 print '</td>';
712}
713
714print '</tr>'."\n";
715
716$totalarray = array();
717$totalarray['nbfield'] = 0;
718
719// Fields title label
720// --------------------------------------------------------------------
721print '<tr class="liste_titre">';
722if ($conf->main_checkbox_left_column) {
723 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ');
724 $totalarray['nbfield']++;
725}
726if (!empty($arrayfields['d.ref']['checked'])) {
727 print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "d.ref", "", $param, '', $sortfield, $sortorder);
728 $totalarray['nbfield']++;
729}
730if (!empty($arrayfields['user']['checked'])) {
731 print_liste_field_titre($arrayfields['user']['label'], $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder);
732 $totalarray['nbfield']++;
733}
734if (!empty($arrayfields['d.date_debut']['checked'])) {
735 print_liste_field_titre($arrayfields['d.date_debut']['label'], $_SERVER["PHP_SELF"], "d.date_debut", "", $param, '', $sortfield, $sortorder, 'center ');
736 $totalarray['nbfield']++;
737}
738if (!empty($arrayfields['d.date_fin']['checked'])) {
739 print_liste_field_titre($arrayfields['d.date_fin']['label'], $_SERVER["PHP_SELF"], "d.date_fin", "", $param, '', $sortfield, $sortorder, 'center ');
740 $totalarray['nbfield']++;
741}
742if (!empty($arrayfields['d.date_valid']['checked'])) {
743 print_liste_field_titre($arrayfields['d.date_valid']['label'], $_SERVER["PHP_SELF"], "d.date_valid", "", $param, '', $sortfield, $sortorder, 'center ');
744 $totalarray['nbfield']++;
745}
746if (!empty($arrayfields['d.date_approve']['checked'])) {
747 print_liste_field_titre($arrayfields['d.date_approve']['label'], $_SERVER["PHP_SELF"], "d.date_approve", "", $param, '', $sortfield, $sortorder, 'center ');
748 $totalarray['nbfield']++;
749}
750if (!empty($arrayfields['d.total_ht']['checked'])) {
751 print_liste_field_titre($arrayfields['d.total_ht']['label'], $_SERVER["PHP_SELF"], "d.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
752 $totalarray['nbfield']++;
753}
754if (!empty($arrayfields['d.total_vat']['checked'])) {
755 print_liste_field_titre($arrayfields['d.total_vat']['label'], $_SERVER["PHP_SELF"], "d.total_tva", "", $param, '', $sortfield, $sortorder, 'right ');
756 $totalarray['nbfield']++;
757}
758if (!empty($arrayfields['d.total_ttc']['checked'])) {
759 print_liste_field_titre($arrayfields['d.total_ttc']['label'], $_SERVER["PHP_SELF"], "d.total_ttc", "", $param, '', $sortfield, $sortorder, 'right ');
760 $totalarray['nbfield']++;
761}
762// Extra fields
763include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
764// Hook fields
765$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
766$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
767print $hookmanager->resPrint;
768if (!empty($arrayfields['d.date_create']['checked'])) {
769 print_liste_field_titre($arrayfields['d.date_create']['label'], $_SERVER["PHP_SELF"], "d.date_create", "", $param, '', $sortfield, $sortorder, 'nowraponall center');
770 $totalarray['nbfield']++;
771}
772if (!empty($arrayfields['d.tms']['checked'])) {
773 print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, '', $sortfield, $sortorder, 'nowraponall center');
774 $totalarray['nbfield']++;
775}
776if (!empty($arrayfields['d.fk_statut']['checked'])) {
777 print_liste_field_titre($arrayfields['d.fk_statut']['label'], $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
778 $totalarray['nbfield']++;
779}
780if (!$conf->main_checkbox_left_column) {
781 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
782 $totalarray['nbfield']++;
783}
784print '</tr>'."\n";
785
786
787// Loop on record
788// --------------------------------------------------------------------
789
790$total_total_ht = 0;
791$total_total_ttc = 0;
792$total_total_tva = 0;
793
794$expensereportstatic = new ExpenseReport($db);
795$usertmp = new User($db);
796
797if ($num > 0) {
798 $i = 0;
799 $savnbfield = $totalarray['nbfield'];
800 $totalarray = array();
801 $totalarray['nbfield'] = 0;
802 $totalarray['val'] = array();
803 $totalarray['val']['d.total_ht'] = 0;
804 $totalarray['val']['d.total_tva'] = 0;
805 $totalarray['val']['d.total_ttc'] = 0;
806 $totalarray['totalizable'] = array();
807
808 $imaxinloop = ($limit ? min($num, $limit) : $num);
809 while ($i < $imaxinloop) {
810 $obj = $db->fetch_object($resql);
811 if (empty($obj)) {
812 break; // Should not happen
813 }
814
815 $expensereportstatic->id = $obj->rowid;
816 $expensereportstatic->ref = $obj->ref;
817 $expensereportstatic->status = $obj->status;
818 $expensereportstatic->date_debut = $db->jdate($obj->date_debut);
819 $expensereportstatic->date_fin = $db->jdate($obj->date_fin);
820 $expensereportstatic->date_create = $db->jdate($obj->date_create);
821 $expensereportstatic->date_modif = $db->jdate($obj->date_modif);
822 $expensereportstatic->date_valid = $db->jdate($obj->date_valid);
823 $expensereportstatic->date_approve = $db->jdate($obj->date_approve);
824 $expensereportstatic->note_private = $obj->note_private;
825 $expensereportstatic->note_public = $obj->note_public;
826 $expensereportstatic->fk_user = $obj->id_user;
827
828 $usertmp->id = $obj->id_user;
829 $usertmp->lastname = $obj->lastname;
830 $usertmp->firstname = $obj->firstname;
831 $usertmp->login = $obj->login;
832 $usertmp->statut = $obj->user_status;
833 $usertmp->status = $obj->user_status;
834 $usertmp->photo = $obj->photo;
835 $usertmp->email = $obj->email;
836
837 if ($mode == 'kanban') {
838 if ($i == 0) {
839 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
840 print '<div class="box-flex-container kanban">';
841 }
842 // TODO Use a cache on user
843 $usertmp->fetch($obj->id_user);
844
845 // Output Kanban
846 if ($massactionbutton || $massaction) {
847 $selected = 0;
848
849 print $expensereportstatic->getKanbanView('', array('userauthor' => $usertmp, 'selected' => in_array($expensereportstatic->id, $arrayofselected)));
850 }
851 if ($i == ($imaxinloop - 1)) {
852 print '</div>';
853 print '</td></tr>';
854 }
855 } else {
856 // Show line of result
857 $j = 0;
858 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
859
860 // Action column
861 if ($conf->main_checkbox_left_column) {
862 print '<td class="nowrap center">';
863 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
864 $selected = 0;
865 if (in_array($obj->rowid, $arrayofselected)) {
866 $selected = 1;
867 }
868 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
869 }
870 print '</td>';
871 if (!$i) {
872 $totalarray['nbfield']++;
873 }
874 }
875 // Ref
876 if (!empty($arrayfields['d.ref']['checked'])) {
877 print '<td class="tdoverflowmax150">';
878 print $expensereportstatic->getNomUrl(1);
879 // Warning late icon and note
880 if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay('toapprove')) {
881 print img_warning($langs->trans("Late"));
882 }
883 if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay('topay')) {
884 print img_warning($langs->trans("Late"));
885 }
886 if (!empty($obj->note_private) || !empty($obj->note_public)) {
887 print ' <span class="note">';
888 print '<a href="'.DOL_URL_ROOT.'/expensereport/note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>';
889 print '</span>';
890 }
891 $filename = dol_sanitizeFileName($obj->ref);
892 $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($obj->ref);
893 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
894 print $formfile->getDocumentsLink($expensereportstatic->element, $filename, $filedir);
895 print '</td>';
896 if (!$i) {
897 $totalarray['nbfield']++;
898 }
899 }
900 // User
901 if (!empty($arrayfields['user']['checked'])) {
902 print '<td class="left">';
903 print $usertmp->getNomUrl(-1);
904 print '</td>';
905 if (!$i) {
906 $totalarray['nbfield']++;
907 }
908 }
909 // Start date
910 if (!empty($arrayfields['d.date_debut']['checked'])) {
911 print '<td class="center">'.($obj->date_debut > 0 ? dol_print_date($db->jdate($obj->date_debut), 'day') : '').'</td>';
912 if (!$i) {
913 $totalarray['nbfield']++;
914 }
915 }
916 // End date
917 if (!empty($arrayfields['d.date_fin']['checked'])) {
918 print '<td class="center">'.($obj->date_fin > 0 ? dol_print_date($db->jdate($obj->date_fin), 'day') : '').'</td>';
919 if (!$i) {
920 $totalarray['nbfield']++;
921 }
922 }
923 // Date validation
924 if (!empty($arrayfields['d.date_valid']['checked'])) {
925 print '<td class="center">'.($obj->date_valid > 0 ? dol_print_date($db->jdate($obj->date_valid), 'day') : '').'</td>';
926 if (!$i) {
927 $totalarray['nbfield']++;
928 }
929 }
930 // Date approval
931 if (!empty($arrayfields['d.date_approve']['checked'])) {
932 print '<td class="center">'.($obj->date_approve > 0 ? dol_print_date($db->jdate($obj->date_approve), 'day') : '').'</td>';
933 if (!$i) {
934 $totalarray['nbfield']++;
935 }
936 }
937 // Amount HT
938 if (!empty($arrayfields['d.total_ht']['checked'])) {
939 print '<td class="right">'.price($obj->total_ht)."</td>\n";
940 if (!$i) {
941 $totalarray['nbfield']++;
942 }
943 if (!$i) {
944 $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ht';
945 }
946 $totalarray['val']['d.total_ht'] += $obj->total_ht;
947 }
948 // Amount VAT
949 if (!empty($arrayfields['d.total_vat']['checked'])) {
950 print '<td class="right">'.price($obj->total_tva)."</td>\n";
951 if (!$i) {
952 $totalarray['nbfield']++;
953 }
954 if (!$i) {
955 $totalarray['pos'][$totalarray['nbfield']] = 'd.total_tva';
956 }
957 $totalarray['val']['d.total_tva'] += $obj->total_tva;
958 }
959 // Amount TTC
960 if (!empty($arrayfields['d.total_ttc']['checked'])) {
961 print '<td class="right">'.price($obj->total_ttc)."</td>\n";
962 if (!$i) {
963 $totalarray['nbfield']++;
964 }
965 if (!$i) {
966 $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ttc';
967 }
968 $totalarray['val']['d.total_ttc'] += $obj->total_ttc;
969 }
970
971 // Extra fields
972 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
973 // Fields from hook
974 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
975 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
976 print $hookmanager->resPrint;
977
978 // Date creation
979 if (!empty($arrayfields['d.date_create']['checked'])) {
980 print '<td class="nowrap center">';
981 print dol_print_date($db->jdate($obj->date_create), 'dayhour');
982 print '</td>';
983 if (!$i) {
984 $totalarray['nbfield']++;
985 }
986 }
987 // Date modification
988 if (!empty($arrayfields['d.tms']['checked'])) {
989 print '<td class="nowrap center">';
990 print dol_print_date($db->jdate($obj->date_modif), 'dayhour');
991 print '</td>';
992 if (!$i) {
993 $totalarray['nbfield']++;
994 }
995 }
996 // Status
997 if (!empty($arrayfields['d.fk_statut']['checked'])) {
998 print '<td class="nowrap center">'.$expensereportstatic->getLibStatut(5).'</td>';
999 if (!$i) {
1000 $totalarray['nbfield']++;
1001 }
1002 }
1003 // Action column
1004 if (!$conf->main_checkbox_left_column) {
1005 print '<td class="nowrap center">';
1006 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1007 $selected = 0;
1008 if (in_array($obj->rowid, $arrayofselected)) {
1009 $selected = 1;
1010 }
1011 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1012 }
1013 print '</td>';
1014 if (!$i) {
1015 $totalarray['nbfield']++;
1016 }
1017 }
1018
1019 print '</tr>'."\n";
1020 }
1021
1022 $total_total_ht += $obj->total_ht;
1023 $total_total_tva += $obj->total_tva;
1024 $total_total_ttc += $obj->total_ttc;
1025
1026 $i++;
1027 }
1028}
1029
1030// Show total line
1031include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1032
1033// If no record found
1034if ($num == 0) {
1035 $colspan = 1;
1036 foreach ($arrayfields as $key => $val) {
1037 if (!empty($val['checked'])) {
1038 $colspan++;
1039 }
1040 }
1041 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1042}
1043
1044$db->free($resql);
1045
1046$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1047$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1048print $hookmanager->resPrint;
1049
1050print '</table>'."\n";
1051print '</div>'."\n";
1052
1053print '</form>'."\n";
1054
1055if (empty($id)) {
1056 $hidegeneratedfilelistifempty = 1;
1057 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1058 $hidegeneratedfilelistifempty = 0;
1059 }
1060
1061 // Show list of available documents
1062 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1063 $urlsource .= str_replace('&amp;', '&', $param);
1064
1065 $filedir = $diroutputmassaction;
1066 $genallowed = $user->hasRight('expensereport', 'lire');
1067 $delallowed = $user->hasRight('expensereport', 'creer');
1068
1069 print $formfile->showdocuments('massfilesarea_expensereport', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1070}
1071
1072// End of page
1073llxFooter();
1074$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...
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.
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).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.
Definition html.lib.php:519
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.
Definition html.lib.php:717
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.