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