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