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