dolibarr  13.0.2
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('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on).
32 //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
33 //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
34 //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
35 //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
36 //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
37 //if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
38 //if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
39 //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
40 //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
41 //if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message
42 //if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies
43 //if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
44 //if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
45 
46 // Load Dolibarr environment
47 $res = 0;
48 // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
49 if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
50 // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
51 $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
52 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
53 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
54 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
55 // Try main.inc.php using relative path
56 if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
57 if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
58 if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
59 if (!$res) die("Include of main fails");
60 
61 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
62 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
63 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
64 
65 // load mymodule libraries
66 require_once __DIR__.'/class/myobject.class.php';
67 
68 // for other modules
69 //dol_include_once('/othermodule/class/otherobject.class.php');
70 
71 // Load translation files required by the page
72 $langs->loadLangs(array("mymodule@mymodule", "other"));
73 
74 $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
75 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
76 $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
77 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
78 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
79 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
80 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search
81 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
82 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
83 
84 $id = GETPOST('id', 'int');
85 
86 // Load variable for pagination
87 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
88 $sortfield = GETPOST('sortfield', 'aZ09comma');
89 $sortorder = GETPOST('sortorder', 'aZ09comma');
90 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
91 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters
92 $offset = $limit * $page;
93 $pageprev = $page - 1;
94 $pagenext = $page + 1;
95 
96 // Initialize technical objects
97 $object = new MyObject($db);
98 $extrafields = new ExtraFields($db);
99 $diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id;
100 $hookmanager->initHooks(array('myobjectlist')); // Note that conf->hooks_modules contains array
101 
102 // Fetch optionals attributes and labels
103 $extrafields->fetch_name_optionals_label($object->table_element);
104 //$extrafields->fetch_name_optionals_label($object->table_element_line);
105 
106 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
107 
108 // Default sort order (if not yet defined by previous GETPOST)
109 if (!$sortfield) { reset($object->fields); $sortfield="t.".key($object->fields); } // Set here default search field. By default 1st field in definition. Reset is required to avoid key() to return null.
110 if (!$sortorder) $sortorder = "ASC";
111 
112 // Initialize array of search criterias
113 $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
114 $search = array();
115 foreach ($object->fields as $key => $val)
116 {
117  if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
118 }
119 
120 // List of fields to search into when doing a "search in all"
121 $fieldstosearchall = array();
122 foreach ($object->fields as $key => $val)
123 {
124  if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
125 }
126 
127 // Definition of array of fields for columns
128 $arrayfields = array();
129 foreach ($object->fields as $key => $val) {
130  // If $val['visible']==0, then we never show the field
131  if (!empty($val['visible'])) {
132  $visible = (int) dol_eval($val['visible'], 1);
133  $arrayfields['t.'.$key] = array(
134  'label'=>$val['label'],
135  'checked'=>(($visible < 0) ? 0 : 1),
136  'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
137  'position'=>$val['position'],
138  'help'=>$val['help']
139  );
140  }
141 }
142 // Extra fields
143 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
144 
145 $object->fields = dol_sort_array($object->fields, 'position');
146 $arrayfields = dol_sort_array($arrayfields, 'position');
147 
148 $permissiontoread = $user->rights->mymodule->myobject->read;
149 $permissiontoadd = $user->rights->mymodule->myobject->write;
150 $permissiontodelete = $user->rights->mymodule->myobject->delete;
151 
152 // Security check
153 if (empty($conf->mymodule->enabled)) accessforbidden('Module not enabled');
154 $socid = 0;
155 if ($user->socid > 0) // Protection if external user
156 {
157  //$socid = $user->socid;
158  accessforbidden();
159 }
160 //$result = restrictedArea($user, 'mymodule', $id, '');
161 //if (!$permissiontoread) accessforbidden();
162 
163 
164 
165 /*
166  * Actions
167  */
168 
169 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
170 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
171 
172 $parameters = array();
173 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
174 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
175 
176 if (empty($reshook))
177 {
178  // Selection of new fields
179  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
180 
181  // Purge search criteria
182  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
183  {
184  foreach ($object->fields as $key => $val) {
185  $search[$key] = '';
186  }
187  $toselect = '';
188  $search_array_options = array();
189  }
190  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
191  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
192  {
193  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
194  }
195 
196  // Mass actions
197  $objectclass = 'MyObject';
198  $objectlabel = 'MyObject';
199  $uploaddir = $conf->mymodule->dir_output;
200  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
201 }
202 
203 
204 
205 /*
206  * View
207  */
208 
209 $form = new Form($db);
210 
211 $now = dol_now();
212 
213 //$help_url="EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject";
214 $help_url = '';
215 $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("MyObjects"));
216 
217 
218 // Build and execute select
219 // --------------------------------------------------------------------
220 $sql = 'SELECT ';
221 foreach ($object->fields as $key => $val)
222 {
223  $sql .= 't.'.$key.', ';
224 }
225 // Add fields from extrafields
226 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
227  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
228 }
229 // Add fields from hooks
230 $parameters = array();
231 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
232 $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
233 $sql = preg_replace('/,\s*$/', '', $sql);
234 $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
235 if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
236 // Add table from hooks
237 $parameters = array();
238 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
239 $sql .= $hookmanager->resPrint;
240 if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
241 else $sql .= " WHERE 1 = 1";
242 foreach ($search as $key => $val)
243 {
244  if ($key == 'status' && $search[$key] == -1) continue;
245  $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
246  if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
247  if ($search[$key] == '-1') $search[$key] = '';
248  $mode_search = 2;
249  }
250  if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
251 }
252 if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
253 //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
254 // Add where from extra fields
255 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
256 // Add where from hooks
257 $parameters = array();
258 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
259 $sql .= $hookmanager->resPrint;
260 
261 /* If a group by is required
262 $sql.= " GROUP BY ";
263 foreach($object->fields as $key => $val)
264 {
265  $sql.='t.'.$key.', ';
266 }
267 // Add fields from extrafields
268 if (! empty($extrafields->attributes[$object->table_element]['label'])) {
269  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
270 }
271 // Add where from hooks
272 $parameters=array();
273 $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters, $object); // Note that $action and $object may have been modified by hook
274 $sql.=$hookmanager->resPrint;
275 $sql=preg_replace('/,\s*$/','', $sql);
276 */
277 
278 $sql .= $db->order($sortfield, $sortorder);
279 
280 // Count total nb of records
281 $nbtotalofrecords = '';
282 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
283  $resql = $db->query($sql);
284  $nbtotalofrecords = $db->num_rows($resql);
285  if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
286  $page = 0;
287  $offset = 0;
288  }
289 }
290 // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
291 if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
292  $num = $nbtotalofrecords;
293 } else {
294  if ($limit) $sql .= $db->plimit($limit + 1, $offset);
295 
296  $resql = $db->query($sql);
297  if (!$resql) {
298  dol_print_error($db);
299  exit;
300  }
301 
302  $num = $db->num_rows($resql);
303 }
304 
305 // Direct jump if only one record found
306 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page)
307 {
308  $obj = $db->fetch_object($resql);
309  $id = $obj->rowid;
310  header("Location: ".dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$id);
311  exit;
312 }
313 
314 
315 // Output page
316 // --------------------------------------------------------------------
317 
318 llxHeader('', $title, $help_url);
319 
320 // Example : Adding jquery code
321 print '<script type="text/javascript" language="javascript">
322 jQuery(document).ready(function() {
323  function init_myfunc()
324  {
325  jQuery("#myid").removeAttr(\'disabled\');
326  jQuery("#myid").attr(\'disabled\',\'disabled\');
327  }
328  init_myfunc();
329  jQuery("#mybutton").click(function() {
330  init_myfunc();
331  });
332 });
333 </script>';
334 
335 $arrayofselected = is_array($toselect) ? $toselect : array();
336 
337 $param = '';
338 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
339 if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
340 foreach ($search as $key => $val)
341 {
342  if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey);
343  else $param .= '&search_'.$key.'='.urlencode($search[$key]);
344 }
345 if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
346 // Add $param from extra fields
347 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
348 // Add $param from hooks
349 $parameters = array();
350 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
351 $param .= $hookmanager->resPrint;
352 
353 // List of mass actions available
354 $arrayofmassactions = array(
355  //'validate'=>$langs->trans("Validate"),
356  //'generate_doc'=>$langs->trans("ReGeneratePDF"),
357  //'builddoc'=>$langs->trans("PDFMerge"),
358  //'presend'=>$langs->trans("SendByMail"),
359 );
360 if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
361 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
362 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
363 
364 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
365 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
366 print '<input type="hidden" name="token" value="'.newToken().'">';
367 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
368 print '<input type="hidden" name="action" value="list">';
369 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
370 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
371 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
372 
373 $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/mymodule/myobject_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
374 
375 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
376 
377 // Add code for pre mass action (confirmation or email presend form)
378 $topicmail = "SendMyObjectRef";
379 $modelmail = "myobject";
380 $objecttmp = new MyObject($db);
381 $trackid = 'xxxx'.$object->id;
382 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
383 
384 if ($search_all)
385 {
386  foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
387  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
388 }
389 
390 $moreforfilter = '';
391 /*$moreforfilter.='<div class="divsearchfield">';
392 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
393 $moreforfilter.= '</div>';*/
394 
395 $parameters = array();
396 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
397 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
398 else $moreforfilter = $hookmanager->resPrint;
399 
400 if (!empty($moreforfilter))
401 {
402  print '<div class="liste_titre liste_titre_bydiv centpercent">';
403  print $moreforfilter;
404  print '</div>';
405 }
406 
407 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
408 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
409 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
410 
411 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
412 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
413 
414 
415 // Fields title search
416 // --------------------------------------------------------------------
417 print '<tr class="liste_titre">';
418 foreach ($object->fields as $key => $val)
419 {
420  $cssforfield = (empty($val['css']) ? '' : $val['css']);
421  if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
422  elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
423  elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
424  elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
425  if (!empty($arrayfields['t.'.$key]['checked']))
426  {
427  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
428  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
429  elseif (strpos($val['type'], 'integer:') === 0) {
430  print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1);
431  } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
432  print '</td>';
433  }
434 }
435 // Extra fields
436 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
437 
438 // Fields from hook
439 $parameters = array('arrayfields'=>$arrayfields);
440 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
441 print $hookmanager->resPrint;
442 // Action column
443 print '<td class="liste_titre maxwidthsearch">';
444 $searchpicto = $form->showFilterButtons();
445 print $searchpicto;
446 print '</td>';
447 print '</tr>'."\n";
448 
449 
450 // Fields title label
451 // --------------------------------------------------------------------
452 print '<tr class="liste_titre">';
453 foreach ($object->fields as $key => $val)
454 {
455  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
456  if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
457  elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
458  elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
459  elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
460  if (!empty($arrayfields['t.'.$key]['checked']))
461  {
462  print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
463  }
464 }
465 // Extra fields
466 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
467 // Hook fields
468 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
469 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
470 print $hookmanager->resPrint;
471 // Action column
472 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
473 print '</tr>'."\n";
474 
475 
476 // Detect if we need a fetch on each output line
477 $needToFetchEachLine = 0;
478 if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0)
479 {
480  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
481  {
482  if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
483  }
484 }
485 
486 
487 // Loop on record
488 // --------------------------------------------------------------------
489 $i = 0;
490 $totalarray = array();
491 while ($i < ($limit ? min($num, $limit) : $num))
492 {
493  $obj = $db->fetch_object($resql);
494  if (empty($obj)) break; // Should not happen
495 
496  // Store properties in $object
497  $object->setVarsFromFetchObj($obj);
498 
499  // Show here line of result
500  print '<tr class="oddeven">';
501  foreach ($object->fields as $key => $val)
502  {
503  $cssforfield = (empty($val['css']) ? '' : $val['css']);
504  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
505  elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
506 
507  if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
508  elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
509 
510  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) $cssforfield .= ($cssforfield ? ' ' : '').'right';
511  //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
512 
513  if (!empty($arrayfields['t.'.$key]['checked']))
514  {
515  print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
516  if ($key == 'status') print $object->getLibStatut(5);
517  else print $object->showOutputField($val, $key, $object->$key, '');
518  print '</td>';
519  if (!$i) $totalarray['nbfield']++;
520  if (!empty($val['isameasure']))
521  {
522  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
523  $totalarray['val']['t.'.$key] += $object->$key;
524  }
525  }
526  }
527  // Extra fields
528  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
529  // Fields from hook
530  $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
531  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
532  print $hookmanager->resPrint;
533  // Action column
534  print '<td class="nowrap center">';
535  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
536  {
537  $selected = 0;
538  if (in_array($object->id, $arrayofselected)) $selected = 1;
539  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
540  }
541  print '</td>';
542  if (!$i) $totalarray['nbfield']++;
543 
544  print '</tr>'."\n";
545 
546  $i++;
547 }
548 
549 // Show total line
550 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
551 
552 // If no record found
553 if ($num == 0)
554 {
555  $colspan = 1;
556  foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
557  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
558 }
559 
560 
561 $db->free($resql);
562 
563 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
564 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
565 print $hookmanager->resPrint;
566 
567 print '</table>'."\n";
568 print '</div>'."\n";
569 
570 print '</form>'."\n";
571 
572 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
573 {
574  $hidegeneratedfilelistifempty = 1;
575  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
576 
577  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
578  $formfile = new FormFile($db);
579 
580  // Show list of available documents
581  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
582  $urlsource .= str_replace('&amp;', '&', $param);
583 
584  $filedir = $diroutputmassaction;
585  $genallowed = $permissiontoread;
586  $delallowed = $permissiontoadd;
587 
588  print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
589 }
590 
591 // End of page
592 llxFooter();
593 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_eval($s, $returnvalue=0, $hideerrors=1)
Replace eval function to add more security.
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.
</td >< tdcolspan="3">< spanclass="opacitymedium"></span ></td ></tr >< trclass="liste_total"> CREANCES DETTES< tdcolspan="3"class="right"></td >< tdcolspan="3"class="right"></td ></tr > CREANCES DETTES RECETTES DEPENSES trips CREANCES DETTES Y m expensereport p date_valid Y m expensereport pe datep $db idate($date_start)."' AND $column < p rowid
foreach($object->fields as $key=> $val) if(is_array($extrafields->attributes[$object->table_element]['label'])&&count($extrafields->attributes[$object->table_element]['label']) > 0) $object fields
dol_now($mode= 'auto')
Return date for now.
Class for MyObject.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:108
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
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.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
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...
Class to offer components to list and upload files.
print $_SERVER["PHP_SELF"]
Edit parameters.
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...
print
Draft customers invoices.
Definition: index.php:89
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
print $_SERVER["PHP_SELF"] n
Edit parameters.
Definition: categories.php:101
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:105
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...