dolibarr  16.0.5
emailcollector_list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
24 require '../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
26 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
28 
29 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
32 
33 dol_include_once('/emailcollector/class/emailcollector.class.php');
34 
35 // Load translation files required by page
36 $langs->loadLangs(array("admin", "other"));
37 
38 $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
39 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
40 $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
41 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
42 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
43 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
44 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'emailcollectorlist'; // To manage different context of search
45 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
46 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
47 $mode = GETPOST('mode', 'aZ');
48 
49 $id = GETPOST('id', 'int');
50 
51 // Load variable for pagination
52 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
53 $sortfield = GETPOST('sortfield', 'aZ09comma');
54 $sortorder = GETPOST('sortorder', 'aZ09comma');
55 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
56 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '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  $page = 0;
59 }
60 $offset = $limit * $page;
61 $pageprev = $page - 1;
62 $pagenext = $page + 1;
63 //if (! $sortfield) $sortfield="p.date_fin";
64 //if (! $sortorder) $sortorder="DESC";
65 
66 // Initialize technical objects
67 $object = new EmailCollector($db);
68 $extrafields = new ExtraFields($db);
69 $diroutputmassaction = $conf->emailcollector->dir_output.'/temp/massgeneration/'.$user->id;
70 $hookmanager->initHooks(array('emailcollectorlist')); // Note that conf->hooks_modules contains array
71 
72 // Fetch optionals attributes and labels
73 $extrafields->fetch_name_optionals_label($object->table_element);
74 
75 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
76 
77 // Default sort order (if not yet defined by previous GETPOST)
78 if (!$sortfield) {
79  $sortfield = "t.ref"; // Set here default search field. By default 1st field in definition.
80 }
81 if (!$sortorder) {
82  $sortorder = "ASC";
83 }
84 
85 // Security check
86 $socid = 0;
87 if ($user->socid > 0) { // Protection if external user
88  //$socid = $user->socid;
90 }
91 //$result = restrictedArea($user, 'emailcollector', $id, '');
92 
93 // Initialize array of search criterias
94 $search_all = GETPOST('search_all', 'alphanohtml');
95 $search = array();
96 foreach ($object->fields as $key => $val) {
97  if (GETPOST('search_'.$key, 'alpha') !== '') {
98  $search[$key] = GETPOST('search_'.$key, 'alpha');
99  }
100  if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
101  $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
102  $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
103  }
104 }
105 
106 // List of fields to search into when doing a "search in all"
107 $fieldstosearchall = array();
108 foreach ($object->fields as $key => $val) {
109  if (!empty($val['searchall'])) {
110  $fieldstosearchall['t.'.$key] = $val['label'];
111  }
112 }
113 
114 // Definition of array of fields for columns
115 $arrayfields = array();
116 foreach ($object->fields as $key => $val) {
117  // If $val['visible']==0, then we never show the field
118  if (!empty($val['visible'])) {
119  $visible = (int) dol_eval($val['visible'], 1);
120  $arrayfields['t.'.$key] = array(
121  'label'=>$val['label'],
122  'checked'=>(($visible < 0) ? 0 : 1),
123  'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)),
124  'position'=>$val['position'],
125  'help'=> isset($val['help']) ? $val['help'] : ''
126  );
127  }
128 }
129 // Extra fields
130 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
131 
132 $object->fields = dol_sort_array($object->fields, 'position');
133 $arrayfields = dol_sort_array($arrayfields, 'position');
134 
135 /*$permissiontoread = $user->rights->emailcollector->read;
136 $permissiontoadd = $user->rights->emailcollector->write;
137 $permissiontodelete = $user->rights->emailcollector->delete;*/
138 $permissiontoread = $user->admin;
139 $permissiontoadd = $user->admin;
140 $permissiontodelete = $user->admin;
141 
142 if (!$user->admin) {
143  accessforbidden();
144 }
145 if (empty($conf->emailcollector->enabled)) {
146  accessforbidden('Module not enabled');
147 }
148 
149 
150 
151 /*
152  * Actions
153  */
154 
155 if (GETPOST('cancel', 'alpha')) {
156  $action = 'list';
157  $massaction = '';
158 }
159 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
160  $massaction = '';
161 }
162 
163 $parameters = array();
164 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
165 if ($reshook < 0) {
166  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
167 }
168 
169 if (empty($reshook)) {
170  // Selection of new fields
171  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
172 
173  // Purge search criteria
174  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
175  foreach ($object->fields as $key => $val) {
176  $search[$key] = '';
177  if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
178  $search[$key.'_dtstart'] = '';
179  $search[$key.'_dtend'] = '';
180  }
181  }
182  $toselect = array();
183  $search_array_options = array();
184  }
185  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
186  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
187  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
188  }
189 
190  // Mass actions
191  $objectclass = 'EmailCollector';
192  $objectlabel = 'EmailCollector';
193  $uploaddir = $conf->emailcollector->dir_output;
194  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
195 }
196 
197 
198 
199 /*
200  * View
201  */
202 
203 $form = new Form($db);
204 
205 $now = dol_now();
206 
207 $help_url = "EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector";
208 $title = $langs->trans('EmailCollectors');
209 $morejs = array();
210 $morecss = array();
211 
212 
213 // Build and execute select
214 // --------------------------------------------------------------------
215 $sql = 'SELECT ';
216 $sql .= $object->getFieldList('t');
217 // Add fields from extrafields
218 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
219  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
220  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
221  }
222 }
223 // Add fields from hooks
224 $parameters = array();
225 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
226 $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
227 $sql = preg_replace('/,\s*$/', '', $sql);
228 $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
229 if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
230  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
231 }
232 if ($object->ismultientitymanaged == 1) {
233  $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
234 } else {
235  $sql .= " WHERE 1 = 1";
236 }
237 foreach ($search as $key => $val) {
238  if (array_key_exists($key, $object->fields)) {
239  if ($key == 'status' && $search[$key] == -1) {
240  continue;
241  }
242  $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
243  if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
244  if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
245  $search[$key] = '';
246  }
247  $mode_search = 2;
248  }
249  if ($search[$key] != '') {
250  $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
251  }
252  } else {
253  if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
254  $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
255  if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
256  if (preg_match('/_dtstart$/', $key)) {
257  $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'";
258  }
259  if (preg_match('/_dtend$/', $key)) {
260  $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'";
261  }
262  }
263  }
264  }
265 }
266 if ($search_all) {
267  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
268 }
269 // Add where from extra fields
270 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
271 // Add where from hooks
272 $parameters = array();
273 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
274 $sql .= $hookmanager->resPrint;
275 
276 /* If a group by is required
277 $sql.= " GROUP BY ";
278 foreach ($object->fields as $key => $val) {
279  $sql .= "t.".$db->escape($key).", ";
280 }
281 // Add fields from extrafields
282 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
283  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
284  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
285  }
286 }
287 // Add where from hooks
288 $parameters=array();
289 $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
290 $sql .= $hookmanager->resPrint;
291 $sql = preg_replace('/,\s*$/', '', $sql);
292 */
293 
294 // Count total nb of records
295 $nbtotalofrecords = '';
296 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
297  $resql = $db->query($sql);
298  $nbtotalofrecords = $db->num_rows($resql);
299 
300  if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
301  $page = 0;
302  $offset = 0;
303  }
304 
305  $db->free($resql);
306 }
307 // Complete request and execute it with limit
308 $sql .= $db->order($sortfield, $sortorder);
309 if ($limit) {
310  $sql .= $db->plimit($limit + 1, $offset);
311 }
312 
313 $resql = $db->query($sql);
314 if (!$resql) {
315  dol_print_error($db);
316  exit;
317 }
318 
319 $num = $db->num_rows($resql);
320 
321 // Direct jump if only one record found
322 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
323  $obj = $db->fetch_object($resql);
324  $id = $obj->rowid;
325  header("Location: ".DOL_URL_ROOT.'/emailcollector/emailcollector_card.php?id='.$id);
326  exit;
327 }
328 
329 
330 // Output page
331 // --------------------------------------------------------------------
332 
333 llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
334 
335 $arrayofselected = is_array($toselect) ? $toselect : array();
336 
337 $param = '';
338 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
339  $param .= '&contextpage='.urlencode($contextpage);
340 }
341 if ($limit > 0 && $limit != $conf->liste_limit) {
342  $param .= '&limit='.urlencode($limit);
343 }
344 foreach ($search as $key => $val) {
345  if (is_array($search[$key]) && count($search[$key])) {
346  foreach ($search[$key] as $skey) {
347  if ($skey != '') {
348  $param .= '&search_'.$key.'[]='.urlencode($skey);
349  }
350  }
351  } elseif ($search[$key] != '') {
352  $param .= '&search_'.$key.'='.urlencode($search[$key]);
353  }
354 }
355 if ($optioncss != '') {
356  $param .= '&optioncss='.urlencode($optioncss);
357 }
358 // Add $param from extra fields
359 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
360 // Add $param from hooks
361 $parameters = array();
362 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
363 $param .= $hookmanager->resPrint;
364 
365 // List of mass actions available
366 $arrayofmassactions = array(
367  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
368  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
369 );
370 if ($permissiontodelete) {
371  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
372 }
373 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
374  $arrayofmassactions = array();
375 }
376 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
377 
378 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
379 if ($optioncss != '') {
380  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
381 }
382 print '<input type="hidden" name="token" value="'.newToken().'">';
383 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
384 print '<input type="hidden" name="action" value="list">';
385 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
386 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
387 print '<input type="hidden" name="page" value="'.$page.'">';
388 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
389 
390 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
391 
392 $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', 'emailcollector_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
393 
394 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'email', 0, $newcardbutton.' '.$linkback, '', $limit, 0, 0, 1);
395 
396 // Add code for pre mass action (confirmation or email presend form)
397 /*$topicmail="";
398 $modelmail="";
399 $objecttmp=new EmailCollector($db);
400 $trackid='xxxx'.$object->id;*/
401 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
402 
403 $moreforfilter = '';
404 /*$moreforfilter.='<div class="divsearchfield">';
405 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
406 $moreforfilter.= '</div>';*/
407 
408 $parameters = array();
409 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
410 if (empty($reshook)) {
411  $moreforfilter .= $hookmanager->resPrint;
412 } else {
413  $moreforfilter = $hookmanager->resPrint;
414 }
415 
416 if (!empty($moreforfilter)) {
417  print '<div class="liste_titre liste_titre_bydiv centpercent">';
418  print $moreforfilter;
419  print '</div>';
420 }
421 
422 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
423 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
424 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
425 
426 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
427 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
428 
429 
430 // Fields title search
431 // --------------------------------------------------------------------
432 print '<tr class="liste_titre">';
433 // Action column
434 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
435  print '<td class="liste_titre maxwidthsearch">';
436  $searchpicto = $form->showFilterButtons('left');
437  print $searchpicto;
438  print '</td>';
439 }
440 foreach ($object->fields as $key => $val) {
441  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
442  if ($key == 'status') {
443  $cssforfield .= ($cssforfield ? ' ' : '').'center';
444  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
445  $cssforfield .= ($cssforfield ? ' ' : '').'center';
446  } elseif (in_array($val['type'], array('timestamp'))) {
447  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
448  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
449  $cssforfield .= ($cssforfield ? ' ' : '').'right';
450  }
451  if (!empty($arrayfields['t.'.$key]['checked'])) {
452  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
453  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
454  print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
455  } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
456  print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1);
457  } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
458  print '<div class="nowrap">';
459  print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
460  print '</div>';
461  print '<div class="nowrap">';
462  print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
463  print '</div>';
464  } elseif ($key == 'lang') {
465  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
466  $formadmin = new FormAdmin($db);
467  print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
468  } else {
469  print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
470  }
471  print '</td>';
472  }
473 }
474 // Extra fields
475 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
476 
477 // Fields from hook
478 $parameters = array('arrayfields'=>$arrayfields);
479 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
480 print $hookmanager->resPrint;
481 // Action column
482 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
483  print '<td class="liste_titre maxwidthsearch">';
484  $searchpicto = $form->showFilterButtons();
485  print $searchpicto;
486  print '</td>';
487 }
488 print '</tr>'."\n";
489 
490 $totalarray = array();
491 $totalarray['nbfield'] = 0;
492 
493 // Fields title label
494 // --------------------------------------------------------------------
495 print '<tr class="liste_titre">';
496 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
497  print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
498 }
499 foreach ($object->fields as $key => $val) {
500  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
501  if ($key == 'status') {
502  $cssforfield .= ($cssforfield ? ' ' : '').'center';
503  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
504  $cssforfield .= ($cssforfield ? ' ' : '').'center';
505  } elseif (in_array($val['type'], array('timestamp'))) {
506  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
507  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
508  $cssforfield .= ($cssforfield ? ' ' : '').'right';
509  }
510  $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
511  if (!empty($arrayfields['t.'.$key]['checked'])) {
512  print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
513  $totalarray['nbfield']++;
514  }
515 }
516 // Extra fields
517 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
518 // Hook fields
519 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
520 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
521 print $hookmanager->resPrint;
522 // Action column
523 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
524  print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
525 }
526 $totalarray['nbfield']++;
527 print '</tr>'."\n";
528 
529 
530 // Detect if we need a fetch on each output line
531 $needToFetchEachLine = 0;
532 if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
533  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
534  if (preg_match('/\$object/', $val)) {
535  $needToFetchEachLine++; // There is at least one compute field that use $object
536  }
537  }
538 }
539 
540 
541 // Loop on record
542 // --------------------------------------------------------------------
543 $i = 0;
544 $savnbfield = $totalarray['nbfield'];
545 $totalarray['nbfield'] = 0;
546 $imaxinloop = ($limit ? min($num, $limit) : $num);
547 while ($i < $imaxinloop) {
548  $obj = $db->fetch_object($resql);
549  if (empty($obj)) {
550  break; // Should not happen
551  }
552 
553  // Store properties in $object
554  $object->setVarsFromFetchObj($obj);
555 
556  if ($mode == 'kanban') {
557  if ($i == 0) {
558  print '<tr><td colspan="'.$savnbfield.'">';
559  print '<div class="box-flex-container">';
560  }
561  // Output Kanban
562  print $object->getKanbanView('');
563  if ($i == ($imaxinloop - 1)) {
564  print '</div>';
565  print '</td></tr>';
566  }
567  } else {
568  // Show here line of result
569  $j = 0;
570  print '<tr data-rowid="'.$object->id.'" class="oddeven">';
571  // Action column
572  if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
573  print '<td class="nowrap center">';
574  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
575  $selected = 0;
576  if (in_array($object->id, $arrayofselected)) {
577  $selected = 1;
578  }
579  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
580  }
581  print '</td>';
582  }
583  foreach ($object->fields as $key => $val) {
584  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
585  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
586  $cssforfield .= ($cssforfield ? ' ' : '').'center';
587  } elseif ($key == 'status') {
588  $cssforfield .= ($cssforfield ? ' ' : '').'center';
589  }
590 
591  if (in_array($val['type'], array('timestamp'))) {
592  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
593  } elseif ($key == 'ref') {
594  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
595  }
596 
597  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
598  $cssforfield .= ($cssforfield ? ' ' : '').'right';
599  }
600  //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
601 
602  if (!empty($arrayfields['t.'.$key]['checked'])) {
603  print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '');
604  if (preg_match('/tdoverflow/', $cssforfield)) {
605  print ' title="'.dol_escape_htmltag($object->$key).'"';
606  }
607  print '>';
608  if ($key == 'status') {
609  print $object->getLibStatut(5);
610  } elseif ($key == 'rowid') {
611  print $object->showOutputField($val, $key, $object->id, '');
612  } else {
613  print $object->showOutputField($val, $key, $object->$key, '');
614  }
615  print '</td>';
616  if (!$i) {
617  $totalarray['nbfield']++;
618  }
619  if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
620  if (!$i) {
621  $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
622  }
623  if (!isset($totalarray['val'])) {
624  $totalarray['val'] = array();
625  }
626  if (!isset($totalarray['val']['t.'.$key])) {
627  $totalarray['val']['t.'.$key] = 0;
628  }
629  $totalarray['val']['t.'.$key] += $object->$key;
630  }
631  }
632  }
633  // Extra fields
634  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
635  // Fields from hook
636  $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
637  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
638  print $hookmanager->resPrint;
639  // Action column
640  if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
641  print '<td class="nowrap center">';
642  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
643  $selected = 0;
644  if (in_array($object->id, $arrayofselected)) {
645  $selected = 1;
646  }
647  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
648  }
649  print '</td>';
650  }
651  if (!$i) {
652  $totalarray['nbfield']++;
653  }
654 
655  print '</tr>'."\n";
656  }
657 
658  $i++;
659 }
660 
661 // Show total line
662 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
663 
664 
665 // If no record found
666 if ($num == 0) {
667  $colspan = 1;
668  foreach ($arrayfields as $key => $val) {
669  if (!empty($val['checked'])) {
670  $colspan++;
671  }
672  }
673  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
674 }
675 
676 
677 $db->free($resql);
678 
679 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
680 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
681 print $hookmanager->resPrint;
682 
683 print '</table>'."\n";
684 print '</div>'."\n";
685 
686 print load_fiche_titre($langs->trans("Other"), '', '');
687 
688 
689 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
690 print '<table class="noborder centpercent">';
691 
692 print '<tr class="liste_titre">';
693 print '<td>'.$langs->trans("Parameter").'</td>';
694 print '<td></td>';
695 print "</tr>\n";
696 
697 // Hide e-mail headers from collected messages
698 print '<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans("EmailCollectorHideMailHeaders"), $langs->transnoentitiesnoconv("EmailCollectorHideMailHeadersHelp")).'</td>';
699 print '<td class="left">';
700 if ($conf->use_javascript_ajax) {
701  print ajax_constantonoff('MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER');
702 } else {
703  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
704  print $form->selectarray("MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER", $arrval, $conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND);
705 }
706 print '</td>';
707 print '</tr>';
708 
709 print '</table>';
710 print '</div>';
711 
712 print '<br>';
713 
714 print '</form>'."\n";
715 
716 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
717  $hidegeneratedfilelistifempty = 1;
718  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
719  $hidegeneratedfilelistifempty = 0;
720  }
721 
722  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
723  $formfile = new FormFile($db);
724 
725  // Show list of available documents
726  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
727  $urlsource .= str_replace('&amp;', '&', $param);
728 
729  $filedir = $diroutputmassaction;
730  $genallowed = $permissiontoread;
731  $delallowed = $permissiontoadd;
732 
733  print $formfile->showdocuments('massfilesarea_emailcollector', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
734 }
735 
736 // End of page
737 llxFooter();
738 $db->close();
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
getTitleFieldOfList
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
Definition: functions.lib.php:5049
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
dol_sort_array
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...
Definition: functions.lib.php:8385
dol_include_once
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
Definition: functions.lib.php:1033
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormAdmin
Class to generate html code for admin pages.
Definition: html.formadmin.class.php:30
$help_url
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:116
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
dolGetButtonTitle
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.
Definition: functions.lib.php:10605
print_barre_liste
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.
Definition: functions.lib.php:5257
ajax_constantonoff
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='')
On/off button for constant.
Definition: ajax.lib.php:573
getDolGlobalString
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:80
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
EmailCollector
Class for EmailCollector.
Definition: emailcollector.class.php:49
natural_search
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...
Definition: functions.lib.php:9420
dol_eval
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
Definition: functions.lib.php:8611
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->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->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
dol_mktime
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Definition: functions.lib.php:2757
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59