dolibarr 24.0.2
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2024 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
6 * Copyright (C) 2019-2026 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2025-2026 MDW <mdeweerd@users.noreply.github.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
40
41
42// Load translation files required by page
43$langs->loadLangs(array("users"));
44
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') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // 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 output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
55
56$search_all = trim(GETPOST('search_all', 'alphanohtml'));
57$search_group = GETPOST('search_group');
58$search = array();
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
73// Initialize a technical objects
74$object = new UserGroup($db);
75
76//$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id;
77$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes
78
79// Fetch optionals attributes and labels
80$extrafields->fetch_name_optionals_label($object->table_element);
81//$extrafields->fetch_name_optionals_label($object->table_element_line);
82
83$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
84
85if (!$sortfield) {
86 $sortfield = "g.nom";
87}
88if (!$sortorder) {
89 $sortorder = "ASC";
90}
91
92$arrayfields = array();
93// Add hook to complete $arrayfield
94$parameters = array('arrayfields' => &$arrayfields);
95$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
96
97// List of fields to search into when doing a "search in all"
98$fieldstosearchall = array();
99foreach ($object->fields as $key => $val) {
100 if (!empty($val['searchall'])) {
101 $fieldstosearchall['t.'.$key] = $val['label'];
102 }
103}
104
105if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
106 if (!$user->hasRight("user", "group_advance", "read") && !$user->admin) {
108 }
109}
110
111if (!$user->hasRight("user", "user", "read") && !$user->admin) {
113}
114
115// Define if user can modify other users and permissions
116$caneditperms = (isModEnabled('multicompany') && !empty($user->entity) && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') ? false : (!empty($user->admin) || $user->hasRight("user", "user", "write")));
117$permissiontodelete = (isModEnabled('multicompany') && !empty($user->entity) && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') ? false : (!empty($user->admin) || $user->hasRight("user", "user", "delete")));
118// Advanced permissions
119if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
120 $caneditperms = (isModEnabled('multicompany') && !empty($user->entity) && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') ? false : ($user->admin || $user->hasRight("user", "group_advance", "write")));
121 $permissiontodelete = (isModEnabled('multicompany') && !empty($user->entity) && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') ? false : ($user->admin || $user->hasRight("user", "group_advance", "delete")));
122}
123
124
125/*
126 * Actions
127 */
128
129if (GETPOST('cancel', 'alpha')) {
130 $action = 'list';
131 $massaction = '';
132}
133if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
134 $massaction = '';
135}
136
137$parameters = array('arrayfields' => &$arrayfields);
138$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
139if ($reshook < 0) {
140 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
141}
142
143if (empty($reshook)) {
144 // Selection of new fields
145 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
146
147 // Purge search criteria
148 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
149 foreach ($object->fields as $key => $val) {
150 $search[$key] = '';
151 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
152 $search[$key.'_dtstart'] = '';
153 $search[$key.'_dtend'] = '';
154 }
155 }
156 $search_all = '';
157 $toselect = array();
158 $search_array_options = array();
159 }
160 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
161 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
162 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
163 }
164
165 // Mass actions
166 $objectclass = 'UserGroup';
167 $objectlabel = 'UserGroup';
168 $uploaddir = $conf->user->dir_output;
169 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
170}
171
172
173/*
174 * View
175 */
176
177$form = new Form($db);
178
179$now = dol_now();
180
181$title = $langs->trans("UserGroups");
182$help_url = '';
183$morejs = array();
184$morecss = array();
185
186// Build and execute select
187// --------------------------------------------------------------------
188$sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec, g.tms, COUNT(DISTINCT ugu.fk_user) as nb, COUNT(DISTINCT ugr.fk_id) as nbpermissions";
189
190$sqlfields = $sql;
191
192$sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g";
193$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
194$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_rights as ugr ON ugr.fk_usergroup = g.rowid";
195if (isModEnabled('multicompany') && $conf->entity == 1 && (getDolGlobalInt('MULTICOMPANY_TRANSVERSE_MODE') || ($user->admin && !$user->entity))) {
196 $sql .= " WHERE g.entity IS NOT NULL";
197} else {
198 $sql .= " WHERE g.entity IN (0,".((int) $conf->entity).")";
199}
200if (!empty($search_group)) {
201 natural_search(array("g.nom", "g.note"), $search_group);
202}
203if ($search_all) {
204 $sql .= natural_search(array("g.nom", "g.note"), $search_all);
205}
206$sql .= " GROUP BY g.rowid, g.nom, g.note, g.entity, g.datec, g.tms";
207
208// Count total nb of records
209$nbtotalofrecords = '';
210if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
211 /* The fast and low memory method to get and count full list converts the sql into a sql count */
212 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(DISTINCT g.rowid) as nbtotalofrecords', $sql);
213 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
214 $resql = $db->query($sqlforcount);
215 if ($resql) {
216 $objforcount = $db->fetch_object($resql);
217 $nbtotalofrecords = $objforcount->nbtotalofrecords;
218 } else {
220 }
221
222 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than paging size (filtering), goto and load page 0
223 $page = 0;
224 $offset = 0;
225 }
226 $db->free($resql);
227}
228
229// Complete request and execute it with limit
230$sql .= $db->order($sortfield, $sortorder);
231if ($limit) {
232 $sql .= $db->plimit($limit + 1, $offset);
233}
234$resql = $db->query($sql);
235if (!$resql) {
237 exit;
238}
239
240$num = $db->num_rows($resql);
241
242$i = 0;
243
244
245// Output page
246// --------------------------------------------------------------------
247
248llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist mod-user page-group_list');
249
250$arrayofselected = is_array($toselect) ? $toselect : array();
251
252$param = "&search_group=".urlencode($search_group)."&search_all=".urlencode($search_all);
253if (!empty($mode)) {
254 $param .= '&mode='.urlencode($mode);
255}
256if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
257 $param .= '&contextpage='.urlencode($contextpage);
258}
259if ($limit > 0 && $limit != $conf->liste_limit) {
260 $param .= '&limit='.((int) $limit);
261}
262if ($optioncss != '') {
263 $param .= '&optioncss='.urlencode($optioncss);
264}
265
266foreach ($search as $key => $val) {
267 if (is_array($search[$key])) {
268 foreach ($search[$key] as $skey) {
269 if ($skey != '') {
270 $param .= '&search_'.$key.'[]='.urlencode($skey);
271 }
272 }
273 } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
274 $param .= '&search_'.$key.'month='.GETPOSTINT('search_'.$key.'month');
275 $param .= '&search_'.$key.'day='.GETPOSTINT('search_'.$key.'day');
276 $param .= '&search_'.$key.'year='.GETPOSTINT('search_'.$key.'year');
277 } elseif ($search[$key] != '') {
278 $param .= '&search_'.$key.'='.urlencode($search[$key]);
279 }
280}
281// Add $param from extra fields
282include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
283// Add $param from hooks
284$parameters = array('param' => &$param);
285$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
286$param .= $hookmanager->resPrint;
287
288// List of mass actions available
289$arrayofmassactions = array(
290 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
291 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
292 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
293 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
294);
295if (!empty($permissiontodelete)) {
296 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
297}
298if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
299 $arrayofmassactions = array();
300}
301$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
302
303print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
304if ($optioncss != '') {
305 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
306}
307print '<input type="hidden" name="token" value="'.newToken().'">';
308print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
309print '<input type="hidden" name="action" value="list">';
310print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
311print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
312print '<input type="hidden" name="page" value="'.$page.'">';
313print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
314print '<input type="hidden" name="page_y" value="">';
315print '<input type="hidden" name="mode" value="'.$mode.'">';
316
317$newcardbutton = '';
318$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'));
319$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'));
320
321if ($caneditperms) {
322 $newcardbutton .= dolGetButtonTitleSeparator();
323 $newcardbutton .= dolGetButtonTitle($langs->trans('NewGroup'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/user/group/card.php?action=create&leftmenu=', '', $caneditperms ? 1 : 0);
324}
325
326print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
327
328// Add code for pre mass action (confirmation or email presend form)
329$topicmail = "SendGroup";
330$modelmail = "group";
331$objecttmp = new UserGroup($db);
332$trackid = 'grp'.$object->id;
333include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
334
335if ($search_all) {
336 $setupstring = '';
337 // @phan-suppress-next-line PhanEmptyForeach
338 foreach ($fieldstosearchall as $key => $val) {
339 $fieldstosearchall[$key] = $langs->trans($val);
340 $setupstring .= $key."=".$val.";";
341 }
342 print '<!-- Search done like if GROUP_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
343 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
344}
345
346$moreforfilter = '';
347
348$parameters = array();
349$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
350if (empty($reshook)) {
351 $moreforfilter .= $hookmanager->resPrint;
352} else {
353 $moreforfilter = $hookmanager->resPrint;
354}
355
356if (!empty($moreforfilter)) {
357 print '<div class="liste_titre liste_titre_bydiv centpercent">';
358 print $moreforfilter;
359 print '</div>';
360}
361
362$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
363$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column ? 'left' : ''); // This also change content of $arrayfields with user setup
364$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
365$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
366
367print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
368print '<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
369
370
371$totalarray = array();
372$totalarray['nbfield'] = 0;
373
374// Fields title label
375// --------------------------------------------------------------------
376print '<tr class="liste_titre_filter">';
377// Action column
378if ($conf->main_checkbox_left_column) {
379 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
380 $totalarray['nbfield']++;
381}
382print_liste_field_titre("Group", $_SERVER["PHP_SELF"], "g.nom", '', $param, "", $sortfield, $sortorder);
383$totalarray['nbfield']++;
384//multicompany
385if (isModEnabled('multicompany') && isset($mc) && is_object($mc) && !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1) {
386 print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], "g.entity", '', $param, '', $sortfield, $sortorder, 'center ');
387 $totalarray['nbfield']++;
388}
389print_liste_field_titre("NbOfUsers", $_SERVER["PHP_SELF"], "nb", '', $param, '', $sortfield, $sortorder, 'center ');
390$totalarray['nbfield']++;
391print_liste_field_titre("NbOfPermissions", $_SERVER["PHP_SELF"], "nbpermissions", '', $param, '', $sortfield, $sortorder, 'center ');
392$totalarray['nbfield']++;
393print_liste_field_titre("DateCreationShort", $_SERVER["PHP_SELF"], "g.datec", '', $param, '', $sortfield, $sortorder, 'center ');
394$totalarray['nbfield']++;
395print_liste_field_titre("DateLastModification", $_SERVER["PHP_SELF"], "g.tms", '', $param, '', $sortfield, $sortorder, 'center ');
396$totalarray['nbfield']++;
397// Extra fields
398include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
399// Hook fields
400$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
401$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
402print $hookmanager->resPrint;
403/*if (!empty($arrayfields['anotherfield']['checked'])) {
404 print '<th class="liste_titre right">'.$langs->trans("AnotherField").'</th>';
405 $totalarray['nbfield']++;
406 }*/
407// Action column
408if (!$conf->main_checkbox_left_column) {
409 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
410 $totalarray['nbfield']++;
411}
412print '</tr>'."\n";
413
414
415// Loop on record
416// --------------------------------------------------------------------
417$i = 0;
418$savnbfield = $totalarray['nbfield'];
419$totalarray = array();
420$totalarray['nbfield'] = 0;
421$imaxinloop = ($limit ? min($num, $limit) : $num);
422while ($i < $imaxinloop) {
423 $obj = $db->fetch_object($resql);
424 if (empty($obj)) {
425 break; // Should not happen
426 }
427
428 // Store properties in $object
429 $object->setVarsFromFetchObj($obj);
430
431 $object->name = $obj->name;
432 $object->note = $obj->note;
433 $object->nb_rights = $obj->nbpermissions;
434 $object->nb_users = $obj->nb;
435
436 if ($mode == 'kanban') {
437 if ($i == 0) {
438 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
439 print '<div class="box-flex-container kanban">';
440 }
441 // Output Kanban
442 $selected = -1;
443 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
444 $selected = 0;
445 if (in_array($object->id, $arrayofselected)) {
446 $selected = 1;
447 }
448 }
449 print $object->getKanbanView('', array('selected' => $selected));
450 if ($i == ($imaxinloop - 1)) {
451 print '</div>';
452 print '</td></tr>';
453 }
454 } else {
455 // Show line of result
456 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
457 // Action column
458 if ($conf->main_checkbox_left_column) {
459 print '<td class="nowrap center">';
460 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
461 $selected = 0;
462 if (in_array($object->id, $arrayofselected)) {
463 $selected = 1;
464 }
465 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
466 }
467 print '</td>';
468 if (!$i) {
469 $totalarray['nbfield']++;
470 }
471 }
472
473 print '<td class="tdoverflowmax200">';
474 print $object->getNomUrl(1);
475 if (isModEnabled('multicompany') && !$obj->entity) {
476 print img_picto($langs->trans("GlobalGroup"), 'superadmin');
477 }
478 print "</td>";
479 if (!$i) {
480 $totalarray['nbfield']++;
481 }
482
483 // Multicompany column
484 if (isModEnabled('multicompany') && isset($mc) && is_object($mc) && !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1) {
485 $mc->getInfo($obj->entity);
486 print '<td class="center">'.dol_escape_htmltag($mc->label).'</td>';
487 if (!$i) {
488 $totalarray['nbfield']++;
489 }
490 }
491
492 // Nb of users in group
493 print '<td class="center">'.($obj->nb ? dol_escape_htmltag($obj->nb) : '').'</td>';
494 if (!$i) {
495 $totalarray['nbfield']++;
496 }
497 print '<td class="center">';
498 print '<a href="'.DOL_URL_ROOT.'/user/group/perms.php?id='.$obj->rowid.'">'.dol_escape_htmltag($obj->nbpermissions).'</a>';
499 print '</td>';
500 if (!$i) {
501 $totalarray['nbfield']++;
502 }
503 print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->datec), "dayhour").'</td>';
504 if (!$i) {
505 $totalarray['nbfield']++;
506 }
507 print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->tms), "dayhour").'</td>';
508 if (!$i) {
509 $totalarray['nbfield']++;
510 }
511 // Extra fields
512 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
513 // Fields from hook
514 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
515 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
516 print $hookmanager->resPrint;
517 // Action column
518 if (empty($conf->main_checkbox_left_column)) {
519 print '<td class="nowrap center">';
520 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
521 $selected = 0;
522 if (in_array($object->id, $arrayofselected)) {
523 $selected = 1;
524 }
525 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
526 }
527 print '</td>';
528 if (!$i) {
529 $totalarray['nbfield']++;
530 }
531 }
532
533 print '</tr>'."\n";
534 }
535 $i++;
536}
537
538// Show total line
539include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
540
541// If no record found
542if ($num == 0) {
543 /*$colspan = 1;
544 foreach ($arrayfields as $key => $val) {
545 if (!empty($val['checked'])) {
546 $colspan++;
547 }
548 }*/
549 $colspan = $savnbfield;
550 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
551}
552
553$db->free($resql);
554
555$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
556$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
557print $hookmanager->resPrint;
558
559print '</table>'."\n";
560print '</div>'."\n";
561
562print '</form>'."\n";
563
564// End of page
565llxFooter();
566$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:501
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 generation of HTML components Only common components must be here.
Class to manage user groups.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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)
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.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
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.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.