dolibarr  16.0.5
cashcontrol_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 require '../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
30 
31 // Load translation files required by the page
32 $langs->loadLangs(array("banks", "other"));
33 
34 $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
35 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
36 $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
37 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
38 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
39 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
40 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'cashcontrol'; // To manage different context of search
41 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
42 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
43 
44 $id = GETPOST('id', 'int');
45 
46 // Load variable for pagination
47 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
48 $sortfield = GETPOST('sortfield', 'aZ09comma');
49 $sortorder = GETPOST('sortorder', 'aZ09comma');
50 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
51 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
52  $page = 0;
53 } // 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 //if (! $sortfield) $sortfield="p.date_fin";
58 //if (! $sortorder) $sortorder="DESC";
59 
60 // Initialize technical objects
61 $object = new CashControl($db);
62 $extrafields = new ExtraFields($db);
63 //$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id;
64 $hookmanager->initHooks(array('cashcontrol')); // Note that conf->hooks_modules contains array
65 
66 // Fetch optionals attributes and labels
67 $extrafields->fetch_name_optionals_label($object->table_element);
68 //$extrafields->fetch_name_optionals_label($object->table_element_line);
69 
70 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
71 
72 // Default sort order (if not yet defined by previous GETPOST)
73 if (!$sortfield) {
74  reset($object->fields); // Reset is required to avoid key() to return null.
75  $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
76 }
77 if (!$sortorder) {
78  $sortorder = "ASC";
79 }
80 
81 // Initialize array of search criterias
82 $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
83 $search = array();
84 foreach ($object->fields as $key => $val) {
85  if (GETPOST('search_'.$key, 'alpha') !== '') {
86  $search[$key] = GETPOST('search_'.$key, 'alpha');
87  }
88  if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
89  $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
90  $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
91  }
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  if (!empty($val['searchall'])) {
98  $fieldstosearchall['t.'.$key] = $val['label'];
99  }
100 }
101 
102 // Definition of array of fields for columns
103 $arrayfields = array();
104 foreach ($object->fields as $key => $val) {
105  // If $val['visible']==0, then we never show the field
106  if (!empty($val['visible'])) {
107  $visible = (int) dol_eval($val['visible'], 1, 1, '1');
108  $arrayfields['t.'.$key] = array(
109  'label'=>$val['label'],
110  'checked'=>(($visible < 0) ? 0 : 1),
111  'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
112  'position'=>$val['position'],
113  'help'=> isset($val['help']) ? $val['help'] : ''
114  );
115  }
116 }
117 // Extra fields
118 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
119 
120 $object->fields = dol_sort_array($object->fields, 'position');
121 $arrayfields = dol_sort_array($arrayfields, 'position');
122 
123 $permissiontoread = (!empty($user->rights->cashdesk->run) || !empty($user->rights->takepos->run));
124 $permissiontoadd = (!empty($user->rights->cashdesk->run) || !empty($user->rights->takepos->run));
125 $permissiontodelete = (!empty($user->rights->cashdesk->run) || !empty($user->rights->takepos->run));
126 
127 // Security check
128 if ($user->socid > 0) { // Protection if external user
129  //$socid = $user->socid;
130  accessforbidden();
131 }
132 if (empty($user->rights->cashdesk->run) && empty($user->rights->takepos->run)) {
133  accessforbidden();
134 }
135 
136 
137 /*
138  * Actions
139  */
140 
141 if (GETPOST('cancel', 'alpha')) {
142  $action = 'list';
143  $massaction = '';
144 }
145 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
146  $massaction = '';
147 }
148 
149 $parameters = array();
150 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
151 if ($reshook < 0) {
152  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
153 }
154 
155 if (empty($reshook)) {
156  // Selection of new fields
157  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
158 
159  // Purge search criteria
160  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
161  foreach ($object->fields as $key => $val) {
162  $search[$key] = '';
163  if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
164  $search[$key.'_dtstart'] = '';
165  $search[$key.'_dtend'] = '';
166  }
167  }
168  $toselect = array();
169  $search_array_options = array();
170  }
171  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
172  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
173  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
174  }
175 
176  // Mass actions
177  $objectclass = 'CashControl';
178  $objectlabel = 'CashControl';
179  //$uploaddir = '';
180  //include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
181 }
182 
183 
184 
185 /*
186  * View
187  */
188 
189 $form = new Form($db);
190 
191 $now = dol_now();
192 
193 //$help_url="EN:Module_pos_cash_fence|FR:Module_pos_cash_fence_FR|ES:Módulo_pos_cash_fence";
194 $help_url = '';
195 $title = $langs->trans('CashControl');
196 
197 
198 // Build and execute select
199 // --------------------------------------------------------------------
200 $sql = 'SELECT ';
201 $sql .= $object->getFieldList('t');
202 // Add fields from extrafields
203 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
204  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
205  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
206  }
207 }
208 // Add fields from hooks
209 $parameters = array();
210 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
211 $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
212 $sql = preg_replace('/,\s*$/', '', $sql);
213 $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
214 if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
215  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
216 }
217 // Add table from hooks
218 $parameters = array();
219 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
220 $sql .= $hookmanager->resPrint;
221 if ($object->ismultientitymanaged == 1) {
222  $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
223 } else {
224  $sql .= " WHERE 1 = 1";
225 }
226 foreach ($search as $key => $val) {
227  if (array_key_exists($key, $object->fields)) {
228  if ($key == 'status' && $search[$key] == -1) {
229  continue;
230  }
231  $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
232  if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
233  if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
234  $search[$key] = '';
235  }
236  $mode_search = 2;
237  }
238  if ($search[$key] != '') {
239  $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
240  }
241  } else {
242  if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
243  $columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key);
244  if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
245  if (preg_match('/_dtstart$/', $key)) {
246  $sql .= " AND t." . $columnName . " >= '" . $db->idate($search[$key]) . "'";
247  }
248  if (preg_match('/_dtend$/', $key)) {
249  $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'";
250  }
251  }
252  }
253  }
254 }
255 if ($search_all) {
256  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
257 }
258 //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
259 // Add where from extra fields
260 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
261 // Add where from hooks
262 $parameters = array();
263 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
264 $sql .= $hookmanager->resPrint;
265 
266 /* If a group by is required
267 $sql.= " GROUP BY ";
268 foreach($object->fields as $key => $val) {
269  $sql .= "t.".$key.", ";
270 }
271 // Add fields from extrafields
272 if (! empty($extrafields->attributes[$object->table_element]['label'])) {
273  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
274 }
275 // Add where from hooks
276 $parameters=array();
277 $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters, $object); // Note that $action and $object may have been modified by hook
278 $sql.=$hookmanager->resPrint;
279 $sql=preg_replace('/,\s*$/','', $sql);
280 */
281 
282 $sql .= $db->order($sortfield, $sortorder);
283 
284 // Count total nb of records
285 $nbtotalofrecords = '';
286 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
287  $resql = $db->query($sql);
288  $nbtotalofrecords = $db->num_rows($resql);
289  if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
290  $page = 0;
291  $offset = 0;
292  }
293 }
294 // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
295 if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
296  $num = $nbtotalofrecords;
297 } else {
298  if ($limit) {
299  $sql .= $db->plimit($limit + 1, $offset);
300  }
301 
302  $resql = $db->query($sql);
303  if (!$resql) {
304  dol_print_error($db);
305  exit;
306  }
307 
308  $num = $db->num_rows($resql);
309 }
310 
311 // Direct jump if only one record found
312 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
313  $obj = $db->fetch_object($resql);
314  $id = $obj->rowid;
315  header("Location: ".DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$id);
316  exit;
317 }
318 
319 
320 // Output page
321 // --------------------------------------------------------------------
322 
323 llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'classforhorizontalscrolloftabs');
324 
325 $arrayofselected = is_array($toselect) ? $toselect : array();
326 
327 $param = '';
328 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
329  $param .= '&contextpage='.urlencode($contextpage);
330 }
331 if ($limit > 0 && $limit != $conf->liste_limit) {
332  $param .= '&limit='.urlencode($limit);
333 }
334 foreach ($search as $key => $val) {
335  if (is_array($search[$key]) && count($search[$key])) {
336  foreach ($search[$key] as $skey) {
337  $param .= '&search_'.$key.'[]='.urlencode($skey);
338  }
339  } else {
340  $param .= '&search_'.$key.'='.urlencode($search[$key]);
341  }
342 }
343 if ($optioncss != '') {
344  $param .= '&optioncss='.urlencode($optioncss);
345 }
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 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
356 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
357 );
358 //if ($permissiontodelete) {
359 // $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
360 //}
361 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
362  $arrayofmassactions = array();
363 }
364 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
365 
366 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
367 if ($optioncss != '') {
368  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
369 }
370 print '<input type="hidden" name="token" value="'.newToken().'">';
371 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
372 print '<input type="hidden" name="action" value="list">';
373 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
374 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
375 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
376 
377 $permforcashfence = 1;
378 
379 $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permforcashfence);
380 
381 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'cash-register', 0, $newcardbutton, '', $limit, 0, 0, 1);
382 
383 // Add code for pre mass action (confirmation or email presend form)
384 $topicmail = "SendCashControlRef";
385 $modelmail = "cashcontrol";
386 $objecttmp = new CashControl($db);
387 $trackid = 'cashfence'.$object->id;
388 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
389 
390 if ($search_all) {
391  foreach ($fieldstosearchall as $key => $val) {
392  $fieldstosearchall[$key] = $langs->trans($val);
393  }
394  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
395 }
396 
397 $moreforfilter = '';
398 /*$moreforfilter.='<div class="divsearchfield">';
399  $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
400  $moreforfilter.= '</div>';*/
401 
402 $parameters = array();
403 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
404 if (empty($reshook)) {
405  $moreforfilter .= $hookmanager->resPrint;
406 } else {
407  $moreforfilter = $hookmanager->resPrint;
408 }
409 
410 if (!empty($moreforfilter)) {
411  print '<div class="liste_titre liste_titre_bydiv centpercent">';
412  print $moreforfilter;
413  print '</div>';
414 }
415 
416 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
417 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
418 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
419 
420 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
421 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
422 
423 
424 // Fields title search
425 // --------------------------------------------------------------------
426 print '<tr class="liste_titre">';
427 foreach ($object->fields as $key => $val) {
428  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
429  if ($key == 'status') {
430  $cssforfield .= ($cssforfield ? ' ' : '').'center';
431  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
432  $cssforfield .= ($cssforfield ? ' ' : '').'center';
433  } elseif (in_array($val['type'], array('timestamp'))) {
434  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
435  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
436  $cssforfield .= ($cssforfield ? ' ' : '').'right';
437  }
438  if (!empty($arrayfields['t.'.$key]['checked'])) {
439  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
440  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
441  print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
442  } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) {
443  print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1);
444  } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
445  print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
446  } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
447  print '<div class="nowrap">';
448  print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
449  print '</div>';
450  print '<div class="nowrap">';
451  print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
452  print '</div>';
453  }
454  print '</td>';
455  }
456 }
457 // Extra fields
458 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
459 
460 // Fields from hook
461 $parameters = array('arrayfields'=>$arrayfields);
462 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
463 print $hookmanager->resPrint;
464 // Action column
465 print '<td class="liste_titre maxwidthsearch">';
466 $searchpicto = $form->showFilterButtons();
467 print $searchpicto;
468 print '</td>';
469 print '</tr>'."\n";
470 
471 
472 // Fields title label
473 // --------------------------------------------------------------------
474 print '<tr class="liste_titre">';
475 foreach ($object->fields as $key => $val) {
476  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
477  if ($key == 'status') {
478  $cssforfield .= ($cssforfield ? ' ' : '').'center';
479  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
480  $cssforfield .= ($cssforfield ? ' ' : '').'center';
481  } elseif (in_array($val['type'], array('timestamp'))) {
482  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
483  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
484  $cssforfield .= ($cssforfield ? ' ' : '').'right';
485  }
486  if (!empty($arrayfields['t.'.$key]['checked'])) {
487  print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
488  }
489 }
490 // Extra fields
491 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
492 // Hook fields
493 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
494 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
495 print $hookmanager->resPrint;
496 // Action column
497 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
498 print '</tr>'."\n";
499 
500 
501 // Detect if we need a fetch on each output line
502 $needToFetchEachLine = 0;
503 if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
504  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
505  if (preg_match('/\$object/', $val)) {
506  $needToFetchEachLine++; // There is at least one compute field that use $object
507  }
508  }
509 }
510 
511 
512 // Loop on record
513 // --------------------------------------------------------------------
514 $i = 0;
515 $totalarray = array();
516 $totalarray['nbfield'] = 0;
517 while ($i < ($limit ? min($num, $limit) : $num)) {
518  $obj = $db->fetch_object($resql);
519  if (empty($obj)) {
520  break; // Should not happen
521  }
522 
523  // Store properties in $object
524  $object->setVarsFromFetchObj($obj);
525 
526  // Show here line of result
527  print '<tr class="oddeven">';
528  foreach ($object->fields as $key => $val) {
529  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
530  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
531  $cssforfield .= ($cssforfield ? ' ' : '').'center';
532  } elseif ($key == 'status') {
533  $cssforfield .= ($cssforfield ? ' ' : '').'center';
534  }
535 
536  if (in_array($val['type'], array('timestamp'))) {
537  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
538  } elseif ($key == 'ref') {
539  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
540  }
541 
542  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
543  $cssforfield .= ($cssforfield ? ' ' : '').'right';
544  }
545  //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
546 
547  if (!empty($arrayfields['t.'.$key]['checked'])) {
548  print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
549  if ($key == 'status') {
550  print $object->getLibStatut(5);
551  } elseif ($key == 'rowid') {
552  print $object->showOutputField($val, $key, $object->id, '');
553  } else {
554  print $object->showOutputField($val, $key, $object->$key, '');
555  }
556  print '</td>';
557  if (!$i) {
558  $totalarray['nbfield']++;
559  }
560  if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
561  if (!$i) {
562  $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
563  }
564  if (!isset($totalarray['val'])) {
565  $totalarray['val'] = array();
566  }
567  if (!isset($totalarray['val']['t.'.$key])) {
568  $totalarray['val']['t.'.$key] = 0;
569  }
570  $totalarray['val']['t.'.$key] += $object->$key;
571  }
572  }
573  }
574  // Extra fields
575  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
576  // Fields from hook
577  $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
578  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
579  print $hookmanager->resPrint;
580  // Action column
581  print '<td class="nowrap center">';
582  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
583  $selected = 0;
584  if (in_array($object->id, $arrayofselected)) {
585  $selected = 1;
586  }
587  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
588  }
589  print '</td>';
590  if (!$i) {
591  $totalarray['nbfield']++;
592  }
593 
594  print '</tr>'."\n";
595 
596  $i++;
597 }
598 
599 // Show total line
600 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
601 
602 
603 // If no record found
604 if ($num == 0) {
605  $colspan = 1;
606  foreach ($arrayfields as $key => $val) {
607  if (!empty($val['checked'])) {
608  $colspan++;
609  }
610  }
611  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
612 }
613 
614 $db->free($resql);
615 
616 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
617 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
618 print $hookmanager->resPrint;
619 
620 print '</table>'."\n";
621 print '</div>'."\n";
622 
623 print '</form>'."\n";
624 
625 /*
626 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
627  $hidegeneratedfilelistifempty = 1;
628  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
629  $hidegeneratedfilelistifempty = 0;
630  }
631 
632  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
633  $formfile = new FormFile($db);
634 
635  // Show list of available documents
636  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
637  $urlsource .= str_replace('&amp;', '&', $param);
638 
639  $filedir = $diroutputmassaction;
640  $genallowed = $permissiontoread;
641  $delallowed = $permissiontoadd;
642 
643  print $formfile->showdocuments('massfilesarea_monmodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
644 }
645 */
646 
647 // End of page
648 llxFooter();
649 $db->close();
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
CashControl
Class to manage cash fence.
Definition: cashcontrol.class.php:30
getTitleFieldOfList
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
Definition: functions.lib.php:5049
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
dol_sort_array
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...
Definition: functions.lib.php:8385
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
$help_url
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:116
dolGetButtonTitle
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.
Definition: functions.lib.php:10605
print_barre_liste
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.
Definition: functions.lib.php:5257
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
natural_search
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...
Definition: functions.lib.php:9420
dol_eval
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
Definition: functions.lib.php:8611
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
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 ...
Definition: security.lib.php:933
dol_mktime
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Definition: functions.lib.php:2757
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59