list.php 25 KB

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