dolibarr 25.0.0-alpha
targetemailing.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2024 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
6 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
7 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
39require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmailing.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
45
46// Load translation files required by the page
47$langs->loadLangs(array("mails", "admin"));
48
49$action = GETPOST('action', 'aZ09');
50$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
51$contextpage = GETPOST('contextpage', 'aZ');
52$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
53$mode = GETPOST('mode', 'aZ'); // The display mode ('list', 'kanban', 'hierarchy', 'calendar', 'gantt', ...)
54
55// Load variable for pagination
56$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
57$sortfield = GETPOST('sortfield', 'aZ09comma');
58$sortorder = GETPOST('sortorder', 'aZ09comma');
59$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
60if (empty($page) || $page == -1) {
61 $page = 0;
62} // If $page is not defined, or '' or -1
63$offset = $limit * $page;
64$pageprev = $page - 1;
65$pagenext = $page + 1;
66if (!$sortfield) {
67 $sortfield = "mc.statut,email";
68}
69if (!$sortorder) {
70 $sortorder = "DESC,ASC";
71}
72
73$id = GETPOSTINT('id');
74$rowid = GETPOSTINT('rowid');
75$search_lastname = GETPOST("search_lastname", 'alphanohtml');
76$search_firstname = GETPOST("search_firstname", 'alphanohtml');
77$search_email = GETPOST("search_email", 'alphanohtml');
78$search_other = GETPOST("search_other", 'alphanohtml');
79$search_dest_status = GETPOST('search_dest_status', 'int');
80
81// Search modules dirs
82$modulesdir = dolGetModulesDirs('/mailings');
83
84$object = new Mailing($db);
85$result = $object->fetch($id);
86
87// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
88$hookmanager->initHooks(array('ciblescard', 'globalcard'));
89
90$sqlmessage = '';
91$mesgs = array();
92
93// List of sending methods
94$listofmethods = array();
95//$listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup');
96$listofmethods['mail'] = 'PHP mail function';
97//$listofmethods['simplemail']='Simplemail class';
98$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
99if (version_compare(phpversion(), '7.0', '>=')) {
100 $listofmethods['swiftmailer'] = 'Swift Mailer socket library';
101}
102
103$arrayfields = array();
104
105// Security check
106if (!$user->hasRight('mailing', 'lire') || (!getDolGlobalString('EXTERNAL_USERS_ARE_AUTHORIZED') && $user->socid > 0)) {
108}
109if (empty($action) && empty($object->id)) {
110 accessforbidden('Object not found');
111}
112
113$permissiontoread = $user->hasRight('mailing', 'lire');
114$permissiontocreate = $user->hasRight('mailing', 'creer');
115$permissiontovalidatesend = $user->hasRight('mailing', 'valider');
116$permissiontodelete = $user->hasRight('mailing', 'supprimer');
117
118
119/*
120 * Actions
121 */
122if (GETPOST('cancel', 'alpha')) {
123 $action = 'list';
124 $massaction = '';
125}
126if (!GETPOST('confirmmassaction', 'alpha')) {
127 $massaction = '';
128}
129
130if ($action == 'add' && $permissiontocreate) { // Add recipients
131 $module = GETPOST("module", 'alpha');
132 $result = -1;
133 $obj = null;
134
135 foreach ($modulesdir as $dir) {
136 // Load modules attributes in arrays (name, numero, orders) from dir directory
137 //print $dir."\n<br>";
138 dol_syslog("Scan directory ".$dir." for modules");
139
140 // Loading Class
141 $file = $dir."/".$module.".modules.php";
142 $classname = "mailing_".$module;
143
144 if (file_exists($file)) {
145 include_once $file;
146
147 // Add targets into database
148 dol_syslog("Call add_to_target() on class ".$classname." evenunsubscribe=".$object->evenunsubscribe);
149
150 $obj = null;
151 if (class_exists($classname)) {
152 $obj = new $classname($db);
153 '@phan-var-force MailingTargets $obj';
154 $obj->evenunsubscribe = $object->evenunsubscribe;
155
156 $result = $obj->add_to_target($id);
157
158 $sqlmessage = $obj->sql;
159 } else {
160 $result = -1;
161 break;
162 }
163 }
164 }
165 if ($result > 0) {
166 // If status of emailing is sent completely, change to to send partially
167 if ($object->status == $object::STATUS_SENTCOMPLETELY) {
168 $object->setStatut($object::STATUS_SENTPARTIALY);
169 }
170
171 setEventMessages($langs->trans("XTargetsAdded", $result), null, 'mesgs');
172 $action = '';
173 }
174 if ($result == 0) {
175 setEventMessages($langs->trans("WarningNoEMailsAdded"), null, 'warnings');
176 }
177 if ($result < 0 && is_object($obj)) {
178 setEventMessages($langs->trans("Error").($obj->error ? ' '.$obj->error : ''), null, 'errors');
179 }
180}
181
182if (GETPOSTINT('clearlist') && $permissiontocreate) {
183 // Loading Class
184 $obj = new MailingTargets($db);
185 $obj->clear_target($id);
186 /* Avoid this to allow reposition
187 header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
188 exit;
189 */
190}
191
192if (GETPOSTINT('exportcsv') && $permissiontoread) { // @phpstan-ignore-line
193 $completefilename = 'targets_emailing'.$object->id.'_'.dol_print_date(dol_now(), 'dayhourlog').'.csv';
194 header('Content-Type: text/csv');
195 header('Content-Disposition: attachment;filename='.$completefilename);
196
197 // List of selected targets
198 $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut as status, mc.date_envoi, mc.tms,";
199 $sql .= " mc.source_id, mc.source_type, mc.error_text";
200 $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
201 $sql .= " WHERE mc.fk_mailing = ".((int) $object->id);
202 $sql .= $db->order($sortfield, $sortorder);
203
204 $resql = $db->query($sql);
205 if ($resql) {
206 $num = $db->num_rows($resql);
207 $sep = ',';
208
209 while ($obj = $db->fetch_object($resql)) {
210 print $obj->rowid.$sep;
211 print '"'.$obj->lastname.'"'.$sep;
212 print '"'.$obj->firstname.'"'.$sep;
213 print $obj->email.$sep;
214 print $obj->other.$sep;
215 print $obj->tms.$sep;
216 print $obj->source_type.$sep;
217 print $obj->source_id.$sep;
218 print $obj->date_envoi.$sep;
219 print $obj->status.$sep;
220 print '"'.$obj->error_text.'"'.$sep;
221 print "\n";
222 }
223
224 exit;
225 } else {
227 }
228 exit;
229}
230
231if ($action == 'delete' && $permissiontocreate) {
232 // Ici, rowid indique le destinataire et id le mailing
233 $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid = ".((int) $rowid);
234 $resql = $db->query($sql);
235 if ($resql) {
236 if (!empty($id)) {
237 $obj = new MailingTargets($db);
238 $obj->update_nb($id);
239
240 setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
241 } else {
242 header("Location: list.php");
243 exit;
244 }
245 } else {
247 }
248}
249
250if ($action == "confirm_reset_target" && $permissiontocreate) {
251 if ($object->id > 0) {
252 $db->begin();
253 $nbok = 0;
254 $error = 0;
255 foreach ($toselect as $toselectid) {
256 $result = $object->resetTargetErrorStatus($user, $toselectid);
257 if ($result < 0) {
258 setEventMessages($object->error, $object->errors, 'errors');
259 $error++;
260 break;
261 } elseif ($result > 0) {
262 $nbok++;
263 } else {
264 setEventMessages($object->error, $object->errors, 'errors');
265 $error++;
266 }
267 }
268 if (!$error) {
269 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
270 $db->commit();
271 } else {
272 $db->rollback();
273 }
274 }
275}
276
277// Purge search criteria
278if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
279 $search_lastname = '';
280 $search_firstname = '';
281 $search_email = '';
282 $search_other = '';
283 $search_dest_status = '';
284 $toselect = array();
285}
286
287// Action update description of emailing
288if (($action == 'settitle' || $action == 'setemail_from' || $action == 'setemail_replyto' || $action == 'setemail_errorsto' || $action == 'setevenunsubscribe') && $permissiontocreate) {
289 $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, getDolGlobalInt('MAILING_USE_NEW_PATH_FOR_FILES') ? 0 : 2, 0, 1, $object, 'mailing');
290
291 $mesg = '';
292 if ($action == 'settitle') { // Test on permission already done
293 $object->title = trim(GETPOST('title', 'alpha'));
294 } elseif ($action == 'setemail_from') { // Test on permission already done
295 $object->email_from = trim(GETPOST('email_from', 'alphawithlgt')); // Must allow 'name <email>'
296 } elseif ($action == 'setemail_replyto') { // Test on permission already done
297 $object->email_replyto = trim(GETPOST('email_replyto', 'alphawithlgt')); // Must allow 'name <email>'
298 } elseif ($action == 'setemail_errorsto') { // Test on permission already done
299 $object->email_errorsto = trim(GETPOST('email_errorsto', 'alphawithlgt')); // Must allow 'name <email>'
300 } elseif ($action == 'setevenunsubscribe') { // Test on permission already done
301 $object->evenunsubscribe = (GETPOST('evenunsubscribe') ? 1 : 0);
302 }
303 if ($action == 'settitle' && empty($object->title)) { // Test on permission already done
304 $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle"));
305 }
306 if ($action == 'setemail_from' && empty($object->email_from)) { // Test on permission already done
307 $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom"));
308 }
309
310 if (!$mesg) {
311 $result = $object->update($user);
312 if ($result >= 0) {
313 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
314 exit;
315 }
316 $mesg = $object->error;
317 }
318
319 setEventMessages($mesg, $mesgs, 'errors');
320 $action = "";
321}
322
323
324/*
325 * View
326 */
327
328$form = new Form($db);
329$formmailing = new FormMailing($db);
330
331$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing';
332llxHeader('', $langs->trans("Mailing"), $help_url);
333
334$arrayofselected = is_array($toselect) ? $toselect : array();
335$totalarray = [
336 'nbfield' => 0,
337];
338
339if ($object->fetch($id) >= 0) {
340 $head = emailing_prepare_head($object);
341
342 print dol_get_fiche_head($head, 'targets', $langs->trans("Mailing"), -1, $object->picto);
343
344 $linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
345
346 $morehtmlref = '<div class="refidno">';
347 // Ref customer
348 $morehtmlref .= $form->editfieldkey("", 'title', $object->title, $object, 0, 'string', '', 0, 1);
349 $morehtmlref .= $form->editfieldval("", 'title', $object->title, $object, 0, 'string', '', null, null, '', 1);
350 $morehtmlref .= '</div>';
351
352 $morehtmlstatus = '';
353 $nbtry = $nbok = 0;
354 if ($object->status == $object::STATUS_SENTPARTIALY || $object->status == $object::STATUS_SENTCOMPLETELY) {
355 $nbtry = $object->countNbOfTargets('alreadysent');
356 $nbko = $object->countNbOfTargets('alreadysentko');
357 $nbok = ($nbtry - $nbko);
358
359 $morehtmlstatus .= ' ('.$nbtry.'/'.$object->nbemail;
360 if ($nbko) {
361 $morehtmlstatus .= ' - '.$nbko.' '.$langs->trans("Error");
362 }
363 $morehtmlstatus .= ') &nbsp; ';
364 }
365
366 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus);
367
368 print '<div class="fichecenter">';
369 print '<div class="fichehalfleft">';
370 print '<div class="underbanner clearboth"></div>';
371
372 print '<table class="border centpercent tableforfield">'."\n";
373
374 // From
375 print '<tr><td class="titlefield">';
376 print $langs->trans("MailFrom").'</td><td>';
377 $emailarray = CMailFile::getArrayAddress($object->email_from);
378 foreach ($emailarray as $email => $name) {
379 if ($name && $name != $email) {
380 print dol_escape_htmltag($name).' &lt;'.$email;
381 print '&gt;';
382 if (!isValidEmail($email)) {
383 $langs->load("errors");
384 print img_warning($langs->trans("ErrorBadEMail", $email));
385 }
386 } else {
387 print dol_print_email($object->email_from, 0, 0, 0, 0, 1);
388 }
389 }
390
391 print '</td></tr>';
392
393 // Errors to
394 if ($object->messtype != 'sms') {
395 print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
396 $emailarray = CMailFile::getArrayAddress($object->email_errorsto);
397 foreach ($emailarray as $email => $name) {
398 if ($name != $email) {
399 print dol_escape_htmltag((string) $name).' &lt;'.$email;
400 print '&gt;';
401 if ($email && !isValidEmail($email)) {
402 $langs->load("errors");
403 print img_warning($langs->trans("ErrorBadEMail", $email));
404 } elseif ($email && !isValidMailDomain($email)) {
405 $langs->load("errors");
406 print img_warning($langs->trans("ErrorBadMXDomain", $email));
407 }
408 } else {
409 print dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1);
410 }
411 }
412 print '</td></tr>';
413 }
414
415 // Reply to
416 if ($object->messtype != 'sms') {
417 print '<tr><td>';
418 print $form->editfieldkey("MailReply", 'email_replyto', $object->email_replyto, $object, (int) ($user->hasRight('mailing', 'creer') && $object->status < $object::STATUS_SENTCOMPLETELY), 'string');
419 print '</td><td>';
420 print $form->editfieldval("MailReply", 'email_replyto', $object->email_replyto, $object, $user->hasRight('mailing', 'creer') && $object->status < $object::STATUS_SENTCOMPLETELY, 'string');
421 $email = CMailFile::getValidAddress($object->email_replyto, 2);
422 if ($action != 'editemail_replyto') {
423 if ($email && !isValidEmail($email)) {
424 $langs->load("errors");
425 print img_warning($langs->trans("ErrorBadEMail", $email));
426 } elseif ($email && !isValidMailDomain($email)) {
427 $langs->load("errors");
428 print img_warning($langs->trans("ErrorBadMXDomain", $email));
429 }
430 }
431 print '</td></tr>';
432 }
433
434 print '</table>';
435 print '</div>';
436
437
438 print '<div class="fichehalfright">';
439 print '<div class="underbanner clearboth"></div>';
440
441 print '<table class="border centpercent tableforfield">';
442
443 // Number of distinct emails
444 print '<tr><td>';
445 print $langs->trans("TotalNbOfDistinctRecipients");
446 print '</td><td>';
447 $nbemail = ($object->nbemail ? $object->nbemail : 0);
448 if (is_numeric($nbemail)) {
449 $htmltooltip = '';
450 if ((getDolGlobalString('MAILING_LIMIT_SENDBYWEB') && getDolGlobalInt('MAILING_LIMIT_SENDBYWEB') < $nbemail) && ($object->status == 1 || ($object->status == 2 && $nbtry < $nbemail))) {
451 if (getDolGlobalInt('MAILING_LIMIT_SENDBYWEB') > 0) {
452 $htmltooltip .= $langs->trans('LimitSendingEmailing', getDolGlobalString('MAILING_LIMIT_SENDBYWEB'));
453 } else {
454 $htmltooltip .= $langs->trans('SendingFromWebInterfaceIsNotAllowed');
455 }
456 }
457 if (empty($nbemail)) {
458 $nbemail .= ' '.img_warning($langs->trans('ToAddRecipientsChooseHere'));//.' <span class="warning">'.$langs->trans("NoTargetYet").'</span>';
459 }
460 if ($htmltooltip) {
461 print $form->textwithpicto($nbemail, $htmltooltip, 1, 'info');
462 } else {
463 print $nbemail;
464 }
465 }
466 print '</td></tr>';
467
468 print '<tr><td>';
469 print $langs->trans("MAIN_MAIL_SENDMODE");
470 print '</td><td>';
471 if ($object->messtype != 'sms') {
472 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') && getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
473 $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING')];
474 } elseif (getDolGlobalString('MAIN_MAIL_SENDMODE')) {
475 $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE')];
476 } else {
477 $text = $listofmethods['mail'];
478 }
479 print $text;
480 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
481 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'mail') {
482 print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER_EMAILING', getDolGlobalString('MAIN_MAIL_SMTP_SERVER')).')</span>';
483 }
484 } elseif (getDolGlobalString('MAIN_MAIL_SENDMODE') != 'mail' && getDolGlobalString('MAIN_MAIL_SMTP_SERVER')) {
485 print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER').')</span>';
486 }
487 } else {
488 print 'SMS ';
489 print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER').')</span>';
490 }
491 print '</td></tr>';
492
493 // Other attributes. Fields from hook formObjectOptions and Extrafields.
494 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
495
496 print '</table>';
497 print '</div>';
498 print '</div>';
499
500 print '<div class="clearboth"></div>';
501
502 print dol_get_fiche_end();
503
504
505 $newcardbutton = '';
506 $allowaddtarget = ($object->status == $object::STATUS_DRAFT);
507 if (GETPOST('allowaddtarget')) {
508 $allowaddtarget = 1;
509 }
510 if (!$allowaddtarget) {
511 $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?id='.$object->id.'&allowaddtarget=1', '', $user->hasRight('mailing', 'creer'));
512 }
513
514 // Show email selectors
515 if ($allowaddtarget && $user->hasRight('mailing', 'creer')) {
516 print '<div class="info">';
517 print $langs->trans("ToAddRecipientsChooseHere").'...';
518 //print ($user->admin ? info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1) : '');
519 print '</div>';
520
521 print '<div class="div-table-responsive">';
522 print '<div class="tagtable centpercentwithout1imp liste_titre_bydiv borderbottom" id="tablelines">';
523
524 print '<div class="tagtr liste_titre">';
525 print '<div class="tagtd"></div>';
526 print '<div class="tagtd">'.$langs->trans("RecipientSelectionModules");
527 print ($user->admin ? info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1) : '');
528 print '</div>';
529 print '<div class="tagtd center maxwidth150">';
530 if ($object->messtype != 'sms') {
531 print $langs->trans("NbOfUniqueEMails");
532 } else {
533 print $langs->trans("NbOfUniquePhones");
534 }
535 print '</div>';
536 print '<div class="tagtd left"><div class="inline-block">'.$langs->trans("Filters").'</div>';
537 if ($object->messtype != 'sms') {
538 print ' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div class="inline-block valignmiddle">';
539 print '<span id="evenunsubscribe_text_'.$object->id.'" class="linkobject" style="cursor: pointer;">'.$langs->trans("EvenUnsubscribe").'</span> ';
540 print ajax_object_onoff($object, 'evenunsubscribe', 'evenunsubscribe', 'EvenUnsubscribe:switch_on:warning', 'EvenUnsubscribe', array(), 'small valignmiddle reposition', '', 1, 'allowaddtarget=1');
541 print '</div>';
542 }
543 print '</div>'."\n";
544 // Add JavaScript to make EvenUnsubscribe text clickable
545 /* This does not work, don't know why
546 print '<script>'."\n";
547 print '$(document).ready(function() {';
548 print ' $("#evenunsubscribe_text_'.dol_escape_js($object->id).'").click(function() {'."\n";
549 print ' console.log("We click on link to switch unsubscribed emails");';
550 print ' jQuery("#set_evenunsubscribe_'.dol_escape_js($object->id).'").trigger("click");';
551 print ' jQuery("#del_evenunsubscribe_'.dol_escape_js($object->id).'").trigger("click");';
552 print ' });'."\n";
553 print '});'."\n";
554 print '</script>'."\n";
555 */
556 print '<div class="tagtd">&nbsp;</div>';
557 print '</div>'; // End tr
558
559 clearstatcache();
560
561 foreach ($modulesdir as $dir) {
562 $modulenames = array();
563
564 // Load modules attributes in arrays (name, numero, orders) from dir directory
565 //print $dir."\n<br>";
566 dol_syslog("Scan directory ".$dir." for modules");
567 $handle = @opendir($dir);
568 if (is_resource($handle)) {
569 while (($file = readdir($handle)) !== false) {
570 if (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS') {
571 $reg = array();
572 if (preg_match("/(.*)\.modules\.php$/i", $file, $reg)) {
573 if ($reg[1] == 'example') {
574 continue;
575 }
576 $modulenames[] = $reg[1];
577 }
578 }
579 }
580 closedir($handle);
581 }
582
583 // Sort $modulenames
584 sort($modulenames);
585
586 // Loop on each submodule
587 foreach ($modulenames as $modulename) {
588 // Loading Class
589 $file = $dir.$modulename.".modules.php";
590 $classname = "mailing_".$modulename;
591 require_once $file;
592
593 $obj = new $classname($db);
594 '@phan-var-force MailingTargets $obj';
595
596 // Check if qualified
597 $qualified = (is_null($obj->enabled) ? 1 : (int) dol_eval((string) $obj->enabled, 1));
598
599 // Check dependencies
600 foreach ($obj->require_module as $key) {
601 if (empty($conf->$key->enabled) || (empty($user->admin) && $obj->require_admin)) {
602 $qualified = 0;
603 //print "Les prerequis d'activation du module mailing ne sont pas respectes. Il ne sera pas actif";
604 break;
605 }
606 }
607
608 // If module is qualified
609 if ($qualified) {
610 if ($allowaddtarget) {
611 print '<form class="oddeven trforbreakperms trforbreaknobg impair tagtr" name="'.$modulename.'" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&module='.$modulename.'" method="POST" enctype="multipart/form-data">';
612 print '<input type="hidden" name="token" value="'.newToken().'">';
613 print '<input type="hidden" name="action" value="add">';
614 print '<input type="hidden" name="page_y" value="'.newToken().'">';
615 //print '<input type="hidden" name="allowaddtarget" value="1">';
616 } else {
617 print '<div class="oddeven trforbreakperms trforbreaknobg impair tagtr">';
618 }
619
620 print '<div class="tagtd paddingleftlarge marginleftonly paddingrightlarge marginrightonly valignmiddle center">';
621 if (empty($obj->picto)) {
622 $obj->picto = 'generic';
623 }
624 print img_object($langs->trans("EmailingTargetSelector").': '.get_class($obj), $obj->picto, 'class="valignmiddle width25 size15x"');
625 print '</div>';
626 print '<div class="tagtd valignmiddle">'; // style="height: 4em"
627 print $obj->getDesc();
628 print '</div>';
629
630 $nbofrecipient = -1;
631
632 try {
633 $obj->evenunsubscribe = $object->evenunsubscribe; // Set flag to include/exclude email that has opt-out.
634
635 $nbofrecipient = $obj->getNbOfRecipients('');
636 } catch (Exception $e) {
637 dol_syslog($e->getMessage(), LOG_ERR);
638 }
639
640 print '<div class="tagtd center valignmiddle">';
641 if ($nbofrecipient === '' || $nbofrecipient >= 0) {
642 if ($nbofrecipient !== '') {
643 print '<span class="badge badge-info">'.$nbofrecipient.'</span>';
644 }
645 } else {
646 print $langs->trans("Error").' '.img_error($obj->error);
647 }
648 print '</div>';
649
650 print '<div class="tagtd left valignmiddle">';
651 if ($allowaddtarget) {
652 $filter = false;
653 try {
654 $filter = $obj->formFilter();
655 } catch (Exception $e) {
656 dol_syslog($e->getMessage(), LOG_ERR);
657 }
658 if ($filter) {
659 print $filter;
660 } else {
661 print $langs->trans("None");
662 }
663 }
664 print '</div>';
665
666 print '<div class="tagtd right valignmiddle">';
667 if ($allowaddtarget) {
668 print '<input type="submit" class="button button-add small reposition" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
669 } else {
670 print '<input type="submit" class="button small disabled" disabled="disabled" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
671 //print $langs->trans("MailNoChangePossible");
672 print "&nbsp;";
673 }
674 print '</div>';
675
676 if ($allowaddtarget) {
677 print '</form>';
678 } else {
679 print '</div>';
680 }
681 }
682 }
683 } // End foreach dir
684
685 $parameters = array();
686 $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
687 print $hookmanager->resPrint;
688
689 print '</div>'; // End table
690 print '</div>';
691
692 print '<br>';
693
694 if ($sqlmessage && $user->admin) {
695 print info_admin($langs->trans("SQLUsedForExport").':<br> '.$sqlmessage, 0, 0, '1', '', 'TechnicalInformation');
696 print '<br>';
697 }
698
699 print '<br><br>';
700 }
701
702
703
704 // List of selected targets
705 $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut as status, mc.date_envoi, mc.tms,";
706 $sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text,";
707 $sql .= " COUNT(mu.rowid) as nb";
708 $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
709 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."mailing_unsubscribe as mu ON mu.email = mc.email";
710 $sql .= " WHERE mc.fk_mailing=".((int) $object->id);
711 $asearchcriteriahasbeenset = 0;
712 if ($search_lastname) {
713 $sql .= natural_search("mc.lastname", $search_lastname);
714 $asearchcriteriahasbeenset++;
715 }
716 if ($search_firstname) {
717 $sql .= natural_search("mc.firstname", $search_firstname);
718 $asearchcriteriahasbeenset++;
719 }
720 if ($search_email) {
721 $sql .= natural_search("mc.email", $search_email);
722 $asearchcriteriahasbeenset++;
723 }
724 if ($search_other) {
725 $sql .= natural_search("mc.other", $search_other);
726 $asearchcriteriahasbeenset++;
727 }
728 if ($search_dest_status != '' && (int) $search_dest_status >= -1) {
729 $sql .= " AND mc.statut = ".((int) $search_dest_status);
730 $asearchcriteriahasbeenset++;
731 }
732 $sql .= ' GROUP BY mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut, mc.date_envoi, mc.tms, mc.source_url, mc.source_id, mc.source_type, mc.error_text';
733 $sql .= $db->order($sortfield, $sortorder);
734
735
736 // Count total nb of records
737 $nbtotalofrecords = '';
738 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
739 $result = $db->query($sql);
740 $nbtotalofrecords = $db->num_rows($result);
741 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
742 $page = 0;
743 $offset = 0;
744 }
745
746 // Fix/update nbemail on emailing record if it differs (may happen if user edit lines from database directly)
747 if (empty($asearchcriteriahasbeenset)) {
748 if ($nbtotalofrecords != $object->nbemail) {
749 dol_syslog("We found a difference in nb of record in target table and the property ->nbemail, we fix ->nbemail");
750 //print "nbemail=".$object->nbemail." nbtotalofrecords=".$nbtotalofrecords;
751 $resultrefresh = $object->refreshNbOfTargets();
752 if ($resultrefresh < 0) {
753 dol_print_error($db, $object->error, $object->errors);
754 }
755 }
756 }
757 }
758
759 //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets
760 $sql .= $db->plimit($limit + 1, $offset);
761
762 $resql = $db->query($sql);
763 if ($resql) {
764 $num = $db->num_rows($resql);
765
766 $param = "&id=".$object->id;
767 //if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
768 if ($limit > 0 && $limit != $conf->liste_limit) {
769 $param .= '&limit='.((int) $limit);
770 }
771 if ($search_lastname) {
772 $param .= "&search_lastname=".urlencode($search_lastname);
773 }
774 if ($search_firstname) {
775 $param .= "&search_firstname=".urlencode($search_firstname);
776 }
777 if ($search_email) {
778 $param .= "&search_email=".urlencode($search_email);
779 }
780 if ($search_other) {
781 $param .= "&search_other=".urlencode($search_other);
782 }
783
784 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
785 print '<input type="hidden" name="token" value="'.newToken().'">';
786 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
787 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
788 print '<input type="hidden" name="page" value="'.$page.'">';
789 print '<input type="hidden" name="id" value="'.$object->id.'">';
790 print '<input type="hidden" name="page_y" value="">';
791
792 $morehtmlcenter = '';
793 $arrayofmassactions = array();
794 if ($permissiontocreate) {
795 $arrayofmassactions['reset_target'] = img_picto('', 'refresh', 'class="pictofixedwidth"').$langs->trans("ResetMailingTargetMassaction");
796 }
797 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
798 $morehtmlcenter .= $massactionbutton .'<br>';
799
800 if ($object->status == $object::STATUS_DRAFT) {
801 $morehtmlcenter = '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ToClearAllRecipientsClickHere").'</span> <a href="'.$_SERVER["PHP_SELF"].'?clearlist=1&id='.$object->id.'" class="button reposition smallpaddingimp">'.$langs->trans("TargetsReset").'</a>';
802 }
803
804 $morehtmlrightbeforearrow = '<a class="reposition marginrightonly" href="'.$_SERVER["PHP_SELF"].'?action=exportcsv&token='.newToken().'&exportcsv=1&id='.$object->id.'">'.img_picto('', 'download', 'class="pictofixedwidth"').$langs->trans("Download").'</a>&nbsp;';
805
806 print '</form>';
807
808 print "\n<!-- List of selected targets -->\n";
809 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
810 print '<input type="hidden" name="token" value="'.newToken().'">';
811 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
812 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
813 print '<input type="hidden" name="page" value="'.$page.'">';
814 print '<input type="hidden" name="id" value="'.$object->id.'">';
815 print '<input type="hidden" name="limit" value="'.$limit.'">';
816 print '<input type="hidden" name="page_y" value="">';
817
818 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
819 print_barre_liste($langs->trans("MailSelectedRecipients"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit, 0, 0, 1, $morehtmlrightbeforearrow);
820
821 if ($massaction == 'reset_target') {
822 // Confirm reset
823 print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ConfirmResetMailingTargetMassaction"), $langs->trans("ConfirmResetMailingTargetMassactionQuestion"), "confirm_reset_target", null, '', 0, 0, 500, 1);
824 }
825
826 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
827 $htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column ? 'left' : ''); // This also change content of $arrayfields with user setup
828 $selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
829 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
830
831 print '<div class="div-table-responsive">';
832 print '<table class="noborder centpercent">';
833
834 // Line of filters
835 print '<tr class="liste_titre_filter">';
836
837 // Action column
838 if ($conf->main_checkbox_left_column) {
839 print '<td class="liste_titre maxwidthsearch">';
840 $searchpicto = $form->showFilterButtons('left');
841 print $searchpicto;
842 print '</td>';
843 }
844 // EMail
845 print '<td class="liste_titre">';
846 print '<input class="flat maxwidth75" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
847 print '</td>';
848 // Name
849 print '<td class="liste_titre">';
850 print '<input class="flat maxwidth50" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'">';
851 print '</td>';
852 // Firstname
853 print '<td class="liste_titre">';
854 print '<input class="flat maxwidth50" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'">';
855 print '</td>';
856 // Other
857 print '<td class="liste_titre">';
858 print '<input class="flat maxwidth100" type="text" name="search_other" value="'.dol_escape_htmltag($search_other).'">';
859 print '</td>';
860 // Source
861 print '<td class="liste_titre">';
862 print '&nbsp;';
863 print '</td>';
864
865 // Date last update
866 print '<td class="liste_titre">';
867 print '&nbsp;';
868 print '</td>';
869
870 // Date sending
871 print '<td class="liste_titre">';
872 print '&nbsp;';
873 print '</td>';
874
875 // Status
876 print '<td class="liste_titre center parentonrightofpage">';
877 print $formmailing->selectDestinariesStatus($search_dest_status, 'search_dest_status', 1, 'width100 onrightofpage');
878 print '</td>';
879
880 // Action column
881 if (!$conf->main_checkbox_left_column) {
882 print '<td class="liste_titre maxwidthsearch">';
883 $searchpicto = $form->showFilterButtons();
884 print $searchpicto;
885 print '</td>';
886 }
887
888 print '</tr>';
889
890 if ($page) {
891 $param .= "&page=".urlencode((string) ($page));
892 }
893
894 print '<tr class="liste_titre">';
895 // Action column
896 if ($conf->main_checkbox_left_column) {
897 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
898 $totalarray['nbfield']++;
899 }
900 print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "mc.email", '', $param, "", $sortfield, $sortorder);
901 print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "mc.lastname", '', $param, "", $sortfield, $sortorder);
902 print_liste_field_titre("Firstname", $_SERVER["PHP_SELF"], "mc.firstname", '', $param, "", $sortfield, $sortorder);
903 print_liste_field_titre("OtherInformations", $_SERVER["PHP_SELF"], '', "", $param, "", $sortfield, $sortorder);
904 print_liste_field_titre("Source", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, 'center ');
905 // Date last update
906 print_liste_field_titre("DateLastModification", $_SERVER["PHP_SELF"], "mc.tms", '', $param, '', $sortfield, $sortorder, 'center ');
907 // Date sending
908 print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", '', $param, '', $sortfield, $sortorder, 'center ');
909 print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "mc.statut", '', $param, '', $sortfield, $sortorder, 'center ');
910 // Action column
911 if (!$conf->main_checkbox_left_column) {
912 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
913 $totalarray['nbfield']++;
914 }
915 print '</tr>';
916
917 $i = 0;
918
919 if ($num) {
920 include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
921 include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
922 include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
923 include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
924 include_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
925
926 $objectstaticmember = new Adherent($db);
927 $objectstaticuser = new User($db);
928 $objectstaticcompany = new Societe($db);
929 $objectstaticcontact = new Contact($db);
930 $objectstaticeventorganization = new ConferenceOrBoothAttendee($db);
931
932 while ($i < min($num, $limit)) {
933 $obj = $db->fetch_object($resql);
934
935 print '<tr class="oddeven">';
936
937 // Action column
938 if ($conf->main_checkbox_left_column) {
939 print '<td class="center nowraponall">';
940 print '<!-- ID mailing_cibles = '.$obj->rowid.' -->';
941 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
942 $selected = 0;
943 if (in_array($obj->rowid, $arrayofselected)) {
944 $selected = 1;
945 }
946 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
947 }
948 if ($obj->status == $object::STATUS_DRAFT) { // Not sent yet
949 if ($user->hasRight('mailing', 'creer')) {
950 print '<a class="reposition marginleftonly" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&rowid='.((int) $obj->rowid).$param.'">'.img_delete($langs->trans("RemoveRecipient")).'</a>';
951 }
952 }
953 /*if ($obj->status == -1) // Sent with error
954 {
955 print '<a href="'.$_SERVER['PHP_SELF'].'?action=retry&token='.newToken().'&rowid='.$obj->rowid.$param.'">'.$langs->trans("Retry").'</a>';
956 }*/
957 print '</td>';
958 }
959
960 print '<td class="tdoverflowmax150">';
961 print img_picto($obj->email, 'email', 'class="paddingright"');
962 if ($obj->nb > 0) {
963 print img_warning($langs->trans("EmailOptedOut"), 'warning', 'pictofixedwidth');
964 }
965 print dolPrintHTML($obj->email);
966 print '</td>';
967
968 print '<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($obj->lastname).'">'.dolPrintHTML($obj->lastname).'</td>';
969
970 print '<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($obj->firstname).'">'.dolPrintHTML($obj->firstname).'</td>';
971
972 print '<td class="tdoverflowmax300" title="'.dolPrintHTMLForAttribute($obj->other).'"><span class="small">'.dolPrintHTML($obj->other).'</small></td>';
973
974 print '<td class="center tdoverflowmax150">';
975 if (empty($obj->source_id) || empty($obj->source_type)) {
976 print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility
977 } else {
978 if ($obj->source_type == 'member') {
979 $objectstaticmember->fetch($obj->source_id);
980 print $objectstaticmember->getNomUrl(1);
981 } elseif ($obj->source_type == 'user') {
982 $objectstaticuser->fetch($obj->source_id);
983 print $objectstaticuser->getNomUrl(1);
984 } elseif ($obj->source_type == 'thirdparty') {
985 $objectstaticcompany->fetch($obj->source_id);
986 print $objectstaticcompany->getNomUrl(1);
987 } elseif ($obj->source_type == 'contact') {
988 $objectstaticcontact->fetch($obj->source_id);
989 print $objectstaticcontact->getNomUrl(1);
990 } elseif ($obj->source_type == 'eventorganizationattendee') {
991 $objectstaticeventorganization->fetch($obj->source_id);
992 print $objectstaticeventorganization->getNomUrl(1);
993 } else {
994 print $obj->source_url;
995 }
996 }
997 print '</td>';
998
999 // Date last update
1000 print '<td class="center nowraponall">';
1001 print dol_print_date($db->jdate($obj->tms), 'dayhour', 'tzuserrel');
1002 print '</td>';
1003
1004 // Date sent
1005 print '<td class="center nowraponall">';
1006 if ($obj->status != $object::STATUS_DRAFT) { // If status of target line is not draft
1007 // Date sent
1008 print dol_print_date($db->jdate($obj->date_envoi), 'dayhour', 'tzuserrel'); // @TODO Must store date in date format
1009 }
1010 print '</td>';
1011
1012 // Status of recipient sending email (Warning != status of emailing)
1013 print '<td class="nowrap center">';
1014 if ($obj->status == $object::STATUS_DRAFT) { // If status of target line is not draft
1015 print $object::libStatutDest((int) $obj->status, 2, '');
1016 } else {
1017 print $object::libStatutDest((int) $obj->status, 2, $obj->error_text);
1018 }
1019 print '</td>';
1020
1021 // Action column
1022 if (!$conf->main_checkbox_left_column) {
1023 print '<td class="center nowraponall">';
1024 print '<!-- ID mailing_cibles = '.$obj->rowid.' -->';
1025 if ($obj->status == $object::STATUS_DRAFT) { // If status of target line is not sent yet
1026 if ($user->hasRight('mailing', 'creer')) {
1027 print '<a class="reposition marginleftonly" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&rowid='.((int) $obj->rowid).$param.'">'.img_delete($langs->trans("RemoveRecipient")).'</a>';
1028 }
1029 }
1030 /*if ($obj->status == -1) // Sent with error
1031 {
1032 print '<a href="'.$_SERVER['PHP_SELF'].'?action=retry&token='.newToken().'&rowid='.$obj->rowid.$param.'">'.$langs->trans("Retry").'</a>';
1033 }*/
1034 print '</td>';
1035 }
1036 print '</tr>';
1037
1038 $i++;
1039 }
1040 } else {
1041 if ($object->status < $object::STATUS_SENTPARTIALY) {
1042 print '<tr><td colspan="9">';
1043 print '<span class="opacitymedium">'.$langs->trans("NoTargetYet").'</span>';
1044 print '</td></tr>';
1045 } else {
1046 print '<tr><td colspan="9">';
1047 print '<span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span>';
1048 print '</td></tr>';
1049 }
1050 }
1051 print "</table><br>";
1052 print '</div>';
1053
1054 print '</form>';
1055
1056 $db->free($resql);
1057 } else {
1059 }
1060
1061 print "\n<!-- End list of selected targets -->\n";
1062}
1063
1064// End of page
1065llxFooter();
1066$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
ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array(), $morecss='', $htmlname='', $forcenojs=0, $moreparam='', $readonly=0)
On/off button to change a property status of an object This uses the ajax service objectonoff....
Definition ajax.lib.php:804
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 members of a foundation.
static getValidAddress($address, $format, $encode=0, $maxnumberofemail=0)
Return a formatted address string for SMTP protocol.
static getArrayAddress($address)
Return a formatted array of address string for SMTP protocol.
Class for ConferenceOrBoothAttendee.
Class to manage contact/addresses.
Class to manage generation of HTML components Only common components must be here.
Class to offer components to list and upload files.
Class to manage emailings module.
Parent class of emailing target selectors modules.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
emailing_prepare_head(Mailing $object)
Prepare array with list of tabs.
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.
dolGetModulesDirs($subdir='')
Return list of directories that contain modules.
isValidMailDomain($mail)
Return true if email has a domain name that can be resolved to MX type.
dol_now($mode='gmt')
Return date for now.
dol_print_email($email, $contactid=0, $socid=0, $addlink=0, $max=0, $showinvalid=2, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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_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).
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
Definition html.lib.php:73
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
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
img_error($titlealt='default')
Show error logo.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
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
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.