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