dolibarr  13.0.2
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) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
4  * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
26 // Load Dolibarr environment
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
32 
33 // Load translation files required by the page
34 $langs->loadLangs(array("assets"));
35 
36 $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
37 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
38 $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
39 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
40 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
41 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
42 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'assetlist'; // To manage different context of search
43 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
44 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
45 
46 $id = GETPOST('id', 'int');
47 
48 // Load variable for pagination
49 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
50 $sortfield = GETPOST('sortfield', 'aZ09comma');
51 $sortorder = GETPOST('sortorder', 'aZ09comma');
52 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
53 if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
54 $offset = $limit * $page;
55 $pageprev = $page - 1;
56 $pagenext = $page + 1;
57 
58 // Initialize technical objects
59 $object = new Asset($db);
60 $extrafields = new ExtraFields($db);
61 $diroutputmassaction = $conf->asset->dir_output.'/temp/massgeneration/'.$user->id;
62 $hookmanager->initHooks(array('assetlist')); // Note that conf->hooks_modules contains array
63 
64 // Fetch optionals attributes and labels
65 $extrafields->fetch_name_optionals_label($object->table_element);
66 //$extrafields->fetch_name_optionals_label($object->table_element_line);
67 
68 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
69 
70 // Default sort order (if not yet defined by previous GETPOST)
71 if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
72 if (!$sortorder) $sortorder = "ASC";
73 
74 // Security check
75 $socid = 0;
76 if ($user->socid) $socid = $user->socid;
77 if ($user->socid > 0) // Protection if external user
78 {
79  //$socid = $user->socid;
81 }
82 // Security check
83 $result = restrictedArea($user, 'asset', $id);
84 
85 
86 // Initialize array of search criterias
87 $search_all = GETPOST("search_all", 'alpha');
88 $search = array();
89 foreach ($object->fields as $key => $val)
90 {
91  if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
92 }
93 
94 // List of fields to search into when doing a "search in all"
95 $fieldstosearchall = array();
96 foreach ($object->fields as $key => $val)
97 {
98  if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
99 }
100 
101 // Definition of fields for list
102 $arrayfields = array();
103 foreach ($object->fields as $key => $val)
104 {
105  // If $val['visible']==0, then we never show the field
106  if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']);
107 }
108 // Extra fields
109 if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
110 {
111  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
112  {
113  if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
114  $arrayfields["ef.".$key] = array(
115  'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
116  'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1),
117  'position'=>$extrafields->attributes[$object->table_element]['pos'][$key],
118  'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])
119  );
120  }
121  }
122 }
123 $object->fields = dol_sort_array($object->fields, 'position');
124 $arrayfields = dol_sort_array($arrayfields, 'position');
125 
126 $permissiontoread = $user->rights->asset->read;
127 $permissiontoadd = $user->rights->asset->write;
128 $permissiontodelete = $user->rights->asset->delete;
129 
130 
131 /*
132  * Actions
133  */
134 
135 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
136 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
137 
138 $parameters = array();
139 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
140 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
141 
142 if (empty($reshook))
143 {
144  // Selection of new fields
145  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
146 
147  // Purge search criteria
148  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
149  {
150  foreach ($object->fields as $key => $val)
151  {
152  $search[$key] = '';
153  }
154  $toselect = '';
155  $search_array_options = array();
156  }
157  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
158  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
159  {
160  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
161  }
162 
163  // Mass actions
164  $objectclass = 'Asset';
165  $objectlabel = 'Asset';
166  $uploaddir = $conf->asset->dir_output;
167  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
168 }
169 
170 
171 
172 /*
173  * View
174  */
175 
176 $form = new Form($db);
177 
178 $now = dol_now();
179 
180 //$help_url="EN:Module_Asset|FR:Module_Asset_FR|ES:Módulo_Asset";
181 $help_url = '';
182 $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Assets"));
183 
184 
185 // Build and execute select
186 // --------------------------------------------------------------------
187 $sql = 'SELECT ';
188 foreach ($object->fields as $key => $val)
189 {
190  $sql .= 't.'.$key.', ';
191 }
192 // Add fields from extrafields
193 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
194  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
195 }
196 // Add fields from hooks
197 $parameters = array();
198 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
199 $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
200 $sql = preg_replace('/,\s*$/', '', $sql);
201 $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
202 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)";
203 if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
204 else $sql .= " WHERE 1 = 1";
205 foreach ($search as $key => $val)
206 {
207  if ($key == 'status' && $search[$key] == -1) continue;
208  $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
209  if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
210  if ($search[$key] == '-1') $search[$key] = '';
211  $mode_search = 2;
212  }
213  if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
214 }
215 if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
216 //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
217 // Add where from extra fields
218 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
219 // Add where from hooks
220 $parameters = array();
221 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
222 $sql .= $hookmanager->resPrint;
223 
224 /* If a group by is required
225 $sql.= " GROUP BY "
226 foreach($object->fields as $key => $val)
227 {
228  $sql.='t.'.$key.', ';
229 }
230 // Add fields from extrafields
231 if (! empty($extrafields->attributes[$object->table_element]['label'])) {
232  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
233 }
234 // Add where from hooks
235 $parameters=array();
236 $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook
237 $sql.=$hookmanager->resPrint;
238 $sql=preg_replace('/,\s*$/','', $sql);
239 */
240 
241 $sql .= $db->order($sortfield, $sortorder);
242 
243 // Count total nb of records
244 $nbtotalofrecords = '';
245 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
246 {
247  $resql = $db->query($sql);
248  $nbtotalofrecords = $db->num_rows($resql);
249  if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
250  {
251  $page = 0;
252  $offset = 0;
253  }
254 }
255 // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
256 if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
257 {
258  $num = $nbtotalofrecords;
259 } else {
260  if ($limit) $sql .= $db->plimit($limit + 1, $offset);
261 
262  $resql = $db->query($sql);
263  if (!$resql)
264  {
265  dol_print_error($db);
266  exit;
267  }
268 
269  $num = $db->num_rows($resql);
270 }
271 
272 // Direct jump if only one record found
273 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page)
274 {
275  $obj = $db->fetch_object($resql);
276  $id = $obj->rowid;
277  header("Location: ".DOL_URL_ROOT.'/asset/card.php?id='.$id);
278  exit;
279 }
280 
281 
282 // Output page
283 // --------------------------------------------------------------------
284 
285 llxHeader('', $title, $help_url);
286 
287 // Example : Adding jquery code
288 print '<script type="text/javascript" language="javascript">
289 jQuery(document).ready(function() {
290  function init_myfunc()
291  {
292  jQuery("#myid").removeAttr(\'disabled\');
293  jQuery("#myid").attr(\'disabled\',\'disabled\');
294  }
295  init_myfunc();
296  jQuery("#mybutton").click(function() {
297  init_myfunc();
298  });
299 });
300 </script>';
301 
302 $arrayofselected = is_array($toselect) ? $toselect : array();
303 
304 $param = '';
305 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
306 if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
307 foreach ($search as $key => $val)
308 {
309  if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey);
310  else $param .= '&search_'.$key.'='.urlencode($search[$key]);
311 }
312 if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
313 // Add $param from extra fields
314 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
315 
316 // List of mass actions available
317 $arrayofmassactions = array(
318  //'presend'=>$langs->trans("SendByMail"),
319  //'builddoc'=>$langs->trans("PDFMerge"),
320 );
321 if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
322 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
323 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
324 
325 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
326 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
327 print '<input type="hidden" name="token" value="'.newToken().'">';
328 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
329 print '<input type="hidden" name="action" value="list">';
330 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
331 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
332 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
333 
334 $newcardbutton = dolGetButtonTitle($langs->trans('NewAsset'), '', 'fa fa-plus-circle', dol_buildpath('/asset/card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
335 
336 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
337 
338 // Add code for pre mass action (confirmation or email presend form)
339 $topicmail = "SendAssetsRef";
340 $modelmail = "asset";
341 $objecttmp = new Asset($db);
342 $trackid = 'asset'.$object->id;
343 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
344 
345 if ($sall)
346 {
347  foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
348  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
349 }
350 
351 $moreforfilter = '';
352 /*$moreforfilter.='<div class="divsearchfield">';
353 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
354 $moreforfilter.= '</div>';*/
355 
356 $parameters = array();
357 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
358 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
359 else $moreforfilter = $hookmanager->resPrint;
360 
361 if (!empty($moreforfilter))
362 {
363  print '<div class="liste_titre liste_titre_bydiv centpercent">';
364  print $moreforfilter;
365  print '</div>';
366 }
367 
368 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
369 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
370 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
371 
372 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
373 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
374 
375 
376 // Fields title search
377 // --------------------------------------------------------------------
378 print '<tr class="liste_titre">';
379 foreach ($object->fields as $key => $val)
380 {
381  $cssforfield = (empty($val['css']) ? '' : $val['css']);
382  if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
383  elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
384  elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
385  elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
386  if (!empty($arrayfields['t.'.$key]['checked']))
387  {
388  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
389  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);
390  elseif (strpos($val['type'], 'integer:') === 0) {
391  print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
392  } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
393  print '</td>';
394  }
395 }
396 // Extra fields
397 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
398 
399 // Fields from hook
400 $parameters = array('arrayfields'=>$arrayfields);
401 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
402 print $hookmanager->resPrint;
403 // Action column
404 print '<td class="liste_titre maxwidthsearch">';
405 $searchpicto = $form->showFilterButtons();
406 print $searchpicto;
407 print '</td>';
408 print '</tr>'."\n";
409 
410 
411 // Fields title label
412 // --------------------------------------------------------------------
413 print '<tr class="liste_titre">';
414 foreach ($object->fields as $key => $val)
415 {
416  $cssforfield = (empty($val['css']) ? '' : $val['css']);
417  if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
418  elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
419  elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
420  elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
421  if (!empty($arrayfields['t.'.$key]['checked']))
422  {
423  print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
424  }
425 }
426 // Extra fields
427 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
428 // Hook fields
429 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
430 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
431 print $hookmanager->resPrint;
432 // Action column
433 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n";
434 print '</tr>'."\n";
435 
436 
437 // Detect if we need a fetch on each output line
438 $needToFetchEachLine = 0;
439 if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0)
440 {
441  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
442  {
443  if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
444  }
445 }
446 
447 
448 // Loop on record
449 // --------------------------------------------------------------------
450 $i = 0;
451 $totalarray = array();
452 while ($i < ($limit ? min($num, $limit) : $num))
453 {
454  $obj = $db->fetch_object($resql);
455  if (empty($obj)) break; // Should not happen
456 
457  // Store properties in $object
458  $object->setVarsFromFetchObj($obj);
459 
460  // Show here line of result
461  print '<tr class="oddeven">';
462  foreach ($object->fields as $key => $val)
463  {
464  $cssforfield = (empty($val['css']) ? '' : $val['css']);
465  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
466  elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
467 
468  if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
469  elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
470 
471  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right';
472 
473  if (!empty($arrayfields['t.'.$key]['checked']))
474  {
475  print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
476  if ($key == 'status') print $object->getLibStatut(5);
477  else print $object->showOutputField($val, $key, $object->$key, '');
478  print '</td>';
479  if (!$i) $totalarray['nbfield']++;
480  if (!empty($val['isameasure']))
481  {
482  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
483  $totalarray['val']['t.'.$key] += $object->$key;
484  }
485  }
486  }
487  // Extra fields
488  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
489  // Fields from hook
490  $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
491  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
492  print $hookmanager->resPrint;
493  // Action column
494  print '<td class="nowrap center">';
495  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
496  {
497  $selected = 0;
498  if (in_array($object->id, $arrayofselected)) $selected = 1;
499  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
500  }
501  print '</td>';
502  if (!$i) $totalarray['nbfield']++;
503 
504  print '</tr>'."\n";
505 
506  $i++;
507 }
508 
509 // Show total line
510 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
511 
512 // If no record found
513 if ($num == 0)
514 {
515  $colspan = 1;
516  foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
517  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
518 }
519 
520 
521 $db->free($resql);
522 
523 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
524 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
525 print $hookmanager->resPrint;
526 
527 print '</table>'."\n";
528 print '</div>'."\n";
529 
530 print '</form>'."\n";
531 
532 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
533 {
534  $hidegeneratedfilelistifempty = 1;
535  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
536 
537  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
538  $formfile = new FormFile($db);
539 
540  // Show list of available documents
541  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
542  $urlsource .= str_replace('&amp;', '&', $param);
543 
544  $filedir = $diroutputmassaction;
545  $genallowed = $permissiontoread;
546  $delallowed = $permissiontoadd;
547 
548  print $formfile->showdocuments('massfilesarea_asset', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '');
549 }
550 
551 // End of page
552 llxFooter();
553 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
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.
$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.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
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
Class for Asset.
Definition: asset.class.php:30
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...