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", "companies"));
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 {
226 dol_print_error($db);
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 $sql .= " AND fk_mailing = ".((int) $object->id);
235 $resql = $db->query($sql);
236 if ($resql) {
237 if (!empty($id)) {
238 $obj = new MailingTargets($db);
239 $obj->update_nb($id);
240
241 setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
242 } else {
243 header("Location: list.php");
244 exit;
245 }
246 } else {
247 dol_print_error($db);
248 }
249}
250
251if ($action == "confirm_reset_target" && $permissiontocreate) {
252 if ($object->id > 0) {
253 $db->begin();
254 $nbok = 0;
255 $error = 0;
256 foreach ($toselect as $toselectid) {
257 $result = $object->resetTargetErrorStatus($user, $toselectid);
258 if ($result < 0) {
259 setEventMessages($object->error, $object->errors, 'errors');
260 $error++;
261 break;
262 } elseif ($result > 0) {
263 $nbok++;
264 } else {
265 setEventMessages($object->error, $object->errors, 'errors');
266 $error++;
267 }
268 }
269 if (!$error) {
270 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
271 $db->commit();
272 } else {
273 $db->rollback();
274 }
275 }
276}
277
278// Purge search criteria
279if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
280 $search_lastname = '';
281 $search_firstname = '';
282 $search_email = '';
283 $search_other = '';
284 $search_dest_status = '';
285 $toselect = array();
286}
287
288// Action update description of emailing
289if (($action == 'settitle' || $action == 'setemail_from' || $action == 'setemail_replyto' || $action == 'setemail_errorsto' || $action == 'setevenunsubscribe') && $permissiontocreate) {
290 $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, getDolGlobalInt('MAILING_USE_NEW_PATH_FOR_FILES') ? 0 : 2, 0, 1, $object, 'mailing');
291
292 $mesg = '';
293 if ($action == 'settitle') { // Test on permission already done
294 $object->title = trim(GETPOST('title', 'alpha'));
295 } elseif ($action == 'setemail_from') { // Test on permission already done
296 $object->email_from = trim(GETPOST('email_from', 'alphawithlgt')); // Must allow 'name <email>'
297 } elseif ($action == 'setemail_replyto') { // Test on permission already done
298 $object->email_replyto = trim(GETPOST('email_replyto', 'alphawithlgt')); // Must allow 'name <email>'
299 } elseif ($action == 'setemail_errorsto') { // Test on permission already done
300 $object->email_errorsto = trim(GETPOST('email_errorsto', 'alphawithlgt')); // Must allow 'name <email>'
301 } elseif ($action == 'setevenunsubscribe') { // Test on permission already done
302 $object->evenunsubscribe = (GETPOST('evenunsubscribe') ? 1 : 0);
303 }
304 if ($action == 'settitle' && empty($object->title)) { // Test on permission already done
305 $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle"));
306 }
307 if ($action == 'setemail_from' && empty($object->email_from)) { // Test on permission already done
308 $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom"));
309 }
310
311 if (!$mesg) {
312 $result = $object->update($user);
313 if ($result >= 0) {
314 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
315 exit;
316 }
317 $mesg = $object->error;
318 }
319
320 setEventMessages($mesg, $mesgs, 'errors');
321 $action = "";
322}
323
324
325/*
326 * View
327 */
328
329$form = new Form($db);
330$formmailing = new FormMailing($db);
331
332$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing';
333llxHeader('', $langs->trans("Mailing"), $help_url);
334
335$arrayofselected = is_array($toselect) ? $toselect : array();
336$totalarray = [
337 'nbfield' => 0,
338];
339
340if ($object->fetch($id) >= 0) {
341 $head = emailing_prepare_head($object);
342
343 print dol_get_fiche_head($head, 'targets', $langs->trans("Mailing"), -1, $object->picto);
344
345 $linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
346
347 $morehtmlref = '<div class="refidno">';
348 // Ref customer
349 $morehtmlref .= $form->editfieldkey("", 'title', $object->title, $object, 0, 'string', '', 0, 1);
350 $morehtmlref .= $form->editfieldval("", 'title', $object->title, $object, 0, 'string', '', null, null, '', 1);
351 $morehtmlref .= '</div>';
352
353 $morehtmlstatus = '';
354 $nbtry = $nbok = 0;
355 if ($object->status == $object::STATUS_SENTPARTIALY || $object->status == $object::STATUS_SENTCOMPLETELY) {
356 $nbtry = $object->countNbOfTargets('alreadysent');
357 $nbko = $object->countNbOfTargets('alreadysentko');
358 $nbok = ($nbtry - $nbko);
359
360 $morehtmlstatus .= ' ('.$nbtry.'/'.$object->nbemail;
361 if ($nbko) {
362 $morehtmlstatus .= ' - '.$nbko.' '.$langs->trans("Error");
363 }
364 $morehtmlstatus .= ') &nbsp; ';
365 }
366
367 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus);
368
369 print '<div class="fichecenter">';
370 print '<div class="fichehalfleft">';
371 print '<div class="underbanner clearboth"></div>';
372
373 print '<table class="border centpercent tableforfield">'."\n";
374
375 // From
376 print '<tr><td class="titlefield">';
377 print $langs->trans("MailFrom").'</td><td>';
378 $emailarray = CMailFile::getArrayAddress($object->email_from);
379 foreach ($emailarray as $email => $name) {
380 if ($name && $name != $email) {
381 print dol_escape_htmltag($name).' &lt;'.$email;
382 print '&gt;';
383 if (!isValidEmail($email)) {
384 $langs->load("errors");
385 print img_warning($langs->trans("ErrorBadEMail", $email));
386 }
387 } else {
388 print dol_print_email($object->email_from, 0, 0, 0, 0, 1);
389 }
390 }
391
392 print '</td></tr>';
393
394 // Errors to
395 if ($object->messtype != 'sms') {
396 print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
397 $emailarray = CMailFile::getArrayAddress($object->email_errorsto);
398 foreach ($emailarray as $email => $name) {
399 if ($name != $email) {
400 print dol_escape_htmltag((string) $name).' &lt;'.$email;
401 print '&gt;';
402 if ($email && !isValidEmail($email)) {
403 $langs->load("errors");
404 print img_warning($langs->trans("ErrorBadEMail", $email));
405 } elseif ($email && !isValidMailDomain($email)) {
406 $langs->load("errors");
407 print img_warning($langs->trans("ErrorBadMXDomain", $email));
408 }
409 } else {
410 print dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1);
411 }
412 }
413 print '</td></tr>';
414 }
415
416 // Reply to
417 if ($object->messtype != 'sms') {
418 print '<tr><td>';
419 print $form->editfieldkey("MailReply", 'email_replyto', $object->email_replyto, $object, (int) ($user->hasRight('mailing', 'creer') && $object->status < $object::STATUS_SENTCOMPLETELY), 'string');
420 print '</td><td>';
421 print $form->editfieldval("MailReply", 'email_replyto', $object->email_replyto, $object, $user->hasRight('mailing', 'creer') && $object->status < $object::STATUS_SENTCOMPLETELY, 'string');
422 $email = CMailFile::getValidAddress($object->email_replyto, 2);
423 if ($action != 'editemail_replyto') {
424 if ($email && !isValidEmail($email)) {
425 $langs->load("errors");
426 print img_warning($langs->trans("ErrorBadEMail", $email));
427 } elseif ($email && !isValidMailDomain($email)) {
428 $langs->load("errors");
429 print img_warning($langs->trans("ErrorBadMXDomain", $email));
430 }
431 }
432 print '</td></tr>';
433 }
434
435 print '</table>';
436 print '</div>';
437
438
439 print '<div class="fichehalfright">';
440 print '<div class="underbanner clearboth"></div>';
441
442 print '<table class="border centpercent tableforfield">';
443
444 // Number of distinct emails
445 print '<tr><td>';
446 print $langs->trans("TotalNbOfDistinctRecipients");
447 print '</td><td>';
448 $nbemail = ($object->nbemail ? $object->nbemail : 0);
449 if (is_numeric($nbemail)) {
450 $htmltooltip = '';
451 if ((getDolGlobalString('MAILING_LIMIT_SENDBYWEB') && getDolGlobalInt('MAILING_LIMIT_SENDBYWEB') < $nbemail) && ($object->status == 1 || ($object->status == 2 && $nbtry < $nbemail))) {
452 if (getDolGlobalInt('MAILING_LIMIT_SENDBYWEB') > 0) {
453 $htmltooltip .= $langs->trans('LimitSendingEmailing', getDolGlobalString('MAILING_LIMIT_SENDBYWEB'));
454 } else {
455 $htmltooltip .= $langs->trans('SendingFromWebInterfaceIsNotAllowed');
456 }
457 }
458 if (empty($nbemail)) {
459 $nbemail .= ' '.img_warning($langs->trans('ToAddRecipientsChooseHere'));//.' <span class="warning">'.$langs->trans("NoTargetYet").'</span>';
460 }
461 if ($htmltooltip) {
462 print $form->textwithpicto($nbemail, $htmltooltip, 1, 'info');
463 } else {
464 print $nbemail;
465 }
466 }
467 print '</td></tr>';
468
469 print '<tr><td>';
470 print $langs->trans("MAIN_MAIL_SENDMODE");
471 print '</td><td>';
472 if ($object->messtype != 'sms') {
473 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') && getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
474 $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING')];
475 } elseif (getDolGlobalString('MAIN_MAIL_SENDMODE')) {
476 $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE')];
477 } else {
478 $text = $listofmethods['mail'];
479 }
480 print $text;
481 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
482 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'mail') {
483 print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER_EMAILING', getDolGlobalString('MAIN_MAIL_SMTP_SERVER')).')</span>';
484 }
485 } elseif (getDolGlobalString('MAIN_MAIL_SENDMODE') != 'mail' && getDolGlobalString('MAIN_MAIL_SMTP_SERVER')) {
486 print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER').')</span>';
487 }
488 } else {
489 print 'SMS ';
490 print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER').')</span>';
491 }
492 print '</td></tr>';
493
494 // Other attributes. Fields from hook formObjectOptions and Extrafields.
495 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
496
497 print '</table>';
498 print '</div>';
499 print '</div>';
500
501 print '<div class="clearboth"></div>';
502
503 print dol_get_fiche_end();
504
505
506 $newcardbutton = '';
507 $allowaddtarget = ($object->status == $object::STATUS_DRAFT);
508 if (GETPOST('allowaddtarget')) {
509 $allowaddtarget = 1;
510 }
511 if (!$allowaddtarget) {
512 $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?id='.$object->id.'&allowaddtarget=1', '', $user->hasRight('mailing', 'creer'));
513 }
514
515 // Show email selectors
516 if ($allowaddtarget && $user->hasRight('mailing', 'creer')) {
517 print '<div class="info">';
518 print $langs->trans("ToAddRecipientsChooseHere").'...';
519 //print ($user->admin ? info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1) : '');
520 print '</div>';
521
522 print '<div class="div-table-responsive">';
523 print '<div class="tagtable centpercentwithout1imp liste_titre_bydiv borderbottom" id="tablelines">';
524
525 print '<div class="tagtr liste_titre">';
526 print '<div class="tagtd"></div>';
527 print '<div class="tagtd">'.$langs->trans("RecipientSelectionModules");
528 print ($user->admin ? info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1) : '');
529 print '</div>';
530 print '<div class="tagtd center maxwidth150">';
531 if ($object->messtype != 'sms') {
532 print $langs->trans("NbOfUniqueEMails");
533 } else {
534 print $langs->trans("NbOfUniquePhones");
535 }
536 print '</div>';
537 print '<div class="tagtd left"><div class="inline-block">'.$langs->trans("Filters").'</div>';
538 if ($object->messtype != 'sms') {
539 print ' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div class="inline-block valignmiddle">';
540 print '<span id="evenunsubscribe_text_'.$object->id.'" class="linkobject" style="cursor: pointer;">'.$langs->trans("EvenUnsubscribe").'</span> ';
541 print ajax_object_onoff($object, 'evenunsubscribe', 'evenunsubscribe', 'EvenUnsubscribe:switch_on:warning', 'EvenUnsubscribe', array(), 'small valignmiddle reposition', '', 1, 'allowaddtarget=1');
542 print '</div>';
543 }
544 print '</div>'."\n";
545 // Add JavaScript to make EvenUnsubscribe text clickable
546 /* This does not work, don't know why
547 print '<script>'."\n";
548 print '$(document).ready(function() {';
549 print ' $("#evenunsubscribe_text_'.dol_escape_js($object->id).'").click(function() {'."\n";
550 print ' console.log("We click on link to switch unsubscribed emails");';
551 print ' jQuery("#set_evenunsubscribe_'.dol_escape_js($object->id).'").trigger("click");';
552 print ' jQuery("#del_evenunsubscribe_'.dol_escape_js($object->id).'").trigger("click");';
553 print ' });'."\n";
554 print '});'."\n";
555 print '</script>'."\n";
556 */
557 print '<div class="tagtd">&nbsp;</div>';
558 print '</div>'; // End tr
559
560 clearstatcache();
561
562 foreach ($modulesdir as $dir) {
563 $modulenames = array();
564
565 // Load modules attributes in arrays (name, numero, orders) from dir directory
566 //print $dir."\n<br>";
567 dol_syslog("Scan directory ".$dir." for modules");
568 $handle = @opendir($dir);
569 if (is_resource($handle)) {
570 while (($file = readdir($handle)) !== false) {
571 if (dol_substr($file, 0, 1) != '.' && dol_substr($file, 0, 3) != 'CVS') {
572 $reg = array();
573 if (preg_match("/(.*)\.modules\.php$/i", $file, $reg)) {
574 if ($reg[1] == 'example') {
575 continue;
576 }
577 $modulenames[] = $reg[1];
578 }
579 }
580 }
581 closedir($handle);
582 }
583
584 // Sort $modulenames
585 sort($modulenames);
586
587 // Loop on each submodule
588 foreach ($modulenames as $modulename) {
589 // Loading Class
590 $file = $dir.$modulename.".modules.php";
591 $classname = "mailing_".$modulename;
592 require_once $file;
593
594 if (!class_exists($classname)) {
595 dol_syslog("Emailing target selector class ".$classname." not found", LOG_WARNING);
596 continue;
597 }
598
599 $obj = new $classname($db);
600 '@phan-var-force MailingTargets $obj';
601
602 // Check if qualified
603 $qualified = (is_null($obj->enabled) ? 1 : (int) dol_eval((string) $obj->enabled, 1));
604
605 // Check dependencies
606 foreach ($obj->require_module as $key) {
607 if (empty($conf->$key->enabled) || (empty($user->admin) && $obj->require_admin)) {
608 $qualified = 0;
609 //print "Les prerequis d'activation du module mailing ne sont pas respectes. Il ne sera pas actif";
610 break;
611 }
612 }
613
614 // If module is qualified
615 if ($qualified) {
616 if ($allowaddtarget) {
617 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">';
618 print '<input type="hidden" name="token" value="'.newToken().'">';
619 print '<input type="hidden" name="action" value="add">';
620 print '<input type="hidden" name="page_y" value="'.newToken().'">';
621 //print '<input type="hidden" name="allowaddtarget" value="1">';
622 } else {
623 print '<div class="oddeven trforbreakperms trforbreaknobg impair tagtr">';
624 }
625
626 print '<div class="tagtd paddingleftlarge marginleftonly paddingrightlarge marginrightonly valignmiddle center">';
627 if (empty($obj->picto)) {
628 $obj->picto = 'generic';
629 }
630 print img_object($langs->trans("EmailingTargetSelector").': '.get_class($obj), $obj->picto, 'class="valignmiddle width25 size15x"');
631 print '</div>';
632 print '<div class="tagtd valignmiddle">'; // style="height: 4em"
633 print $obj->getDesc();
634 print '</div>';
635
636 $nbofrecipient = -1;
637
638 try {
639 $obj->evenunsubscribe = $object->evenunsubscribe; // Set flag to include/exclude email that has opt-out.
640
641 $nbofrecipient = $obj->getNbOfRecipients('');
642 } catch (Exception $e) {
643 dol_syslog($e->getMessage(), LOG_ERR);
644 }
645
646 print '<div class="tagtd center valignmiddle">';
647 if ($nbofrecipient === '' || $nbofrecipient >= 0) {
648 if ($nbofrecipient !== '') {
649 print '<span class="badge badge-info">'.$nbofrecipient.'</span>';
650 }
651 } else {
652 print $langs->trans("Error").' '.img_error($obj->error);
653 }
654 print '</div>';
655
656 print '<div class="tagtd left valignmiddle">';
657 if ($allowaddtarget) {
658 $filter = false;
659 try {
660 $filter = $obj->formFilter();
661 } catch (Exception $e) {
662 dol_syslog($e->getMessage(), LOG_ERR);
663 }
664 if ($filter) {
665 print $filter;
666 } else {
667 print $langs->trans("None");
668 }
669 }
670 print '</div>';
671
672 print '<div class="tagtd right valignmiddle">';
673 if ($allowaddtarget) {
674 print '<input type="submit" class="button button-add small reposition" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
675 } else {
676 print '<input type="submit" class="button small disabled" disabled="disabled" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
677 //print $langs->trans("MailNoChangePossible");
678 print "&nbsp;";
679 }
680 print '</div>';
681
682 if ($allowaddtarget) {
683 print '</form>';
684 } else {
685 print '</div>';
686 }
687 }
688 }
689 } // End foreach dir
690
691 $parameters = array();
692 $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
693 print $hookmanager->resPrint;
694
695 print '</div>'; // End table
696 print '</div>';
697
698 print '<br>';
699
700 if ($sqlmessage && $user->admin) {
701 print info_admin($langs->trans("SQLUsedForExport").':<br> '.$sqlmessage, 0, 0, '1', '', 'TechnicalInformation');
702 print '<br>';
703 }
704
705 print '<br><br>';
706 }
707
708
709
710 // List of selected targets
711 $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut as status, mc.date_envoi, mc.tms,";
712 $sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text,";
713 $sql .= " COUNT(mu.rowid) as nb, MAX(CASE WHEN mu.unsubscribegroup = '' AND mu.entity = ".((int) $conf->entity)." THEN 1 ELSE 0 END) as global_opt_out";
714 $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
715 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."mailing_unsubscribe as mu ON mu.email = mc.email";
716 $sql .= " WHERE mc.fk_mailing=".((int) $object->id);
717 $asearchcriteriahasbeenset = 0;
718 if ($search_lastname) {
719 $sql .= natural_search("mc.lastname", $search_lastname);
720 $asearchcriteriahasbeenset++;
721 }
722 if ($search_firstname) {
723 $sql .= natural_search("mc.firstname", $search_firstname);
724 $asearchcriteriahasbeenset++;
725 }
726 if ($search_email) {
727 $sql .= natural_search("mc.email", $search_email);
728 $asearchcriteriahasbeenset++;
729 }
730 if ($search_other) {
731 $sql .= natural_search("mc.other", $search_other);
732 $asearchcriteriahasbeenset++;
733 }
734 if ($search_dest_status != '' && (int) $search_dest_status >= -1) {
735 $sql .= " AND mc.statut = ".((int) $search_dest_status);
736 $asearchcriteriahasbeenset++;
737 }
738 $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';
739 $sql .= $db->order($sortfield, $sortorder);
740
741
742 // Count total nb of records
743 $nbtotalofrecords = '';
744 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
745 $result = $db->query($sql);
746 $nbtotalofrecords = $db->num_rows($result);
747 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
748 $page = 0;
749 $offset = 0;
750 }
751
752 // Fix/update nbemail on emailing record if it differs (may happen if user edit lines from database directly)
753 if (empty($asearchcriteriahasbeenset)) {
754 if ($nbtotalofrecords != $object->nbemail) {
755 dol_syslog("We found a difference in nb of record in target table and the property ->nbemail, we fix ->nbemail");
756 //print "nbemail=".$object->nbemail." nbtotalofrecords=".$nbtotalofrecords;
757 $resultrefresh = $object->refreshNbOfTargets();
758 if ($resultrefresh < 0) {
759 dol_print_error($db, $object->error, $object->errors);
760 }
761 }
762 }
763 }
764
765 //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets
766 $sql .= $db->plimit($limit + 1, $offset);
767
768 $resql = $db->query($sql);
769 if ($resql) {
770 $num = $db->num_rows($resql);
771
772 $param = "&id=".$object->id;
773 //if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
774 if ($limit > 0 && $limit != $conf->liste_limit) {
775 $param .= '&limit='.((int) $limit);
776 }
777 if ($search_lastname) {
778 $param .= "&search_lastname=".urlencode($search_lastname);
779 }
780 if ($search_firstname) {
781 $param .= "&search_firstname=".urlencode($search_firstname);
782 }
783 if ($search_email) {
784 $param .= "&search_email=".urlencode($search_email);
785 }
786 if ($search_other) {
787 $param .= "&search_other=".urlencode($search_other);
788 }
789
790 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
791 print '<input type="hidden" name="token" value="'.newToken().'">';
792 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
793 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
794 print '<input type="hidden" name="page" value="'.$page.'">';
795 print '<input type="hidden" name="id" value="'.$object->id.'">';
796 print '<input type="hidden" name="page_y" value="">';
797
798 $morehtmlcenter = '';
799 $arrayofmassactions = array();
800 if ($permissiontocreate) {
801 $arrayofmassactions['reset_target'] = img_picto('', 'refresh', 'class="pictofixedwidth"').$langs->trans("ResetMailingTargetMassaction");
802 }
803 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
804 $morehtmlcenter .= $massactionbutton .'<br>';
805
806 if ($object->status == $object::STATUS_DRAFT) {
807 $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>';
808 }
809
810 $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;';
811
812 print '</form>';
813
814 print "\n<!-- List of selected targets -->\n";
815 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
816 print '<input type="hidden" name="token" value="'.newToken().'">';
817 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
818 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
819 print '<input type="hidden" name="page" value="'.$page.'">';
820 print '<input type="hidden" name="id" value="'.$object->id.'">';
821 print '<input type="hidden" name="limit" value="'.$limit.'">';
822 print '<input type="hidden" name="page_y" value="">';
823
824 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
825 print_barre_liste($langs->trans("MailSelectedRecipients"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit, 0, 0, 1, $morehtmlrightbeforearrow);
826
827 if ($massaction == 'reset_target') {
828 // Confirm reset
829 print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ConfirmResetMailingTargetMassaction"), $langs->trans("ConfirmResetMailingTargetMassactionQuestion"), "confirm_reset_target", null, '', 0, 0, 500, 1);
830 }
831
832 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
833 $htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column ? 'left' : ''); // This also change content of $arrayfields with user setup
834 $selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
835 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
836
837 print '<div class="div-table-responsive">';
838 print '<table class="noborder centpercent">';
839
840 // Line of filters
841 print '<tr class="liste_titre_filter">';
842
843 // Action column
844 if ($conf->main_checkbox_left_column) {
845 print '<td class="liste_titre maxwidthsearch">';
846 $searchpicto = $form->showFilterButtons('left');
847 print $searchpicto;
848 print '</td>';
849 }
850 // EMail
851 print '<td class="liste_titre">';
852 print '<input class="flat maxwidth75" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
853 print '</td>';
854 // Name
855 print '<td class="liste_titre">';
856 print '<input class="flat maxwidth50" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'">';
857 print '</td>';
858 // Firstname
859 print '<td class="liste_titre">';
860 print '<input class="flat maxwidth50" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'">';
861 print '</td>';
862 // Other
863 print '<td class="liste_titre">';
864 print '<input class="flat maxwidth100" type="text" name="search_other" value="'.dol_escape_htmltag($search_other).'">';
865 print '</td>';
866 // Source
867 print '<td class="liste_titre">';
868 print '&nbsp;';
869 print '</td>';
870
871 // Date last update
872 print '<td class="liste_titre">';
873 print '&nbsp;';
874 print '</td>';
875
876 // Date sending
877 print '<td class="liste_titre">';
878 print '&nbsp;';
879 print '</td>';
880
881 // Status
882 print '<td class="liste_titre center parentonrightofpage">';
883 print $formmailing->selectDestinariesStatus($search_dest_status, 'search_dest_status', 1, 'width100 onrightofpage');
884 print '</td>';
885
886 // Action column
887 if (!$conf->main_checkbox_left_column) {
888 print '<td class="liste_titre maxwidthsearch">';
889 $searchpicto = $form->showFilterButtons();
890 print $searchpicto;
891 print '</td>';
892 }
893
894 print '</tr>';
895
896 if ($page) {
897 $param .= "&page=".urlencode((string) ($page));
898 }
899
900 print '<tr class="liste_titre">';
901 // Action column
902 if ($conf->main_checkbox_left_column) {
903 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
904 $totalarray['nbfield']++;
905 }
906 print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "mc.email", '', $param, "", $sortfield, $sortorder);
907 print_liste_field_titre("No_Email", $_SERVER["PHP_SELF"], "global_opt_out", '', $param, "", $sortfield, $sortorder);
908 print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "mc.lastname", '', $param, "", $sortfield, $sortorder);
909 print_liste_field_titre("Firstname", $_SERVER["PHP_SELF"], "mc.firstname", '', $param, "", $sortfield, $sortorder);
910 print_liste_field_titre("OtherInformations", $_SERVER["PHP_SELF"], '', "", $param, "", $sortfield, $sortorder);
911 print_liste_field_titre("Source", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, 'center ');
912 // Date last update
913 print_liste_field_titre("DateLastModification", $_SERVER["PHP_SELF"], "mc.tms", '', $param, '', $sortfield, $sortorder, 'center ');
914 // Date sending
915 print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", '', $param, '', $sortfield, $sortorder, 'center ');
916 print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "mc.statut", '', $param, '', $sortfield, $sortorder, 'center ');
917 // Action column
918 if (!$conf->main_checkbox_left_column) {
919 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
920 $totalarray['nbfield']++;
921 }
922 print '</tr>';
923
924 $i = 0;
925
926 if ($num) {
927 include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
928 include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
929 include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
930 include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
931 include_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
932
933 $objectstaticmember = new Adherent($db);
934 $objectstaticuser = new User($db);
935 $objectstaticcompany = new Societe($db);
936 $objectstaticcontact = new Contact($db);
937 $objectstaticeventorganization = new ConferenceOrBoothAttendee($db);
938
939 while ($i < min($num, $limit)) {
940 $obj = $db->fetch_object($resql);
941
942 print '<tr class="oddeven">';
943
944 // Action column
945 if ($conf->main_checkbox_left_column) {
946 print '<td class="center nowraponall">';
947 print '<!-- ID mailing_cibles = '.$obj->rowid.' -->';
948 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
949 $selected = 0;
950 if (in_array($obj->rowid, $arrayofselected)) {
951 $selected = 1;
952 }
953 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
954 }
955 if ($obj->status == $object::STATUS_DRAFT) { // Not sent yet
956 if ($user->hasRight('mailing', 'creer')) {
957 print '<a class="reposition marginleftonly" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&rowid='.((int) $obj->rowid).$param.'">'.img_delete($langs->trans("RemoveRecipient")).'</a>';
958 }
959 }
960 /*if ($obj->status == -1) // Sent with error
961 {
962 print '<a href="'.$_SERVER['PHP_SELF'].'?action=retry&token='.newToken().'&rowid='.$obj->rowid.$param.'">'.$langs->trans("Retry").'</a>';
963 }*/
964 print '</td>';
965 }
966
967 print '<td class="tdoverflowmax150">';
968 print img_picto($obj->email, 'email', 'class="paddingright"');
969 if ($obj->nb > 0) {
970 print img_warning($langs->trans("EmailOptedOut"), 'warning', 'pictofixedwidth');
971 }
972 print dolPrintHTML($obj->email);
973 print '</td>';
974
975 print '<td class="center">'.yn($obj->global_opt_out).'</td>';
976
977 print '<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($obj->lastname).'">'.dolPrintHTML($obj->lastname).'</td>';
978
979 print '<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($obj->firstname).'">'.dolPrintHTML($obj->firstname).'</td>';
980
981 print '<td class="tdoverflowmax300" title="'.dolPrintHTMLForAttribute($obj->other).'"><span class="small">'.dolPrintHTML($obj->other).'</small></td>';
982
983 print '<td class="center tdoverflowmax150">';
984 if (empty($obj->source_id) || empty($obj->source_type)) {
985 print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility
986 } else {
987 if ($obj->source_type == 'member') {
988 $objectstaticmember->fetch($obj->source_id);
989 print $objectstaticmember->getNomUrl(1);
990 } elseif ($obj->source_type == 'user') {
991 $objectstaticuser->fetch($obj->source_id);
992 print $objectstaticuser->getNomUrl(1);
993 } elseif ($obj->source_type == 'thirdparty') {
994 $objectstaticcompany->fetch($obj->source_id);
995 print $objectstaticcompany->getNomUrl(1);
996 } elseif ($obj->source_type == 'contact') {
997 $objectstaticcontact->fetch($obj->source_id);
998 print $objectstaticcontact->getNomUrl(1);
999 } elseif ($obj->source_type == 'eventorganizationattendee') {
1000 $objectstaticeventorganization->fetch($obj->source_id);
1001 print $objectstaticeventorganization->getNomUrl(1);
1002 } else {
1003 print $obj->source_url;
1004 }
1005 }
1006 print '</td>';
1007
1008 // Date last update
1009 print '<td class="center nowraponall">';
1010 print dol_print_date($db->jdate($obj->tms), 'dayhour', 'tzuserrel');
1011 print '</td>';
1012
1013 // Date sent
1014 print '<td class="center nowraponall">';
1015 if ($obj->status != $object::STATUS_DRAFT) { // If status of target line is not draft
1016 // Date sent
1017 print dol_print_date($db->jdate($obj->date_envoi), 'dayhour', 'tzuserrel'); // @TODO Must store date in date format
1018 }
1019 print '</td>';
1020
1021 // Status of recipient sending email (Warning != status of emailing)
1022 print '<td class="nowrap center">';
1023 if ($obj->status == $object::STATUS_DRAFT) { // If status of target line is not draft
1024 print $object::libStatutDest((int) $obj->status, 2, '');
1025 } else {
1026 print $object::libStatutDest((int) $obj->status, 2, $obj->error_text);
1027 }
1028 print '</td>';
1029
1030 // Action column
1031 if (!$conf->main_checkbox_left_column) {
1032 print '<td class="center nowraponall">';
1033 print '<!-- ID mailing_cibles = '.$obj->rowid.' -->';
1034 if ($obj->status == $object::STATUS_DRAFT) { // If status of target line is not sent yet
1035 if ($user->hasRight('mailing', 'creer')) {
1036 print '<a class="reposition marginleftonly" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&rowid='.((int) $obj->rowid).$param.'">'.img_delete($langs->trans("RemoveRecipient")).'</a>';
1037 }
1038 }
1039 /*if ($obj->status == -1) // Sent with error
1040 {
1041 print '<a href="'.$_SERVER['PHP_SELF'].'?action=retry&token='.newToken().'&rowid='.$obj->rowid.$param.'">'.$langs->trans("Retry").'</a>';
1042 }*/
1043 print '</td>';
1044 }
1045 print '</tr>';
1046
1047 $i++;
1048 }
1049 } else {
1050 if ($object->status < $object::STATUS_SENTPARTIALY) {
1051 print '<tr><td colspan="9">';
1052 print '<span class="opacitymedium">'.$langs->trans("NoTargetYet").'</span>';
1053 print '</td></tr>';
1054 } else {
1055 print '<tr><td colspan="9">';
1056 print '<span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span>';
1057 print '</td></tr>';
1058 }
1059 }
1060 print "</table><br>";
1061 print '</div>';
1062
1063 print '</form>';
1064
1065 $db->free($resql);
1066 } else {
1067 dol_print_error($db);
1068 }
1069
1070 print "\n<!-- End list of selected targets -->\n";
1071}
1072
1073// End of page
1074llxFooter();
1075$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
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:827
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
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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.
if(! $sortfield) if(! $sortorder) $module
Definition list.php:193
emailing_prepare_head(Mailing $object)
Prepare array with list of tabs.
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.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
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).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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:542
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:740
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
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)
Definition html.lib.php:183
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.