dolibarr 19.0.3
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
25require '../main.inc.php';
26require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
27require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
28require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
29
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
33
34require_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');
57if (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)
79if (!$sortfield) {
80 $sortfield = "t.ref"; // Set here default search field. By default 1st field in definition.
81}
82if (!$sortorder) {
83 $sortorder = "ASC";
84}
85
86// Security check
87$socid = 0;
88if ($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();
97foreach ($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();
109foreach ($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();
117foreach ($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
131include 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
143if (!$user->admin) {
145}
146if (!isModEnabled('emailcollector')) {
147 accessforbidden('Module not enabled');
148}
149
150
151
152/*
153 * Actions
154 */
155
156if (GETPOST('cancel', 'alpha')) {
157 $action = 'list';
158 $massaction = '';
159}
160if (!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
166if ($reshook < 0) {
167 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
168}
169
170if (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
219if (!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";
230if (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}
233if ($object->ismultientitymanaged == 1) {
234 $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
235} else {
236 $sql .= " WHERE 1 = 1";
237}
238foreach ($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}
267if ($search_all) {
268 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
269}
270// Add where from extra fields
271include 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 = '';
278if (!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);
291if ($limit) {
292 $sql .= $db->plimit($limit + 1, $offset);
293}
294
295$resql = $db->query($sql);
296if (!$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
304if ($num == 1 && getDolGlobalString('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
315llxHeader('', $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>';
319print 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
329print dol_get_fiche_head($head, 'common', '', -1);
330
331
332
333$arrayofselected = is_array($toselect) ? $toselect : array();
334
335$param = '';
336if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
337 $param .= '&contextpage='.urlencode($contextpage);
338}
339if ($limit > 0 && $limit != $conf->liste_limit) {
340 $param .= '&limit='.((int) $limit);
341}
342foreach ($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}
353if ($optioncss != '') {
354 $param .= '&optioncss='.urlencode($optioncss);
355}
356// Add $param from extra fields
357include 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);
368if ($permissiontodelete) {
369 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
370}
371if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
372 $arrayofmassactions = array();
373}
374$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
375
376print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
377if ($optioncss != '') {
378 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
379}
380print '<input type="hidden" name="token" value="'.newToken().'">';
381print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
382print '<input type="hidden" name="action" value="list">';
383print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
384print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
385print '<input type="hidden" name="page" value="'.$page.'">';
386print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
387
388$newcardbutton = '';
389$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', 'emailcollector_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
390
391print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'email', 0, $newcardbutton, '', $limit, 0, 0, 1);
392
393// Add code for pre mass action (confirmation or email presend form)
394/*$topicmail="";
395$modelmail="";
396$objecttmp=new EmailCollector($db);
397$trackid='xxxx'.$object->id;*/
398include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
399
400$moreforfilter = '';
401/*$moreforfilter.='<div class="divsearchfield">';
402$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
403$moreforfilter.= '</div>';*/
404
405$parameters = array();
406$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
407if (empty($reshook)) {
408 $moreforfilter .= $hookmanager->resPrint;
409} else {
410 $moreforfilter = $hookmanager->resPrint;
411}
412
413if (!empty($moreforfilter)) {
414 print '<div class="liste_titre liste_titre_bydiv centpercent">';
415 print $moreforfilter;
416 print '</div>';
417}
418
419$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
420$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
421$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
422
423print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
424print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
425
426
427// Fields title search
428// --------------------------------------------------------------------
429print '<tr class="liste_titre">';
430// Action column
431if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
432 print '<td class="liste_titre maxwidthsearch">';
433 $searchpicto = $form->showFilterButtons('left');
434 print $searchpicto;
435 print '</td>';
436}
437foreach ($object->fields as $key => $val) {
438 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
439 if ($key == 'status') {
440 $cssforfield .= ($cssforfield ? ' ' : '').'center';
441 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
442 $cssforfield .= ($cssforfield ? ' ' : '').'center';
443 } elseif (in_array($val['type'], array('timestamp'))) {
444 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
445 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
446 $cssforfield .= ($cssforfield ? ' ' : '').'right';
447 }
448 if (!empty($arrayfields['t.'.$key]['checked'])) {
449 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
450 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
451 print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
452 } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
453 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1);
454 } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
455 print '<div class="nowrap">';
456 print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
457 print '</div>';
458 print '<div class="nowrap">';
459 print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
460 print '</div>';
461 } elseif ($key == 'lang') {
462 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
463 $formadmin = new FormAdmin($db);
464 print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
465 } else {
466 print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
467 }
468 print '</td>';
469 }
470}
471// Extra fields
472include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
473
474// Fields from hook
475$parameters = array('arrayfields'=>$arrayfields);
476$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
477print $hookmanager->resPrint;
478// Action column
479if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
480 print '<td class="liste_titre maxwidthsearch">';
481 $searchpicto = $form->showFilterButtons();
482 print $searchpicto;
483 print '</td>';
484}
485print '</tr>'."\n";
486
487$totalarray = array();
488$totalarray['nbfield'] = 0;
489
490// Fields title label
491// --------------------------------------------------------------------
492print '<tr class="liste_titre">';
493if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
494 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
495}
496foreach ($object->fields as $key => $val) {
497 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
498 if ($key == 'status') {
499 $cssforfield .= ($cssforfield ? ' ' : '').'center';
500 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
501 $cssforfield .= ($cssforfield ? ' ' : '').'center';
502 } elseif (in_array($val['type'], array('timestamp'))) {
503 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
504 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
505 $cssforfield .= ($cssforfield ? ' ' : '').'right';
506 }
507 $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
508 if (!empty($arrayfields['t.'.$key]['checked'])) {
509 print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
510 $totalarray['nbfield']++;
511 }
512}
513// Extra fields
514include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
515// Hook fields
516$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
517$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
518print $hookmanager->resPrint;
519// Action column
520if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
521 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
522}
523$totalarray['nbfield']++;
524print '</tr>'."\n";
525
526
527// Detect if we need a fetch on each output line
528$needToFetchEachLine = 0;
529if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
530 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
531 if (!is_null($val) && preg_match('/\$object/', $val)) {
532 $needToFetchEachLine++; // There is at least one compute field that use $object
533 }
534 }
535}
536
537
538// Loop on record
539// --------------------------------------------------------------------
540$i = 0;
541$savnbfield = $totalarray['nbfield'];
542$totalarray['nbfield'] = 0;
543$imaxinloop = ($limit ? min($num, $limit) : $num);
544while ($i < $imaxinloop) {
545 $obj = $db->fetch_object($resql);
546 if (empty($obj)) {
547 break; // Should not happen
548 }
549
550 // Store properties in $object
551 $object->setVarsFromFetchObj($obj);
552
553 if ($mode == 'kanban') {
554 if ($i == 0) {
555 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
556 print '<div class="box-flex-container kanban">';
557 }
558 // Output Kanban
559 $selected = -1;
560 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
561 $selected = 0;
562 if (in_array($object->id, $arrayofselected)) {
563 $selected = 1;
564 }
565 }
566 print $object->getKanbanView('', array('selected' => $selected));
567 if ($i == ($imaxinloop - 1)) {
568 print '</div>';
569 print '</td></tr>';
570 }
571 } else {
572 // Show here line of result
573 $j = 0;
574 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
575 // Action column
576 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
577 print '<td class="nowrap center">';
578 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
579 $selected = 0;
580 if (in_array($object->id, $arrayofselected)) {
581 $selected = 1;
582 }
583 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
584 }
585 print '</td>';
586 }
587 foreach ($object->fields as $key => $val) {
588 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
589 if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
590 $cssforfield .= ($cssforfield ? ' ' : '').'center';
591 } elseif ($key == 'status') {
592 $cssforfield .= ($cssforfield ? ' ' : '').'center';
593 }
594
595 if (in_array($val['type'], array('timestamp'))) {
596 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
597 } elseif ($key == 'ref') {
598 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
599 }
600
601 if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
602 $cssforfield .= ($cssforfield ? ' ' : '').'right';
603 }
604 //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
605
606 if (!empty($arrayfields['t.'.$key]['checked'])) {
607 print '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
608 if (preg_match('/tdoverflow/', $cssforfield) && !is_numeric($object->$key)) {
609 print ' title="'.dol_escape_htmltag($object->$key).'"';
610 }
611 print '>';
612 if ($key == 'status') {
613 print $object->getLibStatut(5);
614 } elseif ($key == 'lastresult') {
615 print '<div class="twolinesmax">';
616 print $object->showOutputField($val, $key, $object->$key, '');
617 print '</div>';
618 } elseif ($key == 'rowid') {
619 print $object->showOutputField($val, $key, $object->id, '');
620 } else {
621 print $object->showOutputField($val, $key, $object->$key, '');
622 }
623 print '</td>';
624 if (!$i) {
625 $totalarray['nbfield']++;
626 }
627 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
628 if (!$i) {
629 $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
630 }
631 if (!isset($totalarray['val'])) {
632 $totalarray['val'] = array();
633 }
634 if (!isset($totalarray['val']['t.'.$key])) {
635 $totalarray['val']['t.'.$key] = 0;
636 }
637 $totalarray['val']['t.'.$key] += $object->$key;
638 }
639 }
640 }
641 // Extra fields
642 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
643 // Fields from hook
644 $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
645 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
646 print $hookmanager->resPrint;
647 // Action column
648 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
649 print '<td class="nowrap center">';
650 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
651 $selected = 0;
652 if (in_array($object->id, $arrayofselected)) {
653 $selected = 1;
654 }
655 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
656 }
657 print '</td>';
658 }
659 if (!$i) {
660 $totalarray['nbfield']++;
661 }
662
663 print '</tr>'."\n";
664 }
665
666 $i++;
667}
668
669// Show total line
670include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
671
672
673// If no record found
674if ($num == 0) {
675 $colspan = 1;
676 foreach ($arrayfields as $key => $val) {
677 if (!empty($val['checked'])) {
678 $colspan++;
679 }
680 }
681 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
682}
683
684
685$db->free($resql);
686
687$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
688$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
689print $hookmanager->resPrint;
690
691print '</table>'."\n";
692print '</div>'."\n";
693
694print load_fiche_titre($langs->trans("Other"), '', '');
695
696
697print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
698print '<table class="noborder centpercent">';
699
700print '<tr class="liste_titre">';
701print '<td>'.$langs->trans("Parameter").'</td>';
702print '<td></td>';
703print "</tr>\n";
704
705// MAIN_IMAP_USE_PHPIMAP: Enable use of the PHP Imap library
706print '<tr class="oddeven"><td>';
707//print $form->textwithpicto($langs->trans("MAIN_IMAP_USE_PHPIMAP"), $langs->transnoentitiesnoconv("MAIN_IMAP_USE_PHPIMAPDesc"));
708print $langs->trans("MAIN_IMAP_USE_PHPIMAP");
709print '</td>';
710print '<td class="left">';
711if ($conf->use_javascript_ajax) {
712 print ajax_constantonoff('MAIN_IMAP_USE_PHPIMAP');
713} else {
714 $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
715 print $form->selectarray("MAIN_IMAP_USE_PHPIMAP", $arrval, $conf->global->MAIN_IMAP_USE_PHPIMAP);
716}
717print '</td>';
718print '</tr>';
719
720// MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER: Hide e-mail headers from collected messages
721print '<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans("EmailCollectorHideMailHeaders"), $langs->transnoentitiesnoconv("EmailCollectorHideMailHeadersHelp")).'</td>';
722print '<td class="left">';
723if ($conf->use_javascript_ajax) {
724 print ajax_constantonoff('MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER');
725} else {
726 $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
727 print $form->selectarray("MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER", $arrval, $conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND);
728}
729print '</td>';
730print '</tr>';
731
732print '</table>';
733print '</div>';
734
735print '<br>';
736
737print '</form>'."\n";
738
739if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
740 $hidegeneratedfilelistifempty = 1;
741 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
742 $hidegeneratedfilelistifempty = 0;
743 }
744
745 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
746 $formfile = new FormFile($db);
747
748 // Show list of available documents
749 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
750 $urlsource .= str_replace('&amp;', '&', $param);
751
752 $filedir = $diroutputmassaction;
753 $genallowed = $permissiontoread;
754 $delallowed = $permissiontoadd;
755
756 print $formfile->showdocuments('massfilesarea_emailcollector', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
757}
758
759
761
762
763// End of page
764llxFooter();
765$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
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.
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_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.