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