dolibarr 24.0.0-beta
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-2026 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';
40require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
41require_once DOL_DOCUMENT_ROOT .'/projet/class/project.class.php';
42include_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
43
44// Load translation files required by the page
45$langs->load('mails');
46
47// Get Parameters
48$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
49$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
50$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
51$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
52$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
53$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
54$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
55$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
56$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
57$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
58$projectid = GETPOSTINT('projectid');
59
60// Load variable for pagination
61$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
62$sortfield = GETPOST('sortfield', 'aZ09comma');
63$sortorder = GETPOST('sortorder', 'aZ09comma');
64$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
65if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
66 // If $page is not defined, or '' or -1 or if we click on clear filters
67 $page = 0;
68}
69$offset = $limit * $page;
70$pageprev = $page - 1;
71$pagenext = $page + 1;
72
73// Search Fields
74$search_all = trim(GETPOST('search_all', 'alphanohtml'));
75$search_ref = GETPOST("search_ref", "alpha") ? GETPOST("search_ref", "alpha") : GETPOST("sref", "alpha");
76$search_title = GETPOST("search_title", "alpha");
77$search_subject = GETPOST("search_subject", "alpha");
78$search_messtype = GETPOST("search_messtype", "alpha");
79$filteremail = GETPOST('filteremail', 'alpha');
80
81$search_refproject = GETPOST('search_refproject', 'alpha');
82$search_project = GETPOST('search_project', 'alpha');
83
84// Initialize a technical objects
85$object = new Mailing($db);
86if ($projectid > 0) {
87 $hookmanager->initHooks(array('projectmailing', 'globalcard'));
88} else {
89 $hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes
90}
91
92
93// Fetch optionals attributes and labels
94$extrafields->fetch_name_optionals_label($object->table_element);
95
96$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
97
98// Default sort order (if not yet defined by previous GETPOST)
99if (!$sortorder) {
100 $sortorder = "DESC";
101}
102if (!$sortfield) {
103 $sortfield = "m.date_creat";
104}
105
106// List of fields to search into when doing a "search in all"
107$fieldstosearchall = array(
108 'm.titre' => 'Ref',
109);
110
111$permissiontoread = $user->hasRight('mailing', 'lire');
112$permissiontoadd = $user->hasRight('mailing', 'creer');
113$permissiontodelete = $user->hasRight('mailing', 'delete');
114
115// Security check
116if (!$user->hasRight('mailing', 'lire') || (!getDolGlobalString('EXTERNAL_USERS_ARE_AUTHORIZED') && $user->socid > 0)) {
118}
119//restrictedArea($user, 'mailing');
120
121/*
122 * Actions
123 */
124
125if (GETPOST('cancel', 'alpha')) {
126 $action = 'list';
127 $massaction = '';
128}
129if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
130 $massaction = '';
131}
132
133$parameters = array();
134if ($projectid > 0) {
135 $parameters['projectid'] = $projectid;
136}
137$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
138if ($reshook < 0) {
139 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
140}
141
142if (empty($reshook)) {
143 // Selection of new fields
144 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
145
146 // Purge search criteria
147 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
148 /*foreach($object->fields as $key => $val)
149 {
150 $search[$key]='';
151 }*/
152 $search_ref = '';
153 $search_title = '';
154 $search_subject = '';
155 $search_messtype = '';
156 $search_refproject = '';
157 $search_project = '';
158 $search_all = '';
159 $toselect = array();
160 $search_array_options = array();
161 }
162 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
163 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
164 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
165 }
166
167 // Mass actions
168 $objectclass = 'Mailing';
169 $objectlabel = 'Mailing';
170 $uploaddir = $conf->mailing->dir_output;
171 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
172}
173
174
175/*
176 * View
177 */
178
179$form = new Form($db);
180$projectstatic = new Project($db);
181
182$now = dol_now();
183
184$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing';
185$title = $langs->trans("Mailing");
186$morejs = array();
187$morecss = array();
188
189// Build and execute select
190// --------------------------------------------------------------------
191if ($filteremail) {
192 $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,";
193 $sql .= " mc.statut as sendstatut,";
194 $sql .= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label";
195
196 $sqlfields = $sql; // $sql fields to remove for count total
197
198 $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc";
199 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = m.fk_project";
200 $sql .= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity;
201 $sql .= " AND mc.email = '".$db->escape($filteremail)."'";
202 if ($search_ref) {
203 $sql .= natural_search("m.rowid", $search_ref, 1);
204 }
205 if ($search_title) {
206 $sql .= " AND (m.titre LIKE '%".$db->escape($search_title)."%')";
207 }
208 if ($search_subject) {
209 $sql .= " AND (m.sujet LIKE '%".$db->escape($search_subject)."%')";
210 }
211 if ($search_messtype) {
212 $sql .= " AND m.messtype LIKE '".$db->escape($search_messtype)."'";
213 }
214 if ($search_all) {
215 $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)."%')";
216 }
217 if ($projectid) {
218 $sql .= " AND pr.rowid = ".((int) $projectid)." ";
219 }
220 if ($search_refproject) {
221 $sql .= natural_search('pr.ref', $search_refproject);
222 }
223 if ($search_project) {
224 $sql .= natural_search('pr.title', $search_project);
225 }
226 if (!$sortorder) {
227 $sortorder = "ASC";
228 }
229 if (!$sortfield) {
230 $sortfield = "m.rowid";
231 }
232} else {
233 $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,";
234 $sql .= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label";
235
236 $sqlfields = $sql; // $sql fields to remove for count total
237
238 $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
239 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = m.fk_project";
240 $sql .= " WHERE m.entity = ".((int) $conf->entity);
241 if ($search_ref) {
242 $sql .= natural_search("m.rowid", $search_ref, 1);
243 }
244 if ($search_title) {
245 $sql .= " AND m.titre LIKE '%".$db->escape($search_title)."%'";
246 }
247 if ($search_subject) {
248 $sql .= " AND m.sujet LIKE '%".$db->escape($search_subject)."%'";
249 }
250 if ($search_messtype) {
251 $sql .= " AND m.messtype LIKE '%".$db->escape($search_messtype)."%'";
252 }
253 if ($search_all) {
254 $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)."%')";
255 }
256 if ($projectid) {
257 $sql .= " AND pr.rowid = ".((int) $projectid)." ";
258 }
259 if ($search_refproject) {
260 $sql .= natural_search('pr.ref', $search_refproject);
261 }
262 if ($search_project) {
263 $sql .= natural_search('pr.title', $search_project);
264 }
265 if (!$sortorder) {
266 $sortorder = "ASC";
267 }
268 if (!$sortfield) {
269 $sortfield = "m.rowid";
270 }
271}
272if ($search_all) {
273 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
274}
275//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
276// Add where from extra fields
277include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
278// Add where from hooks
279$parameters = array();
280$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
281$sql .= $hookmanager->resPrint;
282
283// Count total nb of records
284$nbtotalofrecords = '';
285if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
286 /* The fast and low memory method to get and count full list converts the sql into a sql count */
287 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
288 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
289 $resql = $db->query($sqlforcount);
290 if ($resql) {
291 $objforcount = $db->fetch_object($resql);
292 $nbtotalofrecords = $objforcount->nbtotalofrecords;
293 } else {
295 }
296
297 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
298 $page = 0;
299 $offset = 0;
300 }
301 $db->free($resql);
302}
303
304// Complete request and execute it with limit
305$sql .= $db->order($sortfield, $sortorder);
306if ($limit) {
307 $sql .= $db->plimit($limit + 1, $offset);
308}
309
310$resql = $db->query($sql);
311if (!$resql) {
313 exit;
314}
315
316$num = $db->num_rows($resql);
317
318
319// Direct jump if only one record found
320if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
321 $obj = $db->fetch_object($resql);
322 $id = $obj->rowid;
323 header("Location: ".dol_buildpath('/comm/mailing/card.php', 1).'?id='.((int) $id));
324 exit;
325}
326
327
328// Output page
329// --------------------------------------------------------------------
330
331$title = $langs->trans("EMailings");
332if ($filteremail) {
333 $title .= ' ('.$langs->trans("SentTo", $filteremail).')';
334}
335
336llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist');
337
338if ($projectid > 0) {
339 $projectstat = new Project($db);
340 if ($projectstat->fetch($projectid) > 0) {
341 $projectid = $projectstat->id;
342 $projectstat->fetch_thirdparty();
343
344 $savobject = $object;
345 $object = $projectstat;
346
347 // To verify role of users
348 //$userAccess = $object->restrictedProjectArea($user,'read');
349 $userWrite = $projectstat->restrictedProjectArea($user, 'write');
350 //$userDelete = $object->restrictedProjectArea($user,'delete');
351 //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
352
353 $head = project_prepare_head($projectstat);
354 print dol_get_fiche_head($head, 'mailing', $langs->trans("Project"), -1, ($projectstat->public ? 'projectpub' : 'project'));
355
356 // Project card
357
358 $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
359
360 $morehtmlref = '<div class="refidno">';
361 // Title
362 $morehtmlref .= $object->title;
363 // Thirdparty
364 if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
365 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'project');
366 }
367 $morehtmlref .= '</div>';
368
369 // Define a complementary filter for search of next/prev ref.
370 if (!$user->hasRight('projet', 'all', 'lire')) {
371 $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
372 $object->next_prev_filter = "rowid:IN:".$db->sanitize(count($objectsListId) ? implode(',', array_keys($objectsListId)) : '0');
373 }
374
375 dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
376
377 print '<div class="fichecenter">';
378 print '<div class="underbanner clearboth"></div>';
379
380 print '<table class="border tableforfield centpercent">';
381
382 // Visibility
383 print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
384 if ($projectstat->public) {
385 print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
386 print $langs->trans('SharedProject');
387 } else {
388 print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
389 print $langs->trans('PrivateProject');
390 }
391 print '</td></tr>';
392
393 print "</table>";
394
395 print '</div>';
396 print dol_get_fiche_end();
397
398 print '<br>';
399
400 $object = $savobject;
401 } else {
402 print "ErrorRecordNotFound";
403 }
404}
405
406$arrayofselected = is_array($toselect) ? $toselect : array();
407
408$param = "&search_all=".urlencode($search_all);
409if (!empty($mode)) {
410 $param .= '&mode='.urlencode($mode);
411}
412if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
413 $param .= '&contextpage='.urlencode($contextpage);
414}
415if ($limit > 0 && $limit != $conf->liste_limit) {
416 $param .= '&limit='.((int) $limit);
417}
418if ($optioncss != '') {
419 $param .= '&optioncss='.urlencode($optioncss);
420}
421if ($search_ref != '') {
422 $param .= '&search_ref='.urlencode($search_ref);
423}
424if ($search_messtype != '') {
425 $param .= '&search_type='.urlencode($search_messtype);
426}
427if ($search_refproject != '') {
428 $param .= '&search_refproject='.urlencode($search_refproject);
429}
430if ($search_project != '') {
431 $param .= '&search_project='.urlencode($search_project);
432}
433if ($optioncss != '') {
434 $param .= '&optioncss='.urlencode($optioncss);
435}
436if ($projectid > 0) {
437 $param .= '&projectid='.urlencode((string) ($projectid));
438}
439if ($filteremail) {
440 $param .= '&filteremail='.urlencode($filteremail);
441}
442// Add $param from extra fields
443include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
444// Add $param from hooks
445$parameters = array('param' => &$param);
446$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
447$param .= $hookmanager->resPrint;
448
449// List of mass actions available
450$arrayofmassactions = array(
451 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
452 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
453 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
454 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
455);
456if (!empty($permissiontodelete)) {
457 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
458}
459if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
460 $arrayofmassactions = array();
461}
462$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
463
464print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
465if ($optioncss != '') {
466 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
467}
468print '<input type="hidden" name="token" value="'.newToken().'">';
469print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
470print '<input type="hidden" name="action" value="list">';
471print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
472print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
473print '<input type="hidden" name="page" value="'.$page.'">';
474print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
475print '<input type="hidden" name="page_y" value="">';
476print '<input type="hidden" name="mode" value="'.$mode.'">';
477
478if ($projectid) {
479 print '<input type="hidden" name="projectid" value="'.$projectid.'" >';
480}
481
482$url = DOL_URL_ROOT.'/comm/mailing/card.php?action=create'.($projectid ? '&origin=project&originid='.$projectid : '');
483
484$newcardbutton = '';
485if ($user->hasRight('mailing', 'creer')) {
486 $newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', $url);
487}
488
489print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
490
491// Add code for pre mass action (confirmation or email presend form)
492$topicmail = "SendMailingRef";
493$modelmail = "mailing";
494$objecttmp = new Mailing($db);
495$trackid = 'mailing'.$object->id;
496include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
497
498if ($search_all) {
499 $setupstring = '';
500 foreach ($fieldstosearchall as $key => $val) {
501 $fieldstosearchall[$key] = $langs->trans($val);
502 $setupstring .= $key."=".$val.";";
503 }
504 print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
505 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
506}
507
508$moreforfilter = '';
509
510$parameters = array();
511$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
512if (empty($reshook)) {
513 $moreforfilter .= $hookmanager->resPrint;
514} else {
515 $moreforfilter = $hookmanager->resPrint;
516}
517
518if (!empty($moreforfilter)) {
519 print '<div class="liste_titre liste_titre_bydiv centpercent">';
520 print $moreforfilter;
521 print '</div>';
522}
523
524$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
525$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields
526$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
527
528print '<div class="div-table-responsive">';
529print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
530
531// Fields title search
532// --------------------------------------------------------------------
533print '<tr class="liste_titre_filter">';
534// Action column
535if ($conf->main_checkbox_left_column) {
536 print '<td class="liste_titre maxwidthsearch center">';
537 $searchpicto = $form->showFilterButtons('left');
538 print $searchpicto;
539 print '</td>';
540}
541print '<td class="liste_titre">';
542print '<input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
543print '</td>';
544// Message type
545if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
546 print '<td class="liste_titre">';
547 print '<input type="text" class="flat maxwidth50" name="search_messtype" value="'.dol_escape_htmltag($search_messtype).'">';
548 print '</td>';
549}
550// Title
551print '<td class="liste_titre">';
552print '<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_title" value="'.dol_escape_htmltag($search_title).'">';
553print '</td>';
554// Subject
555print '<td class="liste_titre">';
556print '<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_subject" value="'.dol_escape_htmltag($search_subject).'">';
557print '</td>';
558// Creation date
559print '<td class="liste_titre">&nbsp;</td>';
560
561// Project
562print '<td class="liste_titre">';
563print '<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_project" value="'.dol_escape_htmltag($search_project).'">';
564print '</td>';
565
566if (!$filteremail) {
567 print '<td class="liste_titre">&nbsp;</td>';
568}
569print '<td class="liste_titre">&nbsp;</td>';
570print '<td class="liste_titre">&nbsp;</td>';
571// Extra fields
572include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
573// Fields from hook
574$parameters = array('arrayfields' => $arrayfields);
575$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
576print $hookmanager->resPrint;
577// Action column
578if (!$conf->main_checkbox_left_column) {
579 print '<td class="liste_titre center maxwidthsearch">';
580 $searchpicto = $form->showFilterButtons();
581 print $searchpicto;
582 print '</td>';
583}
584print '</tr>'."\n";
585
586$totalarray = array();
587$totalarray['nbfield'] = 0;
588
589// Fields title label
590// --------------------------------------------------------------------
591print '<tr class="liste_titre">';
592if ($conf->main_checkbox_left_column) {
593 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
594 $totalarray['nbfield']++;
595}
596print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "m.rowid", "", $param, "", $sortfield, $sortorder);
597$totalarray['nbfield']++;
598// Message type
599if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
600 print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "m.messtype", "", $param, "", $sortfield, $sortorder);
601 $totalarray['nbfield']++;
602}
603print_liste_field_titre("Title", $_SERVER["PHP_SELF"], "m.titre", "", $param, "", $sortfield, $sortorder);
604$totalarray['nbfield']++;
605print_liste_field_titre("Subject", $_SERVER["PHP_SELF"], "m.sujet", "", $param, "", $sortfield, $sortorder);
606$totalarray['nbfield']++;
607print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "m.date_creat", "", $param, '', $sortfield, $sortorder, 'center ');
608$totalarray['nbfield']++;
609
610// Project
611print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "project_label", "", $param, '', $sortfield, $sortorder);
612$totalarray['nbfield']++;
613
614if (!$filteremail) {
615 $title = $langs->trans("NbOfEMails");
616 if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
617 $title .= ' | '.$langs->trans("SMS");
618 }
619 print_liste_field_titre($title, $_SERVER["PHP_SELF"], "m.nbemail", "", $param, '', $sortfield, $sortorder, 'center ');
620 $totalarray['nbfield']++;
621}
622if (!$filteremail) {
623 print_liste_field_titre("DateLastSend", $_SERVER["PHP_SELF"], "m.date_envoi", "", $param, '', $sortfield, $sortorder, 'center ');
624 $totalarray['nbfield']++;
625} else {
626 print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", "", $param, '', $sortfield, $sortorder, 'center ');
627 $totalarray['nbfield']++;
628}
629// Extra fields
630include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
631// Hook fields
632$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
633$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
634print $hookmanager->resPrint;
635print_liste_field_titre("Status", $_SERVER["PHP_SELF"], ($filteremail ? "mc.statut" : "m.statut"), "", $param, '', $sortfield, $sortorder, 'center ');
636$totalarray['nbfield']++;
637// Action column
638if (!$conf->main_checkbox_left_column) {
639 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
640 $totalarray['nbfield']++;
641}
642print '</tr>'."\n";
643
644// Loop on record
645// --------------------------------------------------------------------
646$i = 0;
647$savnbfield = $totalarray['nbfield'];
648$totalarray = array();
649$totalarray['nbfield'] = 0;
650$imaxinloop = ($limit ? min($num, $limit) : $num);
651while ($i < $imaxinloop) {
652 $obj = $db->fetch_object($resql);
653 if (empty($obj)) {
654 break; // Should not happen
655 }
656
657 $object->id = $obj->rowid;
658 $object->ref = $obj->rowid;
659
660 $projectstatic->id = $obj->project_id;
661 $projectstatic->ref = $obj->project_ref;
662 $projectstatic->title = $obj->project_label;
663
664 // Show here line of result
665 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
666 // Action column
667 if ($conf->main_checkbox_left_column) {
668 print '<td class="nowrap center">';
669 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
670 $selected = 0;
671 if (in_array($object->id, $arrayofselected)) {
672 $selected = 1;
673 }
674 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
675 }
676 print '</td>';
677 if (!$i) {
678 $totalarray['nbfield']++;
679 }
680 }
681
682 // Ref
683 print '<td>';
684 print $object->getNomUrl(1);
685 print '</td>';
686 if (!$i) {
687 $totalarray['nbfield']++;
688 }
689
690 // Message type
691 if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
692 print '<td>';
693 print dol_escape_htmltag($obj->messtype);
694 print '</td>';
695 if (!$i) {
696 $totalarray['nbfield']++;
697 }
698 }
699
700 // Title
701 print '<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($obj->title).'">';
702 $savref = $object->ref;
703 $object->ref = $obj->title;
704 print $object->getNomUrl(0);
705 $object->ref = $savref;
706 print '</td>';
707 if (!$i) {
708 $totalarray['nbfield']++;
709 }
710
711 // Topic
712 print '<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($obj->subject).'">';
713 print $obj->subject;
714 print '</td>';
715 if (!$i) {
716 $totalarray['nbfield']++;
717 }
718
719 // Date creation
720 print '<td class="center">';
721 print dol_print_date($db->jdate($obj->datec), 'day');
722 print '</td>';
723 if (!$i) {
724 $totalarray['nbfield']++;
725 }
726
727 // Project
728 print '<td class="nowraponall">';
729 print '<a href="/projet/card.php?id='.((int) $projectstatic->id).'">'.dol_escape_htmltag($projectstatic->title).'</a>';
730 print '</td>';
731 if (!$i) {
732 $totalarray['nbfield']++;
733 }
734
735 // Nb of email
736 if (!$filteremail) {
737 print '<td class="center nowraponall">';
738 $nbemail = $obj->nbemail;
739 /*if ($obj->status != 3 && !empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail)
740 {
741 $text=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB);
742 print $form->textwithpicto($nbemail,$text,1,'warning');
743 }
744 else
745 {
746 print $nbemail;
747 }*/
748 print $nbemail;
749 print '</td>';
750 if (!$i) {
751 $totalarray['nbfield']++;
752 }
753 }
754
755 // Last send
756 print '<td class="nowrap center">'.dol_print_date($db->jdate($obj->date_envoi), 'day').'</td>';
757 print '</td>';
758 if (!$i) {
759 $totalarray['nbfield']++;
760 }
761
762 // Status
763 print '<td class="nowrap center">';
764 if ($filteremail) {
765 print $object::libStatutDest($obj->sendstatut, 2);
766 } else {
767 print $object->LibStatut($obj->status, 5);
768 }
769 print '</td>';
770 if (!$i) {
771 $totalarray['nbfield']++;
772 }
773
774 // Action column
775 if (!$conf->main_checkbox_left_column) {
776 print '<td class="nowrap center">';
777 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
778 $selected = 0;
779 if (in_array($object->id, $arrayofselected)) {
780 $selected = 1;
781 }
782 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
783 }
784 print '</td>';
785 if (!$i) {
786 $totalarray['nbfield']++;
787 }
788 }
789
790 print '</tr>'."\n";
791
792 $i++;
793}
794
795// Show total line
796include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
797
798// If no record found
799if (empty($num)) {
800 $colspan = $savnbfield;
801 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
802}
803
804
805$db->free($resql);
806
807$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
808$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
809print $hookmanager->resPrint;
810
811print '</table>'."\n";
812print '</div>'."\n";
813
814print '</form>'."\n";
815
816// End of page
817llxFooter();
818$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:497
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 generation of HTML components Only common components must be here.
Class to manage emailings module.
Class to manage projects.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_now($mode='gmt')
Return date for now.
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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...
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.