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