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