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