list.php 21 KB

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