dolibarr  13.0.2
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 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 require '../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formexpensereport.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
40 require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_ik.class.php';
41 
42 // Load translation files required by the page
43 $langs->loadLangs(array('companies', 'users', 'trips'));
44 
45 $action = GETPOST('action', 'aZ09');
46 $massaction = GETPOST('massaction', 'alpha');
47 $show_files = GETPOST('show_files', 'int');
48 $confirm = GETPOST('confirm', 'alpha');
49 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
50 $toselect = GETPOST('toselect', 'array');
51 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'expensereportlist';
52 
53 $childids = $user->getAllChildIds(1);
54 
55 // Security check
56 $socid = GETPOST('socid', 'int');
57 if ($user->socid) $socid = $user->socid;
58 $result = restrictedArea($user, 'expensereport', '', '');
59 $id = GETPOST('id', 'int');
60 // If we are on the view of a specific user
61 if ($id > 0)
62 {
63  $canread = 0;
64  if ($id == $user->id) $canread = 1;
65  if (!empty($user->rights->expensereport->readall)) $canread = 1;
66  if (!empty($user->rights->expensereport->lire) && in_array($id, $childids)) $canread = 1;
67  if (!$canread)
68  {
70  }
71 }
72 
73 $diroutputmassaction = $conf->expensereport->dir_output.'/temp/massgeneration/'.$user->id;
74 
75 
76 // Load variable for pagination
77 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
78 $sortfield = GETPOST('sortfield', 'aZ09comma');
79 $sortorder = GETPOST('sortorder', 'aZ09comma');
80 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
81 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
82 $offset = $limit * $page;
83 $pageprev = $page - 1;
84 $pagenext = $page + 1;
85 if (!$sortorder) $sortorder = "DESC";
86 if (!$sortfield) $sortfield = "d.date_debut";
87 
88 
89 $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
90 $search_ref = GETPOST('search_ref', 'alpha');
91 $search_user = GETPOST('search_user', 'int');
92 $search_amount_ht = GETPOST('search_amount_ht', 'alpha');
93 $search_amount_vat = GETPOST('search_amount_vat', 'alpha');
94 $search_amount_ttc = GETPOST('search_amount_ttc', 'alpha');
95 $search_status = (GETPOST('search_status', 'intcomma') != '' ?GETPOST('search_status', 'intcomma') : GETPOST('statut', 'intcomma'));
96 $month_start = GETPOST("month_start", "int");
97 $year_start = GETPOST("year_start", "int");
98 $day_start = GETPOST("day_start", "int");
99 $day_end = GETPOST("day_end", "int");
100 $month_end = GETPOST("month_end", "int");
101 $year_end = GETPOST("year_end", "int");
102 $optioncss = GETPOST('optioncss', 'alpha');
103 
104 if ($search_status == '') $search_status = -1;
105 if ($search_user == '') $search_user = -1;
106 
107 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
108 $object = new ExpenseReport($db);
109 $hookmanager->initHooks(array('expensereportlist'));
110 $extrafields = new ExtraFields($db);
111 
112 // fetch optionals attributes and labels
113 $extrafields->fetch_name_optionals_label($object->table_element);
114 
115 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
116 
117 
118 // List of fields to search into when doing a "search in all"
119 $fieldstosearchall = array(
120  'd.ref'=>'Ref',
121  'd.note_public'=>"NotePublic",
122  'u.lastname'=>'Lastname',
123  'u.firstname'=>"Firstname",
124  'u.login'=>"Login",
125 );
126 if (empty($user->socid)) $fieldstosearchall["d.note_private"] = "NotePrivate";
127 
128 $arrayfields = array(
129  'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
130  'user'=>array('label'=>$langs->trans("User"), 'checked'=>1),
131  'd.date_debut'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1),
132  'd.date_fin'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1),
133  'd.date_valid'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1),
134  'd.date_approve'=>array('label'=>$langs->trans("DateApprove"), 'checked'=>1),
135  'd.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
136  'd.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1),
137  'd.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1),
138  'd.date_create'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
139  'd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
140  'd.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
141 );
142 // Extra fields
143 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
144 
145 $canedituser = (!empty($user->admin) || $user->rights->user->user->creer);
146 
147 $objectuser = new User($db);
148 
149 
150 /*
151  * Actions
152  */
153 
154 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
155 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
156 
157 $parameters = array('socid'=>$socid);
158 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
159 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
160 
161 if (empty($reshook))
162 {
163  // Selection of new fields
164  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
165 
166  // Purge search criteria
167  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
168  {
169  $search_ref = "";
170  $search_user = "";
171  $search_amount_ht = "";
172  $search_amount_vat = "";
173  $search_amount_ttc = "";
174  $search_status = "";
175  $month_start = "";
176  $year_start = "";
177  $month_end = "";
178  $year_end = "";
179  $day_end = "";
180  $toselect = '';
181  $search_array_options = array();
182  }
183  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
184  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
185  {
186  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
187  }
188 
189  // Mass actions
190  $objectclass = 'ExpenseReport';
191  $objectlabel = 'ExpenseReport';
192  $permissiontoread = $user->rights->expensereport->lire;
193  $permissiontodelete = $user->rights->expensereport->supprimer;
194  $uploaddir = $conf->expensereport->dir_output;
195  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
196 }
197 
198 
199 /*
200  * View
201  */
202 
203 $form = new Form($db);
204 $formother = new FormOther($db);
205 $formfile = new FormFile($db);
206 $formexpensereport = new FormExpenseReport($db);
207 
208 $fuser = new User($db);
209 
210 $title = $langs->trans("ListOfTrips");
211 llxHeader('', $title);
212 
213 $max_year = 5;
214 $min_year = 10;
215 
216 // Get current user id
217 $user_id = $user->id;
218 
219 if ($id > 0)
220 {
221  // Charge utilisateur edite
222  $fuser->fetch($id, '', '', 1);
223  $fuser->getrights();
224  $user_id = $fuser->id;
225 
226  $search_user = $user_id;
227 }
228 
229 $sql = "SELECT d.rowid, d.ref, d.fk_user_author, d.total_ht, d.total_tva, d.total_ttc, d.fk_statut as status,";
230 $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,";
231 $sql .= " u.rowid as id_user, u.firstname, u.lastname, u.login, u.email, u.statut, u.photo";
232 // Add fields from extrafields
233 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
234  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
235 }
236 // Add fields from hooks
237 $parameters = array();
238 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
239 $sql .= $hookmanager->resPrint;
240 $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as d";
241 if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)";
242 $sql .= ", ".MAIN_DB_PREFIX."user as u";
243 $sql .= " WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity('expensereport').")";
244 // Search all
245 if (!empty($sall)) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
246 // Ref
247 if (!empty($search_ref)) $sql .= natural_search('d.ref', $search_ref);
248 // Date Start
249 $sql .= dolSqlDateFilter("d.date_debut", $day_start, $month_start, $year_start);
250 // Date End
251 $sql .= dolSqlDateFilter("d.date_fin", $day_end, $month_end, $year_end);
252 
253 if ($search_amount_ht != '') $sql .= natural_search('d.total_ht', $search_amount_ht, 1);
254 if ($search_amount_ttc != '') $sql .= natural_search('d.total_ttc', $search_amount_ttc, 1);
255 // User
256 if ($search_user != '' && $search_user >= 0) $sql .= " AND u.rowid = '".$db->escape($search_user)."'";
257 // Status
258 if ($search_status != '' && $search_status >= 0) $sql .= " AND d.fk_statut IN (".$db->sanitize($db->escape($search_status)).")";
259 // RESTRICT RIGHTS
260 if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)
261  && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance)))
262 {
263  $sql .= " AND d.fk_user_author IN (".join(',', $childids).")\n";
264 }
265 // Add where from extra fields
266 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
267 // Add where from hooks
268 $parameters = array();
269 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
270 $sql .= $hookmanager->resPrint;
271 
272 $sql .= $db->order($sortfield, $sortorder);
273 
274 // Count total nb of records
275 $nbtotalofrecords = '';
276 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
277 {
278  $result = $db->query($sql);
279  $nbtotalofrecords = $db->num_rows($result);
280  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
281  {
282  $page = 0;
283  $offset = 0;
284  }
285 }
286 
287 $sql .= $db->plimit($limit + 1, $offset);
288 
289 //print $sql;
290 $resql = $db->query($sql);
291 if ($resql)
292 {
293  $num = $db->num_rows($resql);
294 
295  $arrayofselected = is_array($toselect) ? $toselect : array();
296 
297  $param = '';
298  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
299  if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
300  if ($sall) $param .= "&sall=".urlencode($sall);
301  if ($search_ref) $param .= "&search_ref=".urlencode($search_ref);
302  if ($search_user) $param .= "&search_user=".urlencode($search_user);
303  if ($search_amount_ht) $param .= "&search_amount_ht=".urlencode($search_amount_ht);
304  if ($search_amount_ttc) $param .= "&search_amount_ttc=".urlencode($search_amount_ttc);
305  if ($search_status >= 0) $param .= "&search_status=".urlencode($search_status);
306  if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
307  // Add $param from extra fields
308  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
309 
310  // List of mass actions available
311  $arrayofmassactions = array(
312  'generate_doc'=>$langs->trans("ReGeneratePDF"),
313  'builddoc'=>$langs->trans("PDFMerge"),
314  'presend'=>$langs->trans("SendByMail"),
315  );
316  if ($user->rights->expensereport->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
317  if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
318  $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
319 
320  // Lines of title fields
321  print '<form id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
322  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
323  print '<input type="hidden" name="token" value="'.newToken().'">';
324  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
325  print '<input type="hidden" name="action" value="'.($action == 'edit' ? 'update' : 'list').'">';
326  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
327  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
328  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
329  if ($id > 0) print '<input type="hidden" name="id" value="'.$id.'">';
330 
331  if ($id > 0) // For user tab
332  {
333  $title = $langs->trans("User");
334  $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
335  $head = user_prepare_head($fuser);
336 
337  print dol_get_fiche_head($head, 'expensereport', $title, -1, 'user');
338 
339  dol_banner_tab($fuser, 'id', $linkback, $user->rights->user->user->lire || $user->admin);
340 
342 
343  if ($action != 'edit')
344  {
345  print '<div class="tabsAction">';
346 
347  $childids = $user->getAllChildIds(1);
348 
349  $canedit = ((in_array($user_id, $childids) && $user->rights->expensereport->creer)
350  || ($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->expensereport->writeall_advance));
351 
352  // Buttons for actions
353  if ($canedit) {
354  print '<a href="'.DOL_URL_ROOT.'/expensereport/card.php?action=create&fk_user_author='.$fuser->id.'" class="butAction">'.$langs->trans("AddTrip").'</a>';
355  } else {
356  print '<a href="#" class="butActionRefused" title="'.$langs->trans("NotEnoughPermission").'">'.$langs->trans("AddTrip").'</a>';
357  }
358 
359  print '</div>';
360  } else {
361  print '<div class="center">';
362  print '<input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">';
363  print '</div><br>';
364  }
365  } else {
366  $title = $langs->trans("ListTripsAndExpenses");
367 
368  $url = DOL_URL_ROOT.'/expensereport/card.php?action=create';
369  if (!empty($socid)) $url .= '&socid='.$socid;
370  $newcardbutton = dolGetButtonTitle($langs->trans('NewTrip'), '', 'fa fa-plus-circle', $url, '', $user->rights->expensereport->creer);
371 
372  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'trip', 0, $newcardbutton, '', $limit, 0, 0, 1);
373  }
374 
375  $topicmail = "SendExpenseReport";
376  $modelmail = "expensereport";
377  $objecttmp = new ExpenseReport($db);
378  $trackid = 'exp'.$object->id;
379  include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
380 
381  if ($sall)
382  {
383  foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
384  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
385  }
386 
387  $moreforfilter = '';
388 
389  $parameters = array();
390  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
391  if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
392  else $moreforfilter = $hookmanager->resPrint;
393 
394  if (!empty($moreforfilter))
395  {
396  print '<div class="liste_titre liste_titre_bydiv centpercent">';
397  print $moreforfilter;
398  print '</div>';
399  }
400 
401  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
402  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
403  $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
404 
405  print '<div class="div-table-responsive">';
406  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
407 
408  // Filters
409  print '<tr class="liste_titre_filter">';
410  if (!empty($arrayfields['d.ref']['checked']))
411  {
412  print '<td class="liste_titre" align="left">';
413  print '<input class="flat" size="15" type="text" name="search_ref" value="'.$search_ref.'">';
414  print '</td>';
415  }
416  // User
417  if (!empty($arrayfields['user']['checked']))
418  {
419  if ($user->rights->expensereport->readall || $user->rights->expensereport->lire_tous)
420  {
421  print '<td class="liste_titre maxwidthonspartphone" align="left">';
422  print $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
423  print '</td>';
424  } else {
425  print '<td class="liste_titre">&nbsp;</td>';
426  }
427  }
428  // Date start
429  if (!empty($arrayfields['d.date_debut']['checked']))
430  {
431  print '<td class="liste_titre" align="center">';
432  if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
433  print '<input class="flat width25" type="text" maxlength="2" name="day_start" value="'.dol_escape_htmltag($day_start).'">';
434  }
435 
436  print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="month_start" value="'.$month_start.'">';
437  $formother->select_year($year_start, 'year_start', 1, $min_year, $max_year);
438  print '</td>';
439  }
440  // Date end
441  if (!empty($arrayfields['d.date_fin']['checked']))
442  {
443  print '<td class="liste_titre" align="center">';
444  if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
445  print '<input class="flat width25" type="text" maxlength="2" name="day_end" value="'.dol_escape_htmltag($day_end).'">';
446  }
447  print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">';
448  $formother->select_year($year_end, 'year_end', 1, $min_year, $max_year);
449  print '</td>';
450  }
451  // Date valid
452  if (!empty($arrayfields['d.date_valid']['checked']))
453  {
454  print '<td class="liste_titre" align="center">';
455  //print '<input class="flat" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">';
456  //$formother->select_year($year_end,'year_end',1, $min_year, $max_year);
457  print '</td>';
458  }
459  // Date approve
460  if (!empty($arrayfields['d.date_approve']['checked']))
461  {
462  print '<td class="liste_titre" align="center">';
463  //print '<input class="flat" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">';
464  //$formother->select_year($year_end,'year_end',1, $min_year, $max_year);
465  print '</td>';
466  }
467  // Amount with no tax
468  if (!empty($arrayfields['d.total_ht']['checked']))
469  {
470  print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ht" value="'.$search_amount_ht.'"></td>';
471  }
472  if (!empty($arrayfields['d.total_vat']['checked']))
473  {
474  print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_vat" value="'.$search_amount_vat.'"></td>';
475  }
476  // Amount with all taxes
477  if (!empty($arrayfields['d.total_ttc']['checked']))
478  {
479  print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ttc" value="'.$search_amount_ttc.'"></td>';
480  }
481  // Extra fields
482  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
483 
484  // Fields from hook
485  $parameters = array('arrayfields'=>$arrayfields);
486  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
487  print $hookmanager->resPrint;
488  // Date creation
489  if (!empty($arrayfields['d.date_create']['checked']))
490  {
491  print '<td class="liste_titre">';
492  print '</td>';
493  }
494  // Date modification
495  if (!empty($arrayfields['d.tms']['checked']))
496  {
497  print '<td class="liste_titre">';
498  print '</td>';
499  }
500  // Status
501  if (!empty($arrayfields['d.fk_statut']['checked']))
502  {
503  print '<td class="liste_titre right">';
504  $formexpensereport->selectExpensereportStatus($search_status, 'search_status', 1, 1);
505  print '</td>';
506  }
507  // Action column
508  print '<td class="liste_titre maxwidthsearch">';
509  $searchpicto = $form->showFilterButtons();
510  print $searchpicto;
511  print '</td>';
512 
513  print "</tr>\n";
514 
515  print '<tr class="liste_titre">';
516  if (!empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "d.ref", "", $param, '', $sortfield, $sortorder);
517  if (!empty($arrayfields['user']['checked'])) print_liste_field_titre($arrayfields['user']['label'], $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder);
518  if (!empty($arrayfields['d.date_debut']['checked'])) print_liste_field_titre($arrayfields['d.date_debut']['label'], $_SERVER["PHP_SELF"], "d.date_debut", "", $param, 'align="center"', $sortfield, $sortorder);
519  if (!empty($arrayfields['d.date_fin']['checked'])) print_liste_field_titre($arrayfields['d.date_fin']['label'], $_SERVER["PHP_SELF"], "d.date_fin", "", $param, 'align="center"', $sortfield, $sortorder);
520  if (!empty($arrayfields['d.date_valid']['checked'])) print_liste_field_titre($arrayfields['d.date_valid']['label'], $_SERVER["PHP_SELF"], "d.date_valid", "", $param, 'align="center"', $sortfield, $sortorder);
521  if (!empty($arrayfields['d.date_approve']['checked'])) print_liste_field_titre($arrayfields['d.date_approve']['label'], $_SERVER["PHP_SELF"], "d.date_approve", "", $param, 'align="center"', $sortfield, $sortorder);
522  if (!empty($arrayfields['d.total_ht']['checked'])) print_liste_field_titre($arrayfields['d.total_ht']['label'], $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
523  if (!empty($arrayfields['d.total_vat']['checked'])) print_liste_field_titre($arrayfields['d.total_vat']['label'], $_SERVER["PHP_SELF"], "d.total_tva", "", $param, 'align="right"', $sortfield, $sortorder);
524  if (!empty($arrayfields['d.total_ttc']['checked'])) print_liste_field_titre($arrayfields['d.total_ttc']['label'], $_SERVER["PHP_SELF"], "d.total_ttc", "", $param, 'align="right"', $sortfield, $sortorder);
525  // Extra fields
526  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
527  // Hook fields
528  $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
529  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
530  print $hookmanager->resPrint;
531  if (!empty($arrayfields['d.date_create']['checked'])) print_liste_field_titre($arrayfields['d.date_create']['label'], $_SERVER["PHP_SELF"], "d.date_create", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
532  if (!empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
533  if (!empty($arrayfields['d.fk_statut']['checked'])) print_liste_field_titre($arrayfields['d.fk_statut']['label'], $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, 'align="right"', $sortfield, $sortorder);
534  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
535  print "</tr>\n";
536 
537  $total_total_ht = 0;
538  $total_total_ttc = 0;
539  $total_total_tva = 0;
540 
541  $expensereportstatic = new ExpenseReport($db);
542  $usertmp = new User($db);
543 
544  if ($num > 0)
545  {
546  $i = 0;
547  $totalarray = array();
548  while ($i < min($num, $limit))
549  {
550  $obj = $db->fetch_object($resql);
551 
552  $expensereportstatic->id = $obj->rowid;
553  $expensereportstatic->ref = $obj->ref;
554  $expensereportstatic->status = $obj->status;
555  $expensereportstatic->date_debut = $db->jdate($obj->date_debut);
556  $expensereportstatic->date_fin = $db->jdate($obj->date_fin);
557  $expensereportstatic->date_create = $db->jdate($obj->date_create);
558  $expensereportstatic->date_modif = $db->jdate($obj->date_modif);
559  $expensereportstatic->date_valid = $db->jdate($obj->date_valid);
560  $expensereportstatic->date_approve = $db->jdate($obj->date_approve);
561  $expensereportstatic->note_private = $obj->note_private;
562  $expensereportstatic->note_public = $obj->note_public;
563 
564 
565  print '<tr class="oddeven">';
566  // Ref
567  if (!empty($arrayfields['d.ref']['checked'])) {
568  print '<td>';
569  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
570  print '<td class="nobordernopadding nowrap">';
571  print $expensereportstatic->getNomUrl(1);
572  print '</td>';
573  // Warning late icon and note
574  print '<td class="nobordernopadding nowrap">';
575  if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay('toappove')) print img_warning($langs->trans("Late"));
576  if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay('topay')) print img_warning($langs->trans("Late"));
577  if (!empty($obj->note_private) || !empty($obj->note_public))
578  {
579  print ' <span class="note">';
580  print '<a href="'.DOL_URL_ROOT.'/expensereport/note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>';
581  print '</span>';
582  }
583  print '</td>';
584  print '<td width="16" class="nobordernopadding hideonsmartphone right">';
585  $filename = dol_sanitizeFileName($obj->ref);
586  $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($obj->ref);
587  $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
588  print $formfile->getDocumentsLink($expensereportstatic->element, $filename, $filedir);
589  print '</td>';
590  print '</tr></table>';
591  print '</td>';
592  if (!$i) $totalarray['nbfield']++;
593  }
594  // User
595  if (!empty($arrayfields['user']['checked'])) {
596  print '<td class="left">';
597  $usertmp->id = $obj->id_user;
598  $usertmp->lastname = $obj->lastname;
599  $usertmp->firstname = $obj->firstname;
600  $usertmp->login = $obj->login;
601  $usertmp->statut = $obj->statut;
602  $usertmp->photo = $obj->photo;
603  $usertmp->email = $obj->email;
604  print $usertmp->getNomUrl(-1);
605  print '</td>';
606  if (!$i) $totalarray['nbfield']++;
607  }
608  // Start date
609  if (!empty($arrayfields['d.date_debut']['checked'])) {
610  print '<td class="center">'.($obj->date_debut > 0 ? dol_print_date($db->jdate($obj->date_debut), 'day') : '').'</td>';
611  if (!$i) $totalarray['nbfield']++;
612  }
613  // End date
614  if (!empty($arrayfields['d.date_fin']['checked'])) {
615  print '<td class="center">'.($obj->date_fin > 0 ? dol_print_date($db->jdate($obj->date_fin), 'day') : '').'</td>';
616  if (!$i) $totalarray['nbfield']++;
617  }
618  // Date validation
619  if (!empty($arrayfields['d.date_valid']['checked'])) {
620  print '<td class="center">'.($obj->date_valid > 0 ? dol_print_date($db->jdate($obj->date_valid), 'day') : '').'</td>';
621  if (!$i) $totalarray['nbfield']++;
622  }
623  // Date approval
624  if (!empty($arrayfields['d.date_approve']['checked'])) {
625  print '<td class="center">'.($obj->date_approve > 0 ? dol_print_date($db->jdate($obj->date_approve), 'day') : '').'</td>';
626  if (!$i) $totalarray['nbfield']++;
627  }
628  // Amount HT
629  if (!empty($arrayfields['d.total_ht']['checked']))
630  {
631  print '<td class="right">'.price($obj->total_ht)."</td>\n";
632  if (!$i) $totalarray['nbfield']++;
633  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ht';
634  $totalarray['val']['d.total_ht'] += $obj->total_ht;
635  }
636  // Amount VAT
637  if (!empty($arrayfields['d.total_vat']['checked']))
638  {
639  print '<td class="right">'.price($obj->total_tva)."</td>\n";
640  if (!$i) $totalarray['nbfield']++;
641  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'd.total_tva';
642  $totalarray['val']['d.total_tva'] += $obj->total_tva;
643  }
644  // Amount TTC
645  if (!empty($arrayfields['d.total_ttc']['checked']))
646  {
647  print '<td class="right">'.price($obj->total_ttc)."</td>\n";
648  if (!$i) $totalarray['nbfield']++;
649  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ttc';
650  $totalarray['val']['d.total_ttc'] += $obj->total_ttc;
651  }
652 
653  // Extra fields
654  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
655  // Fields from hook
656  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
657  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
658  print $hookmanager->resPrint;
659 
660  // Date creation
661  if (!empty($arrayfields['d.date_create']['checked']))
662  {
663  print '<td class="nowrap center">';
664  print dol_print_date($db->jdate($obj->date_create), 'dayhour');
665  print '</td>';
666  if (!$i) $totalarray['nbfield']++;
667  }
668  // Date modification
669  if (!empty($arrayfields['d.tms']['checked']))
670  {
671  print '<td class="nowrap center">';
672  print dol_print_date($db->jdate($obj->date_modif), 'dayhour');
673  print '</td>';
674  if (!$i) $totalarray['nbfield']++;
675  }
676  // Status
677  if (!empty($arrayfields['d.fk_statut']['checked']))
678  {
679  print '<td class="nowrap right">'.$expensereportstatic->getLibStatut(5).'</td>';
680  if (!$i) $totalarray['nbfield']++;
681  }
682  // Action column
683  print '<td class="nowrap center">';
684  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
685  {
686  $selected = 0;
687  if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
688  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
689  }
690  print '</td>';
691  if (!$i) $totalarray['nbfield']++;
692 
693  print "</tr>\n";
694 
695  $total_total_ht = $total_total_ht + $obj->total_ht;
696  $total_total_tva = $total_total_tva + $obj->total_tva;
697  $total_total_ttc = $total_total_ttc + $obj->total_ttc;
698 
699  $i++;
700  }
701  } else {
702  $colspan = 1;
703  foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
704  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
705  }
706 
707  // Show total line
708  include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
709 
710  $db->free($resql);
711 
712  $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
713  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
714  print $hookmanager->resPrint;
715 
716  print '</table>'."\n";
717  print '</div>';
718 
719  print '</form>'."\n";
720 
721  if (empty($id))
722  {
723  $hidegeneratedfilelistifempty = 1;
724  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
725 
726  // Show list of available documents
727  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
728  $urlsource .= str_replace('&amp;', '&', $param);
729 
730  $filedir = $diroutputmassaction;
731  $genallowed = $user->rights->expensereport->lire;
732  $delallowed = $user->rights->expensereport->creer;
733 
734  print $formfile->showdocuments('massfilesarea_expensereport', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
735  }
736 } else {
737  dol_print_error($db);
738 }
739 
740 // End of page
741 llxFooter();
742 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage generation of HTML components for contract module.
user_prepare_head($object)
Prepare array with list of tabs.
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.
Class to manage Dolibarr users.
Definition: user.class.php:44
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $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.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
Classe permettant la generation de composants html autre Only common components are here...
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=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 Calling this function terminate execution ...
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...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0)
Generate a SQL string to make a filter into a range (for second of date until last second of date) ...
Definition: date.lib.php:281
Class to manage Trips and Expenses.
Class to offer components to list and upload files.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
llxFooter()
Empty footer.
Definition: wrapper.php:59