dolibarr  19.0.0-dev
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 .= $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 // Count total nb of records
277 $nbtotalofrecords = '';
278 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
279  $resql = $db->query($sql);
280  $nbtotalofrecords = $db->num_rows($resql);
281 
282  if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
283  $page = 0;
284  $offset = 0;
285  }
286 
287  $db->free($resql);
288 }
289 // Complete request and execute it with limit
290 $sql .= $db->order($sortfield, $sortorder);
291 if ($limit) {
292  $sql .= $db->plimit($limit + 1, $offset);
293 }
294 
295 $resql = $db->query($sql);
296 if (!$resql) {
297  dol_print_error($db);
298  exit;
299 }
300 
301 $num = $db->num_rows($resql);
302 
303 // Direct jump if only one record found
304 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
305  $obj = $db->fetch_object($resql);
306  $id = $obj->rowid;
307  header("Location: ".DOL_URL_ROOT.'/emailcollector/emailcollector_card.php?id='.$id);
308  exit;
309 }
310 
311 
312 // Output page
313 // --------------------------------------------------------------------
314 
315 llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
316 
317 
318 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
319 print load_fiche_titre($title, $linkback, 'title_setup');
320 
321 
322 $head = array();
323 $h = 0;
324 $head[$h][0] = DOL_URL_ROOT."/admin/emailcollector_list.php";
325 $head[$h][1] = $langs->trans("Setup");
326 $head[$h][2] = 'common';
327 $h++;
328 
329 print dol_get_fiche_head($head, 'common', '', -1);
330 
331 
332 
333 $arrayofselected = is_array($toselect) ? $toselect : array();
334 
335 $param = '';
336 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
337  $param .= '&contextpage='.urlencode($contextpage);
338 }
339 if ($limit > 0 && $limit != $conf->liste_limit) {
340  $param .= '&limit='.((int) $limit);
341 }
342 foreach ($search as $key => $val) {
343  if (is_array($search[$key]) && count($search[$key])) {
344  foreach ($search[$key] as $skey) {
345  if ($skey != '') {
346  $param .= '&search_'.$key.'[]='.urlencode($skey);
347  }
348  }
349  } elseif ($search[$key] != '') {
350  $param .= '&search_'.$key.'='.urlencode($search[$key]);
351  }
352 }
353 if ($optioncss != '') {
354  $param .= '&optioncss='.urlencode($optioncss);
355 }
356 // Add $param from extra fields
357 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
358 // Add $param from hooks
359 $parameters = array();
360 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
361 $param .= $hookmanager->resPrint;
362 
363 // List of mass actions available
364 $arrayofmassactions = array(
365  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
366  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
367 );
368 if ($permissiontodelete) {
369  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
370 }
371 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
372  $arrayofmassactions = array();
373 }
374 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
375 
376 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
377 if ($optioncss != '') {
378  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
379 }
380 print '<input type="hidden" name="token" value="'.newToken().'">';
381 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
382 print '<input type="hidden" name="action" value="list">';
383 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
384 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
385 print '<input type="hidden" name="page" value="'.$page.'">';
386 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
387 
388 $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', 'emailcollector_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
389 
390 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'email', 0, $newcardbutton, '', $limit, 0, 0, 1);
391 
392 // Add code for pre mass action (confirmation or email presend form)
393 /*$topicmail="";
394 $modelmail="";
395 $objecttmp=new EmailCollector($db);
396 $trackid='xxxx'.$object->id;*/
397 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
398 
399 $moreforfilter = '';
400 /*$moreforfilter.='<div class="divsearchfield">';
401 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
402 $moreforfilter.= '</div>';*/
403 
404 $parameters = array();
405 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
406 if (empty($reshook)) {
407  $moreforfilter .= $hookmanager->resPrint;
408 } else {
409  $moreforfilter = $hookmanager->resPrint;
410 }
411 
412 if (!empty($moreforfilter)) {
413  print '<div class="liste_titre liste_titre_bydiv centpercent">';
414  print $moreforfilter;
415  print '</div>';
416 }
417 
418 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
419 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
420 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
421 
422 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
423 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
424 
425 
426 // Fields title search
427 // --------------------------------------------------------------------
428 print '<tr class="liste_titre">';
429 // Action column
430 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
431  print '<td class="liste_titre maxwidthsearch">';
432  $searchpicto = $form->showFilterButtons('left');
433  print $searchpicto;
434  print '</td>';
435 }
436 foreach ($object->fields as $key => $val) {
437  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
438  if ($key == 'status') {
439  $cssforfield .= ($cssforfield ? ' ' : '').'center';
440  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
441  $cssforfield .= ($cssforfield ? ' ' : '').'center';
442  } elseif (in_array($val['type'], array('timestamp'))) {
443  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
444  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
445  $cssforfield .= ($cssforfield ? ' ' : '').'right';
446  }
447  if (!empty($arrayfields['t.'.$key]['checked'])) {
448  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
449  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
450  print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
451  } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
452  print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1);
453  } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
454  print '<div class="nowrap">';
455  print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
456  print '</div>';
457  print '<div class="nowrap">';
458  print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
459  print '</div>';
460  } elseif ($key == 'lang') {
461  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
462  $formadmin = new FormAdmin($db);
463  print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
464  } else {
465  print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
466  }
467  print '</td>';
468  }
469 }
470 // Extra fields
471 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
472 
473 // Fields from hook
474 $parameters = array('arrayfields'=>$arrayfields);
475 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
476 print $hookmanager->resPrint;
477 // Action column
478 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
479  print '<td class="liste_titre maxwidthsearch">';
480  $searchpicto = $form->showFilterButtons();
481  print $searchpicto;
482  print '</td>';
483 }
484 print '</tr>'."\n";
485 
486 $totalarray = array();
487 $totalarray['nbfield'] = 0;
488 
489 // Fields title label
490 // --------------------------------------------------------------------
491 print '<tr class="liste_titre">';
492 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
493  print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
494 }
495 foreach ($object->fields as $key => $val) {
496  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
497  if ($key == 'status') {
498  $cssforfield .= ($cssforfield ? ' ' : '').'center';
499  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
500  $cssforfield .= ($cssforfield ? ' ' : '').'center';
501  } elseif (in_array($val['type'], array('timestamp'))) {
502  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
503  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
504  $cssforfield .= ($cssforfield ? ' ' : '').'right';
505  }
506  $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
507  if (!empty($arrayfields['t.'.$key]['checked'])) {
508  print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
509  $totalarray['nbfield']++;
510  }
511 }
512 // Extra fields
513 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
514 // Hook fields
515 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
516 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
517 print $hookmanager->resPrint;
518 // Action column
519 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
520  print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
521 }
522 $totalarray['nbfield']++;
523 print '</tr>'."\n";
524 
525 
526 // Detect if we need a fetch on each output line
527 $needToFetchEachLine = 0;
528 if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
529  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
530  if (!is_null($val) && preg_match('/\$object/', $val)) {
531  $needToFetchEachLine++; // There is at least one compute field that use $object
532  }
533  }
534 }
535 
536 
537 // Loop on record
538 // --------------------------------------------------------------------
539 $i = 0;
540 $savnbfield = $totalarray['nbfield'];
541 $totalarray['nbfield'] = 0;
542 $imaxinloop = ($limit ? min($num, $limit) : $num);
543 while ($i < $imaxinloop) {
544  $obj = $db->fetch_object($resql);
545  if (empty($obj)) {
546  break; // Should not happen
547  }
548 
549  // Store properties in $object
550  $object->setVarsFromFetchObj($obj);
551 
552  if ($mode == 'kanban') {
553  if ($i == 0) {
554  print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
555  print '<div class="box-flex-container kanban">';
556  }
557  // Output Kanban
558  print $object->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected)));
559  if ($i == ($imaxinloop - 1)) {
560  print '</div>';
561  print '</td></tr>';
562  }
563  } else {
564  // Show here line of result
565  $j = 0;
566  print '<tr data-rowid="'.$object->id.'" class="oddeven">';
567  // Action column
568  if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
569  print '<td class="nowrap center">';
570  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
571  $selected = 0;
572  if (in_array($object->id, $arrayofselected)) {
573  $selected = 1;
574  }
575  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
576  }
577  print '</td>';
578  }
579  foreach ($object->fields as $key => $val) {
580  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
581  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
582  $cssforfield .= ($cssforfield ? ' ' : '').'center';
583  } elseif ($key == 'status') {
584  $cssforfield .= ($cssforfield ? ' ' : '').'center';
585  }
586 
587  if (in_array($val['type'], array('timestamp'))) {
588  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
589  } elseif ($key == 'ref') {
590  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
591  }
592 
593  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
594  $cssforfield .= ($cssforfield ? ' ' : '').'right';
595  }
596  //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
597 
598  if (!empty($arrayfields['t.'.$key]['checked'])) {
599  print '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
600  if (preg_match('/tdoverflow/', $cssforfield) && !is_numeric($object->$key)) {
601  print ' title="'.dol_escape_htmltag($object->$key).'"';
602  }
603  print '>';
604  if ($key == 'status') {
605  print $object->getLibStatut(5);
606  } elseif ($key == 'lastresult') {
607  print '<div class="twolinesmax">';
608  print $object->showOutputField($val, $key, $object->$key, '');
609  print '</div>';
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 // MAIN_IMAP_USE_PHPIMAP: Enable use of the PHP Imap library
698 print '<tr class="oddeven"><td>';
699 //print $form->textwithpicto($langs->trans("MAIN_IMAP_USE_PHPIMAP"), $langs->transnoentitiesnoconv("MAIN_IMAP_USE_PHPIMAPDesc"));
700 print $langs->trans("MAIN_IMAP_USE_PHPIMAP");
701 print '</td>';
702 print '<td class="left">';
703 if ($conf->use_javascript_ajax) {
704  print ajax_constantonoff('MAIN_IMAP_USE_PHPIMAP');
705 } else {
706  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
707  print $form->selectarray("MAIN_IMAP_USE_PHPIMAP", $arrval, $conf->global->MAIN_IMAP_USE_PHPIMAP);
708 }
709 print '</td>';
710 print '</tr>';
711 
712 // MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER: Hide e-mail headers from collected messages
713 print '<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans("EmailCollectorHideMailHeaders"), $langs->transnoentitiesnoconv("EmailCollectorHideMailHeadersHelp")).'</td>';
714 print '<td class="left">';
715 if ($conf->use_javascript_ajax) {
716  print ajax_constantonoff('MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER');
717 } else {
718  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
719  print $form->selectarray("MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER", $arrval, $conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND);
720 }
721 print '</td>';
722 print '</tr>';
723 
724 print '</table>';
725 print '</div>';
726 
727 print '<br>';
728 
729 print '</form>'."\n";
730 
731 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
732  $hidegeneratedfilelistifempty = 1;
733  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
734  $hidegeneratedfilelistifempty = 0;
735  }
736 
737  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
738  $formfile = new FormFile($db);
739 
740  // Show list of available documents
741  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
742  $urlsource .= str_replace('&amp;', '&', $param);
743 
744  $filedir = $diroutputmassaction;
745  $genallowed = $permissiontoread;
746  $delallowed = $permissiontoadd;
747 
748  print $formfile->showdocuments('massfilesarea_emailcollector', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
749 }
750 
751 
753 
754 
755 // End of page
756 llxFooter();
757 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
Definition: functions.lib.php:1600
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:5318
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5477
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:609
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:5107
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:8922
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
FormAdmin
Class to generate html code for admin pages.
Definition: html.formadmin.class.php:30
ajax_constantonoff
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='', $morecss='inline-block')
On/off button for constant.
Definition: ajax.lib.php:630
$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:118
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:4135
llxHeader
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
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:11263
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:5530
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
Definition: functions.lib.php:8673
$sql
if(isModEnabled('facture') && $user->hasRight('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') && $user->hasRight('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)) $sql
Social contributions to pay.
Definition: index.php:746
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2177
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:207
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
Definition: functions.lib.php:1979
getDolGlobalString
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:142
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:509
EmailCollector
Class for EmailCollector.
Definition: emailcollector.class.php:59
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:10024
dol_eval
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
Definition: functions.lib.php:9165
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:53
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:3056
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
Definition: security.lib.php:1169
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:2968
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:156