dolibarr 21.0.0-beta
cashcontrol_list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2024 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
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// Load Dolibarr environment
26require '../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php';
28require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
31
40// Load translation files required by the page
41$langs->loadLangs(array("banks", "other"));
42
43$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
44$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
45$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
46$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
47$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
48$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
49$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'cashcontrol'; // To manage different context of search
50$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
51$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
52$mode = GETPOST('mode', 'alpha'); // for mode view result
53$id = GETPOSTINT('id');
54
55// Load variable for pagination
56$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
57$sortfield = GETPOST('sortfield', 'aZ09comma');
58$sortorder = GETPOST('sortorder', 'aZ09comma');
59$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
60if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
61 // If $page is not defined, or '' or -1 or if we click on clear filters
62 $page = 0;
63}
64$offset = $limit * $page;
65$pageprev = $page - 1;
66$pagenext = $page + 1;
67//if (! $sortfield) $sortfield="p.date_fin";
68//if (! $sortorder) $sortorder="DESC";
69
70// Initialize a technical objects
71$object = new CashControl($db);
72$extrafields = new ExtraFields($db);
73//$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id;
74$hookmanager->initHooks(array('cashcontrol')); // Note that conf->hooks_modules contains array
75
76// Fetch optionals attributes and labels
77$extrafields->fetch_name_optionals_label($object->table_element);
78//$extrafields->fetch_name_optionals_label($object->table_element_line);
79
80$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
81
82// Default sort order (if not yet defined by previous GETPOST)
83if (!$sortfield) {
84 reset($object->fields); // Reset is required to avoid key() to return null.
85 $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
86}
87if (!$sortorder) {
88 $sortorder = "ASC";
89}
90
91// Initialize array of search criteria
92$search_all = GETPOST('search_all', 'alphanohtml');
93$search = array();
94foreach ($object->fields as $key => $val) {
95 if (GETPOST('search_'.$key, 'alpha') !== '') {
96 $search[$key] = GETPOST('search_'.$key, 'alpha');
97 }
98 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
99 $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOSTINT('search_'.$key.'_dtstartmonth'), GETPOSTINT('search_'.$key.'_dtstartday'), GETPOSTINT('search_'.$key.'_dtstartyear'));
100 $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_'.$key.'_dtendmonth'), GETPOSTINT('search_'.$key.'_dtendday'), GETPOSTINT('search_'.$key.'_dtendyear'));
101 }
102}
103
104// List of fields to search into when doing a "search in all"
105$fieldstosearchall = array();
106foreach ($object->fields as $key => $val) {
107 if (!empty($val['searchall'])) {
108 $fieldstosearchall['t.'.$key] = $val['label'];
109 }
110}
111
112// Definition of array of fields for columns
113$arrayfields = array();
114foreach ($object->fields as $key => $val) {
115 // If $val['visible']==0, then we never show the field
116 if (!empty($val['visible'])) {
117 $visible = (int) dol_eval((string) $val['visible'], 1);
118 $arrayfields['t.'.$key] = array(
119 'label'=>$val['label'],
120 'checked'=>(($visible < 0) ? 0 : 1),
121 'enabled'=>(abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)),
122 'position'=>$val['position'],
123 'help'=> isset($val['help']) ? $val['help'] : ''
124 );
125 }
126}
127// Extra fields
128include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
129
130$object->fields = dol_sort_array($object->fields, 'position');
131$arrayfields = dol_sort_array($arrayfields, 'position');
132
133$permissiontoread = ($user->hasRight('cashdesk', 'run') || $user->hasRight('takepos', 'run'));
134$permissiontoadd = ($user->hasRight('cashdesk', 'run') || $user->hasRight('takepos', 'run'));
135$permissiontodelete = ($user->hasRight('cashdesk', 'run') || $user->hasRight('takepos', 'run'));
136
137// Security check
138if ($user->socid > 0) { // Protection if external user
139 //$socid = $user->socid;
141}
142if (!$user->hasRight('cashdesk', 'run') && !$user->hasRight('takepos', 'run')) {
144}
145
146
147/*
148 * Actions
149 */
150
151if (GETPOST('cancel', 'alpha')) {
152 $action = 'list';
153 $massaction = '';
154}
155if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
156 $massaction = '';
157}
158
159$parameters = array();
160$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
161if ($reshook < 0) {
162 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
163}
164
165if (empty($reshook)) {
166 // Selection of new fields
167 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
168
169 // Purge search criteria
170 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
171 foreach ($object->fields as $key => $val) {
172 $search[$key] = '';
173 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
174 $search[$key.'_dtstart'] = '';
175 $search[$key.'_dtend'] = '';
176 }
177 }
178 $toselect = array();
179 $search_array_options = array();
180 }
181 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
182 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
183 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
184 }
185
186 // Mass actions
187 $objectclass = 'CashControl';
188 $objectlabel = 'CashControl';
189 $uploaddir = $conf->bank->dir_output;
190 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
191}
192
193
194
195/*
196 * View
197 */
198
199$form = new Form($db);
200
201$now = dol_now();
202
203//$help_url="EN:Module_pos_cash_fence|FR:Module_pos_cash_fence_FR|ES:Módulo_pos_cash_fence";
204$help_url = '';
205$title = $langs->trans('CashControl');
206$morejs = array();
207$morecss = array();
208
209// Build and execute select
210// --------------------------------------------------------------------
211$sql = 'SELECT ';
212$sql .= $object->getFieldList('t');
213// Add fields from extrafields
214if (!empty($extrafields->attributes[$object->table_element]['label'])) {
215 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
216 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
217 }
218}
219// Add fields from hooks
220$parameters = array();
221$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
222$sql .= $hookmanager->resPrint;
223$sql = preg_replace('/,\s*$/', '', $sql);
224
225$sqlfields = $sql; // $sql fields to remove for count total
226
227$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
228if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
229 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
230}
231// Add table from hooks
232$parameters = array();
233$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
234$sql .= $hookmanager->resPrint;
235if ($object->ismultientitymanaged == 1) {
236 $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
237} else {
238 $sql .= " WHERE 1 = 1";
239}
240foreach ($search as $key => $val) {
241 if (array_key_exists($key, $object->fields)) {
242 if ($key == 'status' && $search[$key] == -1) {
243 continue;
244 }
245 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
246 if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
247 if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
248 $search[$key] = '';
249 }
250 $mode_search = 2;
251 }
252 if ($search[$key] != '') {
253 $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
254 }
255 } else {
256 if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
257 $columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key);
258 if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
259 if (preg_match('/_dtstart$/', $key)) {
260 $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'";
261 }
262 if (preg_match('/_dtend$/', $key)) {
263 $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'";
264 }
265 }
266 }
267 }
268}
269if ($search_all) {
270 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
271}
272//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
273// Add where from extra fields
274include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
275// Add where from hooks
276$parameters = array();
277$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
278$sql .= $hookmanager->resPrint;
279
280/* If a group by is required
281$sql.= " GROUP BY ";
282foreach($object->fields as $key => $val) {
283 $sql .= "t.".$db->escape($key).", ";
284}
285// Add fields from extrafields
286if (!empty($extrafields->attributes[$object->table_element]['label'])) {
287 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
288 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
289 }
290}
291// Add where from hooks
292$parameters=array();
293$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters, $object); // Note that $action and $object may have been modified by hook
294$sql.=$hookmanager->resPrint;
295$sql=preg_replace('/,\s*$/','', $sql);
296*/
297
298
299// Count total nb of records
300$nbtotalofrecords = '';
301if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
302 /* The fast and low memory method to get and count full list converts the sql into a sql count */
303 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
304 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
305 $resql = $db->query($sqlforcount);
306 if ($resql) {
307 $objforcount = $db->fetch_object($resql);
308 $nbtotalofrecords = $objforcount->nbtotalofrecords;
309 } else {
310 dol_print_error($db);
311 }
312
313 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
314 $page = 0;
315 $offset = 0;
316 }
317 $db->free($resql);
318}
319
320// Complete request and execute it with limit
321$sql .= $db->order($sortfield, $sortorder);
322if ($limit) {
323 $sql .= $db->plimit($limit + 1, $offset);
324}
325
326$resql = $db->query($sql);
327if (!$resql) {
328 dol_print_error($db);
329 exit;
330}
331
332$num = $db->num_rows($resql);
333
334
335// Direct jump if only one record found
336if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
337 $obj = $db->fetch_object($resql);
338 $id = $obj->rowid;
339 header("Location: ".DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$id);
340 exit;
341}
342
343
344// Output page
345// --------------------------------------------------------------------
346
347llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist');
348
349$arrayofselected = is_array($toselect) ? $toselect : array();
350
351$param = '';
352if (!empty($mode)) {
353 $param .= '&mode='.urlencode($mode);
354}
355if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
356 $param .= '&contextpage='.urlencode($contextpage);
357}
358if ($limit > 0 && $limit != $conf->liste_limit) {
359 $param .= '&limit='.((int) $limit);
360}
361foreach ($search as $key => $val) {
362 if (is_array($search[$key])) {
363 foreach ($search[$key] as $skey) {
364 if ($skey != '') {
365 $param .= '&search_'.$key.'[]='.urlencode($skey);
366 }
367 }
368 } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
369 $param .= '&search_'.$key.'month='.(GETPOSTINT('search_'.$key.'month'));
370 $param .= '&search_'.$key.'day='.(GETPOSTINT('search_'.$key.'day'));
371 $param .= '&search_'.$key.'year='.(GETPOSTINT('search_'.$key.'year'));
372 } elseif ($search[$key] != '') {
373 $param .= '&search_'.$key.'='.urlencode($search[$key]);
374 }
375}
376if ($optioncss != '') {
377 $param .= '&optioncss='.urlencode($optioncss);
378}
379// Add $param from extra fields
380include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
381// Add $param from hooks
382$parameters = array('param' => &$param);
383$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
384$param .= $hookmanager->resPrint;
385
386// List of mass actions available
387$arrayofmassactions = array();
388if (!empty($permissiontodelete)) {
389 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
390}
391$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
392
393print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
394if ($optioncss != '') {
395 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
396}
397print '<input type="hidden" name="token" value="'.newToken().'">';
398print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
399print '<input type="hidden" name="action" value="list">';
400print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
401print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
402print '<input type="hidden" name="page" value="'.$page.'">';
403print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
404print '<input type="hidden" name="mode" value="'.$mode.'">';
405
406$permforcashfence = 1;
407
408$newcardbutton = '';
409$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
410$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
411$newcardbutton .= dolGetButtonTitleSeparator();
412$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);
413
414print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'cash-register', 0, $newcardbutton, '', $limit, 0, 0, 1);
415
416// Add code for pre mass action (confirmation or email presend form)
417$topicmail = "SendCashControlRef";
418$modelmail = "cashcontrol";
419$objecttmp = new CashControl($db);
420$trackid = 'cashfence'.$object->id;
421include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
422
423if ($search_all) {
424 $setupstring = '';
425 foreach ($fieldstosearchall as $key => $val) {
426 $fieldstosearchall[$key] = $langs->trans($val);
427 $setupstring .= $key."=".$val.";";
428 }
429 print '<!-- Search done like if BOOKCAL_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
430 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
431}
432
433$moreforfilter = '';
434/*$moreforfilter.='<div class="divsearchfield">';
435 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
436 $moreforfilter.= '</div>';*/
437
438$parameters = array();
439$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
440if (empty($reshook)) {
441 $moreforfilter .= $hookmanager->resPrint;
442} else {
443 $moreforfilter = $hookmanager->resPrint;
444}
445
446if (!empty($moreforfilter)) {
447 print '<div class="liste_titre liste_titre_bydiv centpercent">';
448 print $moreforfilter;
449 print '</div>';
450}
451
452$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
453$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
454$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
455
456print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
457print '<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
458
459
460// Fields title search
461// --------------------------------------------------------------------
462print '<tr class="liste_titre">';
463// Action column
464if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
465 print '<td class="liste_titre maxwidthsearch">';
466 $searchpicto = $form->showFilterButtons('left');
467 print $searchpicto;
468 print '</td>';
469}
470foreach ($object->fields as $key => $val) {
471 //$searchkey = empty($search[$key]) ? '' : $search[$key];
472 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
473 if ($key == 'status') {
474 $cssforfield .= ($cssforfield ? ' ' : '').'center';
475 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
476 $cssforfield .= ($cssforfield ? ' ' : '').'center';
477 } elseif (in_array($val['type'], array('timestamp'))) {
478 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
479 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
480 $cssforfield .= ($cssforfield ? ' ' : '').'right';
481 }
482 if (!empty($arrayfields['t.'.$key]['checked'])) {
483 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
484 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
485 print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), 1, 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
486 } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
487 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
488 } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
489 print '<div class="nowrap">';
490 print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
491 print '</div>';
492 print '<div class="nowrap">';
493 print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
494 print '</div>';
495 } elseif ($key == 'lang') {
496 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
497 $formadmin = new FormAdmin($db);
498 print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2);
499 } else {
500 print '<input type="text" class="flat maxwidth'.(in_array($val['type'], array('integer', 'price')) ? '50' : '75').'" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
501 }
502 print '</td>';
503 }
504}
505// Extra fields
506include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
507
508// Fields from hook
509$parameters = array('arrayfields'=>$arrayfields);
510$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
511print $hookmanager->resPrint;
512// Action column
513if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
514 print '<td class="liste_titre maxwidthsearch">';
515 $searchpicto = $form->showFilterButtons();
516 print $searchpicto;
517 print '</td>';
518}
519print '</tr>'."\n";
520
521
522$totalarray = array();
523$totalarray['nbfield'] = 0;
524
525// Fields title label
526// --------------------------------------------------------------------
527print '<tr class="liste_titre">';
528// Action column
529if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
530 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
531 $totalarray['nbfield']++;
532}
533foreach ($object->fields as $key => $val) {
534 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
535 if ($key == 'status') {
536 $cssforfield .= ($cssforfield ? ' ' : '').'center';
537 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
538 $cssforfield .= ($cssforfield ? ' ' : '').'center';
539 } elseif (in_array($val['type'], array('timestamp'))) {
540 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
541 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
542 $cssforfield .= ($cssforfield ? ' ' : '').'right';
543 }
544 if (!empty($arrayfields['t.'.$key]['checked'])) {
545 print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
546 $totalarray['nbfield']++;
547 }
548}
549// Extra fields
550include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
551// Hook fields
552$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
553$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
554print $hookmanager->resPrint;
555// Action column
556if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
557 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
558 $totalarray['nbfield']++;
559}
560print '</tr>'."\n";
561
562
563// Detect if we need a fetch on each output line
564$needToFetchEachLine = 0;
565if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
566 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
567 if (!is_null($val) && preg_match('/\$object/', $val)) {
568 $needToFetchEachLine++; // There is at least one compute field that use $object
569 }
570 }
571}
572
573
574// Loop on record
575// --------------------------------------------------------------------
576$i = 0;
577$savnbfield = $totalarray['nbfield'];
578$totalarray = array();
579$totalarray['nbfield'] = 0;
580while ($i < ($limit ? min($num, $limit) : $num)) {
581 $obj = $db->fetch_object($resql);
582 if (empty($obj)) {
583 break; // Should not happen
584 }
585
586 // Store properties in $object
587 $object->setVarsFromFetchObj($obj);
588
589 // show kanban result
590 if ($mode == 'kanban') {
591 if ($i == 0) {
592 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
593 print '<div class="box-flex-container kanban">';
594 }
595
596 $object->posmodule = $obj->posmodule;
597 $object->cash = $obj->cash;
598 $object->cheque = $obj->cheque;
599 $object->card = $obj->card;
600 $object->opening = $obj->opening;
601 $object->year_close = $obj->year_close;
602
603 // Output Kanban
604 $selected = -1;
605 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
606 $selected = 0;
607 if (in_array($object->id, $arrayofselected)) {
608 $selected = 1;
609 }
610 }
611 print $object->getKanbanView('', array('selected' => $selected));
612 if ($i == (min($num, $limit) - 1)) {
613 print '</div>';
614 print '</td></tr>';
615 }
616 } else {
617 // Show here line of result
618 $j = 0;
619 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
620
621 // Action column
622 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
623 print '<td class="nowrap center">';
624 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
625 $selected = 0;
626 if (in_array($object->id, $arrayofselected)) {
627 $selected = 1;
628 }
629 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
630 }
631 print '</td>';
632 }
633
634 foreach ($object->fields as $key => $val) {
635 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
636 if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
637 $cssforfield .= ($cssforfield ? ' ' : '').'center';
638 } elseif ($key == 'status') {
639 $cssforfield .= ($cssforfield ? ' ' : '').'center';
640 }
641
642 if (in_array($val['type'], array('timestamp'))) {
643 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
644 } elseif ($key == 'ref') {
645 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
646 }
647
648 if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
649 $cssforfield .= ($cssforfield ? ' ' : '').'right';
650 }
651 //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
652
653 if (!empty($arrayfields['t.'.$key]['checked'])) {
654 print '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
655 if (preg_match('/tdoverflow/', $cssforfield) && !is_numeric($object->$key)) {
656 print ' title="'.dol_escape_htmltag($object->$key).'"';
657 }
658 print '>';
659 if ($key == 'status') {
660 print $object->getLibStatut(5);
661 } elseif ($key == 'rowid') {
662 print $object->showOutputField($val, $key, $object->id, '');
663 } else {
664 print $object->showOutputField($val, $key, $object->$key, '');
665 }
666 print '</td>';
667 if (!$i) {
668 $totalarray['nbfield']++;
669 }
670 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
671 if (!$i) {
672 $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
673 }
674 if (!isset($totalarray['val'])) {
675 $totalarray['val'] = array();
676 }
677 if (!isset($totalarray['val']['t.'.$key])) {
678 $totalarray['val']['t.'.$key] = 0;
679 }
680 $totalarray['val']['t.'.$key] += $object->$key;
681 }
682 }
683 }
684 // Extra fields
685 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
686 // Fields from hook
687 $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
688 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
689 print $hookmanager->resPrint;
690 // Action column
691 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
692 print '<td class="nowrap center">';
693 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
694 $selected = 0;
695 if (in_array($object->id, $arrayofselected)) {
696 $selected = 1;
697 }
698 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
699 }
700 print '</td>';
701 }
702 if (!$i) {
703 $totalarray['nbfield']++;
704 }
705
706 print '</tr>'."\n";
707 }
708 $i++;
709}
710
711// Show total line
712include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
713
714
715// If no record found
716if ($num == 0) {
717 $colspan = 1;
718 foreach ($arrayfields as $key => $val) {
719 if (!empty($val['checked'])) {
720 $colspan++;
721 }
722 }
723 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
724}
725
726$db->free($resql);
727
728$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
729$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
730print $hookmanager->resPrint;
731
732print '</table>'."\n";
733print '</div>'."\n";
734
735print '</form>'."\n";
736
737/*
738if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
739 $hidegeneratedfilelistifempty = 1;
740 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
741 $hidegeneratedfilelistifempty = 0;
742 }
743
744 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
745 $formfile = new FormFile($db);
746
747 // Show list of available documents
748 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
749 $urlsource .= str_replace('&amp;', '&', $param);
750
751 $filedir = $diroutputmassaction;
752 $genallowed = $permissiontoread;
753 $delallowed = $permissiontoadd;
754
755 print $formfile->showdocuments('massfilesarea_monmodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
756}
757*/
758
759// End of page
760llxFooter();
761$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage cash fence.
Class to manage standard extra fields.
Class to generate html code for admin pages.
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.