dolibarr 24.0.0-beta
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../main.inc.php';
36require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
37require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
38require_once DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php";
39
40// Load translation files required by the page
41$langs->load("opensurvey");
42
43$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
44$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
45$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
46$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
47$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
48$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
49$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'opensurveylist'; // To manage different context of search
50$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
51$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
52$mode = GETPOST('mode', 'aZ');
53
54$search_all = trim(GETPOST('search_all', 'alphanohtml'));
55$search_expired = GETPOST('search_expired');
56
57$id = GETPOST('id', 'alpha');
58$search_ref = GETPOST('search_ref', 'alpha');
59$search_title = GETPOST('search_title', 'alpha');
60$search_status = GETPOST('search_status', 'alpha');
61
62// Load variable for pagination
63$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
64$sortfield = GETPOST('sortfield', 'aZ09comma');
65$sortorder = GETPOST('sortorder', 'aZ09comma');
66$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
67if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
68 $page = 0;
69} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
70$offset = $limit * $page;
71$pageprev = $page - 1;
72$pagenext = $page + 1;
73
74// Initialize a technical objects
76$opensurvey_static = new Opensurveysondage($db);
77
78$extrafields = new ExtraFields($db);
79$diroutputmassaction = $conf->opensurvey->dir_output.'/temp/massgeneration/'.$user->id;
80$hookmanager->initHooks(array('surveylist')); // Note that conf->hooks_modules contains array
81// Fetch optionals attributes and labels
82$extrafields->fetch_name_optionals_label($object->table_element);
83$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
84
85// Default sort order (if not yet defined by previous GETPOST)
86if (!$sortfield) {
87 $sortfield = "p.date_fin";
88}
89if (!$sortorder) {
90 $sortorder = "DESC";
91}
92
93// Security check
94if (!$user->hasRight('opensurvey', 'read')) {
96}
97
98$fieldstosearchall = array();
99
100// Definition of fields for list
101$arrayfields = array();
102// Extra fields
103include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
104
105
106$object->fields = dol_sort_array($object->fields, 'position');
107$arrayfields = dol_sort_array($arrayfields, 'position');
108
109$permissiontoread = $user->hasRight('opensurvey', 'read');
110$permissiontoadd = $user->hasRight('opensurvey', 'write');
111// permission delete doesn't exists
112$permissiontodelete = $user->hasRight('opensurvey', 'write');
113
114
115/*
116 * Actions
117 */
118
119if (GETPOST('cancel', 'alpha')) {
120 $action = 'list';
121 $massaction = '';
122}
123if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
124 $massaction = '';
125}
126
127$parameters = array('arrayfields' => &$arrayfields);
128$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
129if ($reshook < 0) {
130 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
131}
132
133if (empty($reshook)) {
134 // Selection of new fields
135 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
136
137 // Purge search criteria
138 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
139 $search_status = '';
140 $search_title = '';
141 $search_ref = '';
142 $toselect = array();
143 $search_array_options = array();
144 }
145 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
146 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
147 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
148 }
149
150 // Mass actions
151 $objectclass = 'Opensurveysondage';
152 $objectlabel = 'Opensurveysondage';
153 $uploaddir = $conf->opensurvey->dir_output;
154 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
155}
156
157
158/*
159 * View
160 */
161
162$form = new Form($db);
163
164$now = dol_now();
165
166//$help_url="EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject";
167$help_url = '';
168$title = $langs->trans('OpenSurveyArea');
169
170// Build and execute select
171// --------------------------------------------------------------------
172$sql = "SELECT p.id_sondage as rowid, p.fk_user_creat, p.format, p.date_fin, p.status, p.titre as title, p.nom_admin, p.tms,";
173$sql .= " u.login, u.firstname, u.lastname";
174
175$sqlfields = $sql;
176
177$sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p";
178$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat";
179$sql .= " WHERE p.entity IN (".getEntity('survey').")";
180if ($search_status != '-1' && $search_status != '') {
181 $sql .= natural_search("p.status", $search_status, 2);
182}
183if (!empty($search_expired) && $search_expired == 'expired') {
184 $sql .= " AND p.date_fin < '".$db->idate($now)."'";
185}
186if (!empty($search_expired) && $search_expired == 'opened') {
187 $sql .= " AND p.date_fin >= '".$db->idate($now)."'";
188}
189if (!empty($search_ref)) {
190 $sql .= natural_search("p.id_sondage", $search_ref);
191}
192if (!empty($search_title)) {
193 $sql .= natural_search("p.titre", $search_title);
194}
195// Add where from extra fields
196include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
197// Add where from hooks
198$parameters = array();
199$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
200$sql .= $hookmanager->resPrint;
201
202// Count total nb of records
203$nbtotalofrecords = '';
204if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
205 /* The fast and low memory method to get and count full list converts the sql into a sql count */
206 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
207 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
208
209 $resql = $db->query($sqlforcount);
210 if ($resql) {
211 $objforcount = $db->fetch_object($resql);
212 $nbtotalofrecords = $objforcount->nbtotalofrecords;
213 } else {
215 }
216
217 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
218 $page = 0;
219 $offset = 0;
220 }
221 $db->free($resql);
222}
223
224// Complete request and execute it with limit
225$sql .= $db->order($sortfield, $sortorder);
226if ($limit) {
227 $sql .= $db->plimit($limit + 1, $offset);
228}
229
230$resql = $db->query($sql);
231if (!$resql) {
233 exit;
234}
235
236$num = $db->num_rows($resql);
237
238
239// Direct jump if only one record found
240if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
241 $obj = $db->fetch_object($resql);
242 $id = $obj->rowid;
243 header("Location: ".dol_buildpath('/opensurvey/card.php', 1).'?id='.((int) $id));
244 exit;
245}
246
247
248// Output page
249// --------------------------------------------------------------------
250
251llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist');
252
253$arrayofselected = is_array($toselect) ? $toselect : array();
254
255$param = '';
256if (/* !empty($contextpage) && */ $contextpage != $_SERVER["PHP_SELF"]) { // $contextpage can't be empty
257 $param .= '&contextpage='.urlencode($contextpage);
258}
259if ($limit > 0 && $limit != $conf->liste_limit) {
260 $param .= '&limit='.((int) $limit);
261}
262if ($optioncss != '') {
263 $param .= '&optioncss='.urlencode($optioncss);
264}
265$fieldtosortuser = getDolGlobalString('MAIN_FIRSTNAME_NAME_POSITION') ? 'lastname' : 'firstname';
266
267// Add $param from extra fields
268include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
269
270// List of mass actions available
271$arrayofmassactions = array(
272 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
273 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
274);
275if (!empty($permissiontodelete)) {
276 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
277}
278if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
279 $arrayofmassactions = array();
280}
281$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
282
283print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
284if ($optioncss != '') {
285 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
286}
287print '<input type="hidden" name="token" value="'.newToken().'">';
288print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
289print '<input type="hidden" name="action" value="list">';
290print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
291print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
292print '<input type="hidden" name="page" value="'.$page.'">';
293print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
294print '<input type="hidden" name="page_y" value="">';
295print '<input type="hidden" name="mode" value="'.$mode.'">';
296
297$newcardbutton = '';
298$newcardbutton .= dolGetButtonTitle($langs->trans('NewSurvey'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/opensurvey/wizard/index.php', '', $user->hasRight('opensurvey', 'write'));
299
300print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'poll', 0, $newcardbutton, '', $limit, 0, 0, 1);
301
302// Add code for pre mass action (confirmation or email presend form)
303$topicmail = "SendOpenSurveyRef";
304$modelmail = "opensurvey";
305$objecttmp = new Opensurveysondage($db);
306$trackid = 'surv'.$object->id;
307include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
308
309
310if ($search_all) {
311 $setupstring = '';
312 // @phan-suppress-next-line PhanEmptyForeach
313 foreach ($fieldstosearchall as $key => $val) { // @phpstan-ignore-line
314 $fieldstosearchall[$key] = $langs->trans($val);
315 $setupstring .= $key."=".$val.";";
316 }
317 print '<!-- Search done like if OPENSURVEY_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
318 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
319}
320
321$moreforfilter = '';
322/*$moreforfilter.='<div class="divsearchfield">';
323$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
324$moreforfilter.= '</div>';*/
325
326$parameters = array();
327$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
328if (empty($reshook)) {
329 $moreforfilter .= $hookmanager->resPrint;
330} else {
331 $moreforfilter = $hookmanager->resPrint;
332}
333$parameters = array(
334 'arrayfields' => &$arrayfields,
335);
336
337if (!empty($moreforfilter)) {
338 print '<div class="liste_titre liste_titre_bydiv centpercent">';
339 print $moreforfilter;
340 print '</div>';
341}
342
343$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
344$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
345$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
346$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
347
348print '<div class="div-table-responsive">';
349print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
350
351// Fields title search
352// --------------------------------------------------------------------
353print '<tr class="liste_titre_filter">';
354// Action column
355if ($conf->main_checkbox_left_column) {
356 print '<td class="liste_titre center maxwidthsearch">';
357 $searchpicto = $form->showFilterButtons('left');
358 print $searchpicto;
359 print '</td>';
360}
361print '<td class="liste_titre"><input type="text" class="maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
362print '<td class="liste_titre"><input type="text" class="maxwidth100" name="search_title" value="'.dol_escape_htmltag($search_title).'"></td>';
363print '<td class="liste_titre"></td>';
364print '<td class="liste_titre"></td>';
365print '<td class="liste_titre"></td>';
366print '<td class="liste_titre"></td>';
367print '<td class="liste_titre"></td>';
368$arraystatus = array('-1' => '&nbsp;', '0' => $langs->trans("Draft"), '1' => $langs->trans("Opened"), '2' => $langs->trans("Closed"));
369print '<td class="liste_titre center parentonrightofpage">'.$form->selectarray('search_status', $arraystatus, $search_status, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth100 onrightofpage').'</td>';
370// Extra fields
371include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
372
373// Fields from hook
374$parameters = array('arrayfields' => $arrayfields);
375$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
376print $hookmanager->resPrint;
377// Action column
378if (!$conf->main_checkbox_left_column) {
379 print '<td class="liste_titre center maxwidthsearch">';
380 $searchpicto = $form->showFilterButtons();
381 print $searchpicto;
382 print '</td>';
383}
384print '</tr>'."\n";
385
386$totalarray = array();
387$totalarray['nbfield'] = 0;
388
389// Fields title label
390// --------------------------------------------------------------------
391print '<tr class="liste_titre">';
392// Action column
393if ($conf->main_checkbox_left_column) {
394 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
395 $totalarray['nbfield']++;
396}
397print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.id_sondage", "", $param, "", $sortfield, $sortorder);
398$totalarray['nbfield']++;
399print_liste_field_titre("Title", $_SERVER["PHP_SELF"], "p.titre", "", $param, "", $sortfield, $sortorder);
400$totalarray['nbfield']++;
401print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "p.format", "", $param, "", $sortfield, $sortorder);
402$totalarray['nbfield']++;
403print_liste_field_titre("Author", $_SERVER["PHP_SELF"], "u.".$fieldtosortuser, "", $param, "", $sortfield, $sortorder);
404$totalarray['nbfield']++;
405print_liste_field_titre("NbOfVoters", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder);
406$totalarray['nbfield']++;
407print_liste_field_titre("ExpireDate", $_SERVER["PHP_SELF"], "p.date_fin", "", $param, 'align="center"', $sortfield, $sortorder);
408$totalarray['nbfield']++;
409print_liste_field_titre("DateLastModification", $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center"', $sortfield, $sortorder);
410$totalarray['nbfield']++;
411print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "p.status", "", $param, 'align="center"', $sortfield, $sortorder);
412$totalarray['nbfield']++;
413// Extra fields
414include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
415// Hook fields
416$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
417$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
418print $hookmanager->resPrint;
419// Action column
420if (!$conf->main_checkbox_left_column) {
421 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n";
422 $totalarray['nbfield']++;
423}
424print '</tr>'."\n";
425
426$savnbfield = $totalarray['nbfield'];
427
428
429// Loop on record
430// --------------------------------------------------------------------
431$i = 0;
432$totalarray = array();
433$totalarray['nbfield'] = 0;
434$imaxinloop = ($limit ? min($num, $limit) : $num);
435while ($i < $imaxinloop) {
436 $obj = $db->fetch_object($resql);
437 if (empty($obj)) {
438 break; // Should not happen
439 }
440
441 $nbuser = 0;
442 $sql2 = 'select COUNT(*) as nb from '.MAIN_DB_PREFIX."opensurvey_user_studs where id_sondage='".$db->escape($obj->rowid)."'";
443 $resql2 = $db->query($sql2);
444 if ($resql2) {
445 $obj2 = $db->fetch_object($resql2);
446 $nbuser = $obj2->nb;
447 } else {
449 }
450
451 $opensurvey_static->id = $obj->rowid;
452 $opensurvey_static->ref = $obj->rowid;
453 $opensurvey_static->title = $obj->title;
454 $opensurvey_static->status = $obj->status;
455 $opensurvey_static->date_fin = $db->jdate($obj->date_fin);
456
457 // Show here line of result
458 print '<tr data-rowid="'.$opensurvey_static->id.'" class="oddeven row-with-select">';
459 // Action column
460 if ($conf->main_checkbox_left_column) {
461 print '<td class="nowrap center">';
462 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
463 $selected = 0;
464 if (in_array($obj->rowid, $arrayofselected)) {
465 $selected = 1;
466 }
467 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
468 }
469 print '</td>';
470 if (!$i) {
471 $totalarray['nbfield']++;
472 }
473 }
474
475 // Ref
476 print '<td class="tdoverflowmax150">';
477 print $opensurvey_static->getNomUrl(1);
478 print '</td>';
479 if (!$i) {
480 $totalarray['nbfield']++;
481 }
482
483 // Title
484 print '<td class="tdoverflowmax200">'.dol_htmlentities($obj->title).'</td>';
485 if (!$i) {
486 $totalarray['nbfield']++;
487 }
488
489 // Type
490 print '<td class="tdoverflowmax125">';
491 $type = ($obj->format == 'A') ? 'classic' : 'date';
492 print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic' ? 'chart-32.png' : 'calendar-32.png'), 1), 'width="16"', 1);
493 print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate");
494 print '</td>';
495 if (!$i) {
496 $totalarray['nbfield']++;
497 }
498
499 print '<td class="tdoverflowmax125">';
500 // Author
501 if ($obj->fk_user_creat) {
502 $userstatic = new User($db);
503 $userstatic->id = $obj->fk_user_creat;
504 $userstatic->firstname = $obj->firstname;
505 $userstatic->lastname = $obj->lastname;
506 $userstatic->login = $userstatic->getFullName($langs, 0, -1, 48);
507
508 print $userstatic->getLoginUrl(1);
509 } else {
510 print dol_htmlentities($obj->nom_admin);
511 }
512 print '</td>';
513 if (!$i) {
514 $totalarray['nbfield']++;
515 }
516
517 // Nb of voters
518 print'<td class="right">'.$nbuser.'</td>'."\n";
519 if (!$i) {
520 $totalarray['nbfield']++;
521 }
522
523 print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_fin), 'day');
524 if ($db->jdate($obj->date_fin) < $now && $obj->status == Opensurveysondage::STATUS_VALIDATED) {
525 print img_warning($langs->trans("Expired"));
526 }
527 print '</td>';
528 if (!$i) {
529 $totalarray['nbfield']++;
530 }
531
532 print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->tms), 'dayhour');
533 print '</td>';
534 if (!$i) {
535 $totalarray['nbfield']++;
536 }
537
538 print '<td class="center">'.$opensurvey_static->getLibStatut(5).'</td>'."\n";
539 if (!$i) {
540 $totalarray['nbfield']++;
541 }
542
543 // Extra fields
544 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
545 // Fields from hook
546 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
547 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
548 print $hookmanager->resPrint;
549 // Action column
550 if (!$conf->main_checkbox_left_column) {
551 print '<td class="nowrap center">';
552 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
553 $selected = 0;
554 if (in_array($obj->rowid, $arrayofselected)) {
555 $selected = 1;
556 }
557 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
558 }
559 print '</td>';
560 if (!$i) {
561 $totalarray['nbfield']++;
562 }
563 }
564
565 print '</tr>'."\n";
566 $i++;
567}
568
569// Show total line
570include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
571
572
573// If no record found
574if ($num == 0) {
575 $colspan = $savnbfield;
576 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
577}
578
579
580$db->free($resql);
581
582$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
583$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
584print $hookmanager->resPrint;
585
586print '</table>'."\n";
587print '</div>'."\n";
588
589print '</form>'."\n";
590
591if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
592 $hidegeneratedfilelistifempty = 1;
593 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
594 $hidegeneratedfilelistifempty = 0;
595 }
596
597 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
598 $formfile = new FormFile($db);
599
600 // Show list of available documents
601 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
602 $urlsource .= str_replace('&amp;', '&', $param);
603
604 $filedir = $diroutputmassaction;
605 $genallowed = $permissiontoread;
606 $delallowed = $permissiontoadd;
607
608 print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
609}
610
611// End of page
612llxFooter();
613$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:497
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage standard extra fields.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Put here description of your class.
const STATUS_VALIDATED
Validated/Opened status.
Class to manage Dolibarr users.
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_now($mode='gmt')
Return date for now.
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)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get 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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.