rollerhistory_list.php 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  1. <?php
  2. /* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2023 László Szollősi
  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 rollerhistory_list.php
  20. * \ingroup rollerstorage
  21. * \brief List page for rollerhistory
  22. */
  23. //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
  24. //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
  25. //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
  26. //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
  27. //if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
  28. //if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
  29. //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
  30. //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
  31. //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
  32. //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
  33. //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
  34. //if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
  35. //if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
  36. //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
  37. //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
  38. //if (! defined("MAIN_SECURITY_FORCECSP")) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies
  39. //if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
  40. //if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
  41. //if (! defined('NOSESSION')) define('NOSESSION', '1'); // On CLI mode, no need to use web sessions
  42. // Load Dolibarr environment
  43. $res = 0;
  44. // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
  45. if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
  46. $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"] . "/main.inc.php";
  47. }
  48. // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
  49. $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME'];
  50. $tmp2 = realpath(__FILE__);
  51. $i = strlen($tmp) - 1;
  52. $j = strlen($tmp2) - 1;
  53. while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
  54. $i--;
  55. $j--;
  56. }
  57. if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . "/main.inc.php")) {
  58. $res = @include substr($tmp, 0, ($i + 1)) . "/main.inc.php";
  59. }
  60. if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php")) {
  61. $res = @include dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php";
  62. }
  63. // Try main.inc.php using relative path
  64. if (!$res && file_exists("../main.inc.php")) {
  65. $res = @include "../main.inc.php";
  66. }
  67. if (!$res && file_exists("../../main.inc.php")) {
  68. $res = @include "../../main.inc.php";
  69. }
  70. if (!$res && file_exists("../../../main.inc.php")) {
  71. $res = @include "../../../main.inc.php";
  72. }
  73. if (!$res) {
  74. die("Include of main fails");
  75. }
  76. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
  77. require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
  78. require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
  79. require_once DOL_DOCUMENT_ROOT . '/custom/rollerstorage/class/statuses.class.php';
  80. // load rollerstorage libraries
  81. require_once __DIR__ . '/class/rollerhistory.class.php';
  82. // for other modules
  83. //dol_include_once('/othermodule/class/otherobject.class.php');
  84. // Load translation files required by the page
  85. $langs->loadLangs(array("rollerstorage@rollerstorage", "other"));
  86. $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
  87. $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
  88. $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
  89. $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
  90. $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
  91. $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
  92. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)) . basename(__FILE__, '.php')); // To manage different context of search
  93. $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
  94. $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
  95. $mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
  96. $inventory_id = GETPOST('inventory_id', 'int') ? GETPOST('inventory_id', 'int') : null;
  97. $idmenu = GETPOST('idmenu', 'int');
  98. $fk_inventory = GETPOST('fk_inventory', 'int');
  99. $id = GETPOST('id', 'int') ? GETPOST('id', 'int') : $fk_inventory;
  100. $ref = GETPOST('ref', 'alpha');
  101. // Load variable for pagination
  102. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  103. $sortfield = GETPOST('sortfield', 'aZ09comma');
  104. $sortorder = GETPOST('sortorder', 'aZ09comma');
  105. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  106. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  107. // If $page is not defined, or '' or -1 or if we click on clear filters
  108. $page = 0;
  109. }
  110. $offset = $limit * $page;
  111. $pageprev = $page - 1;
  112. $pagenext = $page + 1;
  113. // Initialize technical objects
  114. $object = new RollerHistory($db);
  115. $extrafields = new ExtraFields($db);
  116. $diroutputmassaction = $conf->rollerstorage->dir_output . '/temp/massgeneration/' . $user->id;
  117. $hookmanager->initHooks(array('rollerhistorylist')); // Note that conf->hooks_modules contains array
  118. $statuses = new Statuses($db);
  119. $statusesObj = $statuses->getStatusIdsWithRowid($db);
  120. // Fetch optionals attributes and labels
  121. $extrafields->fetch_name_optionals_label($object->table_element);
  122. //$extrafields->fetch_name_optionals_label($object->table_element_line);
  123. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  124. // Default sort order (if not yet defined by previous GETPOST)
  125. if (!$sortfield) {
  126. reset($object->fields); // Reset is required to avoid key() to return null.
  127. $sortfield = "t." . key($object->fields); // Set here default search field. By default 1st field in definition.
  128. }
  129. if (!$sortorder) {
  130. $sortorder = "ASC";
  131. }
  132. // Initialize array of search criterias
  133. $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
  134. $search = array();
  135. foreach ($object->fields as $key => $val) {
  136. if (GETPOST('search_' . $key, 'alpha') !== '') {
  137. $search[$key] = GETPOST('search_' . $key, 'alpha');
  138. }
  139. if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  140. $search[$key . '_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_' . $key . '_dtstartmonth', 'int'), GETPOST('search_' . $key . '_dtstartday', 'int'), GETPOST('search_' . $key . '_dtstartyear', 'int'));
  141. $search[$key . '_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_' . $key . '_dtendmonth', 'int'), GETPOST('search_' . $key . '_dtendday', 'int'), GETPOST('search_' . $key . '_dtendyear', 'int'));
  142. }
  143. }
  144. // List of fields to search into when doing a "search in all"
  145. $fieldstosearchall = array();
  146. foreach ($object->fields as $key => $val) {
  147. if (!empty($val['searchall'])) {
  148. $fieldstosearchall['t.' . $key] = $val['label'];
  149. }
  150. }
  151. // Definition of array of fields for columns
  152. $arrayfields = array();
  153. foreach ($object->fields as $key => $val) {
  154. // If $val['visible']==0, then we never show the field
  155. if (!empty($val['visible'])) {
  156. $visible = (int) dol_eval($val['visible'], 1);
  157. $arrayfields['t.' . $key] = array(
  158. 'label' => $val['label'],
  159. 'checked' => (($visible < 0) ? 0 : 1),
  160. 'enabled' => (abs($visible) != 3 && dol_eval($val['enabled'], 1)),
  161. 'position' => $val['position'],
  162. 'help' => isset($val['help']) ? $val['help'] : ''
  163. );
  164. }
  165. }
  166. // Extra fields
  167. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php';
  168. $object->fields = dol_sort_array($object->fields, 'position');
  169. //$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right');
  170. $arrayfields = dol_sort_array($arrayfields, 'position');
  171. // There is several ways to check permission.
  172. // Set $enablepermissioncheck to 1 to enable a minimum low level of checks
  173. $enablepermissioncheck = 0;
  174. if ($enablepermissioncheck) {
  175. $permissiontoread = $user->hasRight('rollerstorage', 'rollerhistory', 'read');
  176. $permissiontoadd = $user->hasRight('rollerstorage', 'rollerhistory', 'write');
  177. $permissiontodelete = $user->hasRight('rollerstorage', 'rollerhistory', 'delete');
  178. } else {
  179. $permissiontoread = 1;
  180. $permissiontoadd = 1;
  181. $permissiontodelete = 1;
  182. }
  183. // Security check (enable the most restrictive one)
  184. if ($user->socid > 0)
  185. accessforbidden();
  186. //if ($user->socid > 0) accessforbidden();
  187. //$socid = 0; if ($user->socid > 0) $socid = $user->socid;
  188. //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
  189. //restrictedArea($user, $object->module, 0, $object->table_element, $object->element, 'fk_soc', 'rowid', $isdraft);
  190. if (!isModEnabled("rollerstorage")) {
  191. accessforbidden('Module rollerstorage not enabled');
  192. }
  193. if (!$permissiontoread)
  194. accessforbidden();
  195. /*
  196. * Actions
  197. */
  198. if (GETPOST('cancel', 'alpha')) {
  199. $action = 'list';
  200. $massaction = '';
  201. }
  202. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  203. $massaction = '';
  204. }
  205. $parameters = array();
  206. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  207. if ($reshook < 0) {
  208. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  209. }
  210. if (empty($reshook)) {
  211. // Selection of new fields
  212. include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php';
  213. // Purge search criteria
  214. 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
  215. foreach ($object->fields as $key => $val) {
  216. $search[$key] = '';
  217. if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  218. $search[$key . '_dtstart'] = '';
  219. $search[$key . '_dtend'] = '';
  220. }
  221. }
  222. $toselect = array();
  223. $search_array_options = array();
  224. }
  225. if (
  226. GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
  227. || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')
  228. ) {
  229. $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
  230. }
  231. // Mass actions
  232. $objectclass = 'RollerHistory';
  233. $objectlabel = 'RollerHistory';
  234. $uploaddir = $conf->rollerstorage->dir_output;
  235. include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php';
  236. // You can add more action here
  237. // if ($action == 'xxx' && $permissiontoxxx) ...
  238. }
  239. /*
  240. * View
  241. */
  242. $form = new Form($db);
  243. $now = dol_now();
  244. //$help_url = "EN:Module_RollerHistory|FR:Module_RollerHistory_FR|ES:Módulo_RollerHistory";
  245. $help_url = '';
  246. $title = $langs->trans("RollerHistorys");
  247. $morejs = array();
  248. $morecss = array();
  249. // Build and execute select
  250. // --------------------------------------------------------------------
  251. $sql = 'SELECT u.login, u.lastname, u.firstname, ent1.ref as wh_from_ref, ent1.lieu as wh_from_lieu, ent1.address as wh_from_address, ent2.ref as wh_to_ref, ent2.lieu as wh_to_lieu, ent2.address as wh_to_address, ';
  252. $sql .= $object->getFieldList('t');
  253. // Add fields from extrafields
  254. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  255. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  256. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef." . $key . " as options_" . $key : '');
  257. }
  258. }
  259. // Add fields from hooks
  260. $parameters = array();
  261. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
  262. $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
  263. $sql = preg_replace('/,\s*$/', '', $sql);
  264. //$sql .= ", COUNT(rc.rowid) as anotherfield";
  265. $sqlfields = $sql; // $sql fields to remove for count total
  266. $sql .= " FROM " . MAIN_DB_PREFIX . $object->table_element . " as t";
  267. //$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."anothertable as rc ON rc.parent = t.rowid";
  268. if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  269. $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $object->table_element . "_extrafields as ef on (t.rowid = ef.fk_object)";
  270. }
  271. $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "entrepot AS ent1 ON t.warehouse_from = ent1.rowid ";
  272. $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "entrepot AS ent2 ON t.warehouse_to = ent2.rowid ";
  273. $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "user AS u ON t.fk_user_creat = u.rowid ";
  274. // Add table from hooks
  275. $parameters = array();
  276. $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
  277. $sql .= $hookmanager->resPrint;
  278. if ($object->ismultientitymanaged == 1) {
  279. $sql .= " WHERE t.entity IN (" . getEntity($object->element) . ")";
  280. } else {
  281. $sql .= " WHERE fk_inventory = {$id}";
  282. }
  283. //print_r($object->id);
  284. //print $sql;
  285. foreach ($search as $key => $val) {
  286. if (array_key_exists($key, $object->fields)) {
  287. if ($key == 'status' && $search[$key] == -1) {
  288. continue;
  289. }
  290. $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
  291. if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
  292. if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
  293. $search[$key] = '';
  294. }
  295. $mode_search = 2;
  296. }
  297. if ($search[$key] != '') {
  298. $sql .= natural_search("t." . $db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
  299. }
  300. } else {
  301. if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
  302. $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
  303. if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
  304. if (preg_match('/_dtstart$/', $key)) {
  305. $sql .= " AND t." . $db->escape($columnName) . " >= '" . $db->idate($search[$key]) . "'";
  306. }
  307. if (preg_match('/_dtend$/', $key)) {
  308. $sql .= " AND t." . $db->escape($columnName) . " <= '" . $db->idate($search[$key]) . "'";
  309. }
  310. }
  311. }
  312. }
  313. }
  314. if ($search_all) {
  315. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  316. }
  317. //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
  318. // Add where from extra fields
  319. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php';
  320. // Add where from hooks
  321. $parameters = array();
  322. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
  323. $sql .= $hookmanager->resPrint;
  324. /* If a group by is required
  325. $sql .= " GROUP BY ";
  326. foreach($object->fields as $key => $val) {
  327. $sql .= "t.".$db->escape($key).", ";
  328. }
  329. // Add fields from extrafields
  330. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  331. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  332. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
  333. }
  334. }
  335. // Add where from hooks
  336. $parameters = array();
  337. $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
  338. $sql .= $hookmanager->resPrint;
  339. $sql = preg_replace('/,\s*$/', '', $sql);
  340. */
  341. // Add HAVING from hooks
  342. /*
  343. $parameters = array();
  344. $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook
  345. $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
  346. */
  347. // Count total nb of records
  348. $nbtotalofrecords = '';
  349. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  350. /* The fast and low memory method to get and count full list converts the sql into a sql count */
  351. $sqlforcount = preg_replace('/^' . preg_quote($sqlfields, '/') . '/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
  352. $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
  353. $resql = $db->query($sqlforcount);
  354. if ($resql) {
  355. $objforcount = $db->fetch_object($resql);
  356. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  357. } else {
  358. dol_print_error($db);
  359. }
  360. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  361. $page = 0;
  362. $offset = 0;
  363. }
  364. $db->free($resql);
  365. }
  366. // Complete request and execute it with limit
  367. $sql .= $db->order($sortfield, $sortorder);
  368. if ($limit) {
  369. $sql .= $db->plimit($limit + 1, $offset);
  370. }
  371. $resql = $db->query($sql);
  372. if (!$resql) {
  373. dol_print_error($db);
  374. exit;
  375. }
  376. $num = $db->num_rows($resql);
  377. // Direct jump if only one record found
  378. if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
  379. $obj = $db->fetch_object($resql);
  380. $id = $obj->rowid;
  381. header("Location: " . dol_buildpath('/rollerstorage/rollerhistory_card.php', 1) . '?id=' . $id);
  382. exit;
  383. }
  384. // Output page
  385. // --------------------------------------------------------------------
  386. llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
  387. // Example : Adding jquery code
  388. // print '<script type="text/javascript">
  389. // jQuery(document).ready(function() {
  390. // function init_myfunc()
  391. // {
  392. // jQuery("#myid").removeAttr(\'disabled\');
  393. // jQuery("#myid").attr(\'disabled\',\'disabled\');
  394. // }
  395. // init_myfunc();
  396. // jQuery("#mybutton").click(function() {
  397. // init_myfunc();
  398. // });
  399. // });
  400. // </script>';
  401. $tabs = array(
  402. array(dol_buildpath('/custom/rollerstorage/card.php?id=' . $id . $get . '&inventory_id='.$inventory_id.'&backtopage=' . $backtopage, 1), $langs->trans('Roller'), 'roller'),
  403. array(dol_buildpath('/custom/rollerstorage/rollerhistory_list.php?id=' . $id . $get . '&inventory_id='.$inventory_id.'&backtopage=' . $backtopage, 1), $langs->trans('Rollerhistory'), 'rollerhistory')
  404. );
  405. $head = $tabs;
  406. $arrayofselected = is_array($toselect) ? $toselect : array();
  407. print dol_get_fiche_head($head, 'rollerhistory', $langs->trans("Rollerhistory"), -1, 'stock');
  408. $param = '';
  409. if (!empty($mode)) {
  410. $param .= '&mode=' . urlencode($mode);
  411. }
  412. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  413. $param .= '&contextpage=' . urlencode($contextpage);
  414. }
  415. if (!empty($id)) {
  416. $param .= '&id=' . $id;
  417. }
  418. if ($limit > 0 && $limit != $conf->liste_limit) {
  419. $param .= '&limit=' . urlencode($limit);
  420. }
  421. foreach ($search as $key => $val) {
  422. if (is_array($search[$key])) {
  423. foreach ($search[$key] as $skey) {
  424. if ($skey != '') {
  425. $param .= '&search_' . $key . '[]=' . urlencode($skey);
  426. }
  427. }
  428. } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
  429. $param .= '&search_' . $key . 'month=' . ((int) GETPOST('search_' . $key . 'month', 'int'));
  430. $param .= '&search_' . $key . 'day=' . ((int) GETPOST('search_' . $key . 'day', 'int'));
  431. $param .= '&search_' . $key . 'year=' . ((int) GETPOST('search_' . $key . 'year', 'int'));
  432. } elseif ($search[$key] != '') {
  433. $param .= '&search_' . $key . '=' . urlencode($search[$key]);
  434. }
  435. }
  436. if ($optioncss != '') {
  437. $param .= '&optioncss=' . urlencode($optioncss);
  438. }
  439. // Add $param from extra fields
  440. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php';
  441. // Add $param from hooks
  442. $parameters = array();
  443. $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
  444. $param .= $hookmanager->resPrint;
  445. // List of mass actions available
  446. $arrayofmassactions = array(
  447. //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
  448. //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  449. //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  450. //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  451. );
  452. if (!empty($permissiontodelete)) {
  453. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"') . $langs->trans("Delete");
  454. }
  455. if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
  456. $arrayofmassactions = array();
  457. }
  458. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  459. print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">' . "\n";
  460. if ($optioncss != '') {
  461. print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
  462. }
  463. print '<input type="hidden" name="token" value="' . newToken() . '">';
  464. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  465. print '<input type="hidden" name="action" value="list">';
  466. print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
  467. print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
  468. print '<input type="hidden" name="page" value="' . $page . '">';
  469. print '<input type="hidden" name="contextpage" value="' . $contextpage . '">';
  470. print '<input type="hidden" name="page_y" value="">';
  471. print '<input type="hidden" name="mode" value="' . $mode . '">';
  472. print '<input type="hidden" name="fk_inventory" value="' . $id . '">';
  473. $newcardbutton = '';
  474. //$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'));
  475. //$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'));
  476. //$newcardbutton .= dolGetButtonTitleSeparator();
  477. //$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/rollerstorage/rollerhistory_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
  478. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_' . $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
  479. // Add code for pre mass action (confirmation or email presend form)
  480. $topicmail = "SendRollerHistoryRef";
  481. $modelmail = "rollerhistory";
  482. $objecttmp = new RollerHistory($db);
  483. $trackid = 'xxxx' . $object->id;
  484. include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php';
  485. if ($search_all) {
  486. $setupstring = '';
  487. foreach ($fieldstosearchall as $key => $val) {
  488. $fieldstosearchall[$key] = $langs->trans($val);
  489. $setupstring .= $key . "=" . $val . ";";
  490. }
  491. print '<!-- Search done like if PRODUCT_QUICKSEARCH_ON_FIELDS = ' . $setupstring . ' -->' . "\n";
  492. print '<div class="divsearchfieldfilter">' . $langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall) . '</div>' . "\n";
  493. }
  494. $moreforfilter = '';
  495. /*$moreforfilter.='<div class="divsearchfield">';
  496. $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
  497. $moreforfilter.= '</div>';*/
  498. $parameters = array();
  499. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
  500. if (empty($reshook)) {
  501. $moreforfilter .= $hookmanager->resPrint;
  502. } else {
  503. $moreforfilter = $hookmanager->resPrint;
  504. }
  505. if (!empty($moreforfilter)) {
  506. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  507. print $moreforfilter;
  508. print '</div>';
  509. }
  510. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  511. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
  512. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  513. print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  514. print '<table class="tagtable nobottomiftotal liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
  515. // Fields title search
  516. // --------------------------------------------------------------------
  517. print '<tr class="liste_titre">';
  518. // Action column
  519. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  520. print '<td class="liste_titre maxwidthsearch">';
  521. $searchpicto = $form->showFilterButtons('left');
  522. print $searchpicto;
  523. print '</td>';
  524. }
  525. foreach ($object->fields as $key => $val) {
  526. $searchkey = empty($search[$key]) ? '' : $search[$key];
  527. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  528. if ($key == 'status') {
  529. $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
  530. } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  531. $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
  532. } elseif (in_array($val['type'], array('timestamp'))) {
  533. $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
  534. } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
  535. $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
  536. }
  537. if (!empty($arrayfields['t.' . $key]['checked'])) {
  538. print '<td class="liste_titre' . ($cssforfield ? ' ' . $cssforfield : '') . '">';
  539. if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
  540. print $form->selectarray('search_' . $key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100' . ($key == 'status' ? ' search_status onrightofpage' : ''), 1);
  541. } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
  542. print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield . ' maxwidth250', 1);
  543. } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  544. print '<div class="nowrap">';
  545. print $form->selectDate($search[$key . '_dtstart'] ? $search[$key . '_dtstart'] : '', "search_" . $key . "_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  546. print '</div>';
  547. print '<div class="nowrap">';
  548. print $form->selectDate($search[$key . '_dtend'] ? $search[$key . '_dtend'] : '', "search_" . $key . "_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  549. print '</div>';
  550. } elseif ($key == 'lang') {
  551. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php';
  552. $formadmin = new FormAdmin($db);
  553. print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
  554. } else {
  555. print '<input type="text" class="flat maxwidth75" name="search_' . $key . '" value="' . dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '') . '">';
  556. }
  557. print '</td>';
  558. }
  559. }
  560. // Extra fields
  561. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php';
  562. // Fields from hook
  563. $parameters = array('arrayfields' => $arrayfields);
  564. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
  565. print $hookmanager->resPrint;
  566. /*if (!empty($arrayfields['anotherfield']['checked'])) {
  567. print '<td class="liste_titre"></td>';
  568. }*/
  569. // Action column
  570. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  571. print '<td class="liste_titre maxwidthsearch">';
  572. $searchpicto = $form->showFilterButtons();
  573. print $searchpicto;
  574. print '</td>';
  575. }
  576. print '</tr>' . "\n";
  577. $totalarray = array();
  578. $totalarray['nbfield'] = 0;
  579. // Fields title label
  580. // --------------------------------------------------------------------
  581. print '<tr class="liste_titre">';
  582. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  583. print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ') . "\n";
  584. $totalarray['nbfield']++;
  585. }
  586. foreach ($object->fields as $key => $val) {
  587. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  588. if ($key == 'status') {
  589. $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
  590. } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  591. $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
  592. } elseif (in_array($val['type'], array('timestamp'))) {
  593. $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
  594. } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
  595. $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
  596. }
  597. $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
  598. if (!empty($arrayfields['t.' . $key]['checked'])) {
  599. print getTitleFieldOfList($arrayfields['t.' . $key]['label'], 0, $_SERVER['PHP_SELF'], 't.' . $key, '', $param, ($cssforfield ? 'class="' . $cssforfield . '"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield . ' ' : '')) . "\n";
  600. $totalarray['nbfield']++;
  601. }
  602. }
  603. // Extra fields
  604. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php';
  605. // Hook fields
  606. $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
  607. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
  608. print $hookmanager->resPrint;
  609. /*if (!empty($arrayfields['anotherfield']['checked'])) {
  610. print '<th class="liste_titre right">'.$langs->trans("AnotherField").'</th>';
  611. $totalarray['nbfield']++;
  612. }*/
  613. // Action column
  614. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  615. print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ') . "\n";
  616. $totalarray['nbfield']++;
  617. }
  618. print '</tr>' . "\n";
  619. $totalarray = array();
  620. $totalarray['nbfield'] = 0;
  621. // Detect if we need a fetch on each output line
  622. $needToFetchEachLine = 0;
  623. if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
  624. foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
  625. if (preg_match('/\$object/', $val)) {
  626. $needToFetchEachLine++; // There is at least one compute field that use $object
  627. }
  628. }
  629. }
  630. // Loop on record
  631. // --------------------------------------------------------------------
  632. $i = 0;
  633. $savnbfield = $totalarray['nbfield'];
  634. $totalarray = array();
  635. $totalarray['nbfield'] = 0;
  636. $imaxinloop = ($limit ? min($num, $limit) : $num);
  637. while ($i < $imaxinloop) {
  638. $obj = $db->fetch_object($resql);
  639. if (empty($obj)) {
  640. break; // Should not happen
  641. }
  642. // Store properties in $object
  643. $object->setVarsFromFetchObj($obj);
  644. if ($mode == 'kanban') {
  645. if ($i == 0) {
  646. print '<tr><td colspan="' . $savnbfield . '">';
  647. print '<div class="box-flex-container">';
  648. }
  649. // Output Kanban
  650. print $object->getKanbanView('');
  651. if ($i == ($imaxinloop - 1)) {
  652. print '</div>';
  653. print '</td></tr>';
  654. }
  655. } else {
  656. // Show here line of result
  657. $j = 0;
  658. print '<tr data-rowid="' . $object->id . '" class="oddeven">';
  659. // Action column
  660. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  661. print '<td class="nowrap center">';
  662. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  663. $selected = 0;
  664. if (in_array($object->id, $arrayofselected)) {
  665. $selected = 1;
  666. }
  667. print '<input id="cb' . $object->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $object->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
  668. }
  669. print '</td>';
  670. if (!$i) {
  671. $totalarray['nbfield']++;
  672. }
  673. }
  674. foreach ($object->fields as $key => $val) {
  675. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  676. if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  677. $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
  678. } elseif ($key == 'status') {
  679. $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
  680. }
  681. if (in_array($val['type'], array('timestamp'))) {
  682. $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
  683. } elseif ($key == 'ref') {
  684. $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
  685. }
  686. if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
  687. $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
  688. }
  689. //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
  690. if (!empty($arrayfields['t.' . $key]['checked'])) {
  691. $typeData = explode(':', $val['type']);
  692. print '<td' . ($cssforfield ? ' class="' . $cssforfield . (preg_match('/tdoverflow/', $cssforfield) ? '' : '') . '"' : '');
  693. if (preg_match('/tdoverflow/', $cssforfield)) {
  694. print ' title="' . dol_escape_htmltag($object->$key) . '"';
  695. }
  696. print '>';
  697. if ($key == 'status') {
  698. print $object->getLibStatut(5);
  699. } elseif ($key == 'rowid') {
  700. print $object->showOutputField($val, $key, $object->id, '');
  701. } elseif ($key == 'status_from' || $key == 'status_to') {
  702. print '<span class="badge badge-status' . array_keys($statusesObj[$object->$key])[0] . ' badge-status" title="Szállítás alatt">' . $statusesObj[$object->$key][array_keys($statusesObj[$object->$key])[0]] . '</span>';
  703. } elseif (isset($typeData[1]) && $typeData[1] == 'Entrepot') {
  704. $address = $key == 'warehouse_from' ? 'wh_from_address' : 'wh_to_address';
  705. $lieu = $key == 'warehouse_from' ? 'wh_from_lieu' : 'wh_to_lieu';
  706. print '<div title="<span class=&quot;fas fa-box-open em080&quot; style=&quot; color: #a69944;&quot; cursor: pointer;></span> <u class=&quot;paddingrightonly&quot;>Raktár</u><br>
  707. <b>Ref.:</b> ' . $obj->$address . '<br><b>A hely rövid neve:</b> ' . $obj->$lieu . '" class="classfortooltip">
  708. <span class="fas fa-box-open em080 paddingright classfortooltip" style=" color: #a69944;"></span>
  709. ' . $obj->$lieu . '</div>';
  710. } elseif ($key == 'fk_user_creat') {
  711. print '<span class="fas fa-user infobox-adherent paddingright" style=""></span>' . $obj->login . '(' . $obj->lastname . ' ' . $obj->firstname . ')';
  712. } else {
  713. print $object->showOutputField($val, $key, $object->$key, '');
  714. }
  715. print '</td>';
  716. if (!$i) {
  717. $totalarray['nbfield']++;
  718. }
  719. if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
  720. if (!$i) {
  721. $totalarray['pos'][$totalarray['nbfield']] = 't.' . $key;
  722. }
  723. if (!isset($totalarray['val'])) {
  724. $totalarray['val'] = array();
  725. }
  726. if (!isset($totalarray['val']['t.' . $key])) {
  727. $totalarray['val']['t.' . $key] = 0;
  728. }
  729. $totalarray['val']['t.' . $key] += $object->$key;
  730. }
  731. }
  732. }
  733. // Extra fields
  734. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php';
  735. // Fields from hook
  736. $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
  737. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
  738. print $hookmanager->resPrint;
  739. /*if (!empty($arrayfields['anotherfield']['checked'])) {
  740. print '<td class="right">'.$obj->anotherfield.'</td>';
  741. }*/
  742. // Action column
  743. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  744. print '<td class="nowrap center">';
  745. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  746. $selected = 0;
  747. if (in_array($object->id, $arrayofselected)) {
  748. $selected = 1;
  749. }
  750. print '<input id="cb' . $object->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $object->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
  751. }
  752. print '</td>';
  753. if (!$i) {
  754. $totalarray['nbfield']++;
  755. }
  756. }
  757. print '</tr>' . "\n";
  758. }
  759. $i++;
  760. }
  761. // Show total line
  762. include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php';
  763. // If no record found
  764. if ($num == 0) {
  765. $colspan = 1;
  766. foreach ($arrayfields as $key => $val) {
  767. if (!empty($val['checked'])) {
  768. $colspan++;
  769. }
  770. }
  771. print '<tr><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs->trans("NoRecordFound") . '</span></td></tr>';
  772. }
  773. $db->free($resql);
  774. $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
  775. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  776. print $hookmanager->resPrint;
  777. print '</table>' . "\n";
  778. print '</div>' . "\n";
  779. print '</form>' . "\n";
  780. if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
  781. $hidegeneratedfilelistifempty = 1;
  782. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
  783. $hidegeneratedfilelistifempty = 0;
  784. }
  785. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
  786. $formfile = new FormFile($db);
  787. // Show list of available documents
  788. $urlsource = $_SERVER['PHP_SELF'] . '?sortfield=' . $sortfield . '&sortorder=' . $sortorder;
  789. $urlsource .= str_replace('&amp;', '&', $param);
  790. $filedir = $diroutputmassaction;
  791. $genallowed = $permissiontoread;
  792. $delallowed = $permissiontoadd;
  793. print $formfile->showdocuments('massfilesarea_rollerstorage', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
  794. }
  795. // End of page
  796. llxFooter();
  797. $db->close();