dolibarr 25.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-2026 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024-2025 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';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
41
42require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
45
46require_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollector.class.php';
47
48// Load translation files required by page
49$langs->loadLangs(array("admin", "other"));
50
51$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
52$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
53$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
54$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
55$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
56$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
57$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : getDolDefaultContextPage(__FILE__); // To manage different context of search
58$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
59$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
60$mode = GETPOST('mode', 'aZ');
61$groupby = GETPOST('mode', 'aZ09');
62
63$id = GETPOSTINT('id');
64
65// Load variable for pagination
66$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
67$sortfield = GETPOST('sortfield', 'aZ09comma');
68$sortorder = GETPOST('sortorder', 'aZ09comma');
69$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
70if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
71 // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
72 $page = 0;
73}
74$offset = $limit * $page;
75$pageprev = $page - 1;
76$pagenext = $page + 1;
77//if (! $sortfield) $sortfield="p.date_fin";
78//if (! $sortorder) $sortorder="DESC";
79
80// Initialize a technical objects
82
83$diroutputmassaction = $conf->emailcollector->dir_output.'/temp/massgeneration/'.$user->id;
84$hookmanager->initHooks(array('emailcollectorlist')); // Note that conf->hooks_modules contains array
85
86// Fetch optionals attributes and labels
87$extrafields->fetch_name_optionals_label($object->table_element);
88
89$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
90
91// Default sort order (if not yet defined by previous GETPOST)
92if (!$sortfield) {
93 $sortfield = "t.ref"; // Set here default search field. By default 1st field in definition.
94}
95if (!$sortorder) {
96 $sortorder = "ASC";
97}
98
99// Security check
100$socid = 0;
101if ($user->socid > 0) { // Protection if external user
102 //$socid = $user->socid;
104}
105//restrictedArea($user, 'emailcollector', $id, '');
106
107// Initialize array of search criteria
108$search_all = trim(GETPOST('search_all', 'alphanohtml'));
109$search = array();
110foreach ($object->fields as $key => $val) {
111 if (GETPOST('search_'.$key, 'alpha') !== '') {
112 $search[$key] = GETPOST('search_'.$key, 'alpha');
113 }
114 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
115 $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOSTINT('search_'.$key.'_dtstartmonth'), GETPOSTINT('search_'.$key.'_dtstartday'), GETPOSTINT('search_'.$key.'_dtstartyear'));
116 $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_'.$key.'_dtendmonth'), GETPOSTINT('search_'.$key.'_dtendday'), GETPOSTINT('search_'.$key.'_dtendyear'));
117 }
118}
119
120// List of fields to search into when doing a "search in all"
121$fieldstosearchall = array();
122foreach ($object->fields as $key => $val) {
123 if (!empty($val['searchall'])) {
124 $fieldstosearchall['t.'.$key] = $val['label'];
125 }
126}
127
128// Definition of array of fields for columns
129$tableprefix = 't';
130$arrayfields = array();
131foreach ($object->fields as $key => $val) {
132 // If $val['visible']==0, then we never show the field
133 if (!empty($val['visible'])) {
134 $visible = (int) dol_eval((string) $val['visible'], 1);
135 $arrayfields[$tableprefix.'.'.$key] = array(
136 'label' => $val['label'],
137 'checked' => (($visible < 0) ? '0' : '1'),
138 'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval((string) $val['enabled'], 1)),
139 'position' => $val['position'],
140 'help' => isset($val['help']) ? $val['help'] : ''
141 );
142 }
143}
144
145// Extra fields
146include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
147// Add hook to complete $arrayfield
148$parameters = array('arrayfields' => &$arrayfields);
149$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
150
151$object->fields = dol_sort_array($object->fields, 'position');
152$arrayfields = dol_sort_array($arrayfields, 'position');
153
154$permissiontoread = $user->admin;
155$permissiontoadd = $user->admin;
156$permissiontodelete = $user->admin;
157
158if (!$user->admin) {
160}
161if (!isModEnabled('emailcollector')) {
162 accessforbidden('Module not enabled');
163}
164
165
166
167
168/*
169 * Actions
170 */
171
172if (GETPOST('cancel', 'alpha')) {
173 $action = 'list';
174 $massaction = '';
175}
176if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
177 $massaction = '';
178}
179
180$parameters = array('arrayfields' => &$arrayfields);
181$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
182if ($reshook < 0) {
183 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
184}
185
186if (empty($reshook)) {
187 // Selection of new fields
188 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
189
190 // Purge search criteria
191 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
192 foreach ($object->fields as $key => $val) {
193 $search[$key] = '';
194 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
195 $search[$key.'_dtstart'] = '';
196 $search[$key.'_dtend'] = '';
197 }
198 }
199 $search_all = '';
200 $toselect = array();
201 $search_array_options = array();
202 }
203 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
204 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
205 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
206 }
207
208 // Mass actions
209 $objectclass = 'EmailCollector';
210 $objectlabel = 'EmailCollector';
211 $uploaddir = $conf->emailcollector->dir_output;
212
213 global $error;
214 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
215}
216
217
218
219/*
220 * View
221 */
222
223$form = new Form($db);
224
225$now = dol_now();
226
227$help_url = "EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector";
228$title = $langs->trans('EmailCollectors');
229$morejs = array();
230$morecss = array();
231
232
233// Build and execute select
234// --------------------------------------------------------------------
235$sql = "SELECT";
236$sql .= " ".$object->getFieldList('t');
237// Add fields from extrafields
238if (!empty($extrafields->attributes[$object->table_element]['label'])) {
239 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
240 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : "");
241 }
242}
243// Add fields from hooks
244$parameters = array();
245$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
246$sql .= $hookmanager->resPrint;
247$sql = preg_replace('/,\s*$/', '', $sql);
248
249$sqlfields = $sql; // $sql fields to remove for count total
250
251$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
252if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
253 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
254}
255if ($object->ismultientitymanaged == 1) {
256 $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
257} else {
258 $sql .= " WHERE 1 = 1";
259}
260foreach ($search as $key => $val) {
261 if (array_key_exists($key, $object->fields)) {
262 if ($key == 'status' && $search[$key] == -1) {
263 continue;
264 }
265 $field_spec = $object->fields[$key];
266 // @phpstan-ignore-next-line PHPStan thinks that $field_spec is never null
267 if ($field_spec === null) {
268 continue;
269 }
270 $mode_search = (($object->isInt($field_spec) || $object->isFloat($field_spec)) ? 1 : 0);
271 if ((strpos($field_spec['type'], 'integer:') === 0) || (strpos($field_spec['type'], 'sellist:') === 0) || !empty($field_spec['arrayofkeyval'])) {
272 if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($field_spec['arrayofkeyval']) || !array_key_exists('0', $field_spec['arrayofkeyval'])))) {
273 $search[$key] = '';
274 }
275 $mode_search = 2;
276 }
277 if ($field_spec['type'] === 'boolean') {
278 $mode_search = 1;
279 if ($search[$key] == '-1') {
280 $search[$key] = '';
281 }
282 }
283 if (empty($field_spec['searchmulti'])) {
284 if (!is_array($search[$key]) && $search[$key] != '') {
285 $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
286 }
287 } else {
288 if (is_array($search[$key]) && !empty($search[$key])) {
289 $sql .= natural_search("t.".$db->escape($key), implode(',', $search[$key]), (($key == 'status') ? 2 : $mode_search));
290 }
291 }
292 } else {
293 if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
294 $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
295 if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
296 if (preg_match('/_dtstart$/', $key)) {
297 $sql .= " AND t.".$db->sanitize($columnName)." >= '".$db->idate($search[$key])."'";
298 }
299 if (preg_match('/_dtend$/', $key)) {
300 $sql .= " AND t.".$db->sanitize($columnName)." <= '".$db->idate($search[$key])."'";
301 }
302 }
303 }
304 }
305}
306if ($search_all) {
307 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
308}
309// Add where from extra fields
310include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
311// Add where from hooks
312$parameters = array();
313$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
314$sql .= $hookmanager->resPrint;
315
316// Count total nb of records
317$nbtotalofrecords = '';
318if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
319 /* The fast and low memory method to get and count full list converts the sql into a sql count */
320 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
321 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
322
323 $resql = $db->query($sqlforcount);
324 if ($resql) {
325 $objforcount = $db->fetch_object($resql);
326 $nbtotalofrecords = $objforcount->nbtotalofrecords;
327 } else {
329 }
330
331 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
332 $page = 0;
333 $offset = 0;
334 }
335
336 $db->free($resql);
337}
338// Complete request and execute it with limit
339$sql .= $db->order($sortfield, $sortorder);
340if ($limit) {
341 $sql .= $db->plimit($limit + 1, $offset);
342}
343
344$resql = $db->query($sql);
345if (!$resql) {
347 exit;
348}
349
350$num = $db->num_rows($resql);
351
352// Direct jump if only one record found
353if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
354 $obj = $db->fetch_object($resql);
355 $id = $obj->rowid;
356 header("Location: ".DOL_URL_ROOT.'/emailcollector/emailcollector_card.php?id='.$id);
357 exit;
358}
359
360
361// Output page
362// --------------------------------------------------------------------
363
364llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist mod-user page-emailcollector_list');
365
366
367$linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
368
369print load_fiche_titre($title, $linkback, 'title_setup');
370
371
372$head = array();
373$h = 0;
374$head[$h][0] = DOL_URL_ROOT."/admin/emailcollector_list.php";
375$head[$h][1] = $langs->trans("Setup");
376$head[$h][2] = 'common';
377$h++;
378
379print dol_get_fiche_head($head, 'common', '', -1);
380
381
382
383$arrayofselected = is_array($toselect) ? $toselect : array();
384
385$param = '';
386if (!empty($mode)) {
387 $param .= '&mode='.urlencode($mode);
388}
389if (!empty($contextpage) && $contextpage != getDolDefaultContextPage(__FILE__)) {
390 $param .= '&contextpage='.urlencode($contextpage);
391}
392if ($limit > 0 && $limit != $conf->liste_limit) {
393 $param .= '&limit='.((int) $limit);
394}
395if ($optioncss != '') {
396 $param .= '&optioncss='.urlencode($optioncss);
397}
398if ($groupby != '') {
399 $param .= '&groupby='.urlencode($groupby);
400}
401foreach ($search as $key => $val) {
402 if (is_array($search[$key])) {
403 foreach ($search[$key] as $skey) {
404 if ($skey != '') {
405 $param .= '&search_'.$key.'[]='.urlencode($skey);
406 }
407 }
408 } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
409 $param .= '&search_'.$key.'month='.GETPOSTINT('search_'.$key.'month');
410 $param .= '&search_'.$key.'day='.GETPOSTINT('search_'.$key.'day');
411 $param .= '&search_'.$key.'year='.GETPOSTINT('search_'.$key.'year');
412 } elseif ($search[$key] != '') {
413 $param .= '&search_'.$key.'='.urlencode($search[$key]);
414 }
415}
416// Add $param from extra fields
417include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
418// Add $param from hooks
419$parameters = array('param' => &$param);
420$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
421$param .= $hookmanager->resPrint;
422
423// List of mass actions available
424$arrayofmassactions = array(
425 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
426 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
427);
428if (!empty($permissiontodelete)) {
429 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
430}
431if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
432 $arrayofmassactions = array();
433}
434$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
435
436print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" spellcheck="false">'."\n";
437if ($optioncss != '') {
438 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
439}
440print '<input type="hidden" name="token" value="'.newToken().'">';
441print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
442print '<input type="hidden" name="action" value="list">';
443print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
444print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
445print '<input type="hidden" name="page" value="'.$page.'">';
446print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
447print '<input type="hidden" name="page_y" value="">';
448print '<input type="hidden" name="mode" value="'.$mode.'">';
449
450$newcardbutton = '';
451$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', 'emailcollector_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
452
453print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'email', 0, $newcardbutton, '', $limit, 0, 0, 1);
454
455// Add code for pre mass action (confirmation or email presend form)
456/*$topicmail="";
457$modelmail="";
458$objecttmp=new EmailCollector($db);
459$trackid='xxxx'.$object->id;*/
460include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
461
462$moreforfilter = '';
463/*$moreforfilter.='<div class="divsearchfield">';
464$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
465$moreforfilter.= '</div>';*/
466
467$parameters = array();
468$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
469if (empty($reshook)) {
470 $moreforfilter .= $hookmanager->resPrint;
471} else {
472 $moreforfilter = $hookmanager->resPrint;
473}
474$parameters = array(
475 'arrayfields' => &$arrayfields,
476);
477
478if (!empty($moreforfilter)) {
479 print '<div class="liste_titre liste_titre_bydiv centpercent">';
480 print $moreforfilter;
481 print '</div>';
482}
483
484$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
485$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
486$selectedfields = (($mode != 'kanban' && $mode != 'kanbangroupby') ? $htmlofselectarray : '');
487$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
488
489print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
490print '<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
491
492
493// Fields title search
494// --------------------------------------------------------------------
495print '<tr class="liste_titre_filter">';
496// Action column
497if ($conf->main_checkbox_left_column) {
498 print '<td class="liste_titre center maxwidthsearch">';
499 $searchpicto = $form->showFilterButtons('left');
500 print $searchpicto;
501 print '</td>';
502}
503foreach ($object->fields as $key => $val) {
504 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
505 if ($key == 'status') {
506 $cssforfield .= ($cssforfield ? ' ' : '').'center';
507 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
508 $cssforfield .= ($cssforfield ? ' ' : '').'center';
509 } elseif (in_array($val['type'], array('timestamp'))) {
510 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
511 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
512 $cssforfield .= ($cssforfield ? ' ' : '').'right';
513 }
514 if (!empty($arrayfields['t.'.$key]['checked'])) {
515 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
516 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
517 if (empty($val['searchmulti'])) {
518 print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), 1, 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
519 } else {
520 print $form->multiselectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : array()), 0, 0, 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
521 }
522 } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
523 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth125', 1);
524 } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
525 print '<div class="nowrap">';
526 print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
527 print '</div>';
528 print '<div class="nowrap">';
529 print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
530 print '</div>';
531 } elseif ($key == 'lang') {
532 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
533 $formadmin = new FormAdmin($db);
534 print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2);
535 } elseif ($val['type'] === 'boolean') {
536 print $form->selectyesno('search_' . $key, $search[$key] ?? '', 1, false, 1);
537 } else {
538 print '<input type="text" class="flat maxwidth'.(in_array($val['type'], array('integer', 'price')) ? '50' : '75').'" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
539 }
540 print '</td>';
541 }
542}
543// Extra fields
544include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
545
546// Fields from hook
547$parameters = array('arrayfields' => $arrayfields);
548$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
549print $hookmanager->resPrint;
550// Action column
551if (!$conf->main_checkbox_left_column) {
552 print '<td class="liste_titre center maxwidthsearch">';
553 $searchpicto = $form->showFilterButtons();
554 print $searchpicto;
555 print '</td>';
556}
557print '</tr>'."\n";
558
559$totalarray = array();
560$totalarray['nbfield'] = 0;
561
562// Fields title label
563// --------------------------------------------------------------------
564print '<tr class="liste_titre">';
565// Action column
566if ($conf->main_checkbox_left_column) {
567 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
568 $totalarray['nbfield']++;
569}
570foreach ($object->fields as $key => $val) {
571 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
572 if ($key == 'status') {
573 $cssforfield .= ($cssforfield ? ' ' : '').'center';
574 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
575 $cssforfield .= ($cssforfield ? ' ' : '').'center';
576 } elseif (in_array($val['type'], array('timestamp'))) {
577 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
578 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
579 $cssforfield .= ($cssforfield ? ' ' : '').'right';
580 }
581 $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
582 if (!empty($arrayfields['t.'.$key]['checked'])) {
583 print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), 0, (empty($val['helplist']) ? '' : $val['helplist']))."\n";
584 $totalarray['nbfield']++;
585 }
586}
587// Extra fields
588include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
589// Hook fields
590$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
591$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
592print $hookmanager->resPrint;
593// Action column
594if (!$conf->main_checkbox_left_column) {
595 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
596 $totalarray['nbfield']++;
597}
598print '</tr>'."\n";
599
600
601// Detect if we need a fetch on each output line
602$needToFetchEachLine = 0;
603if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
604 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
605 if (!is_null($val) && preg_match('/\$object/', $val)) {
606 $needToFetchEachLine++; // There is at least one compute field that use $object
607 }
608 }
609}
610
611
612// Loop on record
613// --------------------------------------------------------------------
614$i = 0;
615$savnbfield = $totalarray['nbfield'];
616$totalarray = array();
617$totalarray['nbfield'] = 0;
618$imaxinloop = ($limit ? min($num, $limit) : $num);
619while ($i < $imaxinloop) {
620 $obj = $db->fetch_object($resql);
621 if (empty($obj)) {
622 break; // Should not happen
623 }
624
625 // Store properties in $object
626 $object->setVarsFromFetchObj($obj);
627
628 if ($mode == 'kanban' || $mode == 'kanbangroupby') {
629 if ($i == 0) {
630 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
631 print '<div class="box-flex-container kanban">';
632 }
633 // Output Kanban
634 $selected = -1;
635 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
636 $selected = 0;
637 if (in_array($object->id, $arrayofselected)) {
638 $selected = 1;
639 }
640 }
641 print $object->getKanbanView('', array('selected' => $selected));
642 if ($i == ($imaxinloop - 1)) {
643 print '</div>';
644 print '</td></tr>';
645 }
646 } else {
647 // Show line of result
648 $j = 0;
649 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
650 // Action column
651 if ($conf->main_checkbox_left_column) {
652 print '<td class="nowrap center">';
653 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
654 $selected = 0;
655 if (in_array($object->id, $arrayofselected)) {
656 $selected = 1;
657 }
658 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
659 }
660 print '</td>';
661 if (!$i) {
662 $totalarray['nbfield']++;
663 }
664 }
665 // Fields
666 foreach ($object->fields as $key => $val) {
667 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
668 if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
669 $cssforfield .= ($cssforfield ? ' ' : '').'center';
670 } elseif ($key == 'status') {
671 $cssforfield .= ($cssforfield ? ' ' : '').'center';
672 }
673
674 if (in_array($val['type'], array('timestamp'))) {
675 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
676 } elseif ($key == 'ref') {
677 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
678 }
679
680 if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && empty($val['arrayofkeyval'])) {
681 $cssforfield .= ($cssforfield ? ' ' : '').'right';
682 }
683 //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
684
685 if (!empty($arrayfields['t.'.$key]['checked'])) {
686 print '<td'.($cssforfield ? ' class="'.$cssforfield.((preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) ? ' classfortooltip' : '').'"' : '');
687 if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key) && !in_array($key, array('ref'))) {
688 print ' title="'.dol_escape_htmltag((string) $object->$key).'"';
689 }
690 print '>';
691 if ($key == 'status') {
692 print $object->getLibStatut(5);
693 } elseif ($key == 'rowid') {
694 print $object->showOutputField($val, $key, (string) $object->id, '');
695 } else {
696 if ($val['type'] == 'html' || $key == 'lastresult') {
697 print '<div class="small lineheightsmall twolinesmax-normallineheight">';
698 }
699 print $object->showOutputField($val, $key, (string) $object->$key, '');
700 if ($val['type'] == 'html' || $key == 'lastresult') {
701 print '</div>';
702 }
703 }
704 print '</td>';
705 if (!$i) {
706 $totalarray['nbfield']++;
707 }
708 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
709 if (!$i) {
710 $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
711 }
712 if (!isset($totalarray['val'])) {
713 $totalarray['val'] = array();
714 }
715 if (!isset($totalarray['val']['t.'.$key])) {
716 $totalarray['val']['t.'.$key] = 0;
717 }
718 $totalarray['val']['t.'.$key] += $object->$key;
719 }
720 }
721 }
722 // Extra fields
723 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
724 // Fields from hook
725 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
726 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
727 print $hookmanager->resPrint;
728 // Action column
729 if (!$conf->main_checkbox_left_column) {
730 print '<td class="nowrap center">';
731 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
732 $selected = 0;
733 if (in_array($object->id, $arrayofselected)) {
734 $selected = 1;
735 }
736 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
737 }
738 print '</td>';
739 if (!$i) {
740 $totalarray['nbfield']++;
741 }
742 }
743
744 print '</tr>'."\n";
745 }
746
747 $i++;
748}
749
750// Show total line
751include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
752
753
754// If no record found
755if ($num == 0) {
756 $colspan = 1;
757 foreach ($arrayfields as $key => $val) {
758 if (!empty($val['checked'])) {
759 $colspan++;
760 }
761 }
762 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
763}
764
765
766$db->free($resql);
767
768$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
769$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
770print $hookmanager->resPrint;
771
772print '</table>'."\n";
773print '</div>'."\n";
774
775print load_fiche_titre($langs->trans("Other"), '', '');
776
777
778print '<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
779print '<table class="noborder centpercent">';
780
781print '<tr class="liste_titre">';
782print '<td>'.$langs->trans("Parameter").'</td>';
783print '<td></td>';
784print "</tr>\n";
785
786// MAIN_IMAP_USE_PHPIMAP: Enable use of the PHP Imap library
787print '<tr class="oddeven"><td>';
788//print $form->textwithpicto($langs->trans("MAIN_IMAP_USE_PHPIMAP"), $langs->transnoentitiesnoconv("MAIN_IMAP_USE_PHPIMAPDesc"));
789print $langs->trans("MAIN_IMAP_USE_PHPIMAP");
790print '</td>';
791print '<td class="left">';
792if ($conf->use_javascript_ajax) {
793 print ajax_constantonoff('MAIN_IMAP_USE_PHPIMAP');
794} else {
795 $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
796 print $form->selectarray("MAIN_IMAP_USE_PHPIMAP", $arrval, getDolGlobalString("MAIN_IMAP_USE_PHPIMAP"));
797}
798print '</td>';
799print '</tr>';
800
801// MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER: Hide e-mail headers from collected messages
802print '<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans("EmailCollectorHideMailHeaders"), $langs->transnoentitiesnoconv("EmailCollectorHideMailHeadersHelp")).'</td>';
803print '<td class="left">';
804if ($conf->use_javascript_ajax) {
805 print ajax_constantonoff('MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER');
806} else {
807 $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
808 print $form->selectarray("MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER", $arrval, getDolGlobalString('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND'));
809}
810print '</td>';
811print '</tr>';
812
813// EMAILCOLLECTOR_ISNOTANSWER_USE_REFERENCES: Consider generic References as answer for "isnotanswer" filter.
814print '<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans("EmailCollectorIsNotAnswerUseReferences"), $langs->transnoentitiesnoconv("EmailCollectorIsNotAnswerUseReferencesHelp")).'</td>';
815print '<td class="left">';
816if ($conf->use_javascript_ajax) {
817 print ajax_constantonoff('EMAILCOLLECTOR_ISNOTANSWER_USE_REFERENCES');
818} else {
819 $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
820 print $form->selectarray("EMAILCOLLECTOR_ISNOTANSWER_USE_REFERENCES", $arrval, getDolGlobalInt('EMAILCOLLECTOR_ISNOTANSWER_USE_REFERENCES', 0));
821}
822print '</td>';
823print '</tr>';
824
825print '</table>';
826print '</div>';
827
828print '<br>';
829
830print '</form>'."\n";
831
832if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
833 $hidegeneratedfilelistifempty = 1;
834 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
835 $hidegeneratedfilelistifempty = 0;
836 }
837
838 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
839 $formfile = new FormFile($db);
840
841 // Show list of available documents
842 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
843 $urlsource .= str_replace('&amp;', '&', $param);
844
845 $filedir = $diroutputmassaction;
846 $genallowed = $permissiontoread;
847 $delallowed = $permissiontoadd;
848
849 print $formfile->showdocuments('massfilesarea_emailcollector', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
850}
851
852
853print dol_get_fiche_end();
854
855
856// End of page
857llxFooter();
858$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:501
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
Class for EmailCollector.
Class to generate html code for admin pages.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_now($mode='gmt')
Return date for now.
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...
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
getDolDefaultContextPage($s)
Return the default context page string.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:519
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.
Definition html.lib.php:717
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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 html.lib.php:172
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.