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