list.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. <?php
  2. /* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
  3. * Copyright (C) 2019-2020 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/intracommreport/list.php
  20. * \ingroup Intracomm Report
  21. * \brief Page to list intracomm report
  22. */
  23. // Load Dolibarr environment
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/intracommreport/class/intracommreport.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  28. // Load translation files required by the page
  29. $langs->loadLangs(array('intracommreport'));
  30. // Get Parameters
  31. $action = GETPOST('action', 'alpha');
  32. $massaction = GETPOST('massaction', 'alpha');
  33. $show_files = GETPOST('show_files', 'int');
  34. $confirm = GETPOST('confirm', 'alpha');
  35. $toselect = GETPOST('toselect', 'array');
  36. $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
  37. $search_ref = GETPOST("search_ref", 'alpha');
  38. $search_type = GETPOST("search_type", 'int');
  39. $optioncss = GETPOST('optioncss', 'alpha');
  40. $type = GETPOST("type", "int");
  41. $diroutputmassaction = $conf->product->dir_output.'/temp/massgeneration/'.$user->id;
  42. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  43. $sortfield = GETPOST('sortfield', 'aZ09comma');
  44. $sortorder = GETPOST('sortorder', 'aZ09comma');
  45. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  46. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  47. // If $page is not defined, or '' or -1 or if we click on clear filters
  48. $page = 0;
  49. }
  50. $offset = $limit * $page;
  51. $pageprev = $page - 1;
  52. $pagenext = $page + 1;
  53. if (!$sortfield) {
  54. $sortfield = "i.ref";
  55. }
  56. if (!$sortorder) {
  57. $sortorder = "ASC";
  58. }
  59. // Initialize context for list
  60. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'intracommreportlist';
  61. if ((string) $type == '1') {
  62. $contextpage = 'DESlist';
  63. if ($search_type == '') {
  64. $search_type = '1';
  65. }
  66. }
  67. if ((string) $type == '0') {
  68. $contextpage = 'DEBlist';
  69. if ($search_type == '') {
  70. $search_type = '0';
  71. }
  72. }
  73. // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
  74. $object = new IntracommReport($db);
  75. $hookmanager->initHooks(array('intracommreportlist'));
  76. $extrafields = new ExtraFields($db);
  77. $form = new Form($db);
  78. /*
  79. // fetch optionals attributes and labels
  80. $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
  81. $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  82. */
  83. if (empty($action)) {
  84. $action = 'list';
  85. }
  86. // Get object canvas (By default, this is not defined, so standard usage of dolibarr)
  87. $canvas = GETPOST("canvas");
  88. $objcanvas = null;
  89. if (!empty($canvas)) {
  90. require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
  91. $objcanvas = new Canvas($db, $action);
  92. $objcanvas->getCanvas('product', 'list', $canvas);
  93. }
  94. // Security check
  95. /*
  96. if ($search_type=='0') $result=restrictedArea($user, 'produit', '', '', '', '', '', $objcanvas);
  97. elseif ($search_type=='1') $result=restrictedArea($user, 'service', '', '', '', '', '', $objcanvas);
  98. else $result=restrictedArea($user, 'produit|service', '', '', '', '', '', $objcanvas);
  99. */
  100. // List of fields to search into when doing a "search in all"
  101. $fieldstosearchall = array(
  102. 'i.ref'=>"Ref",
  103. 'pfi.ref_fourn'=>"RefSupplier",
  104. 'i.label'=>"ProductLabel",
  105. 'i.description'=>"Description",
  106. "i.note"=>"Note",
  107. );
  108. $isInEEC = isInEEC($mysoc);
  109. // Definition of fields for lists
  110. $arrayfields = array(
  111. 'i.ref' => array('label'=>$langs->trans("Ref"), 'checked'=>1),
  112. 'i.label' => array('label'=>$langs->trans("Label"), 'checked'=>1),
  113. 'i.fk_product_type'=>array('label'=>$langs->trans("Type"), 'checked'=>0, 'enabled'=>(isModEnabled("product") && isModEnabled("service"))),
  114. );
  115. /*
  116. // Extra fields
  117. if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']))
  118. {
  119. foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val)
  120. {
  121. if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
  122. $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs((int) $extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
  123. }
  124. }
  125. */
  126. $object->fields = dol_sort_array($object->fields, 'position');
  127. $arrayfields = dol_sort_array($arrayfields, 'position');
  128. // Security check
  129. if ($search_type == '0') {
  130. $result = restrictedArea($user, 'produit', '', '', '', '', '', 0);
  131. } elseif ($search_type == '1') {
  132. $result = restrictedArea($user, 'service', '', '', '', '', '', 0);
  133. } else {
  134. $result = restrictedArea($user, 'produit|service', '', '', '', '', '', 0);
  135. }
  136. $permissiontoread = $user->rights->intracommreport->read;
  137. $permissiontodelete = $user->rights->intracommreport->delete;
  138. /*
  139. * Actions
  140. */
  141. if (GETPOST('cancel', 'alpha')) {
  142. $action = 'list';
  143. $massaction = '';
  144. }
  145. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  146. $massaction = '';
  147. }
  148. $parameters = array();
  149. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  150. if ($reshook < 0) {
  151. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  152. }
  153. if (empty($reshook)) {
  154. // Selection of new fields
  155. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  156. // Purge search criteria
  157. 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
  158. $search_all = "";
  159. $search_ref = "";
  160. $search_label = "";
  161. //$search_type=''; // There is 2 types of list: a list of product and a list of services. No list with both. So when we clear search criteria, we must keep the filter on type.
  162. $show_childproducts = '';
  163. $search_array_options = array();
  164. }
  165. // Mass actions
  166. $objectclass = 'Product';
  167. if ((string) $search_type == '1') {
  168. $objectlabel = 'Services';
  169. }
  170. if ((string) $search_type == '0') {
  171. $objectlabel = 'Products';
  172. }
  173. $uploaddir = $conf->product->dir_output;
  174. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  175. }
  176. /*
  177. * View
  178. */
  179. $formother = new FormOther($db);
  180. $intracommreport_static = new IntracommReport($db);
  181. $title = $langs->trans('IntracommReportList'.$type);
  182. $helpurl = 'EN:Module_IntracommReport|FR:Module_ProDouane';
  183. // Build and execute select
  184. // --------------------------------------------------------------------
  185. $sql = 'SELECT i.rowid, i.type_declaration, i.type_export, i.periods, i.mode, i.entity';
  186. // Add fields from extrafields
  187. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  188. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  189. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  190. }
  191. }
  192. // Add fields from hooks
  193. $parameters = array();
  194. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  195. $sql .= $hookmanager->resPrint;
  196. $sql = preg_replace('/,\s*$/', '', $sql);
  197. $sql .= $hookmanager->resPrint;
  198. $sqlfields = $sql; // $sql fields to remove for count total
  199. $sql .= ' FROM '.MAIN_DB_PREFIX.'intracommreport as i';
  200. // if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."intracommreport_extrafields as ef on (i.rowid = ef.fk_object)";
  201. $sql .= ' WHERE i.entity IN ('.getEntity('intracommreport').')';
  202. if ($search_all) {
  203. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  204. }
  205. // if the type is not 1, we show all products (type = 0,2,3)
  206. if (dol_strlen($search_type) && $search_type != '-1') {
  207. if ($search_type == 1) {
  208. $sql .= " AND i.type = 1";
  209. } else {
  210. $sql .= " AND i.type = 0";
  211. }
  212. }
  213. /*
  214. if ($search_ref) $sql .= natural_search('i.ref', $search_ref);
  215. if ($search_label) $sql .= natural_search('i.label', $search_label);
  216. if ($search_barcode) $sql .= natural_search('i.barcode', $search_barcode);
  217. if (isset($search_tosell) && dol_strlen($search_tosell) > 0 && $search_tosell!=-1) $sql.= " AND i.tosell = ".((int) $search_tosell);
  218. if (isset($search_tobuy) && dol_strlen($search_tobuy) > 0 && $search_tobuy!=-1) $sql.= " AND i.tobuy = ".((int) $search_tobuy);
  219. if (dol_strlen($canvas) > 0) $sql.= " AND i.canvas = '".$db->escape($canvas)."'";
  220. */
  221. /*
  222. // Add where from extra fields
  223. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  224. */
  225. // Add where from hooks
  226. $parameters = array();
  227. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  228. $sql .= $hookmanager->resPrint;
  229. $sql .= " GROUP BY i.rowid, i.type_declaration, i.type_export, i.periods, i.mode, i.entity";
  230. // Add groupby from hooks
  231. /*
  232. $parameters = array();
  233. $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  234. $sql .= $hookmanager->resPrint;
  235. $sql = preg_replace('/,\s*$/', '', $sql);
  236. */
  237. // Add HAVING from hooks
  238. /*
  239. $parameters = array();
  240. $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  241. $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
  242. */
  243. // Count total nb of records
  244. $nbtotalofrecords = '';
  245. if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
  246. /* The fast and low memory method to get and count full list converts the sql into a sql count */
  247. $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
  248. $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
  249. $resql = $db->query($sqlforcount);
  250. if ($resql) {
  251. $objforcount = $db->fetch_object($resql);
  252. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  253. } else {
  254. dol_print_error($db);
  255. }
  256. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
  257. $page = 0;
  258. $offset = 0;
  259. }
  260. $db->free($resql);
  261. }
  262. // Complete request and execute it with limit
  263. $sql .= $db->order($sortfield, $sortorder);
  264. if ($limit) {
  265. $sql .= $db->plimit($limit + 1, $offset);
  266. }
  267. $resql = $db->query($sql);
  268. if (!$resql) {
  269. dol_print_error($db);
  270. exit;
  271. }
  272. $num = $db->num_rows($resql);
  273. // Output page
  274. // --------------------------------------------------------------------
  275. llxHeader('', $title, $helpurl, '');
  276. // Displays product removal confirmation
  277. if (GETPOST('delreport')) {
  278. setEventMessages($langs->trans("IntracommReportDeleted", GETPOST('delreport')), null, 'mesgs');
  279. }
  280. $arrayofselected = is_array($toselect) ? $toselect : array();
  281. $param = '';
  282. if (!empty($mode)) {
  283. $param .= '&mode='.urlencode($mode);
  284. }
  285. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  286. $param .= '&contextpage='.urlencode($contextpage);
  287. }
  288. if ($limit > 0 && $limit != $conf->liste_limit) {
  289. $param .= '&limit='.((int) $limit);
  290. }
  291. if ($search_all) {
  292. $param .= "&search_all=".urlencode($search_all);
  293. }
  294. if ($search_ref) {
  295. $param = "&search_ref=".urlencode($search_ref);
  296. }
  297. if ($search_label) {
  298. $param .= "&search_label=".urlencode($search_label);
  299. }
  300. if ($optioncss != '') {
  301. $param .= '&optioncss='.urlencode($optioncss);
  302. }
  303. // Add $param from extra fields
  304. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  305. // Add $param from hooks
  306. $parameters = array();
  307. $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
  308. $param .= $hookmanager->resPrint;
  309. // List of mass actions available
  310. $arrayofmassactions = array(
  311. 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  312. //'builddoc'=>$langs->trans("PDFMerge"),
  313. //'presend'=>$langs->trans("SendByMail"),
  314. );
  315. if (!empty($permissiontodelete)) {
  316. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  317. }
  318. if (in_array($massaction, array('presend', 'predelete'))) {
  319. $arrayofmassactions = array();
  320. }
  321. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  322. $newcardbutton = '';
  323. if ($user->hasRight('intracommreport', 'write')) {
  324. $newcardbutton .= dolGetButtonTitle($langs->trans("NewDeclaration"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/intracommreport/card.php?action=create&amp;type='.$type);
  325. }
  326. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="formulaire">';
  327. if ($optioncss != '') {
  328. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  329. }
  330. print '<input type="hidden" name="token" value="'.newToken().'">';
  331. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  332. print '<input type="hidden" name="action" value="list">';
  333. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  334. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  335. print '<input type="hidden" name="page" value="'.$page.'">';
  336. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  337. print '<input type="hidden" name="page_y" value="">';
  338. print '<input type="hidden" name="mode" value="'.$mode.'">';
  339. print '<input type="hidden" name="type" value="'.$type.'">';
  340. if (empty($arrayfields['i.fk_product_type']['checked'])) {
  341. print '<input type="hidden" name="search_type" value="'.dol_escape_htmltag($search_type).'">';
  342. }
  343. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'intracommreport', 0, $newcardbutton, '', $limit);
  344. $topicmail = "Information";
  345. $modelmail = "product";
  346. $objecttmp = new IntracommReport($db);
  347. $trackid = 'prod'.$object->id;
  348. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  349. if ($search_all) {
  350. $setupstring = '';
  351. foreach ($fieldstosearchall as $key => $val) {
  352. $fieldstosearchall[$key] = $langs->trans($val);
  353. $setupstring .= $key."=".$val.";";
  354. }
  355. print '<!-- Search done like if INTRACOMM_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
  356. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
  357. }
  358. $parameters = array();
  359. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  360. if (empty($reshook)) {
  361. $moreforfilter .= $hookmanager->resPrint;
  362. } else {
  363. $moreforfilter = $hookmanager->resPrint;
  364. }
  365. if (!empty($moreforfilter)) {
  366. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  367. print $moreforfilter;
  368. $parameters = array();
  369. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  370. print $hookmanager->resPrint;
  371. print '</div>';
  372. }
  373. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  374. $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
  375. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  376. print '<div class="div-table-responsive">';
  377. print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  378. // Fields title search
  379. // --------------------------------------------------------------------
  380. print '<tr class="liste_titre_filter">';
  381. // Action column
  382. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  383. print '<td class="liste_titre center maxwidthsearch">';
  384. $searchpicto = $form->showFilterButtons('left');
  385. print $searchpicto;
  386. print '</td>';
  387. }
  388. if (!empty($arrayfields['i.ref']['checked'])) {
  389. print '<td class="liste_titre left">';
  390. print '<input class="flat" type="text" name="search_ref" size="8" value="'.dol_escape_htmltag($search_ref).'">';
  391. print '</td>';
  392. }
  393. if (!empty($arrayfields['i.label']['checked'])) {
  394. print '<td class="liste_titre left">';
  395. print '<input class="flat" type="text" name="search_label" size="12" value="'.dol_escape_htmltag($search_label).'">';
  396. print '</td>';
  397. }
  398. // Type
  399. // Type (customer/prospect/supplier)
  400. if (!empty($arrayfields['customerorsupplier']['checked'])) {
  401. print '<td class="liste_titre maxwidthonsmartphone center">';
  402. if ($type != '') {
  403. print '<input type="hidden" name="type" value="'.$type.'">';
  404. }
  405. print $formcompany->selectProspectCustomerType($search_type, 'search_type', 'search_type', 'list');
  406. print '</select></td>';
  407. }
  408. if (!empty($arrayfields['i.fk_product_type']['checked'])) {
  409. print '<td class="liste_titre left">';
  410. $array = array('-1'=>'&nbsp;', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service'));
  411. print $form->selectarray('search_type', $array, $search_type);
  412. print '</td>';
  413. }
  414. /*
  415. // Extra fields
  416. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  417. */
  418. // Fields from hook
  419. $parameters = array('arrayfields'=>$arrayfields);
  420. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  421. print $hookmanager->resPrint;
  422. // Date creation
  423. if (!empty($arrayfields['i.datec']['checked'])) {
  424. print '<td class="liste_titre">';
  425. print '</td>';
  426. }
  427. // Date modification
  428. if (!empty($arrayfields['i.tms']['checked'])) {
  429. print '<td class="liste_titre">';
  430. print '</td>';
  431. }
  432. // Action column
  433. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  434. print '<td class="liste_titre center maxwidthsearch">';
  435. $searchpicto = $form->showFilterButtons();
  436. print $searchpicto;
  437. print '</td>';
  438. }
  439. print '</tr>'."\n";
  440. $totalarray = array();
  441. $totalarray['nbfield'] = 0;
  442. // Fields title label
  443. // --------------------------------------------------------------------
  444. print '<tr class="liste_titre">';
  445. // Action column
  446. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  447. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  448. $totalarray['nbfield']++;
  449. }
  450. if (!empty($arrayfields['i.ref']['checked'])) {
  451. print_liste_field_titre($arrayfields['i.ref']['label'], $_SERVER["PHP_SELF"], "i.ref", "", $param, "", $sortfield, $sortorder);
  452. $totalarray['nbfield']++;
  453. }
  454. if (!empty($arrayfields['i.label']['checked'])) {
  455. print_liste_field_titre($arrayfields['i.label']['label'], $_SERVER["PHP_SELF"], "i.label", "", $param, "", $sortfield, $sortorder);
  456. $totalarray['nbfield']++;
  457. }
  458. if (!empty($arrayfields['i.fk_product_type']['checked'])) {
  459. print_liste_field_titre($arrayfields['i.fk_product_type']['label'], $_SERVER["PHP_SELF"], "i.fk_product_type", "", $param, "", $sortfield, $sortorder);
  460. $totalarray['nbfield']++;
  461. }
  462. /*
  463. // Extra fields
  464. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  465. */
  466. // Hook fields
  467. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  468. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  469. print $hookmanager->resPrint;
  470. if (!empty($arrayfields['i.datec']['checked'])) {
  471. print_liste_field_titre($arrayfields['i.datec']['label'], $_SERVER["PHP_SELF"], "i.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  472. $totalarray['nbfield']++;
  473. }
  474. if (!empty($arrayfields['i.tms']['checked'])) {
  475. print_liste_field_titre($arrayfields['i.tms']['label'], $_SERVER["PHP_SELF"], "i.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  476. $totalarray['nbfield']++;
  477. }
  478. // Action column
  479. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  480. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  481. $totalarray['nbfield']++;
  482. }
  483. print '</tr>'."\n";
  484. // Loop on record
  485. // --------------------------------------------------------------------
  486. $i = 0;
  487. $savnbfield = $totalarray['nbfield'];
  488. $totalarray = array();
  489. $totalarray['nbfield'] = 0;
  490. $imaxinloop = ($limit ? min($num, $limit) : $num);
  491. while ($i < $imaxinloop) {
  492. $obj = $db->fetch_object($resql);
  493. if (empty($obj)) {
  494. break; // Should not happen
  495. }
  496. $intracommreport_static->id = $obj->rowid;
  497. $intracommreport_static->ref = $obj->ref;
  498. $intracommreport_static->ref_fourn = $obj->ref_supplier;
  499. $intracommreport_static->label = $obj->label;
  500. $intracommreport_static->type = $obj->fk_product_type;
  501. $intracommreport_static->status_buy = $obj->tobuy;
  502. $intracommreport_static->status = $obj->tosell;
  503. $intracommreport_static->status_batch = $obj->tobatch;
  504. $intracommreport_static->entity = $obj->entity;
  505. if ($mode == 'kanban') {
  506. if ($i == 0) {
  507. print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
  508. print '<div class="box-flex-container kanban">';
  509. }
  510. // Output Kanban
  511. $selected = -1;
  512. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  513. $selected = 0;
  514. if (in_array($object->id, $arrayofselected)) {
  515. $selected = 1;
  516. }
  517. }
  518. print $object->getKanbanView('', array('selected' => $selected));
  519. if ($i == ($imaxinloop - 1)) {
  520. print '</div>';
  521. print '</td></tr>';
  522. }
  523. } else {
  524. // Show line of result
  525. $j = 0;
  526. print '<tr data-rowid="'.$object->id.'" class="oddeven">';
  527. // Action column
  528. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  529. print '<td class="nowrap center">';
  530. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  531. $selected = 0;
  532. if (in_array($object->id, $arrayofselected)) {
  533. $selected = 1;
  534. }
  535. print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
  536. }
  537. print '</td>';
  538. if (!$i) {
  539. $totalarray['nbfield']++;
  540. }
  541. }
  542. // Ref
  543. if (!empty($arrayfields['i.ref']['checked'])) {
  544. print '<td class="tdoverflowmax200">';
  545. print $intracommreport_static->getNomUrl(1);
  546. print "</td>\n";
  547. if (!$i) {
  548. $totalarray['nbfield']++;
  549. }
  550. }
  551. // Label
  552. if (!empty($arrayfields['i.label']['checked'])) {
  553. print '<td class="tdoverflowmax200">'.dol_trunc($obj->label, 80).'</td>';
  554. if (!$i) {
  555. $totalarray['nbfield']++;
  556. }
  557. }
  558. // Type
  559. if (!empty($arrayfields['i.fk_product_type']['checked'])) {
  560. print '<td>'.$obj->fk_product_type.'</td>';
  561. if (!$i) {
  562. $totalarray['nbfield']++;
  563. }
  564. }
  565. // Action column
  566. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  567. print '<td class="nowrap center">';
  568. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  569. $selected = 0;
  570. if (in_array($obj->rowid, $arrayofselected)) {
  571. $selected = 1;
  572. }
  573. }
  574. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  575. print '</td>';
  576. if (!$i) {
  577. $totalarray['nbfield']++;
  578. }
  579. }
  580. print '</tr>'."\n";
  581. }
  582. $i++;
  583. }
  584. // If no record found
  585. if ($num == 0) {
  586. $colspan = 1;
  587. foreach ($arrayfields as $key => $val) {
  588. if (!empty($val['checked'])) {
  589. $colspan++;
  590. }
  591. }
  592. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  593. }
  594. $db->free($resql);
  595. print "</table>";
  596. print "</div>";
  597. print '</form>';
  598. // End of page
  599. llxFooter();
  600. $db->close();