list.php 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  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. /**
  26. * \file htdocs/expensereport/list.php
  27. * \ingroup expensereport
  28. * \brief list of expense reports
  29. */
  30. // Load Dolibarr environment
  31. require '../main.inc.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formexpensereport.class.php';
  38. require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
  39. require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_ik.class.php';
  40. // Load translation files required by the page
  41. $langs->loadLangs(array('companies', 'users', 'trips'));
  42. $action = GETPOST('action', 'aZ09');
  43. $massaction = GETPOST('massaction', 'alpha');
  44. $show_files = GETPOST('show_files', 'int');
  45. $confirm = GETPOST('confirm', 'alpha');
  46. $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
  47. $toselect = GETPOST('toselect', 'array');
  48. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'expensereportlist';
  49. $childids = $user->getAllChildIds(1);
  50. // Security check
  51. $socid = GETPOST('socid', 'int');
  52. if ($user->socid) {
  53. $socid = $user->socid;
  54. }
  55. $result = restrictedArea($user, 'expensereport', '', '');
  56. $id = GETPOST('id', 'int');
  57. // If we are on the view of a specific user
  58. if ($id > 0) {
  59. $canread = 0;
  60. if ($id == $user->id) {
  61. $canread = 1;
  62. }
  63. if (!empty($user->rights->expensereport->readall)) {
  64. $canread = 1;
  65. }
  66. if (!empty($user->rights->expensereport->lire) && in_array($id, $childids)) {
  67. $canread = 1;
  68. }
  69. if (!$canread) {
  70. accessforbidden();
  71. }
  72. }
  73. $diroutputmassaction = $conf->expensereport->dir_output.'/temp/massgeneration/'.$user->id;
  74. // Load variable for pagination
  75. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  76. $sortfield = GETPOST('sortfield', 'aZ09comma');
  77. $sortorder = GETPOST('sortorder', 'aZ09comma');
  78. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  79. if (empty($page) || $page == -1) {
  80. $page = 0;
  81. } // If $page is not defined, or '' or -1
  82. $offset = $limit * $page;
  83. $pageprev = $page - 1;
  84. $pagenext = $page + 1;
  85. if (!$sortorder) {
  86. $sortorder = "DESC";
  87. }
  88. if (!$sortfield) {
  89. $sortfield = "d.date_debut";
  90. }
  91. $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
  92. $search_ref = GETPOST('search_ref', 'alpha');
  93. $search_user = GETPOST('search_user', 'int');
  94. $search_amount_ht = GETPOST('search_amount_ht', 'alpha');
  95. $search_amount_vat = GETPOST('search_amount_vat', 'alpha');
  96. $search_amount_ttc = GETPOST('search_amount_ttc', 'alpha');
  97. $search_status = (GETPOST('search_status', 'intcomma') != '' ?GETPOST('search_status', 'intcomma') : GETPOST('statut', 'intcomma'));
  98. $search_date_startday = GETPOST('search_date_startday', 'int');
  99. $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
  100. $search_date_startyear = GETPOST('search_date_startyear', 'int');
  101. $search_date_startendday = GETPOST('search_date_startendday', 'int');
  102. $search_date_startendmonth = GETPOST('search_date_startendmonth', 'int');
  103. $search_date_startendyear = GETPOST('search_date_startendyear', 'int');
  104. $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
  105. $search_date_startend = dol_mktime(23, 59, 59, $search_date_startendmonth, $search_date_startendday, $search_date_startendyear);
  106. $search_date_endday = GETPOST('search_date_endday', 'int');
  107. $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
  108. $search_date_endyear = GETPOST('search_date_endyear', 'int');
  109. $search_date_endendday = GETPOST('search_date_endendday', 'int');
  110. $search_date_endendmonth = GETPOST('search_date_endendmonth', 'int');
  111. $search_date_endendyear = GETPOST('search_date_endendyear', 'int');
  112. $search_date_end = dol_mktime(0, 0, 0, $search_date_endmonth, $search_date_endday, $search_date_endyear); // Use tzserver
  113. $search_date_endend = dol_mktime(23, 59, 59, $search_date_endendmonth, $search_date_endendday, $search_date_endendyear);
  114. $optioncss = GETPOST('optioncss', 'alpha');
  115. if ($search_status == '') {
  116. $search_status = -1;
  117. }
  118. if ($search_user == '') {
  119. $search_user = -1;
  120. }
  121. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  122. $object = new ExpenseReport($db);
  123. $hookmanager->initHooks(array('expensereportlist'));
  124. $extrafields = new ExtraFields($db);
  125. // fetch optionals attributes and labels
  126. $extrafields->fetch_name_optionals_label($object->table_element);
  127. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  128. // List of fields to search into when doing a "search in all"
  129. $fieldstosearchall = array(
  130. 'd.ref'=>'Ref',
  131. 'd.note_public'=>"NotePublic",
  132. 'u.lastname'=>'EmployeeLastname',
  133. 'u.firstname'=>"EmployeeFirstname",
  134. 'u.login'=>"Login",
  135. );
  136. if (empty($user->socid)) {
  137. $fieldstosearchall["d.note_private"] = "NotePrivate";
  138. }
  139. $arrayfields = array(
  140. 'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
  141. 'user'=>array('label'=>$langs->trans("User"), 'checked'=>1),
  142. 'd.date_debut'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1),
  143. 'd.date_fin'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1),
  144. 'd.date_valid'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1),
  145. 'd.date_approve'=>array('label'=>$langs->trans("DateApprove"), 'checked'=>1),
  146. 'd.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
  147. 'd.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1),
  148. 'd.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1),
  149. 'd.date_create'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
  150. 'd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
  151. 'd.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
  152. );
  153. // Extra fields
  154. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  155. $canedituser = (!empty($user->admin) || $user->rights->user->user->creer);
  156. $objectuser = new User($db);
  157. /*
  158. * Actions
  159. */
  160. if (GETPOST('cancel', 'alpha')) {
  161. $action = 'list'; $massaction = '';
  162. }
  163. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  164. $massaction = '';
  165. }
  166. $parameters = array('socid'=>$socid);
  167. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  168. if ($reshook < 0) {
  169. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  170. }
  171. if (empty($reshook)) {
  172. // Selection of new fields
  173. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  174. // Purge search criteria
  175. 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
  176. $search_ref = "";
  177. $search_user = "";
  178. $search_amount_ht = "";
  179. $search_amount_vat = "";
  180. $search_amount_ttc = "";
  181. $search_status = "";
  182. $search_date_startday = '';
  183. $search_date_startmonth = '';
  184. $search_date_startyear = '';
  185. $search_date_startendday = '';
  186. $search_date_startendmonth = '';
  187. $search_date_startendyear = '';
  188. $search_date_start = '';
  189. $search_date_startend = '';
  190. $search_date_endday = '';
  191. $search_date_endmonth = '';
  192. $search_date_endyear = '';
  193. $search_date_endendday = '';
  194. $search_date_endendmonth = '';
  195. $search_date_endendyear = '';
  196. $search_date_end = '';
  197. $search_date_endend = '';
  198. $toselect = array();
  199. $search_array_options = array();
  200. }
  201. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
  202. || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
  203. $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
  204. }
  205. // Mass actions
  206. $objectclass = 'ExpenseReport';
  207. $objectlabel = 'ExpenseReport';
  208. $permissiontoread = $user->rights->expensereport->lire;
  209. $permissiontodelete = $user->rights->expensereport->supprimer;
  210. $uploaddir = $conf->expensereport->dir_output;
  211. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  212. }
  213. /*
  214. * View
  215. */
  216. $form = new Form($db);
  217. $formother = new FormOther($db);
  218. $formfile = new FormFile($db);
  219. $formexpensereport = new FormExpenseReport($db);
  220. $fuser = new User($db);
  221. $title = $langs->trans("TripsAndExpenses");
  222. llxHeader('', $title);
  223. $max_year = 5;
  224. $min_year = 10;
  225. // Get current user id
  226. $user_id = $user->id;
  227. if ($id > 0) {
  228. // Charge utilisateur edite
  229. $fuser->fetch($id, '', '', 1);
  230. $fuser->getrights();
  231. $user_id = $fuser->id;
  232. $search_user = $user_id;
  233. }
  234. $sql = "SELECT d.rowid, d.ref, d.fk_user_author, d.total_ht, d.total_tva, d.total_ttc, d.fk_statut as status,";
  235. $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,";
  236. $sql .= " u.rowid as id_user, u.firstname, u.lastname, u.login, u.email, u.statut, u.photo";
  237. // Add fields from extrafields
  238. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  239. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  240. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  241. }
  242. }
  243. // Add fields from hooks
  244. $parameters = array();
  245. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
  246. $sql .= $hookmanager->resPrint;
  247. $sqlfields = $sql; // $sql fields to remove for count total
  248. $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as d";
  249. if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  250. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)";
  251. }
  252. $sql .= ", ".MAIN_DB_PREFIX."user as u";
  253. $sql .= " WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity('expensereport').")";
  254. // Search all
  255. if (!empty($sall)) {
  256. $sql .= natural_search(array_keys($fieldstosearchall), $sall);
  257. }
  258. // Ref
  259. if (!empty($search_ref)) {
  260. $sql .= natural_search('d.ref', $search_ref);
  261. }
  262. // Date Start
  263. if ($search_date_start) {
  264. $sql .= " AND d.date_debut >= '".$db->idate($search_date_start)."'";
  265. }
  266. if ($search_date_startend) {
  267. $sql .= " AND d.date_debut <= '".$db->idate($search_date_startend)."'";
  268. }
  269. // Date End
  270. if ($search_date_end) {
  271. $sql .= " AND d.date_fin >= '".$db->idate($search_date_end)."'";
  272. }
  273. if ($search_date_endend) {
  274. $sql .= " AND d.date_fin <= '".$db->idate($search_date_endend)."'";
  275. }
  276. if ($search_amount_ht != '') {
  277. $sql .= natural_search('d.total_ht', $search_amount_ht, 1);
  278. }
  279. if ($search_amount_ttc != '') {
  280. $sql .= natural_search('d.total_ttc', $search_amount_ttc, 1);
  281. }
  282. // User
  283. if ($search_user != '' && $search_user >= 0) {
  284. $sql .= " AND u.rowid = '".$db->escape($search_user)."'";
  285. }
  286. // Status
  287. if ($search_status != '' && $search_status >= 0) {
  288. $sql .= " AND d.fk_statut IN (".$db->sanitize($search_status).")";
  289. }
  290. // RESTRICT RIGHTS
  291. if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)
  292. && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) {
  293. $sql .= " AND d.fk_user_author IN (".$db->sanitize(join(',', $childids)).")\n";
  294. }
  295. // Add where from extra fields
  296. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  297. // Add where from hooks
  298. $parameters = array();
  299. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
  300. $sql .= $hookmanager->resPrint;
  301. // Count total nb of records
  302. $nbtotalofrecords = '';
  303. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  304. /* The fast and low memory method to get and count full list converts the sql into a sql count */
  305. $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
  306. $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
  307. $resql = $db->query($sqlforcount);
  308. if ($resql) {
  309. $objforcount = $db->fetch_object($resql);
  310. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  311. } else {
  312. dol_print_error($db);
  313. }
  314. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  315. $page = 0;
  316. $offset = 0;
  317. }
  318. $db->free($resql);
  319. }
  320. // Complete request and execute it with limit
  321. $sql .= $db->order($sortfield, $sortorder);
  322. if ($limit) {
  323. $sql .= $db->plimit($limit + 1, $offset);
  324. }
  325. //print $sql;
  326. $resql = $db->query($sql);
  327. if ($resql) {
  328. $num = $db->num_rows($resql);
  329. $arrayofselected = is_array($toselect) ? $toselect : array();
  330. $param = '';
  331. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  332. $param .= '&contextpage='.urlencode($contextpage);
  333. }
  334. if ($limit > 0 && $limit != $conf->liste_limit) {
  335. $param .= '&limit='.urlencode($limit);
  336. }
  337. if ($sall) {
  338. $param .= "&sall=".urlencode($sall);
  339. }
  340. if ($search_ref) {
  341. $param .= "&search_ref=".urlencode($search_ref);
  342. }
  343. // Start date
  344. if ($search_date_startday) {
  345. $param .= '&search_date_startday='.urlencode($search_date_startday);
  346. }
  347. if ($search_date_startmonth) {
  348. $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
  349. }
  350. if ($search_date_startyear) {
  351. $param .= '&search_date_startyear='.urlencode($search_date_startyear);
  352. }
  353. if ($search_date_startendday) {
  354. $param .= '&search_date_startendday='.urlencode($search_date_startendday);
  355. }
  356. if ($search_date_startendmonth) {
  357. $param .= '&search_date_startendmonth='.urlencode($search_date_startendmonth);
  358. }
  359. if ($search_date_startendyear) {
  360. $param .= '&search_date_startendyear='.urlencode($search_date_startendyear);
  361. }
  362. // End date
  363. if ($search_date_endday) {
  364. $param .= '&search_date_endday='.urlencode($search_date_endday);
  365. }
  366. if ($search_date_endmonth) {
  367. $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
  368. }
  369. if ($search_date_endyear) {
  370. $param .= '&search_date_endyear='.urlencode($search_date_endyear);
  371. }
  372. if ($search_date_endendday) {
  373. $param .= '&search_date_endendday='.urlencode($search_date_endendday);
  374. }
  375. if ($search_date_endendmonth) {
  376. $param .= '&search_date_endendmonth='.urlencode($search_date_endendmonth);
  377. }
  378. if ($search_date_endendyear) {
  379. $param .= '&search_date_endendyear='.urlencode($search_date_endendyear);
  380. }
  381. if ($search_user) {
  382. $param .= "&search_user=".urlencode($search_user);
  383. }
  384. if ($search_amount_ht) {
  385. $param .= "&search_amount_ht=".urlencode($search_amount_ht);
  386. }
  387. if ($search_amount_ttc) {
  388. $param .= "&search_amount_ttc=".urlencode($search_amount_ttc);
  389. }
  390. if ($search_status >= 0) {
  391. $param .= "&search_status=".urlencode($search_status);
  392. }
  393. if ($optioncss != '') {
  394. $param .= '&optioncss='.urlencode($optioncss);
  395. }
  396. // Add $param from extra fields
  397. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  398. // List of mass actions available
  399. $arrayofmassactions = array(
  400. 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  401. 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  402. 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  403. );
  404. if ($user->rights->expensereport->supprimer) {
  405. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  406. }
  407. if (in_array($massaction, array('presend', 'predelete'))) {
  408. $arrayofmassactions = array();
  409. }
  410. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  411. // Lines of title fields
  412. print '<form id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
  413. if ($optioncss != '') {
  414. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  415. }
  416. print '<input type="hidden" name="token" value="'.newToken().'">';
  417. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  418. print '<input type="hidden" name="action" value="'.($action == 'edit' ? 'update' : 'list').'">';
  419. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  420. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  421. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  422. if ($id > 0) {
  423. print '<input type="hidden" name="id" value="'.$id.'">';
  424. }
  425. if ($id > 0) { // For user tab
  426. $title = $langs->trans("User");
  427. $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  428. $head = user_prepare_head($fuser);
  429. print dol_get_fiche_head($head, 'expensereport', $title, -1, 'user');
  430. dol_banner_tab($fuser, 'id', $linkback, $user->rights->user->user->lire || $user->admin);
  431. print dol_get_fiche_end();
  432. if ($action != 'edit') {
  433. print '<div class="tabsAction">';
  434. $childids = $user->getAllChildIds(1);
  435. $canedit = ((in_array($user_id, $childids) && $user->rights->expensereport->creer)
  436. || ($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->expensereport->writeall_advance));
  437. // Buttons for actions
  438. if ($canedit) {
  439. print '<a href="'.DOL_URL_ROOT.'/expensereport/card.php?action=create&fk_user_author='.$fuser->id.'" class="butAction">'.$langs->trans("AddTrip").'</a>';
  440. } else {
  441. print '<a href="#" class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddTrip").'</a>';
  442. }
  443. print '</div>';
  444. } else {
  445. print $form->buttonsSaveCancel("Save", '');
  446. }
  447. } else {
  448. $title = $langs->trans("ListTripsAndExpenses");
  449. $url = DOL_URL_ROOT.'/expensereport/card.php?action=create';
  450. if (!empty($socid)) {
  451. $url .= '&socid='.$socid;
  452. }
  453. $newcardbutton = dolGetButtonTitle($langs->trans('NewTrip'), '', 'fa fa-plus-circle', $url, '', $user->rights->expensereport->creer);
  454. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'trip', 0, $newcardbutton, '', $limit, 0, 0, 1);
  455. }
  456. $topicmail = "SendExpenseReport";
  457. $modelmail = "expensereport";
  458. $objecttmp = new ExpenseReport($db);
  459. $trackid = 'exp'.$object->id;
  460. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  461. if ($sall) {
  462. foreach ($fieldstosearchall as $key => $val) {
  463. $fieldstosearchall[$key] = $langs->trans($val);
  464. }
  465. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
  466. }
  467. $moreforfilter = '';
  468. $parameters = array();
  469. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  470. if (empty($reshook)) {
  471. $moreforfilter .= $hookmanager->resPrint;
  472. } else {
  473. $moreforfilter = $hookmanager->resPrint;
  474. }
  475. if (!empty($moreforfilter)) {
  476. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  477. print $moreforfilter;
  478. print '</div>';
  479. }
  480. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  481. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
  482. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  483. print '<div class="div-table-responsive">';
  484. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  485. // Filters
  486. print '<tr class="liste_titre_filter">';
  487. // Action column
  488. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  489. print '<td class="liste_titre maxwidthsearch">';
  490. $searchpicto = $form->showFilterButtons('left');
  491. print $searchpicto;
  492. print '</td>';
  493. }
  494. if (!empty($arrayfields['d.ref']['checked'])) {
  495. print '<td class="liste_titre" align="left">';
  496. print '<input class="flat" size="15" type="text" name="search_ref" value="'.$search_ref.'">';
  497. print '</td>';
  498. }
  499. // User
  500. if (!empty($arrayfields['user']['checked'])) {
  501. if ($user->rights->expensereport->readall || $user->rights->expensereport->lire_tous) {
  502. print '<td class="liste_titre maxwidthonspartphone" align="left">';
  503. print $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
  504. print '</td>';
  505. } else {
  506. print '<td class="liste_titre">&nbsp;</td>';
  507. }
  508. }
  509. // Date start
  510. if (!empty($arrayfields['d.date_debut']['checked'])) {
  511. print '<td class="liste_titre" align="center">';
  512. print '<div class="nowrap">';
  513. print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  514. print '</div>';
  515. print '<div class="nowrap">';
  516. print $form->selectDate($search_date_startend ? $search_date_startend : -1, 'search_date_startend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  517. print '</div>';
  518. print '</td>';
  519. }
  520. // Date end
  521. if (!empty($arrayfields['d.date_fin']['checked'])) {
  522. print '<td class="liste_titre" align="center">';
  523. print '<div class="nowrap">';
  524. print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  525. print '</div>';
  526. print '<div class="nowrap">';
  527. print $form->selectDate($search_date_endend ? $search_date_endend : -1, 'search_date_endend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  528. print '</div>';
  529. print '</td>';
  530. }
  531. // Date valid
  532. if (!empty($arrayfields['d.date_valid']['checked'])) {
  533. print '<td class="liste_titre" align="center">';
  534. //print '<input class="flat" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">';
  535. //print $formother->selectyear($year_end,'year_end',1, $min_year, $max_year);
  536. print '</td>';
  537. }
  538. // Date approve
  539. if (!empty($arrayfields['d.date_approve']['checked'])) {
  540. print '<td class="liste_titre" align="center">';
  541. //print '<input class="flat" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">';
  542. //print $formother->selectyear($year_end,'year_end',1, $min_year, $max_year);
  543. print '</td>';
  544. }
  545. // Amount with no tax
  546. if (!empty($arrayfields['d.total_ht']['checked'])) {
  547. print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ht" value="'.$search_amount_ht.'"></td>';
  548. }
  549. if (!empty($arrayfields['d.total_vat']['checked'])) {
  550. print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_vat" value="'.$search_amount_vat.'"></td>';
  551. }
  552. // Amount with all taxes
  553. if (!empty($arrayfields['d.total_ttc']['checked'])) {
  554. print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ttc" value="'.$search_amount_ttc.'"></td>';
  555. }
  556. // Extra fields
  557. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  558. // Fields from hook
  559. $parameters = array('arrayfields'=>$arrayfields);
  560. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  561. print $hookmanager->resPrint;
  562. // Date creation
  563. if (!empty($arrayfields['d.date_create']['checked'])) {
  564. print '<td class="liste_titre">';
  565. print '</td>';
  566. }
  567. // Date modification
  568. if (!empty($arrayfields['d.tms']['checked'])) {
  569. print '<td class="liste_titre">';
  570. print '</td>';
  571. }
  572. // Status
  573. if (!empty($arrayfields['d.fk_statut']['checked'])) {
  574. print '<td class="liste_titre right">';
  575. $formexpensereport->selectExpensereportStatus($search_status, 'search_status', 1, 1);
  576. print '</td>';
  577. }
  578. // Action column
  579. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  580. print '<td class="liste_titre maxwidthsearch">';
  581. $searchpicto = $form->showFilterButtons();
  582. print $searchpicto;
  583. print '</td>';
  584. }
  585. print "</tr>\n";
  586. print '<tr class="liste_titre">';
  587. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  588. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
  589. }
  590. if (!empty($arrayfields['d.ref']['checked'])) {
  591. print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "d.ref", "", $param, '', $sortfield, $sortorder);
  592. }
  593. if (!empty($arrayfields['user']['checked'])) {
  594. print_liste_field_titre($arrayfields['user']['label'], $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder);
  595. }
  596. if (!empty($arrayfields['d.date_debut']['checked'])) {
  597. print_liste_field_titre($arrayfields['d.date_debut']['label'], $_SERVER["PHP_SELF"], "d.date_debut", "", $param, 'align="center"', $sortfield, $sortorder);
  598. }
  599. if (!empty($arrayfields['d.date_fin']['checked'])) {
  600. print_liste_field_titre($arrayfields['d.date_fin']['label'], $_SERVER["PHP_SELF"], "d.date_fin", "", $param, 'align="center"', $sortfield, $sortorder);
  601. }
  602. if (!empty($arrayfields['d.date_valid']['checked'])) {
  603. print_liste_field_titre($arrayfields['d.date_valid']['label'], $_SERVER["PHP_SELF"], "d.date_valid", "", $param, 'align="center"', $sortfield, $sortorder);
  604. }
  605. if (!empty($arrayfields['d.date_approve']['checked'])) {
  606. print_liste_field_titre($arrayfields['d.date_approve']['label'], $_SERVER["PHP_SELF"], "d.date_approve", "", $param, 'align="center"', $sortfield, $sortorder);
  607. }
  608. if (!empty($arrayfields['d.total_ht']['checked'])) {
  609. print_liste_field_titre($arrayfields['d.total_ht']['label'], $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
  610. }
  611. if (!empty($arrayfields['d.total_vat']['checked'])) {
  612. print_liste_field_titre($arrayfields['d.total_vat']['label'], $_SERVER["PHP_SELF"], "d.total_tva", "", $param, 'align="right"', $sortfield, $sortorder);
  613. }
  614. if (!empty($arrayfields['d.total_ttc']['checked'])) {
  615. print_liste_field_titre($arrayfields['d.total_ttc']['label'], $_SERVER["PHP_SELF"], "d.total_ttc", "", $param, 'align="right"', $sortfield, $sortorder);
  616. }
  617. // Extra fields
  618. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  619. // Hook fields
  620. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  621. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  622. print $hookmanager->resPrint;
  623. if (!empty($arrayfields['d.date_create']['checked'])) {
  624. print_liste_field_titre($arrayfields['d.date_create']['label'], $_SERVER["PHP_SELF"], "d.date_create", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
  625. }
  626. if (!empty($arrayfields['d.tms']['checked'])) {
  627. print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
  628. }
  629. if (!empty($arrayfields['d.fk_statut']['checked'])) {
  630. print_liste_field_titre($arrayfields['d.fk_statut']['label'], $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, 'align="right"', $sortfield, $sortorder);
  631. }
  632. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  633. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
  634. }
  635. print "</tr>\n";
  636. $total_total_ht = 0;
  637. $total_total_ttc = 0;
  638. $total_total_tva = 0;
  639. $expensereportstatic = new ExpenseReport($db);
  640. $usertmp = new User($db);
  641. if ($num > 0) {
  642. $i = 0;
  643. $totalarray = array();
  644. $totalarray['nbfield'] = 0;
  645. $totalarray['val'] = array();
  646. $totalarray['val']['d.total_ht'] = 0;
  647. $totalarray['val']['d.total_tva'] = 0;
  648. $totalarray['val']['d.total_ttc'] = 0;
  649. $totalarray['totalizable'] = array();
  650. while ($i < min($num, $limit)) {
  651. $obj = $db->fetch_object($resql);
  652. $expensereportstatic->id = $obj->rowid;
  653. $expensereportstatic->ref = $obj->ref;
  654. $expensereportstatic->status = $obj->status;
  655. $expensereportstatic->date_debut = $db->jdate($obj->date_debut);
  656. $expensereportstatic->date_fin = $db->jdate($obj->date_fin);
  657. $expensereportstatic->date_create = $db->jdate($obj->date_create);
  658. $expensereportstatic->date_modif = $db->jdate($obj->date_modif);
  659. $expensereportstatic->date_valid = $db->jdate($obj->date_valid);
  660. $expensereportstatic->date_approve = $db->jdate($obj->date_approve);
  661. $expensereportstatic->note_private = $obj->note_private;
  662. $expensereportstatic->note_public = $obj->note_public;
  663. print '<tr class="oddeven">';
  664. // Action column
  665. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  666. print '<td class="nowrap center">';
  667. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  668. $selected = 0;
  669. if (in_array($obj->rowid, $arrayofselected)) {
  670. $selected = 1;
  671. }
  672. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  673. }
  674. print '</td>';
  675. }
  676. // Ref
  677. if (!empty($arrayfields['d.ref']['checked'])) {
  678. print '<td>';
  679. print '<table class="nobordernopadding"><tr class="nocellnopadd">';
  680. print '<td class="nobordernopadding nowrap">';
  681. print $expensereportstatic->getNomUrl(1);
  682. print '</td>';
  683. // Warning late icon and note
  684. print '<td class="nobordernopadding nowrap">';
  685. if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay('toappove')) {
  686. print img_warning($langs->trans("Late"));
  687. }
  688. if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay('topay')) {
  689. print img_warning($langs->trans("Late"));
  690. }
  691. if (!empty($obj->note_private) || !empty($obj->note_public)) {
  692. print ' <span class="note">';
  693. print '<a href="'.DOL_URL_ROOT.'/expensereport/note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>';
  694. print '</span>';
  695. }
  696. print '</td>';
  697. print '<td width="16" class="nobordernopadding hideonsmartphone right">';
  698. $filename = dol_sanitizeFileName($obj->ref);
  699. $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($obj->ref);
  700. $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
  701. print $formfile->getDocumentsLink($expensereportstatic->element, $filename, $filedir);
  702. print '</td>';
  703. print '</tr></table>';
  704. print '</td>';
  705. if (!$i) {
  706. $totalarray['nbfield']++;
  707. }
  708. }
  709. // User
  710. if (!empty($arrayfields['user']['checked'])) {
  711. print '<td class="left">';
  712. $usertmp->id = $obj->id_user;
  713. $usertmp->lastname = $obj->lastname;
  714. $usertmp->firstname = $obj->firstname;
  715. $usertmp->login = $obj->login;
  716. $usertmp->statut = $obj->statut;
  717. $usertmp->photo = $obj->photo;
  718. $usertmp->email = $obj->email;
  719. print $usertmp->getNomUrl(-1);
  720. print '</td>';
  721. if (!$i) {
  722. $totalarray['nbfield']++;
  723. }
  724. }
  725. // Start date
  726. if (!empty($arrayfields['d.date_debut']['checked'])) {
  727. print '<td class="center">'.($obj->date_debut > 0 ? dol_print_date($db->jdate($obj->date_debut), 'day') : '').'</td>';
  728. if (!$i) {
  729. $totalarray['nbfield']++;
  730. }
  731. }
  732. // End date
  733. if (!empty($arrayfields['d.date_fin']['checked'])) {
  734. print '<td class="center">'.($obj->date_fin > 0 ? dol_print_date($db->jdate($obj->date_fin), 'day') : '').'</td>';
  735. if (!$i) {
  736. $totalarray['nbfield']++;
  737. }
  738. }
  739. // Date validation
  740. if (!empty($arrayfields['d.date_valid']['checked'])) {
  741. print '<td class="center">'.($obj->date_valid > 0 ? dol_print_date($db->jdate($obj->date_valid), 'day') : '').'</td>';
  742. if (!$i) {
  743. $totalarray['nbfield']++;
  744. }
  745. }
  746. // Date approval
  747. if (!empty($arrayfields['d.date_approve']['checked'])) {
  748. print '<td class="center">'.($obj->date_approve > 0 ? dol_print_date($db->jdate($obj->date_approve), 'day') : '').'</td>';
  749. if (!$i) {
  750. $totalarray['nbfield']++;
  751. }
  752. }
  753. // Amount HT
  754. if (!empty($arrayfields['d.total_ht']['checked'])) {
  755. print '<td class="right">'.price($obj->total_ht)."</td>\n";
  756. if (!$i) {
  757. $totalarray['nbfield']++;
  758. }
  759. if (!$i) {
  760. $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ht';
  761. }
  762. $totalarray['val']['d.total_ht'] += $obj->total_ht;
  763. }
  764. // Amount VAT
  765. if (!empty($arrayfields['d.total_vat']['checked'])) {
  766. print '<td class="right">'.price($obj->total_tva)."</td>\n";
  767. if (!$i) {
  768. $totalarray['nbfield']++;
  769. }
  770. if (!$i) {
  771. $totalarray['pos'][$totalarray['nbfield']] = 'd.total_tva';
  772. }
  773. $totalarray['val']['d.total_tva'] += $obj->total_tva;
  774. }
  775. // Amount TTC
  776. if (!empty($arrayfields['d.total_ttc']['checked'])) {
  777. print '<td class="right">'.price($obj->total_ttc)."</td>\n";
  778. if (!$i) {
  779. $totalarray['nbfield']++;
  780. }
  781. if (!$i) {
  782. $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ttc';
  783. }
  784. $totalarray['val']['d.total_ttc'] += $obj->total_ttc;
  785. }
  786. // Extra fields
  787. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  788. // Fields from hook
  789. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  790. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  791. print $hookmanager->resPrint;
  792. // Date creation
  793. if (!empty($arrayfields['d.date_create']['checked'])) {
  794. print '<td class="nowrap center">';
  795. print dol_print_date($db->jdate($obj->date_create), 'dayhour');
  796. print '</td>';
  797. if (!$i) {
  798. $totalarray['nbfield']++;
  799. }
  800. }
  801. // Date modification
  802. if (!empty($arrayfields['d.tms']['checked'])) {
  803. print '<td class="nowrap center">';
  804. print dol_print_date($db->jdate($obj->date_modif), 'dayhour');
  805. print '</td>';
  806. if (!$i) {
  807. $totalarray['nbfield']++;
  808. }
  809. }
  810. // Status
  811. if (!empty($arrayfields['d.fk_statut']['checked'])) {
  812. print '<td class="nowrap right">'.$expensereportstatic->getLibStatut(5).'</td>';
  813. if (!$i) {
  814. $totalarray['nbfield']++;
  815. }
  816. }
  817. // Action column
  818. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  819. print '<td class="nowrap center">';
  820. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  821. $selected = 0;
  822. if (in_array($obj->rowid, $arrayofselected)) {
  823. $selected = 1;
  824. }
  825. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  826. }
  827. print '</td>';
  828. }
  829. if (!$i) {
  830. $totalarray['nbfield']++;
  831. }
  832. print "</tr>\n";
  833. $total_total_ht = $total_total_ht + $obj->total_ht;
  834. $total_total_tva = $total_total_tva + $obj->total_tva;
  835. $total_total_ttc = $total_total_ttc + $obj->total_ttc;
  836. $i++;
  837. }
  838. } else {
  839. $colspan = 1;
  840. foreach ($arrayfields as $key => $val) {
  841. if (!empty($val['checked'])) {
  842. $colspan++;
  843. }
  844. }
  845. print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
  846. }
  847. // Show total line
  848. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  849. $db->free($resql);
  850. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  851. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
  852. print $hookmanager->resPrint;
  853. print '</table>'."\n";
  854. print '</div>';
  855. print '</form>'."\n";
  856. if (empty($id)) {
  857. $hidegeneratedfilelistifempty = 1;
  858. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
  859. $hidegeneratedfilelistifempty = 0;
  860. }
  861. // Show list of available documents
  862. $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  863. $urlsource .= str_replace('&amp;', '&', $param);
  864. $filedir = $diroutputmassaction;
  865. $genallowed = $user->rights->expensereport->lire;
  866. $delallowed = $user->rights->expensereport->creer;
  867. print $formfile->showdocuments('massfilesarea_expensereport', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
  868. }
  869. } else {
  870. dol_print_error($db);
  871. }
  872. // End of page
  873. llxFooter();
  874. $db->close();