dolibarr 23.0.3
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005-2023 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
6 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2025 Jon Bendtsen <jon.bendtsen.github@jonb.dk>
8 * Copyright (C) 2025 Josep Lluís Amador Teruel <joseplluis@lliuretic.cat>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30// Load Dolibarr environment
31require '../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
40require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
41
42// Load translation files required by the page
43$langs->load('mails');
44
45// Get Parameters
46$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
47$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
48$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
49$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
50$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
51$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
52$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
53$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
54$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
55$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
56
57// Load variable for pagination
58$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
59$sortfield = GETPOST('sortfield', 'aZ09comma');
60$sortorder = GETPOST('sortorder', 'aZ09comma');
61$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
62if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
63 // If $page is not defined, or '' or -1 or if we click on clear filters
64 $page = 0;
65}
66$offset = $limit * $page;
67$pageprev = $page - 1;
68$pagenext = $page + 1;
69
70// Search Fields
71$search_all = trim(GETPOST('search_all', 'alphanohtml'));
72$search_ref = GETPOST("search_ref", "alpha") ? GETPOST("search_ref", "alpha") : GETPOST("sref", "alpha");
73$search_title = GETPOST("search_title", "alpha");
74$search_subject = GETPOST("search_subject", "alpha");
75$search_messtype = GETPOST("search_messtype", "alpha");
76$filteremail = GETPOST('filteremail', 'alpha');
77
78$search_refproject = GETPOST('search_refproject', 'alpha');
79$search_project = GETPOST('search_project', 'alpha');
80
81// Initialize a technical objects
82$object = new Mailing($db);
83$extrafields = new ExtraFields($db);
84$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes
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 (!$sortorder) {
93 $sortorder = "DESC";
94}
95if (!$sortfield) {
96 $sortfield = "m.date_creat";
97}
98
99// List of fields to search into when doing a "search in all"
100$fieldstosearchall = array(
101 'm.titre' => 'Ref',
102);
103
104$permissiontoread = $user->hasRight('mailing', 'lire');
105$permissiontoadd = $user->hasRight('mailing', 'creer');
106$permissiontodelete = $user->hasRight('mailing', 'delete');
107
108// Security check
109if (!$user->hasRight('mailing', 'lire') || (!getDolGlobalString('EXTERNAL_USERS_ARE_AUTHORIZED') && $user->socid > 0)) {
111}
112//restrictedArea($user, 'mailing');
113
114
115/*
116 * Actions
117 */
118
119if (GETPOST('cancel', 'alpha')) {
120 $action = 'list';
121 $massaction = '';
122}
123if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
124 $massaction = '';
125}
126
127$parameters = array();
128$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
129if ($reshook < 0) {
130 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
131}
132
133if (empty($reshook)) {
134 // Selection of new fields
135 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
136
137 // Purge search criteria
138 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
139 /*foreach($object->fields as $key => $val)
140 {
141 $search[$key]='';
142 }*/
143 $search_ref = '';
144 $search_title = '';
145 $search_subject = '';
146 $search_messtype = '';
147 $search_refproject = '';
148 $search_project = '';
149 $search_all = '';
150 $toselect = array();
151 $search_array_options = array();
152 }
153 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
154 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
155 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
156 }
157
158 // Mass actions
159 $objectclass = 'Mailing';
160 $objectlabel = 'Mailing';
161 $uploaddir = $conf->mailing->dir_output;
162 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
163}
164
165
166/*
167 * View
168 */
169
170$form = new Form($db);
171$projectstatic = new Project($db);
172
173$now = dol_now();
174
175$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing';
176$title = $langs->trans("Mailing");
177$morejs = array();
178$morecss = array();
179
180// Build and execute select
181// --------------------------------------------------------------------
182if ($filteremail) {
183 $sql = "SELECT m.rowid, m.messtype, m.titre as title, m.sujet as subject, m.nbemail, m.statut as status, m.date_creat as datec, m.date_envoi as date_envoi,";
184 $sql .= " mc.statut as sendstatut,";
185 $sql .= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label";
186
187 $sqlfields = $sql; // $sql fields to remove for count total
188
189 $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc";
190 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = m.fk_project";
191 $sql .= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity;
192 $sql .= " AND mc.email = '".$db->escape($filteremail)."'";
193 if ($search_ref) {
194 $sql .= natural_search("m.rowid", $search_ref, 1);
195 }
196 if ($search_title) {
197 $sql .= " AND (m.titre LIKE '%".$db->escape($search_title)."%')";
198 }
199 if ($search_subject) {
200 $sql .= " AND (m.sujet LIKE '%".$db->escape($search_subject)."%')";
201 }
202 if ($search_messtype) {
203 $sql .= " AND m.messtype LIKE '".$db->escape($search_messtype)."'";
204 }
205 if ($search_all) {
206 $sql .= " AND (m.titre LIKE '%".$db->escape($search_all)."%' OR m.sujet LIKE '%".$db->escape($search_all)."%' OR m.body LIKE '%".$db->escape($search_all)."%')";
207 }
208 if ($search_refproject) {
209 $sql .= natural_search('pr.ref', $search_refproject);
210 }
211 if ($search_project) {
212 $sql .= natural_search('pr.title', $search_project);
213 }
214 if (!$sortorder) {
215 $sortorder = "ASC";
216 }
217 if (!$sortfield) {
218 $sortfield = "m.rowid";
219 }
220} else {
221 $sql = "SELECT m.rowid, m.messtype, m.titre as title, m.sujet as subject, m.nbemail, m.statut as status, m.date_creat as datec, m.date_envoi as date_envoi,";
222 $sql .= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label";
223
224 $sqlfields = $sql; // $sql fields to remove for count total
225
226 $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
227 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = m.fk_project";
228 $sql .= " WHERE m.entity = ".((int) $conf->entity);
229 if ($search_ref) {
230 $sql .= natural_search("m.rowid", $search_ref, 1);
231 }
232 if ($search_title) {
233 $sql .= " AND m.titre LIKE '%".$db->escape($search_title)."%'";
234 }
235 if ($search_subject) {
236 $sql .= " AND m.sujet LIKE '%".$db->escape($search_subject)."%'";
237 }
238 if ($search_messtype) {
239 $sql .= " AND m.messtype LIKE '%".$db->escape($search_messtype)."%'";
240 }
241 if ($search_all) {
242 $sql .= " AND (m.titre LIKE '%".$db->escape($search_all)."%' OR m.sujet LIKE '%".$db->escape($search_all)."%' OR m.body LIKE '%".$db->escape($search_all)."%')";
243 }
244 if ($search_refproject) {
245 $sql .= natural_search('pr.ref', $search_refproject);
246 }
247 if ($search_project) {
248 $sql .= natural_search('pr.title', $search_project);
249 }
250 if (!$sortorder) {
251 $sortorder = "ASC";
252 }
253 if (!$sortfield) {
254 $sortfield = "m.rowid";
255 }
256}
257if ($search_all) {
258 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
259}
260//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
261// Add where from extra fields
262include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
263// Add where from hooks
264$parameters = array();
265$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
266$sql .= $hookmanager->resPrint;
267
268// Count total nb of records
269$nbtotalofrecords = '';
270if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
271 /* The fast and low memory method to get and count full list converts the sql into a sql count */
272 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
273 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
274 $resql = $db->query($sqlforcount);
275 if ($resql) {
276 $objforcount = $db->fetch_object($resql);
277 $nbtotalofrecords = $objforcount->nbtotalofrecords;
278 } else {
279 dol_print_error($db);
280 }
281
282 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
283 $page = 0;
284 $offset = 0;
285 }
286 $db->free($resql);
287}
288
289// Complete request and execute it with limit
290$sql .= $db->order($sortfield, $sortorder);
291if ($limit) {
292 $sql .= $db->plimit($limit + 1, $offset);
293}
294
295$resql = $db->query($sql);
296if (!$resql) {
297 dol_print_error($db);
298 exit;
299}
300
301$num = $db->num_rows($resql);
302
303
304// Direct jump if only one record found
305if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
306 $obj = $db->fetch_object($resql);
307 $id = $obj->rowid;
308 header("Location: ".dol_buildpath('/comm/mailing/card.php', 1).'?id='.((int) $id));
309 exit;
310}
311
312
313// Output page
314// --------------------------------------------------------------------
315
316$title = $langs->trans("EMailings");
317if ($filteremail) {
318 $title .= ' ('.$langs->trans("SentTo", $filteremail).')';
319}
320
321llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist');
322
323$arrayofselected = is_array($toselect) ? $toselect : array();
324
325$param = "&search_all=".urlencode($search_all);
326if (!empty($mode)) {
327 $param .= '&mode='.urlencode($mode);
328}
329if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
330 $param .= '&contextpage='.urlencode($contextpage);
331}
332if ($limit > 0 && $limit != $conf->liste_limit) {
333 $param .= '&limit='.((int) $limit);
334}
335if ($optioncss != '') {
336 $param .= '&optioncss='.urlencode($optioncss);
337}
338if ($search_ref != '') {
339 $param .= '&search_ref='.urlencode($search_ref);
340}
341if ($search_messtype != '') {
342 $param .= '&search_type='.urlencode($search_messtype);
343}
344if ($search_refproject != '') {
345 $param .= '&search_refproject='.urlencode($search_refproject);
346}
347if ($search_project != '') {
348 $param .= '&search_project='.urlencode($search_project);
349}
350if ($optioncss != '') {
351 $param .= '&optioncss='.urlencode($optioncss);
352}
353
354if ($filteremail) {
355 $param .= '&filteremail='.urlencode($filteremail);
356}
357// Add $param from extra fields
358include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
359// Add $param from hooks
360$parameters = array('param' => &$param);
361$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
362$param .= $hookmanager->resPrint;
363
364// List of mass actions available
365$arrayofmassactions = array(
366 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
367 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
368 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
369 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
370);
371if (!empty($permissiontodelete)) {
372 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
373}
374if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
375 $arrayofmassactions = array();
376}
377$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
378
379print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
380if ($optioncss != '') {
381 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
382}
383print '<input type="hidden" name="token" value="'.newToken().'">';
384print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
385print '<input type="hidden" name="action" value="list">';
386print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
387print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
388print '<input type="hidden" name="page" value="'.$page.'">';
389print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
390print '<input type="hidden" name="page_y" value="">';
391print '<input type="hidden" name="mode" value="'.$mode.'">';
392
393$newcardbutton = '';
394if ($user->hasRight('mailing', 'creer')) {
395 $newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create');
396}
397
398print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_email', 0, $newcardbutton, '', $limit, 0, 0, 1);
399
400// Add code for pre mass action (confirmation or email presend form)
401$topicmail = "SendMailingRef";
402$modelmail = "mailing";
403$objecttmp = new Mailing($db);
404$trackid = 'mailing'.$object->id;
405include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
406
407if ($search_all) {
408 $setupstring = '';
409 foreach ($fieldstosearchall as $key => $val) {
410 $fieldstosearchall[$key] = $langs->trans($val);
411 $setupstring .= $key."=".$val.";";
412 }
413 print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
414 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
415}
416
417$moreforfilter = '';
418
419$parameters = array();
420$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
421if (empty($reshook)) {
422 $moreforfilter .= $hookmanager->resPrint;
423} else {
424 $moreforfilter = $hookmanager->resPrint;
425}
426
427if (!empty($moreforfilter)) {
428 print '<div class="liste_titre liste_titre_bydiv centpercent">';
429 print $moreforfilter;
430 print '</div>';
431}
432
433$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
434$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
435$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
436
437print '<div class="div-table-responsive">';
438print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
439
440// Fields title search
441// --------------------------------------------------------------------
442print '<tr class="liste_titre_filter">';
443// Action column
444if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
445 print '<td class="liste_titre maxwidthsearch center">';
446 $searchpicto = $form->showFilterButtons('left');
447 print $searchpicto;
448 print '</td>';
449}
450print '<td class="liste_titre">';
451print '<input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
452print '</td>';
453// Message type
454if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
455 print '<td class="liste_titre">';
456 print '<input type="text" class="flat maxwidth50" name="search_messtype" value="'.dol_escape_htmltag($search_messtype).'">';
457 print '</td>';
458}
459// Title
460print '<td class="liste_titre">';
461print '<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_title" value="'.dol_escape_htmltag($search_title).'">';
462print '</td>';
463// Subject
464print '<td class="liste_titre">';
465print '<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_subject" value="'.dol_escape_htmltag($search_subject).'">';
466print '</td>';
467// Creation date
468print '<td class="liste_titre">&nbsp;</td>';
469
470// Project
471print '<td class="liste_titre">';
472print '<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_project" value="'.dol_escape_htmltag($search_project).'">';
473print '</td>';
474
475if (!$filteremail) {
476 print '<td class="liste_titre">&nbsp;</td>';
477}
478print '<td class="liste_titre">&nbsp;</td>';
479print '<td class="liste_titre">&nbsp;</td>';
480// Extra fields
481include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
482// Fields from hook
483$parameters = array('arrayfields' => $arrayfields);
484$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // 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 center 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 $totalarray['nbfield']++;
504}
505print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "m.rowid", "", $param, "", $sortfield, $sortorder);
506$totalarray['nbfield']++;
507// Message type
508if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
509 print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "m.messtype", "", $param, "", $sortfield, $sortorder);
510 $totalarray['nbfield']++;
511}
512print_liste_field_titre("Title", $_SERVER["PHP_SELF"], "m.titre", "", $param, "", $sortfield, $sortorder);
513$totalarray['nbfield']++;
514print_liste_field_titre("Subject", $_SERVER["PHP_SELF"], "m.sujet", "", $param, "", $sortfield, $sortorder);
515$totalarray['nbfield']++;
516print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "m.date_creat", "", $param, '', $sortfield, $sortorder, 'center ');
517$totalarray['nbfield']++;
518
519// Project
520print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "project_label", "", $param, '', $sortfield, $sortorder);
521$totalarray['nbfield']++;
522
523if (!$filteremail) {
524 $title = $langs->trans("NbOfEMails");
525 if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
526 $title .= ' | '.$langs->trans("SMS");
527 }
528 print_liste_field_titre($title, $_SERVER["PHP_SELF"], "m.nbemail", "", $param, '', $sortfield, $sortorder, 'center ');
529 $totalarray['nbfield']++;
530}
531if (!$filteremail) {
532 print_liste_field_titre("DateLastSend", $_SERVER["PHP_SELF"], "m.date_envoi", "", $param, '', $sortfield, $sortorder, 'center ');
533 $totalarray['nbfield']++;
534} else {
535 print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", "", $param, '', $sortfield, $sortorder, 'center ');
536 $totalarray['nbfield']++;
537}
538// Extra fields
539include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
540// Hook fields
541$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
542$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
543print $hookmanager->resPrint;
544print_liste_field_titre("Status", $_SERVER["PHP_SELF"], ($filteremail ? "mc.statut" : "m.statut"), "", $param, '', $sortfield, $sortorder, 'center ');
545$totalarray['nbfield']++;
546// Action column
547if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
548 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
549 $totalarray['nbfield']++;
550}
551print '</tr>'."\n";
552
553// Loop on record
554// --------------------------------------------------------------------
555$i = 0;
556$savnbfield = $totalarray['nbfield'];
557$totalarray = array();
558$totalarray['nbfield'] = 0;
559$imaxinloop = ($limit ? min($num, $limit) : $num);
560while ($i < $imaxinloop) {
561 $obj = $db->fetch_object($resql);
562 if (empty($obj)) {
563 break; // Should not happen
564 }
565
566 $object->id = $obj->rowid;
567 $object->ref = $obj->rowid;
568
569 $projectstatic->id = $obj->project_id;
570 $projectstatic->ref = $obj->project_ref;
571 $projectstatic->title = $obj->project_label;
572
573 // Show here line of result
574 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
575 // Action column
576 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
577 print '<td class="nowrap center">';
578 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
579 $selected = 0;
580 if (in_array($object->id, $arrayofselected)) {
581 $selected = 1;
582 }
583 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
584 }
585 print '</td>';
586 if (!$i) {
587 $totalarray['nbfield']++;
588 }
589 }
590
591 // Ref
592 print '<td>';
593 print $object->getNomUrl(1);
594 print '</td>';
595 if (!$i) {
596 $totalarray['nbfield']++;
597 }
598
599 // Message type
600 if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
601 print '<td>';
602 print dol_escape_htmltag($obj->messtype);
603 print '</td>';
604 if (!$i) {
605 $totalarray['nbfield']++;
606 }
607 }
608
609 // Title
610 print '<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($obj->title).'">';
611 $savref = $object->ref;
612 $object->ref = $obj->title;
613 print $object->getNomUrl(0);
614 $object->ref = $savref;
615 print '</td>';
616 if (!$i) {
617 $totalarray['nbfield']++;
618 }
619
620 // Topic
621 print '<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($obj->subject).'">';
622 print $obj->subject;
623 print '</td>';
624 if (!$i) {
625 $totalarray['nbfield']++;
626 }
627
628 // Date creation
629 print '<td class="center">';
630 print dol_print_date($db->jdate($obj->datec), 'day');
631 print '</td>';
632 if (!$i) {
633 $totalarray['nbfield']++;
634 }
635
636 // Project
637 print '<td class="nowraponall">';
638 print '<a href="/projet/card.php?id='.((int) $projectstatic->id).'">'.dol_escape_htmltag($projectstatic->title).'</a>';
639 print '</td>';
640 if (!$i) {
641 $totalarray['nbfield']++;
642 }
643
644 // Nb of email
645 if (!$filteremail) {
646 print '<td class="center nowraponall">';
647 $nbemail = $obj->nbemail;
648 /*if ($obj->status != 3 && !empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail)
649 {
650 $text=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB);
651 print $form->textwithpicto($nbemail,$text,1,'warning');
652 }
653 else
654 {
655 print $nbemail;
656 }*/
657 print $nbemail;
658 print '</td>';
659 if (!$i) {
660 $totalarray['nbfield']++;
661 }
662 }
663
664 // Last send
665 print '<td class="nowrap center">'.dol_print_date($db->jdate($obj->date_envoi), 'day').'</td>';
666 print '</td>';
667 if (!$i) {
668 $totalarray['nbfield']++;
669 }
670
671 // Status
672 print '<td class="nowrap center">';
673 if ($filteremail) {
674 print $object::libStatutDest($obj->sendstatut, 2);
675 } else {
676 print $object->LibStatut($obj->status, 5);
677 }
678 print '</td>';
679 if (!$i) {
680 $totalarray['nbfield']++;
681 }
682
683 // Action column
684 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
685 print '<td class="nowrap center">';
686 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
687 $selected = 0;
688 if (in_array($object->id, $arrayofselected)) {
689 $selected = 1;
690 }
691 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
692 }
693 print '</td>';
694 if (!$i) {
695 $totalarray['nbfield']++;
696 }
697 }
698
699 print '</tr>'."\n";
700
701 $i++;
702}
703
704// Show total line
705include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
706
707// If no record found
708if (empty($num)) {
709 $colspan = $savnbfield;
710 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
711}
712
713
714$db->free($resql);
715
716$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
717$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
718print $hookmanager->resPrint;
719
720print '</table>'."\n";
721print '</div>'."\n";
722
723print '</form>'."\n";
724
725// End of page
726llxFooter();
727$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 export.php:1216
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 to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class to manage emailings module.
Class to manage projects.
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show 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, $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)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
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.
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_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.