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