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