dolibarr 25.0.0-alpha
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// Add hook to complete $arrayfield
176$parameters = array('arrayfields' => &$arrayfields);
177$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
178
179$object->fields = dol_sort_array($object->fields, 'position');
180$arrayfields = dol_sort_array($arrayfields, 'position');
181
182include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
183
184// Do we click on purge search criteria ?
185if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
186 $search_ref = "";
187 $search_type = "";
188 $search_address = "";
189 $search_zip = "";
190 $search_town = "";
191 $search_state = "";
192 $search_country = "";
193 $search_phone = "";
194 $search_email = "";
195 $search_max_users = "";
196 $search_url = "";
197 $toselect = array();
198 $search_array_options = array();
199}
200
201$permissiontoread = $user->hasRight('resource', 'read');
202$permissiontoadd = $user->hasRight('resource', 'write');
203$permissiontodelete = $user->hasRight('resource', 'delete');
204if (!$permissiontoread) {
206}
207
208// Mass actions
209$objectclass = 'Dolresource';
210$objectlabel = 'Resources';
211$uploaddir = $conf->resource->dir_output;
212include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
213
214/*
215 * Actions
216 */
217
218if (GETPOST('cancel', 'alpha')) {
219 $action = 'list';
220 $massaction = '';
221}
222if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
223 $massaction = '';
224}
225
226$parameters = array();
227$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
228if ($reshook < 0) {
229 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
230}
231
232/*
233 * View
234 */
235
236$form = new Form($db);
237$objectstatic = new Dolresource($db);
238
239$help_url = '';
240$title = $langs->trans('Resources');
241$morejs = array();
242$morecss = array();
243
244$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
245$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
246
247$sql = "SELECT";
248$sql .= " t.rowid,";
249$sql .= " t.entity,";
250$sql .= " t.ref,";
251$sql .= " t.address,";
252$sql .= " t.zip,";
253$sql .= " t.town,";
254$sql .= " t.fk_country,";
255$sql .= " t.fk_state,";
256$sql .= " t.description,";
257$sql .= " t.phone,";
258$sql .= " t.email,";
259$sql .= " t.max_users,";
260$sql .= " t.url,";
261$sql .= " t.fk_code_type_resource,";
262$sql .= " t.tms as date_modification,";
263$sql .= " t.datec as date_creation, ";
264$sql .= " ty.label as type_label, ";
265$sql .= " st.nom as state_label, ";
266$sql .= " co.label as country_label ";
267// Add fields from extrafields
268if (!empty($extrafields->attributes[$object->table_element]['label'])) {
269 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
270 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
271 }
272}
273// Add fields from hooks
274$parameters = array();
275$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
276$sql .= $hookmanager->resPrint;
277
278$sqlfields = $sql; // $sql fields to remove for count total
279
280$sql .= " FROM ".MAIN_DB_PREFIX."resource as t";
281$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource";
282$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as st ON st.rowid=t.fk_state";
283$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid=t.fk_country";
284if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
285 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
286}
287
288// Add table from hooks
289$parameters = array();
290$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
291$sql .= $hookmanager->resPrint;
292
293$sql .= " WHERE t.entity IN (".getEntity('resource').")";
294// Search all
295if (!empty($search_all)) {
296 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
297}
298if ($search_ref) {
299 $sql .= natural_search('t.ref', $search_ref);
300}
301if ($search_type) {
302 $sql .= natural_search('ty.label', $search_type);
303}
304if ($search_address) {
305 $sql .= natural_search('t.address', $search_address);
306}
307if ($search_zip) {
308 $sql .= natural_search('t.zip', $search_zip);
309}
310if ($search_town) {
311 $sql .= natural_search('t.town', $search_town);
312}
313if ($search_state) {
314 $sql .= natural_search('st.nom', $search_state);
315}
316if ($search_country && $search_country != '-1') {
317 $sql .= " AND t.fk_country IN (".$db->sanitize($search_country).')';
318}
319if ($search_phone) {
320 $sql .= natural_search('t.phone', $search_phone);
321}
322if ($search_email) {
323 $sql .= natural_search('t.email', $search_email);
324}
325if ($search_max_users) {
326 $sql .= natural_search('t.max_users', $search_max_users, 1);
327}
328if ($search_url) {
329 $sql .= natural_search('t.url', $search_url);
330}
331
332// Add where from extra fields
333include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
334// Add where from hooks
335$parameters = array();
336$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
337$sql .= $hookmanager->resPrint;
338
339// Count total nb of records
340$nbtotalofrecords = '';
341if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
342 /* The fast and low memory method to get and count full list converts the sql into a sql count */
343 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
344 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
345 $resql = $db->query($sqlforcount);
346 if ($resql) {
347 $objforcount = $db->fetch_object($resql);
348 $nbtotalofrecords = $objforcount->nbtotalofrecords;
349 } else {
351 }
352
353 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
354 $page = 0;
355 $offset = 0;
356 }
357 $db->free($resql);
358}
359
360// Complete request and execute it with limit
361$sql .= $db->order($sortfield, $sortorder);
362if ($limit) {
363 $sql .= $db->plimit($limit + 1, $offset);
364}
365
366$resql = $db->query($sql);
367if (!$resql) {
369 exit;
370}
371
372$num = $db->num_rows($resql);
373
374// Direct jump if only one record found
375if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
376 $obj = $db->fetch_object($resql);
377 $id = $obj->rowid;
378 header("Location: ".dol_buildpath('/resource/card.php', 1).'?id='.$id);
379 exit;
380}
381
382// Output page
383
384llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-resource page-list bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
385
386$arrayofselected = is_array($toselect) ? $toselect : array();
387
388$param = '';
389if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
390 $param .= '&contextpage='.urlencode($contextpage);
391}
392if ($limit > 0 && $limit != $conf->liste_limit) {
393 $param .= '&limit='.((int) $limit);
394}
395if ($search_ref != '') {
396 $param .= '&search_ref='.urlencode($search_ref);
397}
398if ($search_type != '') {
399 $param .= '&search_type='.urlencode($search_type);
400}
401if ($search_address != '') {
402 $param .= '&search_address='.urlencode($search_address);
403}
404if ($search_zip != '') {
405 $param .= '&search_zip='.urlencode($search_zip);
406}
407if ($search_town != '') {
408 $param .= '&search_town='.urlencode($search_town);
409}
410if ($search_state != '') {
411 $param .= '&search_state='.urlencode($search_state);
412}
413if ($search_country != '') {
414 $param .= '&search_country='.urlencode($search_country);
415}
416if ($search_phone != '') {
417 $param .= '&search_phone='.urlencode($search_phone);
418}
419if ($search_email != '') {
420 $param .= '&search_email='.urlencode($search_email);
421}
422if ($search_max_users != '') {
423 $param .= '&search_max_users='.urlencode($search_max_users);
424}
425if ($search_url != '') {
426 $param .= '&search_url='.urlencode($search_url);
427}
428
429// Add $param from extra fields
430include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
431
432// List of mass actions available
433$arrayofmassactions = array();
434if (!empty($permissiontodelete)) {
435 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
436}
437if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
438 $arrayofmassactions = array();
439}
440$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
441
442$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
443$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column);
444
445print '<form method="POST" id="searchFormList" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
446if ($optioncss != '') {
447 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
448}
449print '<input type="hidden" name="token" value="'.newToken().'">';
450print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
451print '<input type="hidden" name="action" value="list">';
452print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
453print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
454print '<input type="hidden" name="page" value="'.$page.'">';
455print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
456
457$newcardbutton = '';
458$url = DOL_URL_ROOT.'/resource/card.php?action=create';
459
460$newcardbutton = dolGetButtonTitle($langs->trans('NewResource'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
461
462print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
463
464$objecttmp = new Dolresource($db);
465$trackid = 'int'.$object->id;
466include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
467
468if ($search_all) {
469 $setupstring = '';
470 foreach ($fieldstosearchall as $key => $val) {
471 $fieldstosearchall[$key] = $langs->trans($val);
472 $setupstring .= $key."=".$val.";";
473 }
474 print '<!-- Search done like if RESOURCE_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
475 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
476}
477
478$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
479$selectedfields = ($form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column)); // This also change content of $arrayfields
480$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
481
482print '<div class="div-table-responsive">';
483print '<table class="tagtable liste">'."\n";
484
485// Fields title search
486
487print '<tr class="liste_titre_filter">';
488// Action column
489if ($conf->main_checkbox_left_column) {
490 print '<td class="liste_titre maxwidthsearch center">';
491 $searchpicto = $form->showFilterButtons('left');
492 print $searchpicto;
493 print '</td>';
494}
495if (!empty($arrayfields['t.ref']['checked'])) {
496 print '<td class="liste_titre">';
497 print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="8">';
498 print '</td>';
499}
500if (!empty($arrayfields['ty.label']['checked'])) {
501 print '<td class="liste_titre">';
502 print '<input type="text" class="flat" name="search_type" value="'.$search_type.'" size="8">';
503 print '</td>';
504}
505if (!empty($arrayfields['t.address']['checked'])) {
506 print '<td class="liste_titre">';
507 print '<input type="text" class="flat" name="search_address" value="'.$search_address.'" size="8">';
508 print '</td>';
509}
510if (!empty($arrayfields['t.zip']['checked'])) {
511 print '<td class="liste_titre">';
512 print '<input type="text" class="flat" name="search_zip" value="'.$search_zip.'" size="8">';
513 print '</td>';
514}
515if (!empty($arrayfields['t.town']['checked'])) {
516 print '<td class="liste_titre">';
517 print '<input type="text" class="flat" name="search_town" value="'.$search_town.'" size="8">';
518 print '</td>';
519}
520if (!empty($arrayfields['st.nom']['checked'])) {
521 print '<td class="liste_titre">';
522 print '<input type="text" class="flat" name="search_state" value="'.$search_state.'" size="8">';
523 print '</td>';
524}
525if (!empty($arrayfields['co.label']['checked'])) {
526 print '<td class="liste_titre">';
527 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
528 print '</td>';
529}
530if (!empty($arrayfields['t.phone']['checked'])) {
531 print '<td class="liste_titre">';
532 print '<input type="text" class="flat" name="search_phone" value="'.$search_phone.'" size="8">';
533 print '</td>';
534}
535if (!empty($arrayfields['t.email']['checked'])) {
536 print '<td class="liste_titre">';
537 print '<input type="text" class="flat" name="search_email" value="'.$search_email.'" size="8">';
538 print '</td>';
539}
540if (!empty($arrayfields['t.max_users']['checked'])) {
541 print '<td class="liste_titre">';
542 print '<input type="text" class="flat" name="search_max_users" value="'.$search_max_users.'" size="8">';
543 print '</td>';
544}
545if (!empty($arrayfields['t.url']['checked'])) {
546 print '<td class="liste_titre">';
547 print '<input type="text" class="flat" name="search_url" value="'.$search_url.'" size="8">';
548 print '</td>';
549}
550// Extra fields
551include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
552
553// Action column
554if (!$conf->main_checkbox_left_column) {
555 print '<td class="liste_titre center maxwidthsearch">';
556 $searchpicto = $form->showFilterButtons();
557 print $searchpicto;
558 print '</td>';
559}
560print '</tr>'."\n";
561
562$totalarray = array();
563$totalarray['nbfield'] = 0;
564
565// Fields title label
566
567print '<tr class="liste_titre">';
568// Action column
569if ($conf->main_checkbox_left_column) {
570 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
571}
572if (!empty($arrayfields['t.ref']['checked'])) {
573 // @phan-suppress-next-line PhanTypeInvalidDimOffset
574 print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], "t.ref", "", $param, "", $sortfield, $sortorder);
575}
576if (!empty($arrayfields['ty.label']['checked'])) {
577 print_liste_field_titre($arrayfields['ty.label']['label'], $_SERVER["PHP_SELF"], "ty.label", "", $param, "", $sortfield, $sortorder);
578}
579if (!empty($arrayfields['t.address']['checked'])) {
580 print_liste_field_titre($arrayfields['t.address']['label'], $_SERVER["PHP_SELF"], "t.address", "", $param, "", $sortfield, $sortorder);
581}
582if (!empty($arrayfields['t.zip']['checked'])) {
583 print_liste_field_titre($arrayfields['t.zip']['label'], $_SERVER["PHP_SELF"], "t.zip", "", $param, "", $sortfield, $sortorder);
584}
585if (!empty($arrayfields['t.town']['checked'])) {
586 print_liste_field_titre($arrayfields['t.town']['label'], $_SERVER["PHP_SELF"], "t.town", "", $param, "", $sortfield, $sortorder);
587}
588if (!empty($arrayfields['st.nom']['checked'])) {
589 print_liste_field_titre($arrayfields['st.nom']['label'], $_SERVER["PHP_SELF"], "st.nom", "", $param, "", $sortfield, $sortorder);
590}
591if (!empty($arrayfields['co.label']['checked'])) {
592 print_liste_field_titre($arrayfields['co.label']['label'], $_SERVER["PHP_SELF"], "co.label", "", $param, "", $sortfield, $sortorder);
593}
594if (!empty($arrayfields['t.phone']['checked'])) {
595 print_liste_field_titre($arrayfields['t.phone']['label'], $_SERVER["PHP_SELF"], "t.phone", "", $param, "", $sortfield, $sortorder);
596}
597if (!empty($arrayfields['t.email']['checked'])) {
598 print_liste_field_titre($arrayfields['t.email']['label'], $_SERVER["PHP_SELF"], "t.email", "", $param, "", $sortfield, $sortorder);
599}
600if (!empty($arrayfields['t.max_users']['checked'])) {
601 print_liste_field_titre($arrayfields['t.max_users']['label'], $_SERVER["PHP_SELF"], "t.max_users", "", $param, "", $sortfield, $sortorder);
602}
603if (!empty($arrayfields['t.url']['checked'])) {
604 print_liste_field_titre($arrayfields['t.url']['label'], $_SERVER["PHP_SELF"], "t.url", "", $param, "", $sortfield, $sortorder);
605}
606// Extra fields
607include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
608// Action column
609if (!$conf->main_checkbox_left_column) {
610 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
611}
612print "</tr>\n";
613
614// Loop on record
615
616$i = 0;
617$savnbfield = $totalarray['nbfield'];
618$totalarray = array();
619$totalarray['nbfield'] = 0;
620$imaxinloop = ($limit ? min($num, $limit) : $num);
621while ($i < $imaxinloop) {
622 $obj = $db->fetch_object($resql);
623 $objectstatic->id = $obj->rowid;
624 $objectstatic->ref = $obj->ref;
625 $objectstatic->type_label = $obj->type_label;
626 $objectstatic->address = $obj->address;
627 $objectstatic->zip = $obj->zip;
628 $objectstatic->town = $obj->town;
629 $objectstatic->state = $obj->state_label;
630 $objectstatic->country = $obj->country_label;
631 $objectstatic->phone = $obj->phone;
632 $objectstatic->email = $obj->email;
633 $objectstatic->max_users = $obj->max_users;
634 $objectstatic->url = $obj->url;
635
636 print '<tr data-rowid="'.$obj->rowid.'" class="oddeven row-with-select">';
637
638 // Action column
639 if ($conf->main_checkbox_left_column) {
640 print '<td class="nowrap center">';
641 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
642 $selected = 0;
643 if (in_array($obj->rowid, $arrayofselected)) {
644 $selected = 1;
645 }
646 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
647 }
648 print '</td>';
649 if (!$i) {
650 $totalarray['nbfield']++;
651 }
652 }
653
654 if (!empty($arrayfields['t.ref']['checked'])) {
655 print '<td class="tdoverflowmax150">'.$objectstatic->getNomUrl(5).'</td>';
656 if (!$i) {
657 $totalarray['nbfield']++;
658 }
659 }
660
661 if (!empty($arrayfields['ty.label']['checked'])) {
662 print '<td class="tdoverflowmax200">'.$objectstatic->type_label.'</td>';
663 if (!$i) {
664 $totalarray['nbfield']++;
665 }
666 }
667
668 if (!empty($arrayfields['t.address']['checked'])) {
669 print '<td>'.$objectstatic->address.'</td>';
670 if (!$i) {
671 $totalarray['nbfield']++;
672 }
673 }
674
675 if (!empty($arrayfields['t.zip']['checked'])) {
676 print '<td>'.$objectstatic->zip.'</td>';
677 if (!$i) {
678 $totalarray['nbfield']++;
679 }
680 }
681
682 if (!empty($arrayfields['t.town']['checked'])) {
683 print '<td>'.$objectstatic->town.'</td>';
684 if (!$i) {
685 $totalarray['nbfield']++;
686 }
687 }
688
689 if (!empty($arrayfields['st.nom']['checked'])) {
690 print '<td>'.$objectstatic->state.'</td>';
691 if (!$i) {
692 $totalarray['nbfield']++;
693 }
694 }
695
696 if (!empty($arrayfields['co.label']['checked'])) {
697 print '<td>'.$objectstatic->country.'</td>';
698 if (!$i) {
699 $totalarray['nbfield']++;
700 }
701 }
702
703 if (!empty($arrayfields['t.phone']['checked'])) {
704 print '<td>'.dol_print_phone($objectstatic->phone, '', 0, 0, 'AC_TEL', " ", 'phone').'</td>';
705 if (!$i) {
706 $totalarray['nbfield']++;
707 }
708 }
709
710 if (!empty($arrayfields['t.email']['checked'])) {
711 $showinvalidemail = (int) !getDolGlobalInt('MAIN_SHOW_INVALID_EMAIL_IN_LIST'); // to avoid slow display
712 print '<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($obj->email).'">'.dol_print_email($objectstatic->email, 0, 0, 1, 0, $showinvalidemail, 1).'</td>';
713 if (!$i) {
714 $totalarray['nbfield']++;
715 }
716 }
717
718 if (!empty($arrayfields['t.max_users']['checked'])) {
719 print '<td>'.$objectstatic->max_users.'</td>';
720 if (!$i) {
721 $totalarray['nbfield']++;
722 }
723 }
724
725 if (!empty($arrayfields['t.url']['checked'])) {
726 print '<td>'.dol_print_url($objectstatic->url, '_blank', 32, 1).'</td>';
727 if (!$i) {
728 $totalarray['nbfield']++;
729 }
730 }
731 // Extra fields
732 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
733
734 // Action column
735 if (!$conf->main_checkbox_left_column) {
736 print '<td class="nowrap center">';
737 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
738 $selected = 0;
739 if (in_array($obj->rowid, $arrayofselected)) {
740 $selected = 1;
741 }
742 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
743 }
744 print '</td>';
745 if (!$i) {
746 $totalarray['nbfield']++;
747 }
748 }
749
750 print '</tr>';
751 $i++;
752}
753
754// Show total line
755include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
756
757// If no record found
758if ($num == 0) {
759 $colspan = 1;
760 foreach ($arrayfields as $key => $val) {
761 if (!empty($val['checked'])) {
762 $colspan++;
763 }
764 }
765 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
766}
767
768$db->free($resql);
769
770$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
771$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
772print $hookmanager->resPrint;
773
774print '</table>'."\n";
775print '</div>'."\n";
776print '</form>'."\n";
777
778// End of page
779llxFooter();
780$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: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
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.
dol_print_email($email, $contactid=0, $socid=0, $addlink=0, $max=0, $showinvalid=2, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
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, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.