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