list.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. <?php
  2. /* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
  4. * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/asset/list.php
  21. * \ingroup asset
  22. * \brief List page for asset
  23. */
  24. // Load Dolibarr environment
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
  30. // Load translation files required by the page
  31. $langs->loadLangs(array("assets"));
  32. $action = GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
  33. $massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists)
  34. $show_files = GETPOST('show_files','int'); // Show files area generated by bulk actions ?
  35. $confirm = GETPOST('confirm','alpha'); // Result of a confirmation
  36. $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
  37. $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
  38. $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'assetslist'; // To manage different context of search
  39. $backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page
  40. $optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print')
  41. $id = GETPOST('id','int');
  42. // Load variable for pagination
  43. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  44. $sortfield = GETPOST('sortfield','alpha');
  45. $sortorder = GETPOST('sortorder','alpha');
  46. $page = GETPOST('page','int');
  47. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  48. $offset = $limit * $page;
  49. $pageprev = $page - 1;
  50. $pagenext = $page + 1;
  51. // Initialize technical objects
  52. $object=new Asset($db);
  53. $extrafields = new ExtraFields($db);
  54. $diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->id;
  55. $hookmanager->initHooks(array('assetlist')); // Note that conf->hooks_modules contains array
  56. // Fetch optionals attributes and labels
  57. $extralabels = $extrafields->fetch_name_optionals_label('asset');
  58. $search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_');
  59. // Default sort order (if not yet defined by previous GETPOST)
  60. if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition.
  61. if (! $sortorder) $sortorder="ASC";
  62. // Protection if external user
  63. $socid=0;
  64. if ($user->societe_id > 0)
  65. {
  66. //$socid = $user->societe_id;
  67. accessforbidden();
  68. }
  69. //$result = restrictedArea($user, 'asset', $id,'');
  70. // Initialize array of search criterias
  71. $search_all=trim(GETPOST("search_all",'alpha'));
  72. $search=array();
  73. foreach($object->fields as $key => $val)
  74. {
  75. if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha');
  76. }
  77. // List of fields to search into when doing a "search in all"
  78. $fieldstosearchall = array();
  79. foreach($object->fields as $key => $val)
  80. {
  81. if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label'];
  82. }
  83. // Definition of fields for list
  84. $arrayfields=array();
  85. foreach($object->fields as $key => $val)
  86. {
  87. // If $val['visible']==0, then we never show the field
  88. if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
  89. }
  90. // Extra fields
  91. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  92. {
  93. foreach($extrafields->attribute_label as $key => $val)
  94. {
  95. if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
  96. }
  97. }
  98. $object->fields = dol_sort_array($object->fields, 'position');
  99. $arrayfields = dol_sort_array($arrayfields, 'position');
  100. /*
  101. * Actions
  102. *
  103. * Put here all code to do according to value of "$action" parameter
  104. */
  105. if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
  106. if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
  107. $parameters=array();
  108. $reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  109. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  110. if (empty($reshook))
  111. {
  112. // Selection of new fields
  113. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  114. // Purge search criteria
  115. 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
  116. {
  117. foreach($object->fields as $key => $val)
  118. {
  119. $search[$key]='';
  120. }
  121. $toselect='';
  122. $search_array_options=array();
  123. }
  124. if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')
  125. || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha'))
  126. {
  127. $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation
  128. }
  129. // Mass actions
  130. $objectclass='Asset';
  131. $objectlabel='Asset';
  132. $permtoread = $user->rights->asset->read;
  133. $permtodelete = $user->rights->asset->delete;
  134. $uploaddir = $conf->asset->dir_output;
  135. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  136. }
  137. /*
  138. * View
  139. *
  140. * Put here all code to render page
  141. */
  142. $form=new Form($db);
  143. $now=dol_now();
  144. //$help_url="EN:Module_Asset|FR:Module_Asset_FR|ES:Módulo_Asset";
  145. $help_url='';
  146. $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Assets"));
  147. // Build and execute select
  148. // --------------------------------------------------------------------
  149. $sql = 'SELECT ';
  150. foreach($object->fields as $key => $val)
  151. {
  152. $sql.='t.'.$key.', ';
  153. }
  154. // Add fields from extrafields
  155. foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
  156. // Add fields from hooks
  157. $parameters=array();
  158. $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
  159. $sql.=$hookmanager->resPrint;
  160. $sql=preg_replace('/, $/','', $sql);
  161. $sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
  162. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."assets_extrafields as ef on (t.rowid = ef.fk_object)";
  163. if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('assets').")";
  164. else $sql.=" WHERE 1 = 1";
  165. foreach($search as $key => $val)
  166. {
  167. $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0);
  168. if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search));
  169. }
  170. if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all);
  171. // Add where from extra fields
  172. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  173. // Add where from hooks
  174. $parameters=array();
  175. $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
  176. $sql.=$hookmanager->resPrint;
  177. /* If a group by is required
  178. $sql.= " GROUP BY "
  179. foreach($object->fields as $key => $val)
  180. {
  181. $sql.='t.'.$key.', ';
  182. }
  183. // Add fields from extrafields
  184. foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : '');
  185. // Add where from hooks
  186. $parameters=array();
  187. $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook
  188. $sql.=$hookmanager->resPrint;
  189. */
  190. $sql.=$db->order($sortfield,$sortorder);
  191. // Count total nb of records
  192. $nbtotalofrecords = '';
  193. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  194. {
  195. $result = $db->query($sql);
  196. $nbtotalofrecords = $db->num_rows($result);
  197. if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
  198. {
  199. $page = 0;
  200. $offset = 0;
  201. }
  202. }
  203. $sql.= $db->plimit($limit+1, $offset);
  204. $resql=$db->query($sql);
  205. if (! $resql)
  206. {
  207. dol_print_error($db);
  208. exit;
  209. }
  210. $num = $db->num_rows($resql);
  211. // Direct jump if only one record found
  212. if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
  213. {
  214. $obj = $db->fetch_object($resql);
  215. $id = $obj->rowid;
  216. header("Location: ".DOL_URL_ROOT.'/assets/card.php?id='.$id);
  217. exit;
  218. }
  219. // Output page
  220. // --------------------------------------------------------------------
  221. llxHeader('', $title, $help_url);
  222. // Example : Adding jquery code
  223. print '<script type="text/javascript" language="javascript">
  224. jQuery(document).ready(function() {
  225. function init_myfunc()
  226. {
  227. jQuery("#myid").removeAttr(\'disabled\');
  228. jQuery("#myid").attr(\'disabled\',\'disabled\');
  229. }
  230. init_myfunc();
  231. jQuery("#mybutton").click(function() {
  232. init_myfunc();
  233. });
  234. });
  235. </script>';
  236. $arrayofselected=is_array($toselect)?$toselect:array();
  237. $param='';
  238. if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
  239. if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
  240. foreach($search as $key => $val)
  241. {
  242. $param.= '&search_'.$key.'='.urlencode($search[$key]);
  243. }
  244. if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
  245. // Add $param from extra fields
  246. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  247. // List of mass actions available
  248. $arrayofmassactions = array(
  249. //'presend'=>$langs->trans("SendByMail"),
  250. //'builddoc'=>$langs->trans("PDFMerge"),
  251. );
  252. if ($user->rights->asset->delete) $arrayofmassactions['predelete']=$langs->trans("Delete");
  253. if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
  254. $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
  255. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  256. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  257. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  258. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  259. print '<input type="hidden" name="action" value="list">';
  260. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  261. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  262. print '<input type="hidden" name="page" value="'.$page.'">';
  263. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  264. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit);
  265. // Add code for pre mass action (confirmation or email presend form)
  266. $topicmail="SendAssetsRef";
  267. $modelmail="asset";
  268. $objecttmp=new Asset($db);
  269. $trackid='xxxx'.$object->id;
  270. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  271. if ($sall)
  272. {
  273. foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
  274. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>';
  275. }
  276. $moreforfilter = '';
  277. /*$moreforfilter.='<div class="divsearchfield">';
  278. $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
  279. $moreforfilter.= '</div>';*/
  280. $parameters=array();
  281. $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
  282. if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
  283. else $moreforfilter = $hookmanager->resPrint;
  284. if (! empty($moreforfilter))
  285. {
  286. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  287. print $moreforfilter;
  288. print '</div>';
  289. }
  290. $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
  291. $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  292. $selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  293. print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  294. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  295. // Fields title search
  296. // --------------------------------------------------------------------
  297. print '<tr class="liste_titre">';
  298. foreach($object->fields as $key => $val)
  299. {
  300. $align='';
  301. if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center';
  302. if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
  303. if ($key == 'status') $align.=($align?' ':'').'center';
  304. if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
  305. }
  306. // Extra fields
  307. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  308. // Fields from hook
  309. $parameters=array('arrayfields'=>$arrayfields);
  310. $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
  311. print $hookmanager->resPrint;
  312. // Action column
  313. print '<td class="liste_titre" align="right">';
  314. $searchpicto=$form->showFilterButtons();
  315. print $searchpicto;
  316. print '</td>';
  317. print '</tr>'."\n";
  318. // Fields title label
  319. // --------------------------------------------------------------------
  320. print '<tr class="liste_titre">';
  321. foreach($object->fields as $key => $val)
  322. {
  323. $align='';
  324. if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center';
  325. if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
  326. if ($key == 'status') $align.=($align?' ':'').'center';
  327. if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
  328. }
  329. // Extra fields
  330. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  331. // Hook fields
  332. $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
  333. $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
  334. print $hookmanager->resPrint;
  335. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],'','','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
  336. print '</tr>'."\n";
  337. // Detect if we need a fetch on each output line
  338. $needToFetchEachLine=0;
  339. foreach ($extrafields->attribute_computed as $key => $val)
  340. {
  341. if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object
  342. }
  343. // Loop on record
  344. // --------------------------------------------------------------------
  345. $i=0;
  346. $totalarray=array();
  347. while ($i < min($num, $limit))
  348. {
  349. $obj = $db->fetch_object($resql);
  350. if (empty($obj)) break; // Should not happen
  351. // Store properties in $object
  352. $object->id = $obj->rowid;
  353. foreach($object->fields as $key => $val)
  354. {
  355. if (isset($obj->$key)) $object->$key = $obj->$key;
  356. }
  357. // Show here line of result
  358. print '<tr class="oddeven">';
  359. foreach($object->fields as $key => $val)
  360. {
  361. $align='';
  362. if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center';
  363. if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
  364. if ($key == 'status') $align.=($align?' ':'').'center';
  365. if (! empty($arrayfields['t.'.$key]['checked']))
  366. {
  367. print '<td';
  368. if ($align) print ' class="'.$align.'"';
  369. print '>';
  370. print $object->showOutputField($val, $key, $obj->$key, '');
  371. print '</td>';
  372. if (! $i) $totalarray['nbfield']++;
  373. if (! empty($val['isameasure']))
  374. {
  375. if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
  376. $totalarray['val']['t.'.$key] += $obj->$key;
  377. }
  378. }
  379. }
  380. // Extra fields
  381. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  382. // Fields from hook
  383. $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
  384. $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
  385. print $hookmanager->resPrint;
  386. // Action column
  387. print '<td class="nowrap" align="center">';
  388. if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  389. {
  390. $selected=0;
  391. if (in_array($obj->rowid, $arrayofselected)) $selected=1;
  392. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
  393. }
  394. print '</td>';
  395. if (! $i) $totalarray['nbfield']++;
  396. print '</tr>';
  397. $i++;
  398. }
  399. // Show total line
  400. if (isset($totalarray['pos']))
  401. {
  402. print '<tr class="liste_total">';
  403. $i=0;
  404. while ($i < $totalarray['nbfield'])
  405. {
  406. $i++;
  407. if (! empty($totalarray['pos'][$i])) print '<td class="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
  408. else
  409. {
  410. if ($i == 1)
  411. {
  412. if ($num < $limit) print '<td class="left">'.$langs->trans("Total").'</td>';
  413. else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>';
  414. }
  415. else print '<td></td>';
  416. }
  417. }
  418. print '</tr>';
  419. }
  420. // If no record found
  421. if ($num == 0)
  422. {
  423. $colspan=1;
  424. foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
  425. print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
  426. }
  427. $db->free($resql);
  428. $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  429. $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
  430. print $hookmanager->resPrint;
  431. print '</table>'."\n";
  432. print '</div>'."\n";
  433. print '</form>'."\n";
  434. if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
  435. {
  436. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
  437. {
  438. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  439. $formfile = new FormFile($db);
  440. // Show list of available documents
  441. $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  442. $urlsource.=str_replace('&amp;','&',$param);
  443. $filedir=$diroutputmassaction;
  444. $genallowed=$user->rights->asset->read;
  445. $delallowed=$user->rights->asset->create;
  446. print $formfile->showdocuments('massfilesarea_asset','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
  447. }
  448. else
  449. {
  450. print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
  451. }
  452. }
  453. // End of page
  454. llxFooter();
  455. $db->close();