dolibarr  13.0.2
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 //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('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
35 //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
36 //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
37 //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library
38 //if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
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 
43 require '../../main.inc.php';
44 require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php';
45 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
46 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
47 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
48 
49 // Load translation files required by the page
50 $langs->loadLangs(array("banks", "other"));
51 
52 $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
53 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
54 $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
55 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
56 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
57 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
58 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'cashcontrol'; // To manage different context of search
59 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
60 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
61 
62 $id = GETPOST('id', 'int');
63 
64 // Load variable for pagination
65 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
66 $sortfield = GETPOST('sortfield', 'aZ09comma');
67 $sortorder = GETPOST('sortorder', 'aZ09comma');
68 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
69 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
70 $offset = $limit * $page;
71 $pageprev = $page - 1;
72 $pagenext = $page + 1;
73 //if (! $sortfield) $sortfield="p.date_fin";
74 //if (! $sortorder) $sortorder="DESC";
75 
76 // Initialize technical objects
77 $object = new CashControl($db);
78 $extrafields = new ExtraFields($db);
79 $diroutputmassaction = $conf->monmodule->dir_output.'/temp/massgeneration/'.$user->id;
80 $hookmanager->initHooks(array('cashcontrol')); // Note that conf->hooks_modules contains array
81 
82 // Fetch optionals attributes and labels
83 $extrafields->fetch_name_optionals_label($object->table_element);
84 
85 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
86 
87 // Default sort order (if not yet defined by previous GETPOST)
88 if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
89 if (!$sortorder) $sortorder = "ASC";
90 
91 // Security check
92 $socid = 0;
93 if ($user->socid > 0) // Protection if external user
94 {
95  //$socid = $user->socid;
97 }
98 //$result = restrictedArea($user, 'monmodule', $id, '');
99 
100 // Initialize array of search criterias
101 $search_all = GETPOST("search_all", 'alpha');
102 $search = array();
103 foreach ($object->fields as $key => $val)
104 {
105  if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
106 }
107 
108 // List of fields to search into when doing a "search in all"
109 $fieldstosearchall = array();
110 foreach ($object->fields as $key => $val)
111 {
112  if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
113 }
114 
115 // Definition of fields for list
116 $arrayfields = array();
117 foreach ($object->fields as $key => $val)
118 {
119  // If $val['visible']==0, then we never show the field
120  if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
121 }
122 // Extra fields
123 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
124 
125 $object->fields = dol_sort_array($object->fields, 'position');
126 $arrayfields = dol_sort_array($arrayfields, 'position');
127 
128 
129 
130 /*
131  * Actions
132  */
133 
134 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
135 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
136 
137 $parameters = array();
138 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
139 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
140 
141 if (empty($reshook))
142 {
143  // Selection of new fields
144  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
145 
146  // Purge search criteria
147  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
148  {
149  foreach ($object->fields as $key => $val)
150  {
151  $search[$key] = '';
152  }
153  $toselect = '';
154  $search_array_options = array();
155  }
156  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
157  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
158  {
159  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
160  }
161 
162  // Mass actions
163  $objectclass = 'CashControl';
164  $objectlabel = 'CashControl';
165  $permissiontoread = ($user->rights->cashdesk->run || $user->rights->takepos->run);
166  $permissiontodelete = ($user->rights->cashdesk->run || $user->rights->takepos->run);
167 
168  //$uploaddir = '';
169  //include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
170 }
171 
172 
173 
174 /*
175  * View
176  */
177 
178 $form = new Form($db);
179 
180 $now = dol_now();
181 
182 //$help_url="EN:Module_pos_cash_fence|FR:Module_pos_cash_fence_FR|ES:Módulo_pos_cash_fence";
183 $help_url = '';
184 $title = $langs->trans('CashControl');
185 
186 
187 // Build and execute select
188 // --------------------------------------------------------------------
189 $sql = 'SELECT ';
190 foreach ($object->fields as $key => $val)
191 {
192  $sql .= 't.'.$key.', ';
193 }
194 // Add fields from extrafields
195 if (!empty($extrafields->attributes[$object->table_element]['label']))
196 {
197  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
198 }
199 // Add fields from hooks
200 $parameters = array();
201 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
202 $sql .= $hookmanager->resPrint;
203 $sql = preg_replace('/, $/', '', $sql);
204 $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
205 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)";
206 if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
207 else $sql .= " WHERE 1 = 1";
208 foreach ($search as $key => $val)
209 {
210  if ($key == 'status' && $search[$key] == -1) continue;
211  $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
212  if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
213 }
214 if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
215 // Add where from extra fields
216 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
217 // Add where from hooks
218 $parameters = array();
219 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
220 $sql .= $hookmanager->resPrint;
221 
222 /* If a group by is required
223  $sql.= " GROUP BY "
224  foreach($object->fields as $key => $val)
225  {
226  $sql.='t.'.$key.', ';
227  }
228  // Add fields from extrafields
229  if (! empty($extrafields->attributes[$object->table_element]['label'])) {
230  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
231  // Add where from hooks
232  $parameters=array();
233  $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook
234  $sql.=$hookmanager->resPrint;
235  $sql=preg_replace('/, $/','', $sql);
236  */
237 
238 $sql .= $db->order($sortfield, $sortorder);
239 
240 // Count total nb of records
241 $nbtotalofrecords = '';
242 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
243 {
244  $resql = $db->query($sql);
245  $nbtotalofrecords = $db->num_rows($resql);
246  if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
247  {
248  $page = 0;
249  $offset = 0;
250  }
251 }
252 // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
253 if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
254 {
255  $num = $nbtotalofrecords;
256 } else {
257  $sql .= $db->plimit($limit + 1, $offset);
258 
259  $resql = $db->query($sql);
260  if (!$resql)
261  {
262  dol_print_error($db);
263  exit;
264  }
265 
266  $num = $db->num_rows($resql);
267 }
268 
269 // Direct jump if only one record found
270 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
271 {
272  $obj = $db->fetch_object($resql);
273  $id = $obj->rowid;
274  header("Location: ".dol_buildpath('/compta/cashcontrol/cashcontrol_card.php', 1).'?id='.$id);
275  exit;
276 }
277 
278 
279 // Output page
280 // --------------------------------------------------------------------
281 
282 llxHeader('', $title, $help_url);
283 
284 // Example : Adding jquery code
285 print '<script type="text/javascript" language="javascript">
286 jQuery(document).ready(function() {
287  function init_myfunc()
288  {
289  jQuery("#myid").removeAttr(\'disabled\');
290  jQuery("#myid").attr(\'disabled\',\'disabled\');
291  }
292  init_myfunc();
293  jQuery("#mybutton").click(function() {
294  init_myfunc();
295  });
296 });
297 </script>';
298 
299 $arrayofselected = is_array($toselect) ? $toselect : array();
300 
301 $param = '';
302 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
303 if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
304 foreach ($search as $key => $val)
305 {
306  $param .= '&search_'.$key.'='.urlencode($search[$key]);
307 }
308 if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
309 // Add $param from extra fields
310 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
311 
312 // List of mass actions available
313 $arrayofmassactions = array(
314 //'presend'=>$langs->trans("SendByMail"),
315 //'builddoc'=>$langs->trans("PDFMerge"),
316 );
317 //if ($user->rights->monmodule->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
318 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
319 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
320 
321 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
322 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
323 print '<input type="hidden" name="token" value="'.newToken().'">';
324 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
325 print '<input type="hidden" name="action" value="list">';
326 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
327 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
328 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
329 
330 $permforcashfence = 1;
331 
332 $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);
333 
334 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'cash-register', 0, $newcardbutton, '', $limit, 0, 0, 1);
335 
336 // Add code for pre mass action (confirmation or email presend form)
337 $topicmail = "SendCashControlRef";
338 $modelmail = "cashcontrol";
339 $objecttmp = new CashControl($db);
340 $trackid = 'cashfence'.$object->id;
341 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
342 
343 if ($sall)
344 {
345  foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
346  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
347 }
348 
349 $moreforfilter = '';
350 /*$moreforfilter.='<div class="divsearchfield">';
351  $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
352  $moreforfilter.= '</div>';*/
353 
354 $parameters = array();
355 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
356 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
357 else $moreforfilter = $hookmanager->resPrint;
358 
359 if (!empty($moreforfilter))
360 {
361  print '<div class="liste_titre liste_titre_bydiv centpercent">';
362  print $moreforfilter;
363  print '</div>';
364 }
365 
366 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
367 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
368 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
369 
370 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
371 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
372 
373 
374 // Fields title search
375 // --------------------------------------------------------------------
376 print '<tr class="liste_titre">';
377 foreach ($object->fields as $key => $val)
378 {
379  $cssforfield = (empty($val['css']) ? '' : $val['css']);
380  if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
381  elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
382  elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
383  elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
384  if (!empty($arrayfields['t.'.$key]['checked']))
385  {
386  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
387  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);
388  else print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
389  print '</td>';
390  }
391 }
392 // Extra fields
393 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
394 
395 // Fields from hook
396 $parameters = array('arrayfields'=>$arrayfields);
397 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
398 print $hookmanager->resPrint;
399 // Action column
400 print '<td class="liste_titre maxwidthsearch">';
401 $searchpicto = $form->showFilterButtons();
402 print $searchpicto;
403 print '</td>';
404 print '</tr>'."\n";
405 
406 
407 // Fields title label
408 // --------------------------------------------------------------------
409 print '<tr class="liste_titre">';
410 foreach ($object->fields as $key => $val)
411 {
412  $cssforfield = (empty($val['css']) ? '' : $val['css']);
413  if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
414  elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
415  elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
416  elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
417  if (!empty($arrayfields['t.'.$key]['checked']))
418  {
419  print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
420  }
421 }
422 // Extra fields
423 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
424 // Hook fields
425 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
426 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
427 print $hookmanager->resPrint;
428 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n";
429 print '</tr>'."\n";
430 
431 
432 // Detect if we need a fetch on each output line
433 $needToFetchEachLine = 0;
434 if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0)
435 {
436  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
437  {
438  if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
439  }
440 }
441 
442 
443 // Loop on record
444 // --------------------------------------------------------------------
445 $i = 0;
446 $totalarray = array();
447 while ($i < min($num, $limit))
448 {
449  $obj = $db->fetch_object($resql);
450  if (empty($obj)) break; // Should not happen
451 
452  // Store properties in $object
453  $object->id = $obj->rowid;
454  foreach ($object->fields as $key => $val)
455  {
456  if (property_exists($obj, $key)) $object->$key = $obj->$key;
457  }
458 
459  // Show here line of result
460  print '<tr class="oddeven">';
461  foreach ($object->fields as $key => $val)
462  {
463  $cssforfield = (empty($val['css']) ? '' : $val['css']);
464  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
465  elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
466 
467  if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
468  elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
469 
470  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right';
471 
472  if (!empty($arrayfields['t.'.$key]['checked']))
473  {
474  print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
475  if ($key == 'status') print $object->getLibStatut(5);
476  elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), '');
477  else print $object->showOutputField($val, $key, $obj->$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] += $obj->$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, '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" align="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($obj->rowid, $arrayofselected)) $selected = 1;
499  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
500  }
501  print '</td>';
502  if (!$i) $totalarray['nbfield']++;
503 
504  print '</tr>';
505 
506  $i++;
507 }
508 
509 // Show total line
510 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
511 
512 
513 // If no record found
514 if ($num == 0)
515 {
516  $colspan = 1;
517  foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
518  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
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 = $user->rights->monmodule->read;
546  $delallowed = $user->rights->monmodule->create;
547 
548  print $formfile->showdocuments('massfilesarea_monmodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
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.
dol_now($mode= 'auto')
Return date for now.
Class to manage cash fence.
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.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
Definition: notice.php:44
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...
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...