dolibarr 24.0.0-beta
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-2025 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/intracommreport/class/intracommreport.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
40
41// Load translation files required by the page
42$langs->loadLangs(array('intracommreport'));
43
44// Get parameters
45$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
46$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
47$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
48$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
49$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
50$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
51$optioncss = GETPOST('optioncss', 'alpha');
52$mode = GETPOST('mode', 'aZ');
53$groupby = GETPOST('groupby', 'aZ09'); // Example: $groupby = 'p.fk_opp_status' or $groupby = 'p.fk_statut'
54
55$search_all = trim(GETPOST('search_all', 'alphanohtml'));
56$search_ref = GETPOST("search_ref", 'alpha');
57$search_type = GETPOST("search_type", 'int');
58
59// Initialize context for list
60$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'intracommreportlist';
61// if ((string) $type == '1') {
62// $contextpage = 'DESlist';
63// if ($search_type == '') {
64// $search_type = '1';
65// }
66// }
67// if ((string) $type == '0') {
68// $contextpage = 'DEBlist';
69// if ($search_type == '') {
70// $search_type = '0';
71// }
72// }
73
74$diroutputmassaction = $conf->product->dir_output.'/temp/massgeneration/'.$user->id;
75
76// Load variable for pagination
77$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
78$sortfield = GETPOST('sortfield', 'aZ09comma');
79$sortorder = GETPOST('sortorder', 'aZ09comma');
80$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
81if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
82 // If $page is not defined, or '' or -1 or if we click on clear filters
83 $page = 0;
84}
85$offset = $limit * $page;
86$pageprev = $page - 1;
87$pagenext = $page + 1;
88
89
90// Initialize a technical objects
92
93$diroutputmassaction = $conf->intracommreport->dir_output.'/temp/massgeneration/'.$user->id;
94$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes
95
96// Fetch optionals attributes and labels
97$extrafields->fetch_name_optionals_label($object->table_element);
98//$extrafields->fetch_name_optionals_label($object->table_element_line);
99
100$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
101
102// Default sort order (if not yet defined by previous GETPOST)
103if (!$sortfield) {
104 reset($object->fields); // Reset is required to avoid key() to return null.
105 $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
106}
107if (!$sortorder) {
108 $sortorder = "ASC";
109}
110
111// Initialize array of search criteria
112$search_all = trim(GETPOST('search_all', 'alphanohtml'));
113$search = array();
114foreach ($object->fields as $key => $val) {
115 if (GETPOST('search_'.$key, 'alpha') !== '') {
116 $search[$key] = GETPOST('search_'.$key, 'alpha');
117 }
118 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
119 $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOSTINT('search_'.$key.'_dtstartmonth'), GETPOSTINT('search_'.$key.'_dtstartday'), GETPOSTINT('search_'.$key.'_dtstartyear'));
120 $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_'.$key.'_dtendmonth'), GETPOSTINT('search_'.$key.'_dtendday'), GETPOSTINT('search_'.$key.'_dtendyear'));
121 }
122}
123
124$fieldstosearchall = array(
125 't.ref' => "Ref",
126);
127
128// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
130$hookmanager->initHooks(array('intracommreportlist'));
131$extrafields = new ExtraFields($db);
132$form = new Form($db);
133
134/*
135// fetch optionals attributes and labels
136$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
137$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
138*/
139
140if (empty($action)) {
141 $action = 'list';
142}
143
144
145
146// Definition of array of fields for columns
147$arrayfields = array();
148foreach ($object->fields as $key => $val) {
149 // If $val['visible']==0, then we never show the field
150 if (!empty($val['visible'])) {
151 $visible = (int) dol_eval((string) $val['visible'], 1);
152 $arrayfields['t.'.$key] = array(
153 'label' => $val['label'],
154 'checked' => (($visible < 0) ? 0 : 1),
155 'enabled' => (abs($visible) != 3 && (bool) dol_eval((string) $val['enabled'], 1)),
156 'position' => $val['position'],
157 'help' => isset($val['help']) ? $val['help'] : ''
158 );
159 }
160}
161// Extra fields
162include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
163
164$object->fields = dol_sort_array($object->fields, 'position');
165//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right');
166$arrayfields = dol_sort_array($arrayfields, 'position');
167
168
169//$isInEEC = isInEEC($mysoc);
170
171
172$permissiontoread = $user->hasRight('intracommreport', 'read');
173$permissiontoadd = $user->hasRight('intracommreport', 'write');
174$permissiontodelete = $user->hasRight('intracommreport', 'delete');
175
176// Security check
177if ($search_type == '0') {
178 $result = restrictedArea($user, 'produit', '', '', '', '', '', 0);
179} elseif ($search_type == '1') {
180 $result = restrictedArea($user, 'service', '', '', '', '', '', 0);
181} else {
182 $result = restrictedArea($user, 'produit|service', '', '', '', '', '', 0);
183}
184
185if (!isModEnabled("intracommreport")) {
186 accessforbidden('Module intracommreport not enabled');
187}
188
189
190
191/*
192 * Actions
193 */
194
195if (GETPOST('cancel', 'alpha')) {
196 $action = 'list';
197 $massaction = '';
198}
199if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
200 $massaction = '';
201}
202
203$parameters = array();
204$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
205if ($reshook < 0) {
206 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
207}
208
209if (empty($reshook)) {
210 // Selection of new fields
211 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
212
213 // Purge search criteria
214 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
215 $search_all = "";
216 $search_ref = "";
217 //$search_label = "";
218 //$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.
219
220 //$show_childproducts = '';
221 $search_array_options = array();
222 }
223
224 // Mass actions
225 $objectclass = 'Product';
226 if ((string) $search_type == '1') {
227 $objectlabel = 'Services';
228 }
229 if ((string) $search_type == '0') {
230 $objectlabel = 'Products';
231 }
232
233 $uploaddir = $conf->product->dir_output;
234 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
235}
236
237
238/*
239 * View
240 */
241
242$form = new Form($db);
243
244$now = dol_now();
245
246$title = $langs->trans("IntraCommReports");
247//$help_url = "EN:Module_IntraCommReport|FR:Module_IntraCommReport_FR|ES:Módulo_IntraCommReport";
248$help_url = '';
249$morejs = array();
250$morecss = array();
251
252
253// Build and execute select
254// --------------------------------------------------------------------
255$sql = 'SELECT ';
256$sql .= $object->getFieldList('t');
257// Add fields from extrafields
258if (!empty($extrafields->attributes[$object->table_element]['label'])) {
259 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
260 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : "");
261 }
262}
263// Add fields from hooks
264$parameters = array();
265$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
266$sql .= $hookmanager->resPrint;
267$sql = preg_replace('/,\s*$/', '', $sql);
268
269$sqlfields = $sql; // $sql fields to remove for count total
270
271$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
272//$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."anothertable as rc ON rc.parent = t.rowid";
273if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
274 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
275}
276// Add table from hooks
277$parameters = array();
278$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
279$sql .= $hookmanager->resPrint;
280if ($object->ismultientitymanaged == 1) {
281 $sql .= " WHERE t.entity IN (".getEntity($object->element, (GETPOSTINT('search_current_entity') ? 0 : 1)).")";
282} else {
283 $sql .= " WHERE 1 = 1";
284}
285foreach ($search as $key => $val) {
286 if (array_key_exists($key, $object->fields)) {
287 if ($key == 'status' && $search[$key] == -1) {
288 continue;
289 }
290 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
291 if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
292 if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
293 $search[$key] = '';
294 }
295 $mode_search = 2;
296 }
297 if ($search[$key] != '') {
298 $sql .= natural_search("t.".$db->sanitize($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
299 }
300 } else {
301 if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
302 $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
303 if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
304 if (preg_match('/_dtstart$/', $key)) {
305 $sql .= " AND t.".$db->sanitize($columnName)." >= '".$db->idate($search[$key])."'";
306 }
307 if (preg_match('/_dtend$/', $key)) {
308 $sql .= " AND t.".$db->sanitize($columnName)." <= '".$db->idate($search[$key])."'";
309 }
310 }
311 }
312 }
313}
314if ($search_all) {
315 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
316}
317/*
318 // If the internal user must only see his customers, force searching by him
319 $search_sale = 0;
320 if (!$user->hasRight('societe', 'client', 'voir')) {
321 $search_sale = $user->id;
322 }
323 // Search on sale representative
324 if ($search_sale && $search_sale != '-1') {
325 if ($search_sale == -2) {
326 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)";
327 } elseif ($search_sale > 0) {
328 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
329 }
330 }
331 // Search on socid
332 if ($socid) {
333 $sql .= " AND t.fk_soc = ".((int) $socid);
334 }
335 */
336//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
337// Add where from extra fields
338include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
339// Add where from hooks
340$parameters = array();
341$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
342$sql .= $hookmanager->resPrint;
343
344// Count total nb of records
345$nbtotalofrecords = '';
346if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
347 /* The fast and low memory method to get and count full list converts the sql into a sql count */
348 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
349 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
350
351 $resql = $db->query($sqlforcount);
352 if ($resql) {
353 $objforcount = $db->fetch_object($resql);
354 $nbtotalofrecords = $objforcount->nbtotalofrecords;
355 } else {
357 }
358
359 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
360 $page = 0;
361 $offset = 0;
362 }
363 $db->free($resql);
364}
365
366// Complete request and execute it with limit
367$sql .= $db->order($sortfield, $sortorder);
368if ($limit) {
369 $sql .= $db->plimit($limit + 1, $offset);
370}
371
372$resql = $db->query($sql);
373if (!$resql) {
375 exit;
376}
377
378$num = $db->num_rows($resql);
379
380
381// Direct jump if only one record found
382if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
383 $obj = $db->fetch_object($resql);
384 $id = $obj->rowid;
385 header("Location: ".dol_buildpath('/intracommreport/card.php', 1).'?id='.((int) $id));
386 exit;
387}
388
389
390// Output page
391// --------------------------------------------------------------------
392
393llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-mymodule page-list bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
394
395$arrayofselected = is_array($toselect) ? $toselect : array();
396
397$param = '';
398if (!empty($mode)) {
399 $param .= '&mode='.urlencode($mode);
400}
401if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
402 $param .= '&contextpage='.urlencode($contextpage);
403}
404if ($limit > 0 && $limit != $conf->liste_limit) {
405 $param .= '&limit='.((int) $limit);
406}
407if ($optioncss != '') {
408 $param .= '&optioncss='.urlencode($optioncss);
409}
410if ($groupby != '') {
411 $param .= '&groupby='.urlencode($groupby);
412}
413foreach ($search as $key => $val) {
414 if (is_array($search[$key])) {
415 foreach ($search[$key] as $skey) {
416 if ($skey != '') {
417 $param .= '&search_'.$key.'[]='.urlencode($skey);
418 }
419 }
420 } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
421 $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int'));
422 $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int'));
423 $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int'));
424 } elseif ($search[$key] != '') {
425 $param .= '&search_'.$key.'='.urlencode($search[$key]);
426 }
427}
428// Add $param from extra fields
429include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
430// Add $param from hooks
431$parameters = array('param' => &$param);
432$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
433$param .= $hookmanager->resPrint;
434
435// List of mass actions available
436$arrayofmassactions = array(
437 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
438 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
439 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
440 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
441);
442if (!empty($permissiontodelete)) {
443 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
444}
445if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
446 $arrayofmassactions = array();
447}
448$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
449
450print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
451if ($optioncss != '') {
452 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
453}
454print '<input type="hidden" name="token" value="'.newToken().'">';
455print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
456print '<input type="hidden" name="action" value="list">';
457print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
458print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
459print '<input type="hidden" name="page" value="'.$page.'">';
460print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
461print '<input type="hidden" name="page_y" value="">';
462print '<input type="hidden" name="mode" value="'.$mode.'">';
463
464
465$newcardbutton = '';
466$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
467$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
468$newcardbutton .= dolGetButtonTitleSeparator();
469$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/intracommreport/card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
470
471print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
472
473// Add code for pre mass action (confirmation or email presend form)
474$topicmail = "SendIntraCommReportRef";
475$modelmail = "intracommreport";
476$objecttmp = new IntracommReport($db);
477$trackid = 'xxxx'.$object->id;
478include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
479
480if ($search_all) {
481 $setupstring = '';
482 foreach ($fieldstosearchall as $key => $val) {
483 $fieldstosearchall[$key] = $langs->trans($val);
484 $setupstring .= $key."=".$val.";";
485 }
486 print '<!-- Search done like if INTRACOMMREPORT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
487 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
488}
489
490$moreforfilter = '';
491/*$moreforfilter.='<div class="divsearchfield">';
492 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
493 $moreforfilter.= '</div>';*/
494
495$parameters = array();
496$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
497if (empty($reshook)) {
498 $moreforfilter .= $hookmanager->resPrint;
499} else {
500 $moreforfilter = $hookmanager->resPrint;
501}
502
503if (!empty($moreforfilter)) {
504 print '<div class="liste_titre liste_titre_bydiv centpercent">';
505 print $moreforfilter;
506 print '</div>';
507}
508
509$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
510$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, (string) $conf->main_checkbox_left_column ? 'left' : ''); // This also change content of $arrayfields with user setup
511$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
512$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
513
514print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
515print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
516
517// Fields title search
518// --------------------------------------------------------------------
519print '<tr class="liste_titre_filter">';
520// Action column
521if ($conf->main_checkbox_left_column) {
522 print '<td class="liste_titre center maxwidthsearch">';
523 $searchpicto = $form->showFilterButtons('left');
524 print $searchpicto;
525 print '</td>';
526}
527foreach ($object->fields as $key => $val) {
528 //$searchkey = empty($search[$key]) ? '' : $search[$key];
529 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
530 if ($key == 'status') {
531 $cssforfield .= ($cssforfield ? ' ' : '').'center';
532 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
533 $cssforfield .= ($cssforfield ? ' ' : '').'center';
534 } elseif (in_array($val['type'], array('timestamp'))) {
535 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
536 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
537 $cssforfield .= ($cssforfield ? ' ' : '').'right';
538 }
539 if (!empty($arrayfields['t.'.$key]['checked'])) {
540 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
541 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
542 print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), 1, 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
543 } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
544 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
545 } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
546 print '<div class="nowrap">';
547 print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
548 print '</div>';
549 print '<div class="nowrap">';
550 print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
551 print '</div>';
552 } elseif ($key == 'lang') {
553 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
554 $formadmin = new FormAdmin($db);
555 print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2);
556 } else {
557 print '<input type="text" class="flat maxwidth'.($val['type'] == 'integer' ? '50' : '75').'" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
558 }
559 print '</td>';
560 }
561}
562// Extra fields
563include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
564
565// Fields from hook
566$parameters = array('arrayfields' => $arrayfields);
567$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
568print $hookmanager->resPrint;
569/*if (!empty($arrayfields['anotherfield']['checked'])) {
570 print '<td class="liste_titre"></td>';
571 }*/
572// Action column
573if (!$conf->main_checkbox_left_column) {
574 print '<td class="liste_titre center maxwidthsearch">';
575 $searchpicto = $form->showFilterButtons();
576 print $searchpicto;
577 print '</td>';
578}
579print '</tr>'."\n";
580
581$totalarray = array();
582$totalarray['nbfield'] = 0;
583
584// Fields title label
585// --------------------------------------------------------------------
586print '<tr class="liste_titre">';
587// Action column
588if ($conf->main_checkbox_left_column) {
589 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
590 $totalarray['nbfield']++;
591}
592foreach ($object->fields as $key => $val) {
593 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
594 if ($key == 'status') {
595 $cssforfield .= ($cssforfield ? ' ' : '').'center';
596 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
597 $cssforfield .= ($cssforfield ? ' ' : '').'center';
598 } elseif (in_array($val['type'], array('timestamp'))) {
599 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
600 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
601 $cssforfield .= ($cssforfield ? ' ' : '').'right';
602 }
603 $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
604 if (!empty($arrayfields['t.'.$key]['checked'])) {
605 print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), 0, (empty($val['helplist']) ? '' : $val['helplist']))."\n";
606 $totalarray['nbfield']++;
607 }
608}
609// Extra fields
610include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
611// Hook fields
612$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
613$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
614print $hookmanager->resPrint;
615/*if (!empty($arrayfields['anotherfield']['checked'])) {
616 print '<th class="liste_titre right">'.$langs->trans("AnotherField").'</th>';
617 $totalarray['nbfield']++;
618 }*/
619// Action column
620if (!$conf->main_checkbox_left_column) {
621 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
622 $totalarray['nbfield']++;
623}
624print '</tr>'."\n";
625
626// Detect if we need a fetch on each output line
627$needToFetchEachLine = 0;
628if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
629 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
630 if (!is_null($val) && preg_match('/\$object/', $val)) {
631 $needToFetchEachLine++; // There is at least one compute field that use $object
632 }
633 }
634}
635
636
637// Loop on record
638// --------------------------------------------------------------------
639$i = 0;
640$savnbfield = $totalarray['nbfield'];
641$totalarray = array();
642$totalarray['nbfield'] = 0;
643$imaxinloop = ($limit ? min($num, $limit) : $num);
644while ($i < $imaxinloop) {
645 $obj = $db->fetch_object($resql);
646 if (empty($obj)) {
647 break; // Should not happen
648 }
649
650 // Store properties in $object
651 $object->setVarsFromFetchObj($obj);
652
653 /*
654 $object->thirdparty = null;
655 if ($obj->fk_soc > 0) {
656 if (!empty($conf->cache['thirdparty'][$obj->fk_soc])) {
657 $companyobj = $conf->cache['thirdparty'][$obj->fk_soc];
658 } else {
659 $companyobj = new Societe($db);
660 $companyobj->fetch($obj->fk_soc);
661 $conf->cache['thirdparty'][$obj->fk_soc] = $companyobj;
662 }
663
664 $object->thirdparty = $companyobj;
665 }*/
666
667 if ($mode == 'kanban') {
668 if ($i == 0) {
669 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
670 print '<div class="box-flex-container kanban">';
671 }
672 // Output Kanban
673 $selected = -1;
674 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
675 $selected = 0;
676 if (in_array($object->id, $arrayofselected)) {
677 $selected = 1;
678 }
679 }
680 //print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected));
681 print $object->getKanbanView('', array('selected' => $selected));
682 if ($i == ($imaxinloop - 1)) {
683 print '</div>';
684 print '</td></tr>';
685 }
686 } else {
687 // Show line of result
688 $j = 0;
689 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
690
691 // Action column
692 if ($conf->main_checkbox_left_column) {
693 print '<td class="nowrap center">';
694 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
695 $selected = 0;
696 if (in_array($object->id, $arrayofselected)) {
697 $selected = 1;
698 }
699 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
700 }
701 print '</td>';
702 if (!$i) {
703 $totalarray['nbfield']++;
704 }
705 }
706 // Fields
707 foreach ($object->fields as $key => $val) {
708 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
709 if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
710 $cssforfield .= ($cssforfield ? ' ' : '').'center';
711 } elseif ($key == 'status') {
712 $cssforfield .= ($cssforfield ? ' ' : '').'center';
713 }
714
715 if (in_array($val['type'], array('timestamp'))) {
716 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
717 } elseif ($key == 'ref') {
718 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
719 }
720
721 if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && empty($val['arrayofkeyval'])) {
722 $cssforfield .= ($cssforfield ? ' ' : '').'right';
723 }
724 //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
725
726 if (!empty($arrayfields['t.'.$key]['checked'])) {
727 print '<td'.($cssforfield ? ' class="'.$cssforfield.((preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) ? ' classfortooltip' : '').'"' : '');
728 if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) {
729 print ' title="'.dol_escape_htmltag((string) $object->$key).'"';
730 }
731 print '>';
732 if ($key == 'status') {
733 print $object->getLibStatut(5);
734 } elseif ($key == 'rowid') {
735 print $object->showOutputField($val, $key, (string) $object->id, '');
736 } else {
737 print $object->showOutputField($val, $key, $object->$key, '');
738 }
739 print '</td>';
740 if (!$i) {
741 $totalarray['nbfield']++;
742 }
743 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
744 if (!$i) {
745 $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
746 }
747 if (!isset($totalarray['val'])) {
748 $totalarray['val'] = array();
749 }
750 if (!isset($totalarray['val']['t.'.$key])) {
751 $totalarray['val']['t.'.$key] = 0;
752 }
753 $totalarray['val']['t.'.$key] += $object->$key;
754 }
755 }
756 }
757 // Extra fields
758 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
759 // Fields from hook
760 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
761 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
762 print $hookmanager->resPrint;
763
764 /*if (!empty($arrayfields['anotherfield']['checked'])) {
765 print '<td class="right">'.$obj->anotherfield.'</td>';
766 }*/
767
768 // Action column
769 if (empty($conf->main_checkbox_left_column)) {
770 print '<td class="nowrap center">';
771 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
772 $selected = 0;
773 if (in_array($object->id, $arrayofselected)) {
774 $selected = 1;
775 }
776 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
777 }
778 print '</td>';
779 if (!$i) {
780 $totalarray['nbfield']++;
781 }
782 }
783
784 print '</tr>'."\n";
785 }
786
787 $i++;
788}
789
790// Show total line
791include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
792
793// If no record found
794if ($num == 0) {
795 $colspan = 1;
796 foreach ($arrayfields as $key => $val) {
797 if (!empty($val['checked'])) {
798 $colspan++;
799 }
800 }
801 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
802}
803
804
805$db->free($resql);
806
807$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
808$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
809print $hookmanager->resPrint;
810
811print '</table>'."\n";
812print '</div>'."\n";
813
814print '</form>'."\n";
815
816if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
817 $hidegeneratedfilelistifempty = 1;
818 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
819 $hidegeneratedfilelistifempty = 0;
820 }
821
822 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
823 $formfile = new FormFile($db);
824
825 // Show list of available documents
826 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
827 $urlsource .= str_replace('&amp;', '&', $param);
828
829 $filedir = $diroutputmassaction;
830 $genallowed = $permissiontoread;
831 $delallowed = $permissiontoadd;
832
833 print $formfile->showdocuments('massfilesarea_'.$object->module, '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
834}
835
836// End of page
837llxFooter();
838$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:497
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage standard extra fields.
Class to generate html code for admin pages.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage intracomm report.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
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.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
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...
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.