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