list.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  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) accessforbidden();
  141. /*
  142. * Actions
  143. */
  144. if (GETPOST('cancel', 'alpha')) {
  145. $action = 'list';
  146. $massaction = '';
  147. }
  148. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  149. $massaction = '';
  150. }
  151. $parameters = array();
  152. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  153. if ($reshook < 0) {
  154. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  155. }
  156. if (empty($reshook)) {
  157. // Selection of new fields
  158. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  159. // Purge search criteria
  160. 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
  161. foreach ($object->fields as $key => $val) {
  162. $search[$key] = '';
  163. if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  164. $search[$key.'_dtstart'] = '';
  165. $search[$key.'_dtend'] = '';
  166. }
  167. }
  168. $search['nb_of_values'] = '';
  169. $search['nb_products'] = '';
  170. $toselect = array();
  171. $search_array_options = array();
  172. }
  173. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
  174. || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
  175. $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
  176. }
  177. if ($action == 'up' && $permissiontoadd) {
  178. $object->attributeMoveUp($rowid);
  179. header('Location: '.$_SERVER['PHP_SELF']);
  180. exit();
  181. } elseif ($action == 'down' && $permissiontoadd) {
  182. $object->attributeMoveDown($rowid);
  183. header('Location: '.$_SERVER['PHP_SELF']);
  184. exit();
  185. }
  186. // Mass actions
  187. $objectclass = 'ProductAttribute';
  188. $objectlabel = 'ProductAttribute';
  189. $uploaddir = $conf->variants->dir_output;
  190. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  191. }
  192. /*
  193. * View
  194. */
  195. $form = new Form($db);
  196. $now = dol_now();
  197. $help_url = '';
  198. $title = $langs->trans("ProductAttributes");
  199. $morejs = array();
  200. $morecss = array();
  201. // Build and execute select
  202. // --------------------------------------------------------------------
  203. $sql = "SELECT COUNT(DISTINCT pav.rowid) AS nb_of_values, COUNT(DISTINCT pac2v.fk_prod_combination) AS nb_products, ";
  204. $sql .= $object->getFieldList("t");
  205. // Add fields from extrafields
  206. //if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  207. // foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  208. // $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.", " : "");
  209. // }
  210. //}
  211. // Add fields from hooks
  212. $parameters = array();
  213. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  214. $sql .= $hookmanager->resPrint;
  215. $sql = preg_replace('/,\s*$/', '', $sql);
  216. $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
  217. //if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  218. // $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
  219. //}
  220. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination2val AS pac2v ON pac2v.fk_prod_attr = t.rowid";
  221. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_value AS pav ON pav.fk_product_attribute = t.rowid";
  222. // Add table from hooks
  223. $parameters = array();
  224. $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  225. $sql .= $hookmanager->resPrint;
  226. if ($object->ismultientitymanaged == 1) {
  227. $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
  228. } else {
  229. $sql .= " WHERE 1 = 1";
  230. }
  231. foreach ($search as $key => $val) {
  232. if (array_key_exists($key, $object->fields)) {
  233. if ($key == 'status' && $search[$key] == -1) {
  234. continue;
  235. }
  236. $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
  237. if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
  238. if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
  239. $search[$key] = '';
  240. }
  241. $mode_search = 2;
  242. }
  243. if ($search[$key] != '') {
  244. $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
  245. }
  246. } else {
  247. if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
  248. $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
  249. if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
  250. if (preg_match('/_dtstart$/', $key)) {
  251. $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'";
  252. }
  253. if (preg_match('/_dtend$/', $key)) {
  254. $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'";
  255. }
  256. }
  257. }
  258. }
  259. }
  260. if ($search_all) {
  261. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  262. }
  263. //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
  264. // Add where from extra fields
  265. //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  266. // Add where from hooks
  267. $parameters = array();
  268. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  269. $sql .= $hookmanager->resPrint;
  270. $hasgroupby = true;
  271. $sql .= " GROUP BY ";
  272. foreach ($object->fields as $key => $val) {
  273. $sql .= "t." . $key . ", ";
  274. }
  275. // Add fields from extrafields
  276. //if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  277. // foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  278. // $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
  279. // }
  280. //}
  281. // Add where from hooks
  282. $parameters = array();
  283. $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
  284. $sql .= $hookmanager->resPrint;
  285. $sql = preg_replace("/,\s*$/", "", $sql);
  286. $sql .= " HAVING 1=1";
  287. if ($search['nb_of_values'] != '') {
  288. $sql .= natural_search("nb_of_values", $search['nb_of_values'], 1);
  289. }
  290. if ($search['nb_products'] != '') {
  291. $sql .= natural_search("nb_products", $search['nb_products'], 1);
  292. }
  293. // Add HAVING from hooks
  294. $parameters = array();
  295. $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook
  296. $sql .= empty($hookmanager->resPrint) ? "" : " ".$hookmanager->resPrint;
  297. // Count total nb of records
  298. $nbtotalofrecords = '';
  299. if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
  300. /* This old and fast method to get and count full list returns all record so use a high amount of memory.
  301. $resql = $db->query($sql);
  302. $nbtotalofrecords = $db->num_rows($resql);
  303. */
  304. /* The slow method does not consume memory on mysql (not tested on pgsql) */
  305. /*$resql = $db->query($sql, 0, 'auto', 1);
  306. while ($db->fetch_object($resql)) {
  307. $nbtotalofrecords++;
  308. }*/
  309. /* The fast and low memory method to get and count full list converts the sql into a sql count */
  310. $sqlforcount = preg_replace("/^SELECT[a-z0-9\._\s\(\),]+FROM/i", "SELECT COUNT(*) as nbtotalofrecords FROM", $sql);
  311. $resql = $db->query($sqlforcount);
  312. if ($resql) {
  313. if ($hasgroupby) {
  314. $nbtotalofrecords = $db->num_rows($resql);
  315. } else {
  316. $objforcount = $db->fetch_object($resql);
  317. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  318. }
  319. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
  320. $page = 0;
  321. $offset = 0;
  322. }
  323. $db->free($resql);
  324. }
  325. }
  326. // Complete request and execute it with limit
  327. $sql .= $db->order($sortfield, $sortorder);
  328. if ($limit) {
  329. $sql .= $db->plimit($limit + 1, $offset);
  330. }
  331. $resql = $db->query($sql);
  332. if (!$resql) {
  333. dol_print_error($db);
  334. exit;
  335. }
  336. $num = $db->num_rows($resql);
  337. // Direct jump if only one record found
  338. if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
  339. $obj = $db->fetch_object($resql);
  340. $id = $obj->rowid;
  341. header("Location: " . dol_buildpath('/variants/card.php', 2) . '?id=' . $id);
  342. exit;
  343. }
  344. // Output page
  345. // --------------------------------------------------------------------
  346. llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
  347. $arrayofselected = is_array($toselect) ? $toselect : array();
  348. $param = '';
  349. if (!empty($mode)) {
  350. $param .= '&mode='.urlencode($mode);
  351. }
  352. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  353. $param .= '&contextpage='.urlencode($contextpage);
  354. }
  355. if ($limit > 0 && $limit != $conf->liste_limit) {
  356. $param .= '&limit='.((int) $limit);
  357. }
  358. foreach ($search as $key => $val) {
  359. if (is_array($search[$key])) {
  360. foreach ($search[$key] as $skey) {
  361. if ($skey != '') {
  362. $param .= '&search_'.$key.'[]='.urlencode($skey);
  363. }
  364. }
  365. } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
  366. $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int'));
  367. $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int'));
  368. $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int'));
  369. } elseif ($search[$key] != '') {
  370. $param .= '&search_'.$key.'='.urlencode($search[$key]);
  371. }
  372. }
  373. if ($optioncss != '') {
  374. $param .= '&optioncss='.urlencode($optioncss);
  375. }
  376. // Add $param from extra fields
  377. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  378. // Add $param from hooks
  379. $parameters = array();
  380. $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  381. $param .= $hookmanager->resPrint;
  382. // List of mass actions available
  383. $arrayofmassactions = array(
  384. //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
  385. //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  386. //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  387. //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  388. );
  389. if (!empty($permissiontodelete)) {
  390. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  391. }
  392. if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
  393. $arrayofmassactions = array();
  394. }
  395. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  396. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
  397. if ($optioncss != '') {
  398. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  399. }
  400. print '<input type="hidden" name="token" value="'.newToken().'">';
  401. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  402. print '<input type="hidden" name="action" value="list">';
  403. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  404. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  405. print '<input type="hidden" name="page" value="'.$page.'">';
  406. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  407. print '<input type="hidden" name="page_y" value="">';
  408. print '<input type="hidden" name="mode" value="'.$mode.'">';
  409. $newcardbutton = '';
  410. $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'));
  411. $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'));
  412. $newcardbutton .= dolGetButtonTitleSeparator();
  413. $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/variants/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
  414. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
  415. // Add code for pre mass action (confirmation or email presend form)
  416. $topicmail = "SendProductAttributeRef";
  417. $modelmail = "productattribute";
  418. $objecttmp = new ProductAttribute($db);
  419. $trackid = 'pa'.$object->id;
  420. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  421. if ($search_all) {
  422. $setupstring = '';
  423. foreach ($fieldstosearchall as $key => $val) {
  424. $fieldstosearchall[$key] = $langs->trans($val);
  425. $setupstring .= $key."=".$val.";";
  426. }
  427. print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
  428. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'."\n";
  429. }
  430. $moreforfilter = '';
  431. /*$moreforfilter.='<div class="divsearchfield">';
  432. $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
  433. $moreforfilter.= '</div>';*/
  434. $parameters = array();
  435. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  436. if (empty($reshook)) {
  437. $moreforfilter .= $hookmanager->resPrint;
  438. } else {
  439. $moreforfilter = $hookmanager->resPrint;
  440. }
  441. if (!empty($moreforfilter)) {
  442. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  443. print $moreforfilter;
  444. $parameters = array();
  445. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  446. print $hookmanager->resPrint;
  447. print '</div>';
  448. }
  449. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  450. $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
  451. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  452. print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  453. print '<table id="tableattributes" class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  454. // Fields title search
  455. // --------------------------------------------------------------------
  456. print '<tr class="liste_titre_filter">';
  457. // Action column
  458. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  459. print '<td class="liste_titre center maxwidthsearch">';
  460. $searchpicto = $form->showFilterButtons('left');
  461. print $searchpicto;
  462. print '</td>';
  463. }
  464. foreach ($object->fields as $key => $val) {
  465. $searchkey = empty($search[$key]) ? '' : $search[$key];
  466. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  467. if ($key == 'status') {
  468. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  469. } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  470. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  471. } elseif (in_array($val['type'], array('timestamp'))) {
  472. $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
  473. } 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'])) {
  474. $cssforfield .= ($cssforfield ? ' ' : '').'right';
  475. }
  476. if (!empty($arrayfields['t.'.$key]['checked'])) {
  477. print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
  478. if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
  479. 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);
  480. } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
  481. print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
  482. } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  483. print '<div class="nowrap">';
  484. print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  485. print '</div>';
  486. print '<div class="nowrap">';
  487. print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  488. print '</div>';
  489. } elseif ($key == 'lang') {
  490. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
  491. $formadmin = new FormAdmin($db);
  492. print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
  493. } else {
  494. print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
  495. }
  496. print '</td>';
  497. }
  498. }
  499. // Extra fields
  500. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  501. // Fields from hook
  502. $parameters = array('arrayfields'=>$arrayfields);
  503. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  504. print $hookmanager->resPrint;
  505. $key = 'nb_of_values';
  506. if (!empty($arrayfields[$key]['checked'])) {
  507. print '<td class="liste_titre center">';
  508. print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
  509. print '</td>';
  510. }
  511. $key = 'nb_products';
  512. if (!empty($arrayfields[$key]['checked'])) {
  513. print '<td class="liste_titre center">';
  514. print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
  515. print '</td>';
  516. }
  517. // Action column
  518. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  519. print '<td class="liste_titre center maxwidthsearch">';
  520. $searchpicto = $form->showFilterButtons();
  521. print $searchpicto;
  522. print '</td>';
  523. }
  524. // Move
  525. print '<td class="liste_titre linecolmove width25"></td>';
  526. print '</tr>'."\n";
  527. $totalarray = array();
  528. $totalarray['nbfield'] = 0;
  529. // Fields title label
  530. // --------------------------------------------------------------------
  531. print '<tr class="liste_titre">';
  532. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  533. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  534. $totalarray['nbfield']++;
  535. }
  536. foreach ($object->fields as $key => $val) {
  537. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  538. if ($key == 'status') {
  539. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  540. } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  541. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  542. } elseif (in_array($val['type'], array('timestamp'))) {
  543. $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
  544. } 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'])) {
  545. $cssforfield .= ($cssforfield ? ' ' : '').'right';
  546. }
  547. $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
  548. if (!empty($arrayfields['t.'.$key]['checked'])) {
  549. 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";
  550. $totalarray['nbfield']++;
  551. }
  552. }
  553. // Extra fields
  554. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  555. // Hook fields
  556. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
  557. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  558. print $hookmanager->resPrint;
  559. $key = 'nb_of_values';
  560. if (!empty($arrayfields[$key]['checked'])) {
  561. print getTitleFieldOfList($arrayfields[$key]['label'], 0, $_SERVER['PHP_SELF'], $key, '', $param, 'class="center"', $sortfield, $sortorder, 'center ')."\n";
  562. }
  563. $key = 'nb_products';
  564. if (!empty($arrayfields[$key]['checked'])) {
  565. print getTitleFieldOfList($arrayfields[$key]['label'], 0, $_SERVER['PHP_SELF'], $key, '', $param, 'class="center"', $sortfield, $sortorder, 'center ')."\n";
  566. }
  567. // Action column
  568. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  569. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  570. $totalarray['nbfield']++;
  571. }
  572. // Move
  573. print getTitleFieldOfList('', 0, '', '', '', '', '', '', '', 'linecolmove ')."\n";
  574. print '</tr>'."\n";
  575. // Detect if we need a fetch on each output line
  576. $needToFetchEachLine = 0;
  577. //if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
  578. // foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
  579. // if (!is_null($val) && preg_match('/\$object/', $val)) {
  580. // $needToFetchEachLine++; // There is at least one compute field that use $object
  581. // }
  582. // }
  583. //}
  584. // Loop on record
  585. // --------------------------------------------------------------------
  586. $i = 0;
  587. $savnbfield = $totalarray['nbfield'];
  588. $totalarray = array();
  589. $totalarray['nbfield'] = 0;
  590. $imaxinloop = ($limit ? min($num, $limit) : $num);
  591. while ($i < $imaxinloop) {
  592. $obj = $db->fetch_object($resql);
  593. if (empty($obj)) {
  594. break; // Should not happen
  595. }
  596. // Store properties in $object
  597. $object->setVarsFromFetchObj($obj);
  598. if ($mode == 'kanban') {
  599. if ($i == 0) {
  600. print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
  601. print '<div class="box-flex-container kanban">';
  602. }
  603. // Output Kanban
  604. $selected = -1;
  605. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  606. $selected = 0;
  607. if (in_array($object->id, $arrayofselected)) {
  608. $selected = 1;
  609. }
  610. }
  611. print $object->getKanbanView('', array('selected' => $selected));
  612. if ($i == ($imaxinloop - 1)) {
  613. print '</div>';
  614. print '</td></tr>';
  615. }
  616. } else {
  617. // Show here line of result
  618. $j = 0;
  619. print '<tr data-rowid="'.$object->id.'" class="oddeven">';
  620. // Action column
  621. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  622. print '<td class="nowrap center">';
  623. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  624. $selected = 0;
  625. if (in_array($object->id, $arrayofselected)) {
  626. $selected = 1;
  627. }
  628. print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
  629. }
  630. print '</td>';
  631. if (!$i) {
  632. $totalarray['nbfield']++;
  633. }
  634. }
  635. foreach ($object->fields as $key => $val) {
  636. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  637. if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  638. $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
  639. } elseif ($key == 'status') {
  640. $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
  641. }
  642. if (in_array($val['type'], array('timestamp'))) {
  643. $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
  644. } elseif ($key == 'ref') {
  645. $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
  646. }
  647. if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
  648. $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
  649. }
  650. //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
  651. if (!empty($arrayfields['t.' . $key]['checked'])) {
  652. print '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
  653. if (preg_match('/tdoverflow/', $cssforfield) && !is_numeric($object->$key)) {
  654. print ' title="'.dol_escape_htmltag($object->$key).'"';
  655. }
  656. print '>';
  657. if ($key == 'status') {
  658. print $object->getLibStatut(5);
  659. } elseif ($key == 'rowid') {
  660. print $object->showOutputField($val, $key, $object->id, '');
  661. } else {
  662. print $object->showOutputField($val, $key, $object->$key, '');
  663. }
  664. print '</td>';
  665. if (!$i) {
  666. $totalarray['nbfield']++;
  667. }
  668. if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
  669. if (!$i) {
  670. $totalarray['pos'][$totalarray['nbfield']] = 't.' . $key;
  671. }
  672. if (!isset($totalarray['val'])) {
  673. $totalarray['val'] = array();
  674. }
  675. if (!isset($totalarray['val']['t.' . $key])) {
  676. $totalarray['val']['t.' . $key] = 0;
  677. }
  678. $totalarray['val']['t.' . $key] += $object->$key;
  679. }
  680. }
  681. }
  682. // Extra fields
  683. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  684. // Fields from hook
  685. $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  686. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  687. print $hookmanager->resPrint;
  688. // Other
  689. $key = 'nb_of_values';
  690. if (!empty($arrayfields[$key]['checked'])) {
  691. print '<td class="center">';
  692. print $obj->$key;
  693. print '</td>';
  694. if (!$i) {
  695. $totalarray['nbfield']++;
  696. }
  697. }
  698. $key = 'nb_products';
  699. if (!empty($arrayfields[$key]['checked'])) {
  700. print '<td class="center">';
  701. print $obj->$key;
  702. print '</td>';
  703. if (!$i) {
  704. $totalarray['nbfield']++;
  705. }
  706. }
  707. // Action column
  708. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  709. print '<td class="nowrap center">';
  710. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  711. $selected = 0;
  712. if (in_array($object->id, $arrayofselected)) {
  713. $selected = 1;
  714. }
  715. print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
  716. }
  717. print '</td>';
  718. if (!$i) {
  719. $totalarray['nbfield']++;
  720. }
  721. }
  722. // Move
  723. print '<td class="center linecolmove tdlineupdown">';
  724. if ($i > 0) {
  725. print '<a class="lineupdown" href="' . $_SERVER['PHP_SELF'] . '?action=up&amp;rowid=' . $obj->rowid . '">' . img_up('default', 0, 'imgupforline') . '</a>';
  726. }
  727. if ($i < $num - 1) {
  728. print '<a class="lineupdown" href="' . $_SERVER['PHP_SELF'] . '?action=down&amp;rowid=' . $obj->rowid . '">' . img_down('default', 0, 'imgdownforline') . '</a>';
  729. }
  730. print '</td>';
  731. print '</tr>' . "\n";
  732. }
  733. $i++;
  734. }
  735. // Show total line
  736. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  737. // If no record found
  738. if ($num == 0) {
  739. $colspan = 3;
  740. foreach ($arrayfields as $key => $val) {
  741. if (!empty($val['checked'])) {
  742. $colspan++;
  743. }
  744. }
  745. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  746. }
  747. $db->free($resql);
  748. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  749. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  750. print $hookmanager->resPrint;
  751. print '</table>'."\n";
  752. print '</div>'."\n";
  753. print '</form>'."\n";
  754. $forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1;
  755. $tagidfortablednd = (empty($tagidfortablednd) ? 'tableattributes' : $tagidfortablednd);
  756. ?>
  757. <script>
  758. $(document).ready(function(){
  759. $(".imgupforline, .imgdownforline").hide();
  760. $(".lineupdown").removeAttr('href');
  761. $(".tdlineupdown")
  762. .css("background-image", 'url(<?php echo DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/grip.png'; ?>)')
  763. .css("background-repeat", "no-repeat")
  764. .css("background-position", "center center")
  765. .hover(
  766. function () {
  767. $(this).addClass('showDragHandle');
  768. }, function () {
  769. $(this).removeClass('showDragHandle');
  770. }
  771. );
  772. $("#<?php echo $tagidfortablednd; ?>").tableDnD({
  773. onDrop: function(table, row) {
  774. console.log('drop');
  775. $('#<?php echo $tagidfortablednd; ?> tr[data-element=extrafield]').attr('id', ''); // Set extrafields id to empty value in order to ignore them in tableDnDSerialize function
  776. $('#<?php echo $tagidfortablednd; ?> tr[data-ignoreidfordnd=1]').attr('id', ''); // Set id to empty value in order to ignore them in tableDnDSerialize function
  777. var reloadpage = "<?php echo $forcereloadpage; ?>";
  778. var roworder = cleanSerialize(decodeURI($("#<?php echo $tagidfortablednd; ?>").tableDnDSerialize()));
  779. $.post("<?php echo DOL_URL_ROOT; ?>/variants/ajax/orderAttribute.php",
  780. {
  781. roworder: roworder,
  782. token: "<?php echo currentToken(); ?>"
  783. },
  784. function() {
  785. if (reloadpage == 1) {
  786. location.href = '<?php echo dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']); ?>';
  787. }
  788. });
  789. },
  790. onDragClass: "dragClass",
  791. dragHandle: "td.tdlineupdown"
  792. });
  793. });
  794. </script>
  795. <?php
  796. if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
  797. $hidegeneratedfilelistifempty = 1;
  798. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
  799. $hidegeneratedfilelistifempty = 0;
  800. }
  801. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  802. $formfile = new FormFile($db);
  803. // Show list of available documents
  804. $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  805. $urlsource .= str_replace('&amp;', '&', $param);
  806. $filedir = $diroutputmassaction;
  807. $genallowed = $permissiontoread;
  808. $delallowed = $permissiontoadd;
  809. print $formfile->showdocuments('massfilesarea_productattribute', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
  810. }
  811. // End of page
  812. llxFooter();
  813. $db->close();