dolibarr 24.0.0-beta
myobject_list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) ---Replace with your own copyright and developer email---
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// General defined Options
27//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
28//if (! defined('MAIN_AUTHENTICATION_MODE')) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
29//if (! defined('MAIN_LANG_DEFAULT')) define('MAIN_LANG_DEFAULT', 'auto'); // Force LANG (language) to a particular value
30//if (! defined('MAIN_SECURITY_FORCECSP')) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies
31//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
32//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
33//if (! defined('NOLOGIN')) define('NOLOGIN', '1'); // Do not use login - if this page is public (can be called outside logged session). This includes the NOIPCHECK too.
34//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
35//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
36//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // Do not load html.form.class.php
37//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // Do not load and show top and left menu
38//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
39//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
40//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
41//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
42//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
43//if (! defined('NOSESSION')) define('NOSESSION', '1'); // On CLI mode, no need to use web sessions
44//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
45//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
46
47
48// Load Dolibarr environment
49$res = 0;
50// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
51if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
52 $res = @include str_replace("..", "", $_SERVER["CONTEXT_DOCUMENT_ROOT"])."/main.inc.php";
53}
54// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
55$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME'];
56$tmp2 = realpath(__FILE__);
57$i = strlen($tmp) - 1;
58$j = strlen($tmp2) - 1;
59while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
60 $i--;
61 $j--;
62}
63if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
64 $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
65}
66if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
67 $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
68}
69// Try main.inc.php using relative path
70if (!$res && file_exists("../main.inc.php")) {
71 $res = @include "../main.inc.php";
72}
73if (!$res && file_exists("../../main.inc.php")) {
74 $res = @include "../../main.inc.php";
75}
76if (!$res && file_exists("../../../main.inc.php")) {
77 $res = @include "../../../main.inc.php";
78}
79if (!$res) {
80 die("Include of main fails");
81}
90include_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
91include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
92include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
93// load module libraries
94include_once __DIR__.'/class/myobject.class.php';
95// for other modules
96//dol_include_once('/othermodule/class/otherobject.class.php');
97
98// Load translation files required by the page
99$langs->loadLangs(array("mymodule@mymodule", "other"));
100
101// Get parameters
102$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
103$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
104$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
105$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
106$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
107$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
108$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : getDolDefaultContextPage(__FILE__); // To manage different context of search
109$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
110$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
111$mode = GETPOST('mode', 'aZ'); // The display mode ('list', 'kanban', 'hierarchy', 'calendar', 'gantt', ...)
112$groupby = GETPOST('groupby', 'aZ09'); // Example: $groupby = 'p.fk_opp_status' or $groupby = 'p.fk_statut'
113
114$id = GETPOSTINT('id');
115$ref = GETPOST('ref', 'alpha');
116
117// Load variable for pagination
118$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
119$sortfield = GETPOST('sortfield', 'aZ09comma');
120$sortorder = GETPOST('sortorder', 'aZ09comma');
121$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
122if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
123 // If $page is not defined, or '' or -1 or if we click on clear filters
124 $page = 0;
125}
126$offset = $limit * $page;
127$pageprev = $page - 1;
128$pagenext = $page + 1;
129
130// Initialize technical objects
131$object = new MyObject($db);
132$extrafields = new ExtraFields($db);
133$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id;
134$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes
135
136// Fetch optionals attributes and labels
137$extrafields->fetch_name_optionals_label($object->table_element);
138//$extrafields->fetch_name_optionals_label($object->table_element_line);
139
140$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
141
142// Default sort order (if not yet defined by previous GETPOST)
143if (!$sortfield) {
144 reset($object->fields); // Reset is required to avoid key() to return null.
145 $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
146}
147if (!$sortorder) {
148 $sortorder = "ASC";
149}
150
151// Initialize array of search criteria
152$search_all = trim(GETPOST('search_all', 'alphanohtml'));
153$search = array();
154foreach ($object->fields as $key => $val) {
155 if (GETPOST('search_'.$key, 'alpha') !== '') {
156 $search[$key] = GETPOST('search_'.$key, 'alpha');
157 }
158 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
159 $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOSTINT('search_'.$key.'_dtstartmonth'), GETPOSTINT('search_'.$key.'_dtstartday'), GETPOSTINT('search_'.$key.'_dtstartyear'));
160 $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_'.$key.'_dtendmonth'), GETPOSTINT('search_'.$key.'_dtendday'), GETPOSTINT('search_'.$key.'_dtendyear'));
161 }
162}
163
164// List of fields to search into when doing a "search in all"
165$fieldstosearchall = array();
166// foreach ($object->fields as $key => $val) {
167// if (!empty($val['searchall'])) {
168// $fieldstosearchall['t.'.$key] = $val['label'];
169// }
170// }
171// $parameters = array('fieldstosearchall'=>$fieldstosearchall);
172// $reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
173// if ($reshook > 0) {
174// $fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall'];
175// } elseif ($reshook == 0) {
176// $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']);
177// }
178
179// Definition of array of fields for columns from ->fields
180$tableprefix = 't';
181$arrayfields = array();
182foreach ($object->fields as $key => $val) {
183 // If $val['visible']==0, then we never show the field
184 if (!empty($val['visible'])) {
185 $visible = (int) dol_eval((string) $val['visible'], 1);
186 $arrayfields[$tableprefix.'.'.$key] = array(
187 'label' => $val['label'],
188 'checked' => (($visible < 0) ? '0' : '1'),
189 'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval((string) $val['enabled'], 1)),
190 'position' => $val['position'],
191 'help' => isset($val['help']) ? $val['help'] : ''
192 );
193 }
194}
195
196// Extra fields
197include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
198// Add hook to complete $arrayfield
199$parameters = array('arrayfields' => &$arrayfields);
200$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
201
202// Complete arrayfields with special fields
203/*$arrayfields = array_merge($arrayfields, array(
204 'anotherfield' => array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>'1', 'enabled'=>'1', 'position'=>'90', 'csslist'=>'right'),
205));*/
206
207// Change position of fields in arrayfield and object
208include DOL_DOCUMENT_ROOT.'/core/tpl/arrayfield_object_position_fields.tpl.php';
209
210$object->fields = dol_sort_array($object->fields, 'position');
211$arrayfields = dol_sort_array($arrayfields, 'position');
212
213// There is several ways to check permission.
214// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
215$enablepermissioncheck = getDolGlobalInt('MYMODULE_ENABLE_PERMISSION_CHECK');
216if ($enablepermissioncheck) {
217 $permissiontoread = $user->hasRight('mymodule', 'myobject', 'read');
218 $permissiontoadd = $user->hasRight('mymodule', 'myobject', 'write');
219 $permissiontodelete = $user->hasRight('mymodule', 'myobject', 'delete');
220} else {
221 $permissiontoread = 1;
222 $permissiontoadd = 1;
223 $permissiontodelete = 1;
224}
225
226// Security check (enable the most restrictive one)
227if ($user->socid > 0) {
229}
230//if ($user->socid > 0) accessforbidden();
231//$socid = 0; if ($user->socid > 0) $socid = $user->socid;
232//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
233//restrictedArea($user, $object->module, 0, $object->table_element, $object->element, 'fk_soc', 'rowid', $isdraft);
234if (!isModEnabled("mymodule")) {
235 accessforbidden('Module mymodule not enabled');
236}
237if (!$permissiontoread) {
239}
240
241
242/*
243 * Actions
244 */
245
246if (GETPOST('cancel', 'alpha')) {
247 $action = 'list';
248 $massaction = '';
249}
250if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
251 $massaction = '';
252}
253
254$parameters = array('arrayfields' => &$arrayfields);
255$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
256if ($reshook < 0) {
257 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
258}
259
260if (empty($reshook)) {
261 // Selection of new fields
262 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
263
264 // Purge search criteria
265 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
266 foreach ($object->fields as $key => $val) {
267 $search[$key] = '';
268 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
269 $search[$key.'_dtstart'] = '';
270 $search[$key.'_dtend'] = '';
271 }
272 }
273 $search_all = '';
274 $toselect = array();
275 $search_array_options = array();
276 }
277 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
278 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
279 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
280 }
281
282 // Mass actions
283 $objectclass = 'MyObject';
284 $objectlabel = 'MyObject';
285 $uploaddir = $conf->mymodule->dir_output;
286
287 global $error;
288 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
289
290 // You can add more action here
291 // if ($action == 'xxx' && $permissiontoxxx) ...
292}
293
294
295
296/*
297 * View
298 */
299
300$form = new Form($db);
301
302$now = dol_now();
303
304$title = $langs->trans("MyObjects");
305//$help_url = "EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject";
306$help_url = '';
307$morejs = array();
308$morecss = array();
309
310
311// Build and execute select
312// --------------------------------------------------------------------
313$sql = "SELECT";
314$sql .= " ".$object->getFieldList('t');
315// Add fields from extrafields
316if (!empty($extrafields->attributes[$object->table_element]['label'])) {
317 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
318 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : "");
319 }
320}
321// Add fields from hooks
322$parameters = array();
323$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
324$sql .= $hookmanager->resPrint;
325$sql = preg_replace('/,\s*$/', '', $sql);
326
327$sqlfields = $sql; // $sql fields to remove for count total
328
329$sql .= " FROM ".$db->prefix().$object->table_element." as t";
330//$sql .= " LEFT JOIN ".$db->prefix()."anothertable as rc ON rc.parent = t.rowid";
331if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
332 $sql .= " LEFT JOIN ".$db->prefix().$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
333}
334// Add table from hooks
335$parameters = array();
336$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
337$sql .= $hookmanager->resPrint;
338
339if (!empty($object->ismultientitymanaged) && (int) $object->ismultientitymanaged == 1) {
340 $sql .= " WHERE t.entity IN (".getEntity($object->element, (GETPOSTINT('search_current_entity') ? 0 : 1)).")";
341} elseif (preg_match('/^\w+@\w+$/', (string) $object->ismultientitymanaged)) {
342 $tmparray = explode('@', (string) $object->ismultientitymanaged);
343 $sql .= " LEFT JOIN ".$object->db->prefix().$tmparray[1]." as pt ON t.".$db->sanitize($tmparray[0])." = pt.rowid";
344 $sql .= " WHERE pt.entity IN (".getEntity($object->element, (GETPOSTINT('search_current_entity') ? 0 : 1)).")";
345} else {
346 $sql .= " WHERE 1 = 1";
347}
348foreach ($search as $key => $val) {
349 if (array_key_exists($key, $object->fields)) {
350 if ($key == 'status' && $search[$key] == -1) {
351 continue;
352 }
353 $field_spec = $object->fields[$key];
354 // Ignore false positive @phan-suppress-next-line PhanTypeMismatchArgumentNullable
355 $mode_search = (($object->isInt($field_spec) || $object->isFloat($field_spec)) ? 1 : 0);
356 if ((strpos($field_spec['type'], 'integer:') === 0) || (strpos($field_spec['type'], 'sellist:') === 0) || !empty($field_spec['arrayofkeyval'])) {
357 if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($field_spec['arrayofkeyval']) || !array_key_exists('0', $field_spec['arrayofkeyval'])))) {
358 $search[$key] = '';
359 }
360 $mode_search = 2;
361 }
362 if ($field_spec['type'] === 'boolean') {
363 $mode_search = 1;
364 if ($search[$key] == '-1') {
365 $search[$key] = '';
366 }
367 }
368 if (empty($field_spec['searchmulti'])) {
369 if (!is_array($search[$key]) && $search[$key] != '') {
370 $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
371 }
372 } else {
373 if (is_array($search[$key]) && !empty($search[$key])) {
374 $sql .= natural_search("t.".$db->escape($key), implode(',', $search[$key]), (($key == 'status') ? 2 : $mode_search));
375 }
376 }
377 } else {
378 if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
379 $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
380 if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
381 if (preg_match('/_dtstart$/', $key)) {
382 $sql .= " AND t.".$db->sanitize($columnName)." >= '".$db->idate($search[$key])."'";
383 }
384 if (preg_match('/_dtend$/', $key)) {
385 $sql .= " AND t.".$db->sanitize($columnName)." <= '".$db->idate($search[$key])."'";
386 }
387 }
388 }
389 }
390}
391if ($search_all) {
392 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
393}
394/*
395// If the internal user must only see his customers, force searching by him
396$search_sale = 0;
397if (!$user->hasRight('societe', 'client', 'voir')) {
398 $search_sale = $user->id;
399}
400// Search on sale representative
401if ($search_sale && $search_sale != '-1') {
402 if ($search_sale == -2) {
403 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".$db->prefix()."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)";
404 } elseif ($search_sale > 0) {
405 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".$db->prefix()."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
406 }
407}
408// Search on socid
409if ($socid) {
410 $sql .= " AND t.fk_soc = ".((int) $socid);
411}
412*/
413//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
414// Add where from extra fields
415include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
416// Add where from hooks
417$parameters = array();
418$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
419$sql .= $hookmanager->resPrint;
420
421/* If a group by is required
422$sql .= " GROUP BY ";
423foreach($object->fields as $key => $val) {
424 $sql .= "t.".$db->sanitize($key).", ";
425}
426// Add fields from extrafields
427if (!empty($extrafields->attributes[$object->table_element]['label'])) {
428 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
429 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
430 }
431}
432// Add groupby from hooks
433$parameters = array();
434$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
435if (empty($reshook)) {
436 $sql .= $hookmanager->resPrint;
437} else {
438 $sql = $hookmanager->resPrint;
439}
440
441$sql = preg_replace('/,\s*$/', '', $sql);
442*/
443
444// Add HAVING from hooks
445/*
446$parameters = array();
447$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
448if (empty($reshook)) {
449 $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
450} else {
451 $sql = $hookmanager->resPrint;
452}
453*/
454
455// Count total nb of records
456$nbtotalofrecords = '';
457if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
458 /* The fast and low memory method to get and count full list converts the sql into a sql count */
459 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
460 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
461
462 $resql = $db->query($sqlforcount);
463 if ($resql) {
464 $objforcount = $db->fetch_object($resql);
465 $nbtotalofrecords = $objforcount->nbtotalofrecords;
466 } else {
468 }
469
470 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
471 $page = 0;
472 $offset = 0;
473 }
474 $db->free($resql);
475}
476
477// Complete request and execute it with limit
478$sql .= $db->order($sortfield, $sortorder);
479if ($limit) {
480 $sql .= $db->plimit($limit + 1, $offset);
481}
482
483$resql = $db->query($sql);
484if (!$resql) {
486 exit;
487}
488
489$num = $db->num_rows($resql);
490
491
492// Direct jump if only one record found
493if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
494 $obj = $db->fetch_object($resql);
495 $id = $obj->rowid;
496 header("Location: ".dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.((int) $id));
497 exit;
498}
499
500
501// Output page
502// --------------------------------------------------------------------
503
504llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-mymodule page-list bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for a horizontal scroll in the table instead of page
505
506// Example : Adding jquery code
507// print '<script type="text/javascript">
508// jQuery(document).ready(function() {
509// function init_myfunc()
510// {
511// jQuery("#myid").removeAttr(\'disabled\');
512// jQuery("#myid").attr(\'disabled\',\'disabled\');
513// }
514// init_myfunc();
515// jQuery("#mybutton").click(function() {
516// init_myfunc();
517// });
518// });
519// </script>';
520
521$arrayofselected = is_array($toselect) ? $toselect : array();
522
523$param = '';
524if (!empty($mode)) {
525 $param .= '&mode='.urlencode($mode);
526}
527if (!empty($contextpage) && $contextpage != getDolDefaultContextPage(__FILE__)) {
528 $param .= '&contextpage='.urlencode($contextpage);
529}
530if ($limit > 0 && $limit != $conf->liste_limit) {
531 $param .= '&limit='.((int) $limit);
532}
533if ($optioncss != '') {
534 $param .= '&optioncss='.urlencode($optioncss);
535}
536if ($groupby != '') {
537 $param .= '&groupby='.urlencode($groupby);
538}
539foreach ($search as $key => $val) {
540 if (is_array($search[$key])) {
541 foreach ($search[$key] as $skey) {
542 if ($skey != '') {
543 $param .= '&search_'.$key.'[]='.urlencode($skey);
544 }
545 }
546 } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
547 $param .= '&search_'.$key.'month='.GETPOSTINT('search_'.$key.'month');
548 $param .= '&search_'.$key.'day='.GETPOSTINT('search_'.$key.'day');
549 $param .= '&search_'.$key.'year='.GETPOSTINT('search_'.$key.'year');
550 } elseif ($search[$key] != '') {
551 $param .= '&search_'.$key.'='.urlencode((string) $search[$key]);
552 }
553}
554// Add $param from extra fields
555include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
556// Add $param from hooks
557$parameters = array('param' => &$param);
558$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
559$param .= $hookmanager->resPrint;
560
561// List of mass actions available
562$arrayofmassactions = array(
563 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
564 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
565 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
566 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
567);
568if (!empty($permissiontodelete)) {
569 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
570}
571if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
572 $arrayofmassactions = array();
573}
574$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
575
576print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
577if ($optioncss != '') {
578 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
579}
580print '<input type="hidden" name="token" value="'.newToken().'">';
581print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
582print '<input type="hidden" name="action" value="list">';
583print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
584print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
585print '<input type="hidden" name="page" value="'.$page.'">';
586print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
587print '<input type="hidden" name="page_y" value="">';
588print '<input type="hidden" name="mode" value="'.$mode.'">';
589
590
591$newcardbutton = '';
592$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*(mode|groupby)=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
593$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*(mode|groupby)=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
594//$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanbanGroupBy'), '', 'fa fa-grip-vertical imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanbangroupby&groupby=p.fk_opp_status'.preg_replace('/(&|\?)*(mode|groupby)=[^&]+/', '', $param), '', ($mode == 'kanbangroupby' ? 2 : 1), array('morecss' => 'reposition'));
595//$newcardbutton .= dolGetButtonTitle($langs->trans('HierarchicView'), '', 'fa fa-stream paddingleft imgforviewmode', $_SERVER["PHP_SELF"].'?mode=hierarchy'.preg_replace('/(&|\?)*(mode|groupby)=[^&]+/', '', $param), '', (($mode == 'hierarchy') ? 2 : 1), array('morecss' => 'reposition'));
596$newcardbutton .= dolGetButtonTitle($langs->trans('Statistics'), '', 'fa fa-chart-bar imgforviewmode', dol_buildpath('/mymodule/stats/myobject_index.php', 1).'?mode=statistics&objecttype=myobject@mymodule'.preg_replace('/(&|\?)*(mode|groupby)=[^&]+/', '', $param), '', ($mode == 'statistics' ? 2 : 1), array('morecss' => 'reposition'));
597$newcardbutton .= dolGetButtonTitleSeparator();
598$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/mymodule/myobject_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
599
600print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
601
602// Add code for pre mass action (confirmation or email presend form)
603$topicmail = "SendMyObjectRef";
604$modelmail = "myobject";
605$objecttmp = new MyObject($db);
606$trackid = 'myobject'.$object->id;
607include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
608
609if ($search_all) {
610 $setupstring = '';
611 // @phan-suppress-next-line PhanEmptyForeach
612 foreach ($fieldstosearchall as $key => $val) {
613 $fieldstosearchall[$key] = $langs->trans($val);
614 $setupstring .= $key."=".$val.";";
615 }
616 print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
617 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
618}
619
620$moreforfilter = '';
621/*$moreforfilter.='<div class="divsearchfield">';
622$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
623$moreforfilter.= '</div>';*/
624
625$parameters = array();
626$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
627if (empty($reshook)) {
628 $moreforfilter .= $hookmanager->resPrint;
629} else {
630 $moreforfilter = $hookmanager->resPrint;
631}
632$parameters = array(
633 'arrayfields' => &$arrayfields,
634);
635
636if (!empty($moreforfilter)) {
637 print '<div class="liste_titre liste_titre_bydiv centpercent">';
638 print $moreforfilter;
639 print '</div>';
640}
641
642$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
643$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column, 1); // This also change content of $arrayfields with user setup
644$selectedfields = (($mode != 'kanban' && $mode != 'kanbangroupby') ? $htmlofselectarray : '');
645$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
646
647print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
648print '<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
649
650// Fields title search
651// --------------------------------------------------------------------
652print '<tr class="liste_titre_filter">';
653// Action column
654if ($conf->main_checkbox_left_column) {
655 print '<td class="liste_titre center maxwidthsearch">';
656 $searchpicto = $form->showFilterButtons('left');
657 print $searchpicto;
658 print '</td>';
659}
660foreach ($object->fields as $key => $val) {
661 //$searchkey = empty($search[$key]) ? '' : $search[$key];
662 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
663 if ($key == 'status') {
664 $cssforfield .= ($cssforfield ? ' ' : '').'center';
665 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
666 $cssforfield .= ($cssforfield ? ' ' : '').'center';
667 } elseif (in_array($val['type'], array('timestamp'))) {
668 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
669 } 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'])) {
670 $cssforfield .= ($cssforfield ? ' ' : '').'right';
671 }
672 if (!empty($arrayfields['t.'.$key]['checked'])) {
673 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
674 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
675 if (empty($val['searchmulti'])) {
676 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);
677 } else {
678 print $form->multiselectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), 0, 0, 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
679 }
680 } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
681 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
682 } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
683 print '<div class="nowrap">';
684 print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
685 print '</div>';
686 print '<div class="nowrap">';
687 print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
688 print '</div>';
689 } elseif ($key == 'lang') {
690 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
691 $formadmin = new FormAdmin($db);
692 print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2);
693 } elseif ($val['type'] === 'boolean') {
694 print $form->selectyesno('search_' . $key, $search[$key] ?? '', 1, false, 1);
695 } else {
696 print '<input type="text" class="flat maxwidth'.(in_array($val['type'], array('integer', 'price')) ? '50' : '75').'" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
697 }
698 print '</td>';
699 }
700}
701// Extra fields
702include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
703
704// Fields from hook
705$parameters = array('arrayfields' => $arrayfields);
706$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
707print $hookmanager->resPrint;
708/*if (!empty($arrayfields['anotherfield']['checked'])) {
709 print '<td class="liste_titre"></td>';
710}*/
711// Action column
712if (!$conf->main_checkbox_left_column) {
713 print '<td class="liste_titre center maxwidthsearch">';
714 $searchpicto = $form->showFilterButtons();
715 print $searchpicto;
716 print '</td>';
717}
718print '</tr>'."\n";
719
720$totalarray = array();
721$totalarray['nbfield'] = 0;
722
723// Fields title label
724// --------------------------------------------------------------------
725print '<tr class="liste_titre">';
726// Action column
727if ($conf->main_checkbox_left_column) {
728 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
729 $totalarray['nbfield']++;
730}
731foreach ($object->fields as $key => $val) {
732 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
733 if ($key == 'status') {
734 $cssforfield .= ($cssforfield ? ' ' : '').'center';
735 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
736 $cssforfield .= ($cssforfield ? ' ' : '').'center';
737 } elseif (in_array($val['type'], array('timestamp'))) {
738 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
739 } 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'])) {
740 $cssforfield .= ($cssforfield ? ' ' : '').'right';
741 }
742 $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
743 if (!empty($arrayfields['t.'.$key]['checked'])) {
744 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";
745 $totalarray['nbfield']++;
746 }
747}
748// Extra fields
749include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
750// Hook fields
751$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
752$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
753print $hookmanager->resPrint;
754/*if (!empty($arrayfields['anotherfield']['checked'])) {
755 print '<th class="liste_titre">'.$langs->trans("AnotherField").'</th>';
756 $totalarray['nbfield']++;
757}*/
758// Action column
759if (!$conf->main_checkbox_left_column) {
760 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
761 $totalarray['nbfield']++;
762}
763print '</tr>'."\n";
764
765// Detect if we need a fetch on each output line
766$needToFetchEachLine = 0;
767if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
768 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
769 if (!is_null($val) && preg_match('/\$object/', $val)) {
770 $needToFetchEachLine++; // There is at least one compute field that use $object
771 }
772 }
773}
774
775
776// Loop on record
777// --------------------------------------------------------------------
778$i = 0;
779$savnbfield = $totalarray['nbfield'];
780$totalarray = array();
781$totalarray['nbfield'] = 0;
782$imaxinloop = ($limit ? min($num, $limit) : $num);
783while ($i < $imaxinloop) {
784 $obj = $db->fetch_object($resql);
785 if (empty($obj)) {
786 break; // Should not happen
787 }
788
789 // Store properties in $object
790 $object->setVarsFromFetchObj($obj);
791
792 /*
793 $object->thirdparty = null;
794 if ($obj->fk_soc > 0) {
795 if (!empty($conf->cache['thirdparty'][$obj->fk_soc])) {
796 $companyobj = $conf->cache['thirdparty'][$obj->fk_soc];
797 } else {
798 $companyobj = new Societe($db);
799 $companyobj->fetch($obj->fk_soc);
800 $conf->cache['thirdparty'][$obj->fk_soc] = $companyobj;
801 }
802
803 $object->thirdparty = $companyobj;
804 }*/
805
806 if ($mode == 'kanban' || $mode == 'kanbangroupby') {
807 if ($i == 0) {
808 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
809 print '<div class="box-flex-container kanban">';
810 }
811 // Output Kanban
812 $selected = -1;
813 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
814 $selected = 0;
815 if (in_array($object->id, $arrayofselected)) {
816 $selected = 1;
817 }
818 }
819 //print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected));
820 print $object->getKanbanView('', array('selected' => $selected));
821 if ($i == ($imaxinloop - 1)) {
822 print '</div>';
823 print '</td></tr>';
824 }
825 } else {
826 // Show line of result
827 $j = 0;
828 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
829
830 // Action column
831 if ($conf->main_checkbox_left_column) {
832 print '<td class="nowrap center">';
833 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
834 $selected = 0;
835 if (in_array($object->id, $arrayofselected)) {
836 $selected = 1;
837 }
838 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
839 }
840 print '</td>';
841 if (!$i) {
842 $totalarray['nbfield']++;
843 }
844 }
845 // Fields
846 foreach ($object->fields as $key => $val) {
847 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
848 if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
849 $cssforfield .= ($cssforfield ? ' ' : '').'center';
850 } elseif ($key == 'status') {
851 $cssforfield .= ($cssforfield ? ' ' : '').'center';
852 }
853
854 if (in_array($val['type'], array('timestamp'))) {
855 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
856 } elseif ($key == 'ref') {
857 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
858 }
859
860 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'])) {
861 $cssforfield .= ($cssforfield ? ' ' : '').'right';
862 }
863 //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
864
865 if (!empty($arrayfields['t.'.$key]['checked'])) {
866 print '<td'.($cssforfield ? ' class="'.$cssforfield.((preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) ? ' classfortooltip' : '').'"' : '');
867 if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key) && !in_array($key, array('ref'))) {
868 print ' title="'.dol_escape_htmltag((string) $object->$key).'"';
869 }
870 print '>';
871 if ($key == 'status') {
872 print $object->getLibStatut(5);
873 } elseif ($key == 'rowid') {
874 print $object->showOutputField($val, $key, (string) $object->id, '');
875 } else {
876 if ($val['type'] == 'html') {
877 print '<div class="small lineheightsmall twolinesmax-normallineheight">';
878 }
879 print $object->showOutputField($val, $key, (string) $object->$key, '');
880 if ($val['type'] == 'html') {
881 print '</div>';
882 }
883 }
884 print '</td>';
885 if (!$i) {
886 $totalarray['nbfield']++;
887 }
888 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
889 if (!$i) {
890 $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
891 }
892 if (!isset($totalarray['val'])) {
893 $totalarray['val'] = array();
894 }
895 if (!isset($totalarray['val']['t.'.$key])) {
896 $totalarray['val']['t.'.$key] = 0;
897 }
898 $totalarray['val']['t.'.$key] += $object->$key;
899 }
900 }
901 }
902 // Extra fields
903 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
904 // Fields from hook
905 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
906 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
907 print $hookmanager->resPrint;
908
909 /*if (!empty($arrayfields['anotherfield']['checked'])) {
910 print '<td class="right">'.$obj->anotherfield.'</td>';
911 }*/
912
913 // Action column
914 if (empty($conf->main_checkbox_left_column)) {
915 print '<td class="nowrap center">';
916 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
917 $selected = 0;
918 if (in_array($object->id, $arrayofselected)) {
919 $selected = 1;
920 }
921 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
922 }
923 print '</td>';
924 if (!$i) {
925 $totalarray['nbfield']++;
926 }
927 }
928
929 print '</tr>'."\n";
930 }
931
932 $i++;
933}
934
935// Show total line
936include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
937
938// If no record found
939if ($num == 0) {
940 $colspan = 1;
941 foreach ($arrayfields as $key => $val) {
942 if (!empty($val['checked'])) {
943 $colspan++;
944 }
945 }
946 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
947}
948
949
950$db->free($resql);
951
952$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
953$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
954print $hookmanager->resPrint;
955
956print '</table>'."\n";
957print '</div>'."\n";
958
959print '</form>'."\n";
960
961if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
962 $hidegeneratedfilelistifempty = 1;
963 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
964 $hidegeneratedfilelistifempty = 0;
965 }
966
967 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
968 $formfile = new FormFile($db);
969
970 // Show list of available documents
971 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
972 $urlsource .= str_replace('&amp;', '&', $param);
973
974 $filedir = $diroutputmassaction;
975 $genallowed = $permissiontoread;
976 $delallowed = $permissiontoadd;
977
978 print $formfile->showdocuments('massfilesarea_'.$object->module, '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
979}
980
981// End of page
982llxFooter();
983$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 for MyObject.
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.
getDolDefaultContextPage($s)
Return the default context page string.
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
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.