dolibarr  17.0.4
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  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
25 // Load Dolibarr environment
26 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
28 require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
29 require_once DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php";
30 
31 // Load translation files required by the page
32 $langs->load("opensurvey");
33 
34 $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
35 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
36 $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
37 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
38 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
39 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
40 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'opensurveylist'; // To manage different context of search
41 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
42 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
43 $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
44 
45 $id = GETPOST('id', 'alpha');
46 $search_ref = GETPOST('search_ref', 'alpha');
47 $search_title = GETPOST('search_title', 'alpha');
48 $search_status = GETPOST('search_status', 'alpha');
49 
50 // Load variable for pagination
51 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
52 $sortfield = GETPOST('sortfield', 'aZ09comma');
53 $sortorder = GETPOST('sortorder', 'aZ09comma');
54 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
55 if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
56  $page = 0;
57 } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
58 $offset = $limit * $page;
59 $pageprev = $page - 1;
60 $pagenext = $page + 1;
61 
62 // Initialize technical objects
63 $object = new Opensurveysondage($db);
64 $opensurvey_static = new Opensurveysondage($db);
65 
66 $extrafields = new ExtraFields($db);
67 $diroutputmassaction = $conf->opensurvey->dir_output.'/temp/massgeneration/'.$user->id;
68 $hookmanager->initHooks(array('surveylist')); // Note that conf->hooks_modules contains array
69 // Fetch optionals attributes and labels
70 $extrafields->fetch_name_optionals_label($object->table_element);
71 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
72 
73 // Default sort order (if not yet defined by previous GETPOST)
74 if (!$sortfield) {
75  $sortfield = "p.date_fin";
76 }
77 if (!$sortorder) {
78  $sortorder = "DESC";
79 }
80 
81 // Security check
82 if (!$user->rights->opensurvey->read) {
84 }
85 
86 // Definition of fields for list
87 $arrayfields = array();
88 foreach ($arrayfields as $key => $val) {
89  // If $val['visible']==0, then we never show the field
90  if (!empty($val['visible'])) {
91  $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
92  }
93 }
94 // Extra fields
95 if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
96  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
97  if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
98  $arrayfields["ef.".$key] = array(
99  'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
100  'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1),
101  'position'=>$extrafields->attributes[$object->table_element]['pos'][$key],
102  'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])
103  );
104  }
105  }
106 }
107 $object->fields = dol_sort_array($object->fields, 'position');
108 $arrayfields = dol_sort_array($arrayfields, 'position');
109 
110 $permissiontoread = $user->rights->opensurvey->read;
111 $permissiontoadd = $user->rights->opensurvey->write;
112 // permission delete doesn't exists
113 $permissiontodelete = $user->rights->opensurvey->write;
114 
115 
116 /*
117  * Actions
118  */
119 
120 if (GETPOST('cancel', 'alpha')) {
121  $action = 'list'; $massaction = '';
122 }
123 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
124  $massaction = '';
125 }
126 
127 $parameters = array();
128 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
129 if ($reshook < 0) {
130  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
131 }
132 
133 if (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 
171 $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,";
172 $sql .= " u.login, u.firstname, u.lastname";
173 $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p";
174 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat";
175 $sql .= " WHERE p.entity IN (".getEntity('survey').")";
176 if ($search_status != '-1' && $search_status != '') {
177  $sql .= natural_search("p.status", $search_status, 2);
178 }
179 if (!empty($search_expired) && $search_expired == 'expired') {
180  $sql .= " AND p.date_fin < '".$db->idate($now)."'";
181 }
182 if (!empty($search_expired) && $search_expired == 'opened') {
183  $sql .= " AND p.date_fin >= '".$db->idate($now)."'";
184 }
185 if (!empty($search_ref)) {
186  $sql .= natural_search("p.id_sondage", $search_ref);
187 }
188 if (!empty($search_title)) {
189  $sql .= natural_search("p.titre", $search_title);
190 }
191 // Add where from extra fields
192 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
193 // Add where from hooks
194 $parameters = array();
195 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
196 $sql .= $hookmanager->resPrint;
197 
198 $sql .= $db->order($sortfield, $sortorder);
199 
200 // Count total nb of records
201 $nbtotalofrecords = '';
202 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
203  $resql = $db->query($sql);
204  $nbtotalofrecords = $db->num_rows($resql);
205  if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
206  $page = 0;
207  $offset = 0;
208  }
209 }
210 // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
211 if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
212  $num = $nbtotalofrecords;
213 } else {
214  $sql .= $db->plimit($limit + 1, $offset);
215 
216  $resql = $db->query($sql);
217  if (!$resql) {
218  dol_print_error($db);
219  exit;
220  }
221 
222  $num = $db->num_rows($resql);
223 }
224 
225 // Direct jump if only one record found
226 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) {
227  $obj = $db->fetch_object($resql);
228  $id = $obj->rowid;
229  header("Location: ".dol_buildpath('/opensurvey/card.php', 1).'?id='.$id);
230  exit;
231 }
232 
233 
234 // Output page
235 // --------------------------------------------------------------------
236 
237 llxHeader('', $title, $help_url);
238 
239 $arrayofselected = is_array($toselect) ? $toselect : array();
240 
241 $param = '';
242 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
243  $param .= '&contextpage='.urlencode($contextpage);
244 }
245 if ($limit > 0 && $limit != $conf->liste_limit) {
246  $param .= '&limit='.urlencode($limit);
247 }
248 $fieldtosortuser = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 'firstname' : 'lastname';
249 
250 if ($optioncss != '') {
251  $param .= '&optioncss='.urlencode($optioncss);
252 }
253 // Add $param from extra fields
254 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
255 
256 // List of mass actions available
257 $arrayofmassactions = array(
258  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
259  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
260 );
261 if ($permissiontodelete) {
262  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
263 }
264 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
265  $arrayofmassactions = array();
266 }
267 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
268 
269 
270 // List of surveys into database
271 
272 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
273 if ($optioncss != '') {
274  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
275 }
276 print '<input type="hidden" name="token" value="'.newToken().'">';
277 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
278 print '<input type="hidden" name="action" value="list">';
279 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
280 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
281 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
282 
283 $newcardbutton = dolGetButtonTitle($langs->trans('NewSurvey'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/opensurvey/wizard/index.php', '', $user->rights->opensurvey->write);
284 
285 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'poll', 0, $newcardbutton, '', $limit, 0, 0, 1);
286 
287 // Add code for pre mass action (confirmation or email presend form)
288 $topicmail = "SendOpenSurveyRef";
289 $modelmail = "opensurvey";
290 $objecttmp = new Opensurveysondage($db);
291 $trackid = 'surv'.$object->id;
292 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
293 
294 if ($sall) {
295  foreach ($fieldstosearchall as $key => $val) {
296  $fieldstosearchall[$key] = $langs->trans($val);
297  }
298  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
299 }
300 
301 $moreforfilter = '';
302 /*$moreforfilter.='<div class="divsearchfield">';
303 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
304 $moreforfilter.= '</div>';*/
305 
306 $parameters = array();
307 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
308 if (empty($reshook)) {
309  $moreforfilter .= $hookmanager->resPrint;
310 } else {
311  $moreforfilter = $hookmanager->resPrint;
312 }
313 
314 if (!empty($moreforfilter)) {
315  print '<div class="liste_titre liste_titre_bydiv centpercent">';
316  print $moreforfilter;
317  print '</div>';
318 }
319 
320 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
321 //$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
322 $selectedfields = '';
323 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
324 
325 print '<div class="div-table-responsive">';
326 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
327 
328 // Fields title search
329 // --------------------------------------------------------------------
330 print '<tr class="liste_titre_filter">';
331 // Action column
332 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
333  print '<td class="liste_titre maxwidthsearch">';
334  $searchpicto = $form->showFilterButtons('left');
335  print $searchpicto;
336  print '</td>';
337 }
338 print '<td class="liste_titre"><input type="text" class="maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
339 print '<td class="liste_titre"><input type="text" class="maxwidth100onsmartphone" name="search_title" value="'.dol_escape_htmltag($search_title).'"></td>';
340 print '<td class="liste_titre"></td>';
341 print '<td class="liste_titre"></td>';
342 print '<td class="liste_titre"></td>';
343 print '<td class="liste_titre"></td>';
344 print '<td class="liste_titre"></td>';
345 $arraystatus = array('-1'=>'&nbsp;', '0'=>$langs->trans("Draft"), '1'=>$langs->trans("Opened"), '2'=>$langs->trans("Closed"));
346 print '<td class="liste_titre" align="center">'.$form->selectarray('search_status', $arraystatus, $search_status, 0, 0, 0, '', 0, 0, 0, '', 'onroghtofpage').'</td>';
347 // Extra fields
348 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
349 
350 // Fields from hook
351 $parameters = array('arrayfields'=>$arrayfields);
352 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
353 print $hookmanager->resPrint;
354 // Action column
355 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
356  print '<td class="liste_titre maxwidthsearch">';
357  $searchpicto = $form->showFilterButtons();
358  print $searchpicto;
359  print '</td>';
360 }
361 print '</tr>'."\n";
362 
363 
364 // Fields title label
365 // --------------------------------------------------------------------
366 print '<tr class="liste_titre">';
367 // Action column
368 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
369  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n";
370 }
371 print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.id_sondage", $param, "", "", $sortfield, $sortorder);
372 print_liste_field_titre("Title", $_SERVER["PHP_SELF"], "p.titre", $param, "", "", $sortfield, $sortorder);
373 print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "p.format", $param, "", "", $sortfield, $sortorder);
374 print_liste_field_titre("Author", $_SERVER["PHP_SELF"], "u.".$fieldtosortuser, $param, "", "", $sortfield, $sortorder);
375 print_liste_field_titre("NbOfVoters", $_SERVER["PHP_SELF"], "", $param, "", 'align="right"', $sortfield, $sortorder);
376 print_liste_field_titre("ExpireDate", $_SERVER["PHP_SELF"], "p.date_fin", $param, "", 'align="center"', $sortfield, $sortorder);
377 print_liste_field_titre("DateLastModification", $_SERVER["PHP_SELF"], "p.tms", $param, "", 'align="center"', $sortfield, $sortorder);
378 print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "p.status", $param, "", 'align="center"', $sortfield, $sortorder);
379 // Extra fields
380 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
381 // Hook fields
382 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
383 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
384 print $hookmanager->resPrint;
385 // Action column
386 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
387  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n";
388 }
389 print '</tr>'."\n";
390 
391 
392 
393 // Loop on record
394 // --------------------------------------------------------------------
395 $i = 0;
396 $totalarray = array();
397 $totalarray['nbfield'] = 0;
398 while ($i < min($num, $limit)) {
399  $obj = $db->fetch_object($resql);
400  if (empty($obj)) {
401  break; // Should not happen
402  }
403 
404  $sql2 = 'select COUNT(*) as nb from '.MAIN_DB_PREFIX."opensurvey_user_studs where id_sondage='".$db->escape($obj->rowid)."'";
405  $resql2 = $db->query($sql2);
406  if ($resql2) {
407  $obj2 = $db->fetch_object($resql2);
408  $nbuser = $obj2->nb;
409  } else {
410  dol_print_error($db);
411  }
412 
413  $opensurvey_static->id = $obj->rowid;
414  $opensurvey_static->ref = $obj->rowid;
415  $opensurvey_static->title = $obj->title;
416  $opensurvey_static->status = $obj->status;
417  $opensurvey_static->date_fin = $db->jdate($obj->date_fin);
418 
419  // Show here line of result
420  print '<tr class="oddeven">';
421  // Action column
422  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
423  print '<td class="nowrap center">';
424  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
425  $selected = 0;
426  if (in_array($obj->rowid, $arrayofselected)) {
427  $selected = 1;
428  }
429  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
430  }
431  print '</td>';
432  }
433  // Ref
434  print '<td>';
435  print $opensurvey_static->getNomUrl(1);
436  print '</td>';
437  if (!$i) {
438  $totalarray['nbfield']++;
439  }
440 
441  // Title
442  print '<td>'.dol_htmlentities($obj->title).'</td>';
443  if (!$i) {
444  $totalarray['nbfield']++;
445  }
446 
447  // Type
448  print '<td>';
449  $type = ($obj->format == 'A') ? 'classic' : 'date';
450  print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic' ? 'chart-32.png' : 'calendar-32.png'), 1), 'width="16"', 1);
451  print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate");
452  print '</td>';
453  if (!$i) {
454  $totalarray['nbfield']++;
455  }
456 
457  print '<td>';
458  // Author
459  if ($obj->fk_user_creat) {
460  $userstatic = new User($db);
461  $userstatic->id = $obj->fk_user_creat;
462  $userstatic->firstname = $obj->firstname;
463  $userstatic->lastname = $obj->lastname;
464  $userstatic->login = $userstatic->getFullName($langs, 0, -1, 48);
465 
466  print $userstatic->getLoginUrl(1);
467  } else {
468  print dol_htmlentities($obj->nom_admin);
469  }
470  print '</td>';
471  if (!$i) {
472  $totalarray['nbfield']++;
473  }
474 
475  // Nb of voters
476  print'<td class="right">'.$nbuser.'</td>'."\n";
477  if (!$i) {
478  $totalarray['nbfield']++;
479  }
480 
481  print '<td class="center">'.dol_print_date($db->jdate($obj->date_fin), 'day');
482  if ($db->jdate($obj->date_fin) < $now && $obj->status == Opensurveysondage::STATUS_VALIDATED) {
483  print img_warning($langs->trans("Expired"));
484  }
485  print '</td>';
486  if (!$i) {
487  $totalarray['nbfield']++;
488  }
489 
490  print '<td class="center">'.dol_print_date($db->jdate($obj->tms), 'dayhour');
491  print '</td>';
492  if (!$i) {
493  $totalarray['nbfield']++;
494  }
495 
496  print '<td class="center">'.$opensurvey_static->getLibStatut(5).'</td>'."\n";
497  if (!$i) {
498  $totalarray['nbfield']++;
499  }
500 
501  // Extra fields
502  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
503  // Fields from hook
504  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
505  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
506  print $hookmanager->resPrint;
507  // Action column
508  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
509  print '<td class="nowrap center">';
510  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
511  $selected = 0;
512  if (in_array($obj->rowid, $arrayofselected)) {
513  $selected = 1;
514  }
515  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
516  }
517  print '</td>';
518  }
519  if (!$i) {
520  $totalarray['nbfield']++;
521  }
522 
523  print '</tr>'."\n";
524  $i++;
525 }
526 
527 // Show total line
528 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
529 
530 
531 // If no record found
532 if ($num == 0) {
533  $colspan = 8;
534  foreach ($arrayfields as $key => $val) {
535  if (!empty($val['checked'])) {
536  $colspan++;
537  }
538  }
539  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
540 }
541 
542 
543 $db->free($resql);
544 
545 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
546 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
547 print $hookmanager->resPrint;
548 
549 print '</table>'."\n";
550 print '</div>'."\n";
551 
552 print '</form>'."\n";
553 
554 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
555  $hidegeneratedfilelistifempty = 1;
556  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
557  $hidegeneratedfilelistifempty = 0;
558  }
559 
560  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
561  $formfile = new FormFile($db);
562 
563  // Show list of available documents
564  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
565  $urlsource .= str_replace('&amp;', '&', $param);
566 
567  $filedir = $diroutputmassaction;
568  $genallowed = $permissiontoread;
569  $delallowed = $permissiontoadd;
570 
571  print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
572 }
573 
574 // End of page
575 llxFooter();
576 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
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.
Definition: user.class.php:47
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.
print_barre_liste($titre, $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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
$nbtotalofrecords
Count total nb of records.
Definition: list.php:329
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.