list.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  1. <?php
  2. /* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
  3. * Copyright (C) 2022 Open-Dsi <support@open-dsi.fr>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/variants/list.php
  20. * \ingroup variants
  21. * \brief List page for product attribute
  22. */
  23. // Load Dolibarr environment
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php';
  27. // Load translation files required by the page
  28. $langs->loadLangs(array("products", "other"));
  29. $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
  30. $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
  31. $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
  32. $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
  33. $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
  34. $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
  35. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
  36. $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
  37. $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
  38. $mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
  39. $id = GETPOST('id', 'int');
  40. // Load variable for pagination
  41. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  42. $sortfield = GETPOST('sortfield', 'aZ09comma');
  43. $sortorder = GETPOST('sortorder', 'aZ09comma');
  44. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  45. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  46. // If $page is not defined, or '' or -1 or if we click on clear filters
  47. $page = 0;
  48. }
  49. $offset = $limit * $page;
  50. $pageprev = $page - 1;
  51. $pagenext = $page + 1;
  52. // Initialize technical objects
  53. $object = new ProductAttribute($db);
  54. //$extrafields = new ExtraFields($db);
  55. $diroutputmassaction = $conf->variants->dir_output.'/temp/massgeneration/'.$user->id;
  56. $hookmanager->initHooks(array('productattributelist')); // Note that conf->hooks_modules contains array
  57. // Fetch optionals attributes and labels
  58. //$extrafields->fetch_name_optionals_label($object->table_element);
  59. //$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  60. // Default sort order (if not yet defined by previous GETPOST)
  61. if (!$sortfield) {
  62. $sortfield = "t.position"; // Set here default search field. By default 1st field in definition.
  63. }
  64. if (!$sortorder) {
  65. $sortorder = "ASC";
  66. }
  67. // Initialize array of search criterias
  68. $search_all = GETPOST('search_all', 'alphanohtml');
  69. $search = array();
  70. foreach ($object->fields as $key => $val) {
  71. if (GETPOST('search_'.$key, 'alpha') !== '') {
  72. $search[$key] = GETPOST('search_'.$key, 'alpha');
  73. }
  74. if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  75. $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
  76. $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
  77. }
  78. }
  79. $search['nb_of_values'] = GETPOST('search_nb_of_values', 'alpha');
  80. $search['nb_products'] = GETPOST('search_nb_products', 'alpha');
  81. // List of fields to search into when doing a "search in all"
  82. $fieldstosearchall = array();
  83. foreach ($object->fields as $key => $val) {
  84. if (!empty($val['searchall'])) {
  85. $fieldstosearchall['t.'.$key] = $val['label'];
  86. }
  87. }
  88. $parameters = array('fieldstosearchall'=>$fieldstosearchall);
  89. $reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  90. if ($reshook > 0) {
  91. $fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall'];
  92. } elseif ($reshook == 0) {
  93. $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']);
  94. }
  95. // Definition of array of fields for columns
  96. $arrayfields = array();
  97. foreach ($object->fields as $key => $val) {
  98. // If $val['visible']==0, then we never show the field
  99. if (!empty($val['visible'])) {
  100. $visible = (int) dol_eval($val['visible'], 1);
  101. $arrayfields['t.'.$key] = array(
  102. 'label'=>$val['label'],
  103. 'checked'=>(($visible < 0) ? 0 : 1),
  104. 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)),
  105. 'position'=>$val['position'],
  106. 'help'=> isset($val['help']) ? $val['help'] : ''
  107. );
  108. }
  109. }
  110. $arrayfields['nb_of_values'] = array(
  111. 'label' => $langs->trans('NbOfDifferentValues'),
  112. 'checked' => 1,
  113. 'enabled' => 1,
  114. 'position' => 40,
  115. 'help' => ''
  116. );
  117. $arrayfields['nb_products'] = array(
  118. 'label' => $langs->trans('NbProducts'),
  119. 'checked' => 1,
  120. 'enabled' => 1,
  121. 'position' => 50,
  122. 'help' => ''
  123. );
  124. // Extra fields
  125. //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  126. $object->fields = dol_sort_array($object->fields, 'position');
  127. $arrayfields = dol_sort_array($arrayfields, 'position');
  128. $permissiontoread = $user->hasRight('variants', 'read');
  129. $permissiontoadd = $user->hasRight('variants', 'write');
  130. $permissiontodelete = $user->hasRight('variants', 'delete');
  131. // Security check
  132. if (!isModEnabled('variants')) {
  133. accessforbidden('Module not enabled');
  134. }
  135. $socid = 0;
  136. if ($user->socid > 0) { // Protection if external user
  137. //$socid = $user->socid;
  138. accessforbidden();
  139. }
  140. if (!$permissiontoread) {
  141. accessforbidden();
  142. }
  143. /*
  144. * Actions
  145. */
  146. if (GETPOST('cancel', 'alpha')) {
  147. $action = 'list';
  148. $massaction = '';
  149. }
  150. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  151. $massaction = '';
  152. }
  153. $parameters = array();
  154. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  155. if ($reshook < 0) {
  156. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  157. }
  158. if (empty($reshook)) {
  159. // Selection of new fields
  160. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  161. // Purge search criteria
  162. 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
  163. foreach ($object->fields as $key => $val) {
  164. $search[$key] = '';
  165. if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  166. $search[$key.'_dtstart'] = '';
  167. $search[$key.'_dtend'] = '';
  168. }
  169. }
  170. $search['nb_of_values'] = '';
  171. $search['nb_products'] = '';
  172. $toselect = array();
  173. $search_array_options = array();
  174. }
  175. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
  176. || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
  177. $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
  178. }
  179. if ($action == 'up' && $permissiontoadd) {
  180. $object->attributeMoveUp($rowid);
  181. header('Location: '.$_SERVER['PHP_SELF']);
  182. exit();
  183. } elseif ($action == 'down' && $permissiontoadd) {
  184. $object->attributeMoveDown($rowid);
  185. header('Location: '.$_SERVER['PHP_SELF']);
  186. exit();
  187. }
  188. // Mass actions
  189. $objectclass = 'ProductAttribute';
  190. $objectlabel = 'ProductAttribute';
  191. $uploaddir = $conf->variants->dir_output;
  192. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  193. }
  194. /*
  195. * View
  196. */
  197. $form = new Form($db);
  198. $now = dol_now();
  199. $help_url = '';
  200. $title = $langs->trans("ProductAttributes");
  201. $morejs = array();
  202. $morecss = array();
  203. // Build and execute select
  204. // --------------------------------------------------------------------
  205. $sql = "SELECT COUNT(DISTINCT pav.rowid) AS nb_of_values, COUNT(DISTINCT pac2v.fk_prod_combination) AS nb_products, ";
  206. $sql .= $object->getFieldList("t");
  207. // Add fields from extrafields
  208. //if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  209. // foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  210. // $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.", " : "");
  211. // }
  212. //}
  213. // Add fields from hooks
  214. $parameters = array();
  215. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  216. $sql .= $hookmanager->resPrint;
  217. $sql = preg_replace('/,\s*$/', '', $sql);
  218. $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
  219. //if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  220. // $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
  221. //}
  222. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination2val AS pac2v ON pac2v.fk_prod_attr = t.rowid";
  223. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_value AS pav ON pav.fk_product_attribute = t.rowid";
  224. // Add table from hooks
  225. $parameters = array();
  226. $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  227. $sql .= $hookmanager->resPrint;
  228. if ($object->ismultientitymanaged == 1) {
  229. $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
  230. } else {
  231. $sql .= " WHERE 1 = 1";
  232. }
  233. foreach ($search as $key => $val) {
  234. if (array_key_exists($key, $object->fields)) {
  235. if ($key == 'status' && $search[$key] == -1) {
  236. continue;
  237. }
  238. $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
  239. if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
  240. if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
  241. $search[$key] = '';
  242. }
  243. $mode_search = 2;
  244. }
  245. if ($search[$key] != '') {
  246. $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
  247. }
  248. } else {
  249. if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
  250. $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
  251. if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
  252. if (preg_match('/_dtstart$/', $key)) {
  253. $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'";
  254. }
  255. if (preg_match('/_dtend$/', $key)) {
  256. $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'";
  257. }
  258. }
  259. }
  260. }
  261. }
  262. if ($search_all) {
  263. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  264. }
  265. //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
  266. // Add where from extra fields
  267. //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  268. // Add where from hooks
  269. $parameters = array();
  270. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  271. $sql .= $hookmanager->resPrint;
  272. $hasgroupby = true;
  273. $sql .= " GROUP BY ";
  274. foreach ($object->fields as $key => $val) {
  275. $sql .= "t." . $key . ", ";
  276. }
  277. // Add fields from extrafields
  278. //if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  279. // foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  280. // $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
  281. // }
  282. //}
  283. // Add where from hooks
  284. $parameters = array();
  285. $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
  286. $sql .= $hookmanager->resPrint;
  287. $sql = preg_replace("/,\s*$/", "", $sql);
  288. $sql .= " HAVING 1=1";
  289. if ($search['nb_of_values'] != '') {
  290. $sql .= natural_search("nb_of_values", $search['nb_of_values'], 1);
  291. }
  292. if ($search['nb_products'] != '') {
  293. $sql .= natural_search("nb_products", $search['nb_products'], 1);
  294. }
  295. // Add HAVING from hooks
  296. $parameters = array();
  297. $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook
  298. $sql .= empty($hookmanager->resPrint) ? "" : " ".$hookmanager->resPrint;
  299. // Count total nb of records
  300. $nbtotalofrecords = '';
  301. if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
  302. /* This old and fast method to get and count full list returns all record so use a high amount of memory.
  303. $resql = $db->query($sql);
  304. $nbtotalofrecords = $db->num_rows($resql);
  305. */
  306. /* The slow method does not consume memory on mysql (not tested on pgsql) */
  307. /*$resql = $db->query($sql, 0, 'auto', 1);
  308. while ($db->fetch_object($resql)) {
  309. $nbtotalofrecords++;
  310. }*/
  311. /* The fast and low memory method to get and count full list converts the sql into a sql count */
  312. $sqlforcount = preg_replace("/^SELECT[a-z0-9\._\s\(\),]+FROM/i", "SELECT COUNT(*) as nbtotalofrecords FROM", $sql);
  313. $resql = $db->query($sqlforcount);
  314. if ($resql) {
  315. if ($hasgroupby) {
  316. $nbtotalofrecords = $db->num_rows($resql);
  317. } else {
  318. $objforcount = $db->fetch_object($resql);
  319. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  320. }
  321. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
  322. $page = 0;
  323. $offset = 0;
  324. }
  325. $db->free($resql);
  326. }
  327. }
  328. // Complete request and execute it with limit
  329. $sql .= $db->order($sortfield, $sortorder);
  330. if ($limit) {
  331. $sql .= $db->plimit($limit + 1, $offset);
  332. }
  333. $resql = $db->query($sql);
  334. if (!$resql) {
  335. dol_print_error($db);
  336. exit;
  337. }
  338. $num = $db->num_rows($resql);
  339. // Direct jump if only one record found
  340. if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
  341. $obj = $db->fetch_object($resql);
  342. $id = $obj->rowid;
  343. header("Location: " . dol_buildpath('/variants/card.php', 2) . '?id=' . $id);
  344. exit;
  345. }
  346. // Output page
  347. // --------------------------------------------------------------------
  348. llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
  349. $arrayofselected = is_array($toselect) ? $toselect : array();
  350. $param = '';
  351. if (!empty($mode)) {
  352. $param .= '&mode='.urlencode($mode);
  353. }
  354. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  355. $param .= '&contextpage='.urlencode($contextpage);
  356. }
  357. if ($limit > 0 && $limit != $conf->liste_limit) {
  358. $param .= '&limit='.((int) $limit);
  359. }
  360. foreach ($search as $key => $val) {
  361. if (is_array($search[$key])) {
  362. foreach ($search[$key] as $skey) {
  363. if ($skey != '') {
  364. $param .= '&search_'.$key.'[]='.urlencode($skey);
  365. }
  366. }
  367. } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
  368. $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int'));
  369. $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int'));
  370. $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int'));
  371. } elseif ($search[$key] != '') {
  372. $param .= '&search_'.$key.'='.urlencode($search[$key]);
  373. }
  374. }
  375. if ($optioncss != '') {
  376. $param .= '&optioncss='.urlencode($optioncss);
  377. }
  378. // Add $param from extra fields
  379. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  380. // Add $param from hooks
  381. $parameters = array();
  382. $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  383. $param .= $hookmanager->resPrint;
  384. // List of mass actions available
  385. $arrayofmassactions = array(
  386. //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
  387. //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  388. //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  389. //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  390. );
  391. if (!empty($permissiontodelete)) {
  392. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  393. }
  394. if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
  395. $arrayofmassactions = array();
  396. }
  397. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  398. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
  399. if ($optioncss != '') {
  400. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  401. }
  402. print '<input type="hidden" name="token" value="'.newToken().'">';
  403. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  404. print '<input type="hidden" name="action" value="list">';
  405. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  406. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  407. print '<input type="hidden" name="page" value="'.$page.'">';
  408. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  409. print '<input type="hidden" name="page_y" value="">';
  410. print '<input type="hidden" name="mode" value="'.$mode.'">';
  411. $newcardbutton = '';
  412. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
  413. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
  414. $newcardbutton .= dolGetButtonTitleSeparator();
  415. $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/variants/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
  416. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
  417. // Add code for pre mass action (confirmation or email presend form)
  418. $topicmail = "SendProductAttributeRef";
  419. $modelmail = "productattribute";
  420. $objecttmp = new ProductAttribute($db);
  421. $trackid = 'pa'.$object->id;
  422. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  423. if ($search_all) {
  424. $setupstring = '';
  425. foreach ($fieldstosearchall as $key => $val) {
  426. $fieldstosearchall[$key] = $langs->trans($val);
  427. $setupstring .= $key."=".$val.";";
  428. }
  429. print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
  430. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'."\n";
  431. }
  432. $moreforfilter = '';
  433. /*$moreforfilter.='<div class="divsearchfield">';
  434. $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
  435. $moreforfilter.= '</div>';*/
  436. $parameters = array();
  437. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  438. if (empty($reshook)) {
  439. $moreforfilter .= $hookmanager->resPrint;
  440. } else {
  441. $moreforfilter = $hookmanager->resPrint;
  442. }
  443. if (!empty($moreforfilter)) {
  444. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  445. print $moreforfilter;
  446. $parameters = array();
  447. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  448. print $hookmanager->resPrint;
  449. print '</div>';
  450. }
  451. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  452. $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
  453. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  454. print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  455. print '<table id="tableattributes" class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  456. // Fields title search
  457. // --------------------------------------------------------------------
  458. print '<tr class="liste_titre_filter">';
  459. // Action column
  460. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  461. print '<td class="liste_titre center maxwidthsearch">';
  462. $searchpicto = $form->showFilterButtons('left');
  463. print $searchpicto;
  464. print '</td>';
  465. }
  466. foreach ($object->fields as $key => $val) {
  467. $searchkey = empty($search[$key]) ? '' : $search[$key];
  468. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  469. if ($key == 'status') {
  470. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  471. } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  472. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  473. } elseif (in_array($val['type'], array('timestamp'))) {
  474. $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
  475. } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
  476. $cssforfield .= ($cssforfield ? ' ' : '').'right';
  477. }
  478. if (!empty($arrayfields['t.'.$key]['checked'])) {
  479. print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
  480. if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
  481. print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
  482. } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
  483. print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
  484. } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  485. print '<div class="nowrap">';
  486. print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  487. print '</div>';
  488. print '<div class="nowrap">';
  489. print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  490. print '</div>';
  491. } elseif ($key == 'lang') {
  492. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
  493. $formadmin = new FormAdmin($db);
  494. print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
  495. } else {
  496. print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
  497. }
  498. print '</td>';
  499. }
  500. }
  501. // Extra fields
  502. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  503. // Fields from hook
  504. $parameters = array('arrayfields'=>$arrayfields);
  505. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  506. print $hookmanager->resPrint;
  507. $key = 'nb_of_values';
  508. if (!empty($arrayfields[$key]['checked'])) {
  509. print '<td class="liste_titre center">';
  510. print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
  511. print '</td>';
  512. }
  513. $key = 'nb_products';
  514. if (!empty($arrayfields[$key]['checked'])) {
  515. print '<td class="liste_titre center">';
  516. print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
  517. print '</td>';
  518. }
  519. // Action column
  520. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  521. print '<td class="liste_titre center maxwidthsearch">';
  522. $searchpicto = $form->showFilterButtons();
  523. print $searchpicto;
  524. print '</td>';
  525. }
  526. // Move
  527. print '<td class="liste_titre linecolmove width25"></td>';
  528. print '</tr>'."\n";
  529. $totalarray = array();
  530. $totalarray['nbfield'] = 0;
  531. // Fields title label
  532. // --------------------------------------------------------------------
  533. print '<tr class="liste_titre">';
  534. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  535. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  536. $totalarray['nbfield']++;
  537. }
  538. foreach ($object->fields as $key => $val) {
  539. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  540. if ($key == 'status') {
  541. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  542. } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  543. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  544. } elseif (in_array($val['type'], array('timestamp'))) {
  545. $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
  546. } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
  547. $cssforfield .= ($cssforfield ? ' ' : '').'right';
  548. }
  549. $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
  550. if (!empty($arrayfields['t.'.$key]['checked'])) {
  551. print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), 0, (empty($val['helplist']) ? '' : $val['helplist']))."\n";
  552. $totalarray['nbfield']++;
  553. }
  554. }
  555. // Extra fields
  556. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  557. // Hook fields
  558. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
  559. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  560. print $hookmanager->resPrint;
  561. $key = 'nb_of_values';
  562. if (!empty($arrayfields[$key]['checked'])) {
  563. print getTitleFieldOfList($arrayfields[$key]['label'], 0, $_SERVER['PHP_SELF'], $key, '', $param, 'class="center"', $sortfield, $sortorder, 'center ')."\n";
  564. }
  565. $key = 'nb_products';
  566. if (!empty($arrayfields[$key]['checked'])) {
  567. print getTitleFieldOfList($arrayfields[$key]['label'], 0, $_SERVER['PHP_SELF'], $key, '', $param, 'class="center"', $sortfield, $sortorder, 'center ')."\n";
  568. }
  569. // Action column
  570. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  571. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  572. $totalarray['nbfield']++;
  573. }
  574. // Move
  575. print getTitleFieldOfList('', 0, '', '', '', '', '', '', '', 'linecolmove ')."\n";
  576. print '</tr>'."\n";
  577. // Detect if we need a fetch on each output line
  578. $needToFetchEachLine = 0;
  579. //if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
  580. // foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
  581. // if (!is_null($val) && preg_match('/\$object/', $val)) {
  582. // $needToFetchEachLine++; // There is at least one compute field that use $object
  583. // }
  584. // }
  585. //}
  586. // Loop on record
  587. // --------------------------------------------------------------------
  588. $i = 0;
  589. $savnbfield = $totalarray['nbfield'];
  590. $totalarray = array();
  591. $totalarray['nbfield'] = 0;
  592. $imaxinloop = ($limit ? min($num, $limit) : $num);
  593. while ($i < $imaxinloop) {
  594. $obj = $db->fetch_object($resql);
  595. if (empty($obj)) {
  596. break; // Should not happen
  597. }
  598. // Store properties in $object
  599. $object->setVarsFromFetchObj($obj);
  600. if ($mode == 'kanban') {
  601. if ($i == 0) {
  602. print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
  603. print '<div class="box-flex-container kanban">';
  604. }
  605. // Output Kanban
  606. $selected = -1;
  607. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  608. $selected = 0;
  609. if (in_array($object->id, $arrayofselected)) {
  610. $selected = 1;
  611. }
  612. }
  613. print $object->getKanbanView('', array('selected' => $selected));
  614. if ($i == ($imaxinloop - 1)) {
  615. print '</div>';
  616. print '</td></tr>';
  617. }
  618. } else {
  619. // Show here line of result
  620. $j = 0;
  621. print '<tr data-rowid="'.$object->id.'" class="oddeven">';
  622. // Action column
  623. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  624. print '<td class="nowrap center">';
  625. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  626. $selected = 0;
  627. if (in_array($object->id, $arrayofselected)) {
  628. $selected = 1;
  629. }
  630. print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
  631. }
  632. print '</td>';
  633. if (!$i) {
  634. $totalarray['nbfield']++;
  635. }
  636. }
  637. foreach ($object->fields as $key => $val) {
  638. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  639. if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  640. $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
  641. } elseif ($key == 'status') {
  642. $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
  643. }
  644. if (in_array($val['type'], array('timestamp'))) {
  645. $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
  646. } elseif ($key == 'ref') {
  647. $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
  648. }
  649. if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
  650. $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
  651. }
  652. //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
  653. if (!empty($arrayfields['t.' . $key]['checked'])) {
  654. print '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
  655. if (preg_match('/tdoverflow/', $cssforfield) && !is_numeric($object->$key)) {
  656. print ' title="'.dol_escape_htmltag($object->$key).'"';
  657. }
  658. print '>';
  659. if ($key == 'status') {
  660. print $object->getLibStatut(5);
  661. } elseif ($key == 'rowid') {
  662. print $object->showOutputField($val, $key, $object->id, '');
  663. } else {
  664. print $object->showOutputField($val, $key, $object->$key, '');
  665. }
  666. print '</td>';
  667. if (!$i) {
  668. $totalarray['nbfield']++;
  669. }
  670. if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
  671. if (!$i) {
  672. $totalarray['pos'][$totalarray['nbfield']] = 't.' . $key;
  673. }
  674. if (!isset($totalarray['val'])) {
  675. $totalarray['val'] = array();
  676. }
  677. if (!isset($totalarray['val']['t.' . $key])) {
  678. $totalarray['val']['t.' . $key] = 0;
  679. }
  680. $totalarray['val']['t.' . $key] += $object->$key;
  681. }
  682. }
  683. }
  684. // Extra fields
  685. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  686. // Fields from hook
  687. $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  688. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  689. print $hookmanager->resPrint;
  690. // Other
  691. $key = 'nb_of_values';
  692. if (!empty($arrayfields[$key]['checked'])) {
  693. print '<td class="center">';
  694. print $obj->$key;
  695. print '</td>';
  696. if (!$i) {
  697. $totalarray['nbfield']++;
  698. }
  699. }
  700. $key = 'nb_products';
  701. if (!empty($arrayfields[$key]['checked'])) {
  702. print '<td class="center">';
  703. print $obj->$key;
  704. print '</td>';
  705. if (!$i) {
  706. $totalarray['nbfield']++;
  707. }
  708. }
  709. // Action column
  710. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  711. print '<td class="nowrap center">';
  712. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  713. $selected = 0;
  714. if (in_array($object->id, $arrayofselected)) {
  715. $selected = 1;
  716. }
  717. print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
  718. }
  719. print '</td>';
  720. if (!$i) {
  721. $totalarray['nbfield']++;
  722. }
  723. }
  724. // Move
  725. print '<td class="center linecolmove tdlineupdown">';
  726. if ($i > 0) {
  727. print '<a class="lineupdown" href="' . $_SERVER['PHP_SELF'] . '?action=up&amp;rowid=' . $obj->rowid . '">' . img_up('default', 0, 'imgupforline') . '</a>';
  728. }
  729. if ($i < $num - 1) {
  730. print '<a class="lineupdown" href="' . $_SERVER['PHP_SELF'] . '?action=down&amp;rowid=' . $obj->rowid . '">' . img_down('default', 0, 'imgdownforline') . '</a>';
  731. }
  732. print '</td>';
  733. print '</tr>' . "\n";
  734. }
  735. $i++;
  736. }
  737. // Show total line
  738. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  739. // If no record found
  740. if ($num == 0) {
  741. $colspan = 3;
  742. foreach ($arrayfields as $key => $val) {
  743. if (!empty($val['checked'])) {
  744. $colspan++;
  745. }
  746. }
  747. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  748. }
  749. $db->free($resql);
  750. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  751. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  752. print $hookmanager->resPrint;
  753. print '</table>'."\n";
  754. print '</div>'."\n";
  755. print '</form>'."\n";
  756. $forcereloadpage = !getDolGlobalString('MAIN_FORCE_RELOAD_PAGE') ? 0 : 1;
  757. $tagidfortablednd = (empty($tagidfortablednd) ? 'tableattributes' : $tagidfortablednd);
  758. ?>
  759. <script>
  760. $(document).ready(function(){
  761. $(".imgupforline, .imgdownforline").hide();
  762. $(".lineupdown").removeAttr('href');
  763. $(".tdlineupdown")
  764. .css("background-image", 'url(<?php echo DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/grip.png'; ?>)')
  765. .css("background-repeat", "no-repeat")
  766. .css("background-position", "center center")
  767. .hover(
  768. function () {
  769. $(this).addClass('showDragHandle');
  770. }, function () {
  771. $(this).removeClass('showDragHandle');
  772. }
  773. );
  774. $("#<?php echo $tagidfortablednd; ?>").tableDnD({
  775. onDrop: function(table, row) {
  776. console.log('drop');
  777. $('#<?php echo $tagidfortablednd; ?> tr[data-element=extrafield]').attr('id', ''); // Set extrafields id to empty value in order to ignore them in tableDnDSerialize function
  778. $('#<?php echo $tagidfortablednd; ?> tr[data-ignoreidfordnd=1]').attr('id', ''); // Set id to empty value in order to ignore them in tableDnDSerialize function
  779. var reloadpage = "<?php echo $forcereloadpage; ?>";
  780. var roworder = cleanSerialize(decodeURI($("#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
  781. $.post("<?php echo DOL_URL_ROOT; ?>/variants/ajax/orderAttribute.php",
  782. {
  783. roworder: roworder,
  784. token: "<?php echo currentToken(); ?>"
  785. },
  786. function() {
  787. if (reloadpage == 1) {
  788. location.href = '<?php echo dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']); ?>';
  789. }
  790. });
  791. },
  792. onDragClass: "dragClass",
  793. dragHandle: "td.tdlineupdown"
  794. });
  795. });
  796. </script>
  797. <?php
  798. if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
  799. $hidegeneratedfilelistifempty = 1;
  800. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
  801. $hidegeneratedfilelistifempty = 0;
  802. }
  803. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  804. $formfile = new FormFile($db);
  805. // Show list of available documents
  806. $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  807. $urlsource .= str_replace('&amp;', '&', $param);
  808. $filedir = $diroutputmassaction;
  809. $genallowed = $permissiontoread;
  810. $delallowed = $permissiontoadd;
  811. print $formfile->showdocuments('massfilesarea_productattribute', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
  812. }
  813. // End of page
  814. llxFooter();
  815. $db->close();