dolibarr 24.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-2026 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2025-2026 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Load Dolibarr environment
27require '../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php';
37require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
40
41// Load translation files required by the page
42$langs->loadLangs(array("banks", "other"));
43
44// Get parameters
45$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
46$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
47$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
48$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
49$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
50$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
51$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : getDolDefaultContextPage(__FILE__); // To manage different context of search
52$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
53$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
54$mode = GETPOST('mode', 'aZ'); // The display mode ('list', 'kanban', 'hierarchy', 'calendar', 'gantt', ...)
55$groupby = GETPOST('groupby', 'aZ09'); // Example: $groupby = 'p.fk_opp_status' or $groupby = 'p.fk_statut'
56
57$id = GETPOSTINT('id');
58$ref = GETPOST('ref', 'alpha');
59
60// Load variable for pagination
61$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
62$sortfield = GETPOST('sortfield', 'aZ09comma');
63$sortorder = GETPOST('sortorder', 'aZ09comma');
64$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
65if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
66 // If $page is not defined, or '' or -1 or if we click on clear filters
67 $page = 0;
68}
69$offset = $limit * $page;
70$pageprev = $page - 1;
71$pagenext = $page + 1;
72//if (! $sortfield) $sortfield="p.date_fin";
73//if (! $sortorder) $sortorder="DESC";
74
75// Initialize a technical objects
77//$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id;
78$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array
79
80// Fetch optionals attributes and labels
81$extrafields->fetch_name_optionals_label($object->table_element);
82//$extrafields->fetch_name_optionals_label($object->table_element_line);
83
84$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
85
86// Default sort order (if not yet defined by previous GETPOST)
87if (!$sortfield) {
88 reset($object->fields); // Reset is required to avoid key() to return null.
89 $sortfield = "t.year_close,t.month_close,t.day_close"; // Set here default search field. By default 1st field in definition.
90}
91if (!$sortorder) {
92 $sortorder = "DESC";
93}
94if ($sortfield == 't.year_close') {
95 $sortfield = "t.year_close,t.month_close,t.day_close"; // Set here default search field. By default 1st field in definition.
96}
97
98// Initialize array of search criteria
99$search_all = trim(GETPOST('search_all', 'alphanohtml'));
100$search = array();
101foreach ($object->fields as $key => $val) {
102 if (GETPOST('search_'.$key, 'alpha') !== '') {
103 $search[$key] = GETPOST('search_'.$key, 'alpha');
104 }
105 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
106 $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOSTINT('search_'.$key.'_dtstartmonth'), GETPOSTINT('search_'.$key.'_dtstartday'), GETPOSTINT('search_'.$key.'_dtstartyear'));
107 $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_'.$key.'_dtendmonth'), GETPOSTINT('search_'.$key.'_dtendday'), GETPOSTINT('search_'.$key.'_dtendyear'));
108 }
109}
110
111// List of fields to search into when doing a "search in all"
112$fieldstosearchall = array();
113// foreach ($object->fields as $key => $val) {
114// if (!empty($val['searchall'])) {
115// $fieldstosearchall['t.'.$key] = $val['label'];
116// }
117// }
118// $parameters = array('fieldstosearchall'=>$fieldstosearchall);
119// $reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
120// if ($reshook > 0) {
121// $fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall'];
122// } elseif ($reshook == 0) {
123// $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']);
124// }
125
126// Definition of array of fields for columns from ->fields
127$tableprefix = 't';
128$arrayfields = array();
129foreach ($object->fields as $key => $val) {
130 // If $val['visible']==0, then we never show the field
131 if (!empty($val['visible'])) {
132 $visible = (int) dol_eval((string) $val['visible'], 1);
133 $arrayfields[$tableprefix.'.'.$key] = array(
134 'label' => $val['label'],
135 'checked' => (($visible < 0) ? '0' : '1'),
136 'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval((string) $val['enabled'], 1)),
137 'position' => $val['position'],
138 'help' => isset($val['help']) ? $val['help'] : ''
139 );
140 }
141}
142// Extra fields
143include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
144
145$object->fields = dol_sort_array($object->fields, 'position');
146$arrayfields = dol_sort_array($arrayfields, 'position');
147
148$permissiontoread = ($user->hasRight('cashdesk', 'run') || $user->hasRight('takepos', 'run'));
149$permissiontoadd = ($user->hasRight('cashdesk', 'run') || $user->hasRight('takepos', 'run'));
150$permissiontodelete = ($user->hasRight('cashdesk', 'run') || $user->hasRight('takepos', 'run'));
151
152// Security check
153if ($user->socid > 0) { // Protection if external user
154 //$socid = $user->socid;
156}
157if (!$permissiontoread) {
159}
160
161
162/*
163 * Actions
164 */
165
166if (GETPOST('cancel', 'alpha')) {
167 $action = 'list';
168 $massaction = '';
169}
170if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
171 $massaction = '';
172}
173
174$parameters = array('arrayfields' => &$arrayfields);
175$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
176if ($reshook < 0) {
177 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
178}
179
180if (empty($reshook)) {
181 // Selection of new fields
182 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
183
184 // Purge search criteria
185 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
186 foreach ($object->fields as $key => $val) {
187 $search[$key] = '';
188 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
189 $search[$key.'_dtstart'] = '';
190 $search[$key.'_dtend'] = '';
191 }
192 }
193 $search_all = '';
194 $toselect = array();
195 $search_array_options = array();
196 }
197 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
198 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
199 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
200 }
201
202 // Mass actions
203 $objectclass = 'CashControl';
204 $objectlabel = 'CashControl';
205 $uploaddir = $conf->bank->dir_output;
206
207 global $error;
208 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
209}
210
211
212
213/*
214 * View
215 */
216
217$form = new Form($db);
218
219$now = dol_now();
220
221$title = $langs->trans('CashControl');
222//$help_url = "EN:Module_pos_cash_fence|FR:Module_pos_cash_fence_FR|ES:Módulo_pos_cash_fence";
223$help_url = '';
224$morejs = array();
225$morecss = array();
226
227// Build and execute select
228// --------------------------------------------------------------------
229$sql = "SELECT";
230$sql .= " ".$object->getFieldList('t');
231// Add fields from extrafields
232if (!empty($extrafields->attributes[$object->table_element]['label'])) {
233 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
234 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : "");
235 }
236}
237// Add fields from hooks
238$parameters = array();
239$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
240$sql .= $hookmanager->resPrint;
241$sql = preg_replace('/,\s*$/', '', $sql);
242
243$sqlfields = $sql; // $sql fields to remove for count total
244
245$sql .= " FROM ".$db->prefix().$object->table_element." as t";
246if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
247 $sql .= " LEFT JOIN ".$db->prefix().$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
248}
249// Add table from hooks
250$parameters = array();
251$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
252$sql .= $hookmanager->resPrint;
253
254if (!empty($object->ismultientitymanaged) && (int) $object->ismultientitymanaged == 1) {
255 $sql .= " WHERE t.entity IN (".getEntity($object->element, (GETPOSTINT('search_current_entity') ? 0 : 1)).")";
256} elseif (preg_match('/^\w+@\w+$/', (string) $object->ismultientitymanaged)) {
257 $tmparray = explode('@', (string) $object->ismultientitymanaged);
258 $sql .= " LEFT JOIN ".$object->db->prefix().$tmparray[1]." as pt ON t.".$db->sanitize($tmparray[0])." = pt.rowid";
259 $sql .= " WHERE pt.entity IN (".getEntity($object->element, (GETPOSTINT('search_current_entity') ? 0 : 1)).")";
260} else {
261 $sql .= " WHERE 1 = 1";
262}
263foreach ($search as $key => $val) {
264 if (array_key_exists($key, $object->fields)) {
265 if ($key == 'status' && $search[$key] == -1) {
266 continue;
267 }
268 $field_spec = $object->fields[$key];
269 $mode_search = (($object->isInt($field_spec) || $object->isFloat($field_spec)) ? 1 : 0);
270 if ((strpos($field_spec['type'], 'integer:') === 0) || (strpos($field_spec['type'], 'sellist:') === 0) || !empty($field_spec['arrayofkeyval'])) {
271 if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($field_spec['arrayofkeyval']) || !array_key_exists('0', $field_spec['arrayofkeyval'])))) {
272 $search[$key] = '';
273 }
274 $mode_search = 2;
275 }
276 if ($field_spec['type'] === 'boolean') {
277 $mode_search = 1;
278 if ($search[$key] == '-1') {
279 $search[$key] = '';
280 }
281 }
282 if (empty($field_spec['searchmulti'])) {
283 if (!is_array($search[$key]) && $search[$key] != '') {
284 $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
285 }
286 } else {
287 if ($search[$key] != '') {
288 if ($key == 'day_close' && $search[$key] === '0') {
289 $sql .= " AND t.day_close IS NULL";
290 } elseif ($key == 'month_close' && $search[$key] === '0') {
291 $sql .= " AND t.month_close IS NULL";
292 } elseif (is_array($search[$key]) && !empty($search[$key])) {
293 $sql .= natural_search("t.".$db->escape($key), implode(',', $search[$key]), (($key == 'status') ? 2 : $mode_search));
294 }
295 }
296 }
297 } else {
298 if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
299 $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
300 if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
301 if (preg_match('/_dtstart$/', $key)) {
302 $sql .= " AND t.".$db->sanitize($columnName)." >= '".$db->idate($search[$key])."'";
303 }
304 if (preg_match('/_dtend$/', $key)) {
305 $sql .= " AND t.".$db->sanitize($columnName)." <= '".$db->idate($search[$key])."'";
306 }
307 }
308 }
309 }
310}
311if ($search_all) {
312 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
313}
314//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
315// Add where from extra fields
316include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
317// Add where from hooks
318$parameters = array();
319$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
320$sql .= $hookmanager->resPrint;
321
322/* If a group by is required
323$sql.= " GROUP BY ";
324foreach($object->fields as $key => $val) {
325 $sql .= "t.".$db->sanitize($key).", ";
326}
327// Add fields from extrafields
328if (!empty($extrafields->attributes[$object->table_element]['label'])) {
329 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
330 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
331 }
332}
333// Add groupby from hooks
334$parameters=array();
335$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
336if (empty($reshook)) {
337 $sql .= $hookmanager->resPrint;
338} else {
339 $sql = $hookmanager->resPrint;
340}
341
342$sql=preg_replace('/,\s*$/','', $sql);
343*/
344
345
346// Count total nb of records
347$nbtotalofrecords = '';
348if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
349 /* The fast and low memory method to get and count full list converts the sql into a sql count */
350 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
351 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
352 $resql = $db->query($sqlforcount);
353 if ($resql) {
354 $objforcount = $db->fetch_object($resql);
355 $nbtotalofrecords = $objforcount->nbtotalofrecords;
356 } else {
358 }
359
360 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
361 $page = 0;
362 $offset = 0;
363 }
364 $db->free($resql);
365}
366
367// Complete request and execute it with limit
368$sql .= $db->order($sortfield, $sortorder);
369if ($limit) {
370 $sql .= $db->plimit($limit + 1, $offset);
371}
372
373$resql = $db->query($sql);
374if (!$resql) {
376 exit;
377}
378
379$num = $db->num_rows($resql);
380
381
382// Direct jump if only one record found
383if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
384 $obj = $db->fetch_object($resql);
385 $id = $obj->rowid;
386 header("Location: ".DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.((int) $id));
387 exit;
388}
389
390
391// Output page
392// --------------------------------------------------------------------
393
394llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-takepos page-list bodyforlist');
395
396$arrayofselected = is_array($toselect) ? $toselect : array();
397
398$param = '';
399if (!empty($mode)) {
400 $param .= '&mode='.urlencode($mode);
401}
402if (!empty($contextpage) && $contextpage != getDolDefaultContextPage(__FILE__)) {
403 $param .= '&contextpage='.urlencode($contextpage);
404}
405if ($limit > 0 && $limit != $conf->liste_limit) {
406 $param .= '&limit='.((int) $limit);
407}
408if ($optioncss != '') {
409 $param .= '&optioncss='.urlencode($optioncss);
410}
411if ($groupby != '') {
412 $param .= '&groupby='.urlencode($groupby);
413}
414foreach ($search as $key => $val) {
415 if (is_array($search[$key])) {
416 foreach ($search[$key] as $skey) {
417 if ($skey != '') {
418 $param .= '&search_'.$key.'[]='.urlencode($skey);
419 }
420 }
421 } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
422 $param .= '&search_'.$key.'month='.GETPOSTINT('search_'.$key.'month');
423 $param .= '&search_'.$key.'day='.GETPOSTINT('search_'.$key.'day');
424 $param .= '&search_'.$key.'year='.GETPOSTINT('search_'.$key.'year');
425 } elseif ($search[$key] != '') {
426 $param .= '&search_'.$key.'='.urlencode((string) $search[$key]);
427 }
428}
429// Add $param from extra fields
430include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
431// Add $param from hooks
432$parameters = array('param' => &$param);
433$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
434$param .= $hookmanager->resPrint;
435
436// List of mass actions available
437$arrayofmassactions = array(
438 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
439 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
440 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
441 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
442);
443if (!empty($permissiontodelete)) {
444 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
445}
446if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
447 $arrayofmassactions = array();
448}
449$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
450
451print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
452if ($optioncss != '') {
453 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
454}
455print '<input type="hidden" name="token" value="'.newToken().'">';
456print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
457print '<input type="hidden" name="action" value="list">';
458print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
459print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
460print '<input type="hidden" name="page" value="'.$page.'">';
461print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
462print '<input type="hidden" name="page_y" value="">';
463print '<input type="hidden" name="mode" value="'.$mode.'">';
464
465$permforcashfence = 1;
466
467$newcardbutton = '';
468$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'));
469$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'));
470$newcardbutton .= dolGetButtonTitleSeparator();
471$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);
472
473print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'cash-register', 0, $newcardbutton, '', $limit, 0, 0, 1);
474
475// Add code for pre mass action (confirmation or email presend form)
476$topicmail = "SendCashControlRef";
477$modelmail = "cashcontrol";
478$objecttmp = new CashControl($db);
479$trackid = 'cashfence'.$object->id;
480include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
481
482if ($search_all) {
483 $setupstring = '';
484 // @phan-suppress-next-line PhanEmptyForeach
485 foreach ($fieldstosearchall as $key => $val) {
486 $fieldstosearchall[$key] = $langs->trans($val);
487 $setupstring .= $key."=".$val.";";
488 }
489 print '<!-- Search done like if CASHFENCE_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
490 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
491}
492
493$moreforfilter = '';
494/*$moreforfilter.='<div class="divsearchfield">';
495 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
496 $moreforfilter.= '</div>';*/
497
498$parameters = array();
499$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
500if (empty($reshook)) {
501 $moreforfilter .= $hookmanager->resPrint;
502} else {
503 $moreforfilter = $hookmanager->resPrint;
504}
505$parameters = array(
506 'arrayfields' => &$arrayfields,
507);
508
509if (!empty($moreforfilter)) {
510 print '<div class="liste_titre liste_titre_bydiv centpercent">';
511 print $moreforfilter;
512 print '</div>';
513}
514
515$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
516$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
517$selectedfields = (($mode != 'kanban' && $mode != 'kanbangroupby') ? $htmlofselectarray : '');
518$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
519
520print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
521print '<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
522
523
524// Fields title search
525// --------------------------------------------------------------------
526print '<tr class="liste_titre_filter">';
527// Action column
528if ($conf->main_checkbox_left_column) {
529 print '<td class="liste_titre center maxwidthsearch">';
530 $searchpicto = $form->showFilterButtons('left');
531 print $searchpicto;
532 print '</td>';
533}
534foreach ($object->fields as $key => $val) {
535 //$searchkey = empty($search[$key]) ? '' : $search[$key];
536 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
537 if ($key == 'status') {
538 $cssforfield .= ($cssforfield ? ' ' : '').'center';
539 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
540 $cssforfield .= ($cssforfield ? ' ' : '').'center';
541 } elseif (in_array($val['type'], array('timestamp'))) {
542 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
543 } 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'])) {
544 $cssforfield .= ($cssforfield ? ' ' : '').'right';
545 }
546 if (!empty($arrayfields['t.'.$key]['checked'])) {
547 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
548 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
549 if (empty($val['searchmulti'])) {
550 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);
551 } else {
552 print $form->multiselectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), 0, 0, 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
553 }
554 } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
555 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
556 } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
557 print '<div class="nowrap">';
558 print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
559 print '</div>';
560 print '<div class="nowrap">';
561 print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
562 print '</div>';
563 } elseif ($key == 'lang') {
564 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
565 $formadmin = new FormAdmin($db);
566 print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2);
567 } elseif ($val['type'] === 'boolean') {
568 print $form->selectyesno('search_' . $key, $search[$key] ?? '', 1, false, 1);
569 } else {
570 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] : '').'">';
571 }
572 print '</td>';
573 }
574}
575// Extra fields
576include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
577
578// Fields from hook
579$parameters = array('arrayfields' => $arrayfields);
580$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
581print $hookmanager->resPrint;
582// Action column
583if (!$conf->main_checkbox_left_column) {
584 print '<td class="liste_titre center maxwidthsearch">';
585 $searchpicto = $form->showFilterButtons();
586 print $searchpicto;
587 print '</td>';
588}
589print '</tr>'."\n";
590
591
592$totalarray = array();
593$totalarray['nbfield'] = 0;
594
595// Fields title label
596// --------------------------------------------------------------------
597print '<tr class="liste_titre">';
598// Action column
599if ($conf->main_checkbox_left_column) {
600 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
601 $totalarray['nbfield']++;
602}
603foreach ($object->fields as $key => $val) {
604 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
605 if ($key == 'status') {
606 $cssforfield .= ($cssforfield ? ' ' : '').'center';
607 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
608 $cssforfield .= ($cssforfield ? ' ' : '').'center';
609 } elseif (in_array($val['type'], array('timestamp'))) {
610 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
611 } 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'])) {
612 $cssforfield .= ($cssforfield ? ' ' : '').'right';
613 }
614 $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
615 if (!empty($arrayfields['t.'.$key]['checked'])) {
616 print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), 0, (empty($val['helplist']) ? '' : $val['helplist']))."\n";
617 $totalarray['nbfield']++;
618 }
619}
620// Extra fields
621include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
622// Hook fields
623$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
624$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
625print $hookmanager->resPrint;
626// Action column
627if (!$conf->main_checkbox_left_column) {
628 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
629 $totalarray['nbfield']++;
630}
631print '</tr>'."\n";
632
633
634// Detect if we need a fetch on each output line
635$needToFetchEachLine = 0;
636if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
637 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
638 if (!is_null($val) && preg_match('/\$object/', $val)) {
639 $needToFetchEachLine++; // There is at least one compute field that use $object
640 }
641 }
642}
643
644
645// Loop on record
646// --------------------------------------------------------------------
647$i = 0;
648$savnbfield = $totalarray['nbfield'];
649$totalarray = array();
650$totalarray['nbfield'] = 0;
651$imaxinloop = ($limit ? min($num, $limit) : $num);
652while ($i < $imaxinloop) {
653 $obj = $db->fetch_object($resql);
654 if (empty($obj)) {
655 break; // Should not happen
656 }
657
658 // Store properties in $object
659 $object->setVarsFromFetchObj($obj);
660
661 if ($mode == 'kanban' || $mode == 'kanbangroupby') {
662 if ($i == 0) {
663 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
664 print '<div class="box-flex-container kanban">';
665 }
666
667 $object->posmodule = $obj->posmodule;
668 $object->cash = $obj->cash;
669 $object->cheque = (float) $obj->cheque;
670 $object->card = $obj->card;
671 $object->opening = $obj->opening;
672 $object->year_close = $obj->year_close;
673
674 // Output Kanban
675 $selected = -1;
676 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
677 $selected = 0;
678 if (in_array($object->id, $arrayofselected)) {
679 $selected = 1;
680 }
681 }
682 print $object->getKanbanView('', array('selected' => $selected));
683 if ($i == ($imaxinloop - 1)) {
684 print '</div>';
685 print '</td></tr>';
686 }
687 } else {
688 // Show line of result
689 $j = 0;
690 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
691
692 // Action column
693 if ($conf->main_checkbox_left_column) {
694 print '<td class="nowrap center">';
695 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
696 $selected = 0;
697 if (in_array($object->id, $arrayofselected)) {
698 $selected = 1;
699 }
700 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
701 }
702 print '</td>';
703 if (!$i) {
704 $totalarray['nbfield']++;
705 }
706 }
707 // Fields
708 foreach ($object->fields as $key => $val) {
709 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
710 if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
711 $cssforfield .= ($cssforfield ? ' ' : '').'center';
712 } elseif ($key == 'status') {
713 $cssforfield .= ($cssforfield ? ' ' : '').'center';
714 }
715
716 if (in_array($val['type'], array('timestamp'))) {
717 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
718 } elseif ($key == 'ref') {
719 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
720 }
721
722 if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && empty($val['arrayofkeyval'])) {
723 $cssforfield .= ($cssforfield ? ' ' : '').'right';
724 }
725 //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
726
727 if (!empty($arrayfields['t.'.$key]['checked'])) {
728 print '<td'.($cssforfield ? ' class="'.$cssforfield.((preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) ? ' classfortooltip' : '').'"' : '');
729 if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key) && !in_array($key, array('ref'))) {
730 print ' title="'.dol_escape_htmltag((string) $object->$key).'"';
731 }
732 print '>';
733 if ($key == 'status') {
734 print $object->getLibStatut(5);
735 } elseif ($key == 'rowid') {
736 print $object->showOutputField($val, $key, (string) $object->id, '');
737 } else {
738 if ($val['type'] == 'html') {
739 print '<div class="small lineheightsmall twolinesmax-normallineheight">';
740 }
741 print $object->showOutputField($val, $key, (string) $object->$key, '');
742 if ($val['type'] == 'html') {
743 print '</div>';
744 }
745 }
746 print '</td>';
747 if (!$i) {
748 $totalarray['nbfield']++;
749 }
750 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
751 if (!$i) {
752 $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
753 }
754 if (!isset($totalarray['val'])) {
755 $totalarray['val'] = array();
756 }
757 if (!isset($totalarray['val']['t.'.$key])) {
758 $totalarray['val']['t.'.$key] = 0;
759 }
760 $totalarray['val']['t.'.$key] += $object->$key;
761 }
762 }
763 }
764 // Extra fields
765 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
766 // Fields from hook
767 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
768 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
769 print $hookmanager->resPrint;
770
771 // Action column
772 if (empty($conf->main_checkbox_left_column)) {
773 print '<td class="nowrap center">';
774 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
775 $selected = 0;
776 if (in_array($object->id, $arrayofselected)) {
777 $selected = 1;
778 }
779 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
780 }
781 print '</td>';
782 if (!$i) {
783 $totalarray['nbfield']++;
784 }
785 }
786
787 print '</tr>'."\n";
788 }
789 $i++;
790}
791
792// Show total line
793include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
794
795
796// If no record found
797if ($num == 0) {
798 $colspan = 1;
799 foreach ($arrayfields as $key => $val) {
800 if (!empty($val['checked'])) {
801 $colspan++;
802 }
803 }
804 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
805}
806
807$db->free($resql);
808
809$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
810$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
811print $hookmanager->resPrint;
812
813print '</table>'."\n";
814print '</div>'."\n";
815
816print '</form>'."\n";
817
818/*
819if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
820 $hidegeneratedfilelistifempty = 1;
821 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
822 $hidegeneratedfilelistifempty = 0;
823 }
824
825 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
826 $formfile = new FormFile($db);
827
828 // Show list of available documents
829 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
830 $urlsource .= str_replace('&amp;', '&', $param);
831
832 $filedir = $diroutputmassaction;
833 $genallowed = $permissiontoread;
834 $delallowed = $permissiontoadd;
835
836 print $formfile->showdocuments('massfilesarea_'.$object->module, '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
837}
838*/
839
840// End of page
841llxFooter();
842$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:497
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
Class to manage cash fence.
Class to generate html code for admin pages.
Class to manage generation of HTML components Only common components must be here.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_now($mode='gmt')
Return date for now.
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, $allowothertags=array())
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.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
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.
getDolDefaultContextPage($s)
Return the default context page string.
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...
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...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.