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