dolibarr  19.0.0-dev
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) ---Put here your own copyright and developer email---
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
25 //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
26 //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
27 //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
28 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
29 //if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
30 //if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
31 //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
32 //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
33 //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
34 //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
35 //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
36 //if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
37 //if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
38 //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
39 //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
40 //if (! defined("MAIN_SECURITY_FORCECSP")) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies
41 //if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
42 //if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
43 //if (! defined('NOSESSION')) define('NOSESSION', '1'); // On CLI mode, no need to use web sessions
44 
45 // Load Dolibarr environment
46 $res = 0;
47 // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
48 if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
49  $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
50 }
51 // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
52 $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
53 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
54  $i--;
55  $j--;
56 }
57 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
58  $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
59 }
60 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
61  $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
62 }
63 // Try main.inc.php using relative path
64 if (!$res && file_exists("../main.inc.php")) {
65  $res = @include "../main.inc.php";
66 }
67 if (!$res && file_exists("../../main.inc.php")) {
68  $res = @include "../../main.inc.php";
69 }
70 if (!$res && file_exists("../../../main.inc.php")) {
71  $res = @include "../../../main.inc.php";
72 }
73 if (!$res) {
74  die("Include of main fails");
75 }
76 
77 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
78 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
79 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
80 
81 // load module libraries
82 require_once __DIR__.'/class/myobject.class.php';
83 
84 // for other modules
85 //dol_include_once('/othermodule/class/otherobject.class.php');
86 
87 // Load translation files required by the page
88 $langs->loadLangs(array("mymodule@mymodule", "other"));
89 
90 $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
91 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
92 $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
93 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
94 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
95 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
96 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
97 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
98 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
99 $mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
100 
101 $id = GETPOST('id', 'int');
102 $ref = GETPOST('ref', 'alpha');
103 
104 // Load variable for pagination
105 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
106 $sortfield = GETPOST('sortfield', 'aZ09comma');
107 $sortorder = GETPOST('sortorder', 'aZ09comma');
108 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
109 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
110  // If $page is not defined, or '' or -1 or if we click on clear filters
111  $page = 0;
112 }
113 $offset = $limit * $page;
114 $pageprev = $page - 1;
115 $pagenext = $page + 1;
116 
117 // Initialize technical objects
118 $object = new MyObject($db);
119 $extrafields = new ExtraFields($db);
120 $diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id;
121 $hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes
122 
123 // Fetch optionals attributes and labels
124 $extrafields->fetch_name_optionals_label($object->table_element);
125 //$extrafields->fetch_name_optionals_label($object->table_element_line);
126 
127 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
128 
129 // Default sort order (if not yet defined by previous GETPOST)
130 if (!$sortfield) {
131  reset($object->fields); // Reset is required to avoid key() to return null.
132  $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
133 }
134 if (!$sortorder) {
135  $sortorder = "ASC";
136 }
137 
138 // Initialize array of search criterias
139 $search_all = GETPOST('search_all', 'alphanohtml');
140 $search = array();
141 foreach ($object->fields as $key => $val) {
142  if (GETPOST('search_'.$key, 'alpha') !== '') {
143  $search[$key] = GETPOST('search_'.$key, 'alpha');
144  }
145  if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
146  $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
147  $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
148  }
149 }
150 
151 // List of fields to search into when doing a "search in all"
152 // $fieldstosearchall = array();
153 // foreach ($object->fields as $key => $val) {
154 // if (!empty($val['searchall'])) {
155 // $fieldstosearchall['t.'.$key] = $val['label'];
156 // }
157 // }
158 // $parameters = array('fieldstosearchall'=>$fieldstosearchall);
159 // $reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
160 // if ($reshook > 0) {
161 // $fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall'];
162 // } elseif ($reshook == 0) {
163 // $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']);
164 // }
165 
166 // Definition of array of fields for columns
167 $arrayfields = array();
168 foreach ($object->fields as $key => $val) {
169  // If $val['visible']==0, then we never show the field
170  if (!empty($val['visible'])) {
171  $visible = (int) dol_eval($val['visible'], 1);
172  $arrayfields['t.'.$key] = array(
173  'label'=>$val['label'],
174  'checked'=>(($visible < 0) ? 0 : 1),
175  'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)),
176  'position'=>$val['position'],
177  'help'=> isset($val['help']) ? $val['help'] : ''
178  );
179  }
180 }
181 // Extra fields
182 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
183 
184 $object->fields = dol_sort_array($object->fields, 'position');
185 //$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right');
186 $arrayfields = dol_sort_array($arrayfields, 'position');
187 
188 // There is several ways to check permission.
189 // Set $enablepermissioncheck to 1 to enable a minimum low level of checks
190 $enablepermissioncheck = 0;
191 if ($enablepermissioncheck) {
192  $permissiontoread = $user->hasRight('mymodule', 'myobject', 'read');
193  $permissiontoadd = $user->hasRight('mymodule', 'myobject', 'write');
194  $permissiontodelete = $user->hasRight('mymodule', 'myobject', 'delete');
195 } else {
196  $permissiontoread = 1;
197  $permissiontoadd = 1;
198  $permissiontodelete = 1;
199 }
200 
201 // Security check (enable the most restrictive one)
202 if ($user->socid > 0) accessforbidden();
203 //if ($user->socid > 0) accessforbidden();
204 //$socid = 0; if ($user->socid > 0) $socid = $user->socid;
205 //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
206 //restrictedArea($user, $object->module, 0, $object->table_element, $object->element, 'fk_soc', 'rowid', $isdraft);
207 if (!isModEnabled("mymodule")) {
208  accessforbidden('Module mymodule not enabled');
209 }
210 if (!$permissiontoread) accessforbidden();
211 
212 
213 /*
214  * Actions
215  */
216 
217 if (GETPOST('cancel', 'alpha')) {
218  $action = 'list';
219  $massaction = '';
220 }
221 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
222  $massaction = '';
223 }
224 
225 $parameters = array();
226 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
227 if ($reshook < 0) {
228  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
229 }
230 
231 if (empty($reshook)) {
232  // Selection of new fields
233  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
234 
235  // Purge search criteria
236  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
237  foreach ($object->fields as $key => $val) {
238  $search[$key] = '';
239  if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
240  $search[$key.'_dtstart'] = '';
241  $search[$key.'_dtend'] = '';
242  }
243  }
244  $toselect = array();
245  $search_array_options = array();
246  }
247  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
248  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
249  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
250  }
251 
252  // Mass actions
253  $objectclass = 'MyObject';
254  $objectlabel = 'MyObject';
255  $uploaddir = $conf->mymodule->dir_output;
256  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
257 
258  // You can add more action here
259  // if ($action == 'xxx' && $permissiontoxxx) ...
260 }
261 
262 
263 
264 /*
265  * View
266  */
267 
268 $form = new Form($db);
269 
270 $now = dol_now();
271 
272 $title = $langs->trans("MyObjects");
273 //$help_url = "EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject";
274 $help_url = '';
275 $morejs = array();
276 $morecss = array();
277 
278 
279 // Build and execute select
280 // --------------------------------------------------------------------
281 $sql = 'SELECT ';
282 $sql .= $object->getFieldList('t');
283 // Add fields from extrafields
284 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
285  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
286  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
287  }
288 }
289 // Add fields from hooks
290 $parameters = array();
291 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
292 $sql .= $hookmanager->resPrint;
293 $sql = preg_replace('/,\s*$/', '', $sql);
294 //$sql .= ", COUNT(rc.rowid) as anotherfield";
295 
296 $sqlfields = $sql; // $sql fields to remove for count total
297 
298 $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
299 //$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."anothertable as rc ON rc.parent = t.rowid";
300 if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
301  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
302 }
303 // Add table from hooks
304 $parameters = array();
305 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
306 $sql .= $hookmanager->resPrint;
307 if ($object->ismultientitymanaged == 1) {
308  $sql .= " WHERE t.entity IN (".getEntity($object->element, (GETPOST('search_current_entity', 'int') ? 0 : 1)).")";
309 } else {
310  $sql .= " WHERE 1 = 1";
311 }
312 foreach ($search as $key => $val) {
313  if (array_key_exists($key, $object->fields)) {
314  if ($key == 'status' && $search[$key] == -1) {
315  continue;
316  }
317  $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
318  if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
319  if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
320  $search[$key] = '';
321  }
322  $mode_search = 2;
323  }
324  if ($search[$key] != '') {
325  $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
326  }
327  } else {
328  if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
329  $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
330  if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
331  if (preg_match('/_dtstart$/', $key)) {
332  $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'";
333  }
334  if (preg_match('/_dtend$/', $key)) {
335  $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'";
336  }
337  }
338  }
339  }
340 }
341 if ($search_all) {
342  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
343 }
344 //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
345 // Add where from extra fields
346 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
347 // Add where from hooks
348 $parameters = array();
349 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
350 $sql .= $hookmanager->resPrint;
351 
352 /* If a group by is required
353 $sql .= " GROUP BY ";
354 foreach($object->fields as $key => $val) {
355  $sql .= "t.".$db->escape($key).", ";
356 }
357 // Add fields from extrafields
358 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
359  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
360  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
361  }
362 }
363 // Add groupby from hooks
364 $parameters = array();
365 $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
366 $sql .= $hookmanager->resPrint;
367 $sql = preg_replace('/,\s*$/', '', $sql);
368 */
369 
370 // Add HAVING from hooks
371 /*
372 $parameters = array();
373 $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
374 $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
375 */
376 
377 // Count total nb of records
378 $nbtotalofrecords = '';
379 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
380  /* The fast and low memory method to get and count full list converts the sql into a sql count */
381  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
382  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
383  $resql = $db->query($sqlforcount);
384  if ($resql) {
385  $objforcount = $db->fetch_object($resql);
386  $nbtotalofrecords = $objforcount->nbtotalofrecords;
387  } else {
388  dol_print_error($db);
389  }
390 
391  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
392  $page = 0;
393  $offset = 0;
394  }
395  $db->free($resql);
396 }
397 
398 // Complete request and execute it with limit
399 $sql .= $db->order($sortfield, $sortorder);
400 if ($limit) {
401  $sql .= $db->plimit($limit + 1, $offset);
402 }
403 
404 $resql = $db->query($sql);
405 if (!$resql) {
406  dol_print_error($db);
407  exit;
408 }
409 
410 $num = $db->num_rows($resql);
411 
412 
413 // Direct jump if only one record found
414 if ($num == 1 && !getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
415  $obj = $db->fetch_object($resql);
416  $id = $obj->rowid;
417  header("Location: ".dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.((int) $id));
418  exit;
419 }
420 
421 
422 // Output page
423 // --------------------------------------------------------------------
424 
425 llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
426 
427 // Example : Adding jquery code
428 // print '<script type="text/javascript">
429 // jQuery(document).ready(function() {
430 // function init_myfunc()
431 // {
432 // jQuery("#myid").removeAttr(\'disabled\');
433 // jQuery("#myid").attr(\'disabled\',\'disabled\');
434 // }
435 // init_myfunc();
436 // jQuery("#mybutton").click(function() {
437 // init_myfunc();
438 // });
439 // });
440 // </script>';
441 
442 $arrayofselected = is_array($toselect) ? $toselect : array();
443 
444 $param = '';
445 if (!empty($mode)) {
446  $param .= '&mode='.urlencode($mode);
447 }
448 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
449  $param .= '&contextpage='.urlencode($contextpage);
450 }
451 if ($limit > 0 && $limit != $conf->liste_limit) {
452  $param .= '&limit='.((int) $limit);
453 }
454 if ($optioncss != '') {
455  $param .= '&optioncss='.urlencode($optioncss);
456 }
457 foreach ($search as $key => $val) {
458  if (is_array($search[$key])) {
459  foreach ($search[$key] as $skey) {
460  if ($skey != '') {
461  $param .= '&search_'.$key.'[]='.urlencode($skey);
462  }
463  }
464  } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
465  $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int'));
466  $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int'));
467  $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int'));
468  } elseif ($search[$key] != '') {
469  $param .= '&search_'.$key.'='.urlencode($search[$key]);
470  }
471 }
472 // Add $param from extra fields
473 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
474 // Add $param from hooks
475 $parameters = array();
476 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
477 $param .= $hookmanager->resPrint;
478 
479 // List of mass actions available
480 $arrayofmassactions = array(
481  //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
482  //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
483  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
484  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
485 );
486 if (!empty($permissiontodelete)) {
487  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
488 }
489 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
490  $arrayofmassactions = array();
491 }
492 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
493 
494 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
495 if ($optioncss != '') {
496  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
497 }
498 print '<input type="hidden" name="token" value="'.newToken().'">';
499 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
500 print '<input type="hidden" name="action" value="list">';
501 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
502 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
503 print '<input type="hidden" name="page" value="'.$page.'">';
504 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
505 print '<input type="hidden" name="page_y" value="">';
506 print '<input type="hidden" name="mode" value="'.$mode.'">';
507 
508 
509 $newcardbutton = '';
510 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
511 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
512 $newcardbutton .= dolGetButtonTitleSeparator();
513 $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/mymodule/myobject_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
514 
515 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
516 
517 // Add code for pre mass action (confirmation or email presend form)
518 $topicmail = "SendMyObjectRef";
519 $modelmail = "myobject";
520 $objecttmp = new MyObject($db);
521 $trackid = 'xxxx'.$object->id;
522 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
523 
524 if ($search_all) {
525  $setupstring = '';
526  foreach ($fieldstosearchall as $key => $val) {
527  $fieldstosearchall[$key] = $langs->trans($val);
528  $setupstring .= $key."=".$val.";";
529  }
530  print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
531  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'."\n";
532 }
533 
534 $moreforfilter = '';
535 /*$moreforfilter.='<div class="divsearchfield">';
536 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
537 $moreforfilter.= '</div>';*/
538 
539 $parameters = array();
540 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
541 if (empty($reshook)) {
542  $moreforfilter .= $hookmanager->resPrint;
543 } else {
544  $moreforfilter = $hookmanager->resPrint;
545 }
546 
547 if (!empty($moreforfilter)) {
548  print '<div class="liste_titre liste_titre_bydiv centpercent">';
549  print $moreforfilter;
550  $parameters = array();
551  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
552  print $hookmanager->resPrint;
553  print '</div>';
554 }
555 
556 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
557 $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
558 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
559 
560 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
561 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
562 
563 // Fields title search
564 // --------------------------------------------------------------------
565 print '<tr class="liste_titre_filter">';
566 // Action column
567 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
568  print '<td class="liste_titre center maxwidthsearch">';
569  $searchpicto = $form->showFilterButtons('left');
570  print $searchpicto;
571  print '</td>';
572 }
573 foreach ($object->fields as $key => $val) {
574  $searchkey = empty($search[$key]) ? '' : $search[$key];
575  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
576  if ($key == 'status') {
577  $cssforfield .= ($cssforfield ? ' ' : '').'center';
578  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
579  $cssforfield .= ($cssforfield ? ' ' : '').'center';
580  } elseif (in_array($val['type'], array('timestamp'))) {
581  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
582  } 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'])) {
583  $cssforfield .= ($cssforfield ? ' ' : '').'right';
584  }
585  if (!empty($arrayfields['t.'.$key]['checked'])) {
586  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
587  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
588  print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
589  } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
590  print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
591  } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
592  print '<div class="nowrap">';
593  print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
594  print '</div>';
595  print '<div class="nowrap">';
596  print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
597  print '</div>';
598  } elseif ($key == 'lang') {
599  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
600  $formadmin = new FormAdmin($db);
601  print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
602  } else {
603  print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
604  }
605  print '</td>';
606  }
607 }
608 // Extra fields
609 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
610 
611 // Fields from hook
612 $parameters = array('arrayfields'=>$arrayfields);
613 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
614 print $hookmanager->resPrint;
615 /*if (!empty($arrayfields['anotherfield']['checked'])) {
616  print '<td class="liste_titre"></td>';
617 }*/
618 // Action column
619 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
620  print '<td class="liste_titre center maxwidthsearch">';
621  $searchpicto = $form->showFilterButtons();
622  print $searchpicto;
623  print '</td>';
624 }
625 print '</tr>'."\n";
626 
627 $totalarray = array();
628 $totalarray['nbfield'] = 0;
629 
630 // Fields title label
631 // --------------------------------------------------------------------
632 print '<tr class="liste_titre">';
633 // Action column
634 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
635  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
636  $totalarray['nbfield']++;
637 }
638 foreach ($object->fields as $key => $val) {
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  $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
650  if (!empty($arrayfields['t.'.$key]['checked'])) {
651  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";
652  $totalarray['nbfield']++;
653  }
654 }
655 // Extra fields
656 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
657 // Hook fields
658 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
659 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
660 print $hookmanager->resPrint;
661 /*if (!empty($arrayfields['anotherfield']['checked'])) {
662  print '<th class="liste_titre right">'.$langs->trans("AnotherField").'</th>';
663  $totalarray['nbfield']++;
664 }*/
665 // Action column
666 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
667  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
668  $totalarray['nbfield']++;
669 }
670 print '</tr>'."\n";
671 
672 // Detect if we need a fetch on each output line
673 $needToFetchEachLine = 0;
674 if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
675  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
676  if (!is_null($val) && preg_match('/\$object/', $val)) {
677  $needToFetchEachLine++; // There is at least one compute field that use $object
678  }
679  }
680 }
681 
682 
683 // Loop on record
684 // --------------------------------------------------------------------
685 $i = 0;
686 $savnbfield = $totalarray['nbfield'];
687 $totalarray = array();
688 $totalarray['nbfield'] = 0;
689 $imaxinloop = ($limit ? min($num, $limit) : $num);
690 while ($i < $imaxinloop) {
691  $obj = $db->fetch_object($resql);
692  if (empty($obj)) {
693  break; // Should not happen
694  }
695 
696  // Store properties in $object
697  $object->setVarsFromFetchObj($obj);
698 
699  if ($mode == 'kanban') {
700  if ($i == 0) {
701  print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
702  print '<div class="box-flex-container kanban">';
703  }
704  // Output Kanban
705  $selected = -1;
706  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
707  $selected = 0;
708  if (in_array($object->id, $arrayofselected)) {
709  $selected = 1;
710  }
711  }
712  print $object->getKanbanView('', array('selected' => $selected));
713  if ($i == ($imaxinloop - 1)) {
714  print '</div>';
715  print '</td></tr>';
716  }
717  } else {
718  // Show line of result
719  $j = 0;
720  print '<tr data-rowid="'.$object->id.'" class="oddeven">';
721 
722  // Action column
723  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
724  print '<td class="nowrap center">';
725  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
726  $selected = 0;
727  if (in_array($object->id, $arrayofselected)) {
728  $selected = 1;
729  }
730  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
731  }
732  print '</td>';
733  if (!$i) {
734  $totalarray['nbfield']++;
735  }
736  }
737  foreach ($object->fields as $key => $val) {
738  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
739  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
740  $cssforfield .= ($cssforfield ? ' ' : '').'center';
741  } elseif ($key == 'status') {
742  $cssforfield .= ($cssforfield ? ' ' : '').'center';
743  }
744 
745  if (in_array($val['type'], array('timestamp'))) {
746  $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
747  } elseif ($key == 'ref') {
748  $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
749  }
750 
751  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'])) {
752  $cssforfield .= ($cssforfield ? ' ' : '').'right';
753  }
754  //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
755 
756  if (!empty($arrayfields['t.'.$key]['checked'])) {
757  print '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
758  if (preg_match('/tdoverflow/', $cssforfield) && !is_numeric($object->$key)) {
759  print ' title="'.dol_escape_htmltag($object->$key).'"';
760  }
761  print '>';
762  if ($key == 'status') {
763  print $object->getLibStatut(5);
764  } elseif ($key == 'rowid') {
765  print $object->showOutputField($val, $key, $object->id, '');
766  } else {
767  print $object->showOutputField($val, $key, $object->$key, '');
768  }
769  print '</td>';
770  if (!$i) {
771  $totalarray['nbfield']++;
772  }
773  if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
774  if (!$i) {
775  $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
776  }
777  if (!isset($totalarray['val'])) {
778  $totalarray['val'] = array();
779  }
780  if (!isset($totalarray['val']['t.'.$key])) {
781  $totalarray['val']['t.'.$key] = 0;
782  }
783  $totalarray['val']['t.'.$key] += $object->$key;
784  }
785  }
786  }
787  // Extra fields
788  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
789  // Fields from hook
790  $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
791  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
792  print $hookmanager->resPrint;
793 
794  /*if (!empty($arrayfields['anotherfield']['checked'])) {
795  print '<td class="right">'.$obj->anotherfield.'</td>';
796  }*/
797 
798  // Action column
799  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
800  print '<td class="nowrap center">';
801  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
802  $selected = 0;
803  if (in_array($object->id, $arrayofselected)) {
804  $selected = 1;
805  }
806  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
807  }
808  print '</td>';
809  if (!$i) {
810  $totalarray['nbfield']++;
811  }
812  }
813 
814  print '</tr>'."\n";
815  }
816 
817  $i++;
818 }
819 
820 // Show total line
821 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
822 
823 // If no record found
824 if ($num == 0) {
825  $colspan = 1;
826  foreach ($arrayfields as $key => $val) {
827  if (!empty($val['checked'])) {
828  $colspan++;
829  }
830  }
831  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
832 }
833 
834 
835 $db->free($resql);
836 
837 $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
838 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
839 print $hookmanager->resPrint;
840 
841 print '</table>'."\n";
842 print '</div>'."\n";
843 
844 print '</form>'."\n";
845 
846 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
847  $hidegeneratedfilelistifempty = 1;
848  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
849  $hidegeneratedfilelistifempty = 0;
850  }
851 
852  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
853  $formfile = new FormFile($db);
854 
855  // Show list of available documents
856  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
857  $urlsource .= str_replace('&amp;', '&', $param);
858 
859  $filedir = $diroutputmassaction;
860  $genallowed = $permissiontoread;
861  $delallowed = $permissiontoadd;
862 
863  print $formfile->showdocuments('massfilesarea_'.$object->module, '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
864 }
865 
866 // End of page
867 llxFooter();
868 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
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('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.