dolibarr 21.0.0-alpha
emailcollector_list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
32
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
36
37require_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollector.class.php';
38
39// Load translation files required by page
40$langs->loadLangs(array("admin", "other"));
41
42$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
43$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
44$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
45$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
46$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
47$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
48$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'emailcollectorlist'; // To manage different context of search
49$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
50$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
51$mode = GETPOST('mode', 'aZ');
52
53$id = GETPOSTINT('id');
54
55// Load variable for pagination
56$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
57$sortfield = GETPOST('sortfield', 'aZ09comma');
58$sortorder = GETPOST('sortorder', 'aZ09comma');
59$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
60if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
61 // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
62 $page = 0;
63}
64$offset = $limit * $page;
65$pageprev = $page - 1;
66$pagenext = $page + 1;
67//if (! $sortfield) $sortfield="p.date_fin";
68//if (! $sortorder) $sortorder="DESC";
69
70// Initialize a technical objects
71$object = new EmailCollector($db);
72$extrafields = new ExtraFields($db);
73$diroutputmassaction = $conf->emailcollector->dir_output.'/temp/massgeneration/'.$user->id;
74$hookmanager->initHooks(array('emailcollectorlist')); // Note that conf->hooks_modules contains array
75
76// Fetch optionals attributes and labels
77$extrafields->fetch_name_optionals_label($object->table_element);
78
79$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
80
81// Default sort order (if not yet defined by previous GETPOST)
82if (!$sortfield) {
83 $sortfield = "t.ref"; // Set here default search field. By default 1st field in definition.
84}
85if (!$sortorder) {
86 $sortorder = "ASC";
87}
88
89// Security check
90$socid = 0;
91if ($user->socid > 0) { // Protection if external user
92 //$socid = $user->socid;
94}
95//$result = restrictedArea($user, 'emailcollector', $id, '');
96
97// Initialize array of search criteria
98$search_all = GETPOST('search_all', 'alphanohtml');
99$search = array();
100foreach ($object->fields as $key => $val) {
101 if (GETPOST('search_'.$key, 'alpha') !== '') {
102 $search[$key] = GETPOST('search_'.$key, 'alpha');
103 }
104 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
105 $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOSTINT('search_'.$key.'_dtstartmonth'), GETPOSTINT('search_'.$key.'_dtstartday'), GETPOSTINT('search_'.$key.'_dtstartyear'));
106 $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_'.$key.'_dtendmonth'), GETPOSTINT('search_'.$key.'_dtendday'), GETPOSTINT('search_'.$key.'_dtendyear'));
107 }
108}
109
110// List of fields to search into when doing a "search in all"
111$fieldstosearchall = array();
112foreach ($object->fields as $key => $val) {
113 if (!empty($val['searchall'])) {
114 $fieldstosearchall['t.'.$key] = $val['label'];
115 }
116}
117
118// Definition of array of fields for columns
119$arrayfields = array();
120foreach ($object->fields as $key => $val) {
121 // If $val['visible']==0, then we never show the field
122 if (!empty($val['visible'])) {
123 $visible = (int) dol_eval((string) $val['visible'], 1);
124 $arrayfields['t.'.$key] = array(
125 'label' => $val['label'],
126 'checked' => (($visible < 0) ? 0 : 1),
127 'enabled' => (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)),
128 'position' => $val['position'],
129 'help' => isset($val['help']) ? $val['help'] : ''
130 );
131 }
132}
133// Extra fields
134include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
135
136$object->fields = dol_sort_array($object->fields, 'position');
137$arrayfields = dol_sort_array($arrayfields, 'position');
138
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->sanitize($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, '', 'bodyforlist mod-user page-emailcollector_list');
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 (GETPOSTINT('nomassaction') || 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, $action); // 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 don't 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, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2);
465 } else {
466 print '<input type="text" class="flat maxwidth'.($val['type'] == 'integer' ? '50' : '75').'" 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 don't 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, getDolGlobalString('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();
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
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.
llxFooter()
Footer empty.
Definition document.php:107
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
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.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a 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.