dolibarr 24.0.0-beta
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2014 Jean-François Ferry <jfefe@aternatik.fr>
3 * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
4 * Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
6 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
7 * Copyright (C) 2026 Anthony Berton <anthony.berton@bb2a.fr>
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';
38require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
39
40// Load translation files required by the page
41$langs->loadLangs(array("resource", "companies", "other"));
42
43// Get parameters
44$id = GETPOSTINT('id');
45$action = GETPOST('action', 'alpha');
46$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
47$confirm = GETPOST('confirm', 'alpha');
48$toselect = GETPOST('toselect', 'array:int');
49$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'interventionlist';
50
51$lineid = GETPOSTINT('lineid');
52$element = GETPOST('element', 'alpha');
53$element_id = GETPOSTINT('element_id');
54$resource_id = GETPOSTINT('resource_id');
55
56$sortorder = GETPOST('sortorder', 'aZ09comma');
57$sortfield = GETPOST('sortfield', 'aZ09comma');
58$optioncss = GETPOST('optioncss', 'alpha');
59
60// Initialize context for list
61$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'resourcelist';
62
63// Initialize a technical objects
65$extrafields = new ExtraFields($db);
66
67// Fetch optionals attributes and labels
68$extrafields->fetch_name_optionals_label($object->table_element);
69$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
70if (!is_array($search_array_options)) {
71 $search_array_options = array();
72}
73$search_all = trim(GETPOST('search_all', 'alphanohtml'));
74$search_ref = GETPOST("search_ref", 'alpha');
75$search_type = GETPOST("search_type", 'alpha');
76$search_address = GETPOST("search_address", 'alpha');
77$search_zip = GETPOST("search_zip", 'alpha');
78$search_town = GETPOST("search_town", 'alpha');
79$search_state = GETPOST("search_state", 'alpha');
80$search_country = GETPOST("search_country", 'alpha');
81$search_phone = GETPOST("search_phone", 'alpha');
82$search_email = GETPOST("search_email", 'alpha');
83$search_max_users = GETPOST("search_max_users", 'alpha');
84$search_url = GETPOST("search_url", 'alpha');
85
86$filter = array();
87
88$hookmanager->initHooks(array('resourcelist'));
89
90if (empty($sortorder)) {
91 $sortorder = "ASC";
92}
93if (empty($sortfield)) {
94 $sortfield = "t.ref";
95}
96
97$search_all = trim(GETPOST('search_all', 'alphanohtml'));
98
99// Load variable for pagination
100$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
101
102$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
103if (empty($page) || $page == -1) {
104 $page = 0;
105} // If $page is not defined, or '' or -1
106$offset = $limit * $page;
107$pageprev = $page - 1;
108$pagenext = $page + 1;
109
110// List of fields to search into when doing a "search in all"
111$fieldstosearchall = array(
112 't.ref' => 'Ref',
113 't.description' => 'Description',
114);
115
116$arrayfields = array(
117 't.ref' => array(
118 'label' => $langs->trans("Ref"),
119 'checked' => '1',
120 'position' => 1
121 ),
122 'ty.label' => array(
123 'label' => $langs->trans("Type"),
124 'checked' => '1',
125 'position' => 2
126 ),
127 't.address' => array(
128 'label' => $langs->trans("Address"),
129 'checked' => '0',
130 'position' => 3
131 ),
132 't.zip' => array(
133 'label' => $langs->trans("Zip"),
134 'checked' => '0',
135 'position' => 4
136 ),
137 't.town' => array(
138 'label' => $langs->trans("Town"),
139 'checked' => '1',
140 'position' => 5
141 ),
142 'st.nom' => array(
143 'label' => $langs->trans("State"),
144 'checked' => '0',
145 'position' => 6
146 ),
147 'co.label' => array(
148 'label' => $langs->trans("Country"),
149 'checked' => '1',
150 'position' => 7
151 ),
152 't.phone' => array(
153 'label' => $langs->trans("Phone"),
154 'checked' => '0',
155 'position' => 8
156 ),
157 't.email' => array(
158 'label' => $langs->trans("Email"),
159 'checked' => '0',
160 'position' => 9
161 ),
162 't.max_users' => array(
163 'label' => $langs->trans("MaxUsersLabel"),
164 'checked' => '1',
165 'position' => 10
166 ),
167 't.url' => array(
168 'label' => $langs->trans("URL"),
169 'checked' => '0',
170 'position' => 11
171 ),
172);
173// Extra fields
174include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
175
176$object->fields = dol_sort_array($object->fields, 'position');
177$arrayfields = dol_sort_array($arrayfields, 'position');
178
179include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
180
181// Do we click on purge search criteria ?
182if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
183 $search_ref = "";
184 $search_type = "";
185 $search_address = "";
186 $search_zip = "";
187 $search_town = "";
188 $search_state = "";
189 $search_country = "";
190 $search_phone = "";
191 $search_email = "";
192 $search_max_users = "";
193 $search_url = "";
194 $toselect = array();
195 $search_array_options = array();
196}
197
198$permissiontoread = $user->hasRight('resource', 'read');
199$permissiontoadd = $user->hasRight('resource', 'write');
200$permissiontodelete = $user->hasRight('resource', 'delete');
201if (!$permissiontoread) {
203}
204
205// Mass actions
206$objectclass = 'Dolresource';
207$objectlabel = 'Resources';
208$uploaddir = $conf->resource->dir_output;
209include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
210
211/*
212 * Actions
213 */
214
215if (GETPOST('cancel', 'alpha')) {
216 $action = 'list';
217 $massaction = '';
218}
219if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
220 $massaction = '';
221}
222
223$parameters = array();
224$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
225if ($reshook < 0) {
226 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
227}
228
229/*
230 * View
231 */
232
233$form = new Form($db);
234$objectstatic = new Dolresource($db);
235
236$help_url = '';
237$title = $langs->trans('Resources');
238$morejs = array();
239$morecss = array();
240
241$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
242$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
243
244$sql = "SELECT";
245$sql .= " t.rowid,";
246$sql .= " t.entity,";
247$sql .= " t.ref,";
248$sql .= " t.address,";
249$sql .= " t.zip,";
250$sql .= " t.town,";
251$sql .= " t.fk_country,";
252$sql .= " t.fk_state,";
253$sql .= " t.description,";
254$sql .= " t.phone,";
255$sql .= " t.email,";
256$sql .= " t.max_users,";
257$sql .= " t.url,";
258$sql .= " t.fk_code_type_resource,";
259$sql .= " t.tms as date_modification,";
260$sql .= " t.datec as date_creation, ";
261$sql .= " ty.label as type_label, ";
262$sql .= " st.nom as state_label, ";
263$sql .= " co.label as country_label ";
264// Add fields from extrafields
265if (!empty($extrafields->attributes[$object->table_element]['label'])) {
266 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
267 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
268 }
269}
270// Add fields from hooks
271$parameters = array();
272$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
273$sql .= $hookmanager->resPrint;
274
275$sqlfields = $sql; // $sql fields to remove for count total
276
277$sql .= " FROM ".MAIN_DB_PREFIX."resource as t";
278$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource";
279$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as st ON st.rowid=t.fk_state";
280$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid=t.fk_country";
281if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
282 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
283}
284
285// Add table from hooks
286$parameters = array();
287$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
288$sql .= $hookmanager->resPrint;
289
290$sql .= " WHERE t.entity IN (".getEntity('resource').")";
291// Search all
292if (!empty($search_all)) {
293 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
294}
295if ($search_ref) {
296 $sql .= natural_search('t.ref', $search_ref);
297}
298if ($search_type) {
299 $sql .= natural_search('ty.label', $search_type);
300}
301if ($search_address) {
302 $sql .= natural_search('t.address', $search_address);
303}
304if ($search_zip) {
305 $sql .= natural_search('t.zip', $search_zip);
306}
307if ($search_town) {
308 $sql .= natural_search('t.town', $search_town);
309}
310if ($search_state) {
311 $sql .= natural_search('st.nom', $search_state);
312}
313if ($search_country && $search_country != '-1') {
314 $sql .= " AND t.fk_country IN (".$db->sanitize($search_country).')';
315}
316if ($search_phone) {
317 $sql .= natural_search('t.phone', $search_phone);
318}
319if ($search_email) {
320 $sql .= natural_search('t.email', $search_email);
321}
322if ($search_max_users) {
323 $sql .= natural_search('t.max_users', $search_max_users, 1);
324}
325if ($search_url) {
326 $sql .= natural_search('t.url', $search_url);
327}
328
329// Add where from extra fields
330include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
331// Add where from hooks
332$parameters = array();
333$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
334$sql .= $hookmanager->resPrint;
335
336// Count total nb of records
337$nbtotalofrecords = '';
338if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
339 /* The fast and low memory method to get and count full list converts the sql into a sql count */
340 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
341 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
342 $resql = $db->query($sqlforcount);
343 if ($resql) {
344 $objforcount = $db->fetch_object($resql);
345 $nbtotalofrecords = $objforcount->nbtotalofrecords;
346 } else {
348 }
349
350 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
351 $page = 0;
352 $offset = 0;
353 }
354 $db->free($resql);
355}
356
357// Complete request and execute it with limit
358$sql .= $db->order($sortfield, $sortorder);
359if ($limit) {
360 $sql .= $db->plimit($limit + 1, $offset);
361}
362
363$resql = $db->query($sql);
364if (!$resql) {
366 exit;
367}
368
369$num = $db->num_rows($resql);
370
371// Direct jump if only one record found
372if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
373 $obj = $db->fetch_object($resql);
374 $id = $obj->rowid;
375 header("Location: ".dol_buildpath('/resource/card.php', 1).'?id='.$id);
376 exit;
377}
378
379// Output page
380
381llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-resource page-list bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
382
383$arrayofselected = is_array($toselect) ? $toselect : array();
384
385$param = '';
386if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
387 $param .= '&contextpage='.urlencode($contextpage);
388}
389if ($limit > 0 && $limit != $conf->liste_limit) {
390 $param .= '&limit='.((int) $limit);
391}
392if ($search_ref != '') {
393 $param .= '&search_ref='.urlencode($search_ref);
394}
395if ($search_type != '') {
396 $param .= '&search_type='.urlencode($search_type);
397}
398if ($search_address != '') {
399 $param .= '&search_address='.urlencode($search_address);
400}
401if ($search_zip != '') {
402 $param .= '&search_zip='.urlencode($search_zip);
403}
404if ($search_town != '') {
405 $param .= '&search_town='.urlencode($search_town);
406}
407if ($search_state != '') {
408 $param .= '&search_state='.urlencode($search_state);
409}
410if ($search_country != '') {
411 $param .= '&search_country='.urlencode($search_country);
412}
413if ($search_phone != '') {
414 $param .= '&search_phone='.urlencode($search_phone);
415}
416if ($search_email != '') {
417 $param .= '&search_email='.urlencode($search_email);
418}
419if ($search_max_users != '') {
420 $param .= '&search_max_users='.urlencode($search_max_users);
421}
422if ($search_url != '') {
423 $param .= '&search_url='.urlencode($search_url);
424}
425
426// Add $param from extra fields
427include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
428
429// List of mass actions available
430$arrayofmassactions = array();
431if (!empty($permissiontodelete)) {
432 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
433}
434if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
435 $arrayofmassactions = array();
436}
437$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
438
439$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
440$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column);
441
442print '<form method="POST" id="searchFormList" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
443if ($optioncss != '') {
444 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
445}
446print '<input type="hidden" name="token" value="'.newToken().'">';
447print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
448print '<input type="hidden" name="action" value="list">';
449print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
450print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
451print '<input type="hidden" name="page" value="'.$page.'">';
452print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
453
454$newcardbutton = '';
455$url = DOL_URL_ROOT.'/resource/card.php?action=create';
456
457$newcardbutton = dolGetButtonTitle($langs->trans('NewResource'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
458
459print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
460
461$objecttmp = new Dolresource($db);
462$trackid = 'int'.$object->id;
463include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
464
465if ($search_all) {
466 $setupstring = '';
467 foreach ($fieldstosearchall as $key => $val) {
468 $fieldstosearchall[$key] = $langs->trans($val);
469 $setupstring .= $key."=".$val.";";
470 }
471 print '<!-- Search done like if RESOURCE_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
472 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
473}
474
475$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
476$selectedfields = ($form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column)); // This also change content of $arrayfields
477$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
478
479print '<div class="div-table-responsive">';
480print '<table class="tagtable liste">'."\n";
481
482// Fields title search
483
484print '<tr class="liste_titre_filter">';
485// Action column
486if ($conf->main_checkbox_left_column) {
487 print '<td class="liste_titre maxwidthsearch center">';
488 $searchpicto = $form->showFilterButtons('left');
489 print $searchpicto;
490 print '</td>';
491}
492if (!empty($arrayfields['t.ref']['checked'])) {
493 print '<td class="liste_titre">';
494 print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="8">';
495 print '</td>';
496}
497if (!empty($arrayfields['ty.label']['checked'])) {
498 print '<td class="liste_titre">';
499 print '<input type="text" class="flat" name="search_type" value="'.$search_type.'" size="8">';
500 print '</td>';
501}
502if (!empty($arrayfields['t.address']['checked'])) {
503 print '<td class="liste_titre">';
504 print '<input type="text" class="flat" name="search_address" value="'.$search_address.'" size="8">';
505 print '</td>';
506}
507if (!empty($arrayfields['t.zip']['checked'])) {
508 print '<td class="liste_titre">';
509 print '<input type="text" class="flat" name="search_zip" value="'.$search_zip.'" size="8">';
510 print '</td>';
511}
512if (!empty($arrayfields['t.town']['checked'])) {
513 print '<td class="liste_titre">';
514 print '<input type="text" class="flat" name="search_town" value="'.$search_town.'" size="8">';
515 print '</td>';
516}
517if (!empty($arrayfields['st.nom']['checked'])) {
518 print '<td class="liste_titre">';
519 print '<input type="text" class="flat" name="search_state" value="'.$search_state.'" size="8">';
520 print '</td>';
521}
522if (!empty($arrayfields['co.label']['checked'])) {
523 print '<td class="liste_titre">';
524 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
525 print '</td>';
526}
527if (!empty($arrayfields['t.phone']['checked'])) {
528 print '<td class="liste_titre">';
529 print '<input type="text" class="flat" name="search_phone" value="'.$search_phone.'" size="8">';
530 print '</td>';
531}
532if (!empty($arrayfields['t.email']['checked'])) {
533 print '<td class="liste_titre">';
534 print '<input type="text" class="flat" name="search_email" value="'.$search_email.'" size="8">';
535 print '</td>';
536}
537if (!empty($arrayfields['t.max_users']['checked'])) {
538 print '<td class="liste_titre">';
539 print '<input type="text" class="flat" name="search_max_users" value="'.$search_max_users.'" size="8">';
540 print '</td>';
541}
542if (!empty($arrayfields['t.url']['checked'])) {
543 print '<td class="liste_titre">';
544 print '<input type="text" class="flat" name="search_url" value="'.$search_url.'" size="8">';
545 print '</td>';
546}
547// Extra fields
548include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
549
550// Action column
551if (!$conf->main_checkbox_left_column) {
552 print '<td class="liste_titre center maxwidthsearch">';
553 $searchpicto = $form->showFilterButtons();
554 print $searchpicto;
555 print '</td>';
556}
557print '</tr>'."\n";
558
559$totalarray = array();
560$totalarray['nbfield'] = 0;
561
562// Fields title label
563
564print '<tr class="liste_titre">';
565// Action column
566if ($conf->main_checkbox_left_column) {
567 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
568}
569if (!empty($arrayfields['t.ref']['checked'])) {
570 // @phan-suppress-next-line PhanTypeInvalidDimOffset
571 print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], "t.ref", "", $param, "", $sortfield, $sortorder);
572}
573if (!empty($arrayfields['ty.label']['checked'])) {
574 print_liste_field_titre($arrayfields['ty.label']['label'], $_SERVER["PHP_SELF"], "ty.label", "", $param, "", $sortfield, $sortorder);
575}
576if (!empty($arrayfields['t.address']['checked'])) {
577 print_liste_field_titre($arrayfields['t.address']['label'], $_SERVER["PHP_SELF"], "t.address", "", $param, "", $sortfield, $sortorder);
578}
579if (!empty($arrayfields['t.zip']['checked'])) {
580 print_liste_field_titre($arrayfields['t.zip']['label'], $_SERVER["PHP_SELF"], "t.zip", "", $param, "", $sortfield, $sortorder);
581}
582if (!empty($arrayfields['t.town']['checked'])) {
583 print_liste_field_titre($arrayfields['t.town']['label'], $_SERVER["PHP_SELF"], "t.town", "", $param, "", $sortfield, $sortorder);
584}
585if (!empty($arrayfields['st.nom']['checked'])) {
586 print_liste_field_titre($arrayfields['st.nom']['label'], $_SERVER["PHP_SELF"], "st.nom", "", $param, "", $sortfield, $sortorder);
587}
588if (!empty($arrayfields['co.label']['checked'])) {
589 print_liste_field_titre($arrayfields['co.label']['label'], $_SERVER["PHP_SELF"], "co.label", "", $param, "", $sortfield, $sortorder);
590}
591if (!empty($arrayfields['t.phone']['checked'])) {
592 print_liste_field_titre($arrayfields['t.phone']['label'], $_SERVER["PHP_SELF"], "t.phone", "", $param, "", $sortfield, $sortorder);
593}
594if (!empty($arrayfields['t.email']['checked'])) {
595 print_liste_field_titre($arrayfields['t.email']['label'], $_SERVER["PHP_SELF"], "t.email", "", $param, "", $sortfield, $sortorder);
596}
597if (!empty($arrayfields['t.max_users']['checked'])) {
598 print_liste_field_titre($arrayfields['t.max_users']['label'], $_SERVER["PHP_SELF"], "t.max_users", "", $param, "", $sortfield, $sortorder);
599}
600if (!empty($arrayfields['t.url']['checked'])) {
601 print_liste_field_titre($arrayfields['t.url']['label'], $_SERVER["PHP_SELF"], "t.url", "", $param, "", $sortfield, $sortorder);
602}
603// Extra fields
604include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
605// Action column
606if (!$conf->main_checkbox_left_column) {
607 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
608}
609print "</tr>\n";
610
611// Loop on record
612
613$i = 0;
614$savnbfield = $totalarray['nbfield'];
615$totalarray = array();
616$totalarray['nbfield'] = 0;
617$imaxinloop = ($limit ? min($num, $limit) : $num);
618while ($i < $imaxinloop) {
619 $obj = $db->fetch_object($resql);
620 $objectstatic->id = $obj->rowid;
621 $objectstatic->ref = $obj->ref;
622 $objectstatic->type_label = $obj->type_label;
623 $objectstatic->address = $obj->address;
624 $objectstatic->zip = $obj->zip;
625 $objectstatic->town = $obj->town;
626 $objectstatic->state = $obj->state_label;
627 $objectstatic->country = $obj->country_label;
628 $objectstatic->phone = $obj->phone;
629 $objectstatic->email = $obj->email;
630 $objectstatic->max_users = $obj->max_users;
631 $objectstatic->url = $obj->url;
632
633 print '<tr data-rowid="'.$obj->rowid.'" class="oddeven row-with-select">';
634
635 // Action column
636 if ($conf->main_checkbox_left_column) {
637 print '<td class="nowrap center">';
638 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
639 $selected = 0;
640 if (in_array($obj->rowid, $arrayofselected)) {
641 $selected = 1;
642 }
643 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
644 }
645 print '</td>';
646 if (!$i) {
647 $totalarray['nbfield']++;
648 }
649 }
650
651 if (!empty($arrayfields['t.ref']['checked'])) {
652 print '<td class="tdoverflowmax150">'.$objectstatic->getNomUrl(5).'</td>';
653 if (!$i) {
654 $totalarray['nbfield']++;
655 }
656 }
657
658 if (!empty($arrayfields['ty.label']['checked'])) {
659 print '<td class="tdoverflowmax200">'.$objectstatic->type_label.'</td>';
660 if (!$i) {
661 $totalarray['nbfield']++;
662 }
663 }
664
665 if (!empty($arrayfields['t.address']['checked'])) {
666 print '<td>'.$objectstatic->address.'</td>';
667 if (!$i) {
668 $totalarray['nbfield']++;
669 }
670 }
671
672 if (!empty($arrayfields['t.zip']['checked'])) {
673 print '<td>'.$objectstatic->zip.'</td>';
674 if (!$i) {
675 $totalarray['nbfield']++;
676 }
677 }
678
679 if (!empty($arrayfields['t.town']['checked'])) {
680 print '<td>'.$objectstatic->town.'</td>';
681 if (!$i) {
682 $totalarray['nbfield']++;
683 }
684 }
685
686 if (!empty($arrayfields['st.nom']['checked'])) {
687 print '<td>'.$objectstatic->state.'</td>';
688 if (!$i) {
689 $totalarray['nbfield']++;
690 }
691 }
692
693 if (!empty($arrayfields['co.label']['checked'])) {
694 print '<td>'.$objectstatic->country.'</td>';
695 if (!$i) {
696 $totalarray['nbfield']++;
697 }
698 }
699
700 if (!empty($arrayfields['t.phone']['checked'])) {
701 print '<td>'.dol_print_phone($objectstatic->phone, '', 0, 0, 'AC_TEL', " ", 'phone').'</td>';
702 if (!$i) {
703 $totalarray['nbfield']++;
704 }
705 }
706
707 if (!empty($arrayfields['t.email']['checked'])) {
708 print '<td>'.dol_print_email($objectstatic->email, 0, 0, 1, 0, 0, 1).'</td>';
709 if (!$i) {
710 $totalarray['nbfield']++;
711 }
712 }
713
714 if (!empty($arrayfields['t.max_users']['checked'])) {
715 print '<td>'.$objectstatic->max_users.'</td>';
716 if (!$i) {
717 $totalarray['nbfield']++;
718 }
719 }
720
721 if (!empty($arrayfields['t.url']['checked'])) {
722 print '<td>'.dol_print_url($objectstatic->url, '_blank', 32, 1).'</td>';
723 if (!$i) {
724 $totalarray['nbfield']++;
725 }
726 }
727 // Extra fields
728 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
729
730 // Action column
731 if (!$conf->main_checkbox_left_column) {
732 print '<td class="nowrap center">';
733 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
734 $selected = 0;
735 if (in_array($obj->rowid, $arrayofselected)) {
736 $selected = 1;
737 }
738 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
739 }
740 print '</td>';
741 if (!$i) {
742 $totalarray['nbfield']++;
743 }
744 }
745
746 print '</tr>';
747 $i++;
748}
749
750// Show total line
751include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
752
753// If no record found
754if ($num == 0) {
755 $colspan = 1;
756 foreach ($arrayfields as $key => $val) {
757 if (!empty($val['checked'])) {
758 $colspan++;
759 }
760 }
761 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
762}
763
764$db->free($resql);
765
766$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
767$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
768print $hookmanager->resPrint;
769
770print '</table>'."\n";
771print '</div>'."\n";
772print '</form>'."\n";
773
774// End of page
775llxFooter();
776$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
DAO Resource object.
Class to manage standard extra fields.
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.
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)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.