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