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