30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/modules/mailings/modules_mailings.php';
32require_once DOL_DOCUMENT_ROOT.
'/comm/mailing/class/mailing.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmailing.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/emailing.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
49$langs->loadLangs(array(
"mails",
"admin"));
51$action =
GETPOST(
'action',
'aZ09');
52$toselect =
GETPOST(
'toselect',
'array');
53$massaction =
GETPOST(
'massaction',
'alpha');
58$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
59$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
61if (empty($page) || $page == -1) {
64$offset = $limit * $page;
68 $sortfield =
"mc.statut,email";
71 $sortorder =
"DESC,ASC";
76$search_lastname =
GETPOST(
"search_lastname",
'alphanohtml');
77$search_firstname =
GETPOST(
"search_firstname",
'alphanohtml');
78$search_email =
GETPOST(
"search_email",
'alphanohtml');
79$search_other =
GETPOST(
"search_other",
'alphanohtml');
80$search_dest_status =
GETPOST(
'search_dest_status',
'int');
89$hookmanager->initHooks(array(
'ciblescard',
'globalcard'));
95$listofmethods = array();
97$listofmethods[
'mail'] =
'PHP mail function';
99$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
100if (version_compare(phpversion(),
'7.0',
'>=')) {
101 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
105if (!$user->hasRight(
'mailing',
'lire') || (!
getDolGlobalString(
'EXTERNAL_USERS_ARE_AUTHORIZED') && $user->socid > 0)) {
108if (empty($action) && empty(
$object->id)) {
112$permissiontoread = $user->hasRight(
'mailing',
'lire');
113$permissiontocreate = $user->hasRight(
'mailing',
'creer');
114$permissiontovalidatesend = $user->hasRight(
'mailing',
'valider');
115$permissiontodelete = $user->hasRight(
'mailing',
'supprimer');
121if (
GETPOST(
'cancel',
'alpha')) {
125if (!
GETPOST(
'confirmmassaction',
'alpha')) {
129if ($action ==
'add' && $permissiontocreate) {
130 $module =
GETPOST(
"module",
'alpha');
134 foreach ($modulesdir as $dir) {
137 dol_syslog(
"Scan directory ".$dir.
" for modules");
140 $file = $dir.
"/".$module.
".modules.php";
141 $classname =
"mailing_".$module;
143 if (file_exists($file)) {
147 dol_syslog(
"Call add_to_target() on class ".$classname.
" evenunsubscribe=".
$object->evenunsubscribe);
150 if (class_exists($classname)) {
151 $obj =
new $classname($db);
152 '@phan-var-force MailingTargets $obj';
153 $obj->evenunsubscribe =
$object->evenunsubscribe;
155 $result = $obj->add_to_target($id);
157 $sqlmessage = $obj->sql;
166 if (
$object->status == $object::STATUS_SENTCOMPLETELY) {
167 $object->setStatut($object::STATUS_SENTPARTIALY);
176 if ($result < 0 && is_object($obj)) {
177 setEventMessages($langs->trans(
"Error").($obj->error ?
' '.$obj->error :
''), null,
'errors');
181if (
GETPOSTINT(
'clearlist') && $permissiontocreate) {
184 $obj->clear_target($id);
191if (
GETPOSTINT(
'exportcsv') && $permissiontoread) {
192 $completefilename =
'targets_emailing'.$object->id.
'_'.
dol_print_date(
dol_now(),
'dayhourlog').
'.csv';
193 header(
'Content-Type: text/csv');
194 header(
'Content-Disposition: attachment;filename='.$completefilename);
197 $sql =
"SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut as status, mc.date_envoi, mc.tms,";
198 $sql .=
" mc.source_id, mc.source_type, mc.error_text";
199 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
200 $sql .=
" WHERE mc.fk_mailing = ".((int)
$object->id);
201 $sql .= $db->order($sortfield, $sortorder);
203 $resql = $db->query($sql);
205 $num = $db->num_rows($resql);
208 while ($obj = $db->fetch_object($resql)) {
209 print $obj->rowid.$sep;
210 print
'"'.$obj->lastname.
'"'.$sep;
211 print
'"'.$obj->firstname.
'"'.$sep;
212 print $obj->email.$sep;
213 print $obj->other.$sep;
214 print $obj->tms.$sep;
215 print $obj->source_type.$sep;
216 print $obj->source_id.$sep;
217 print $obj->date_envoi.$sep;
218 print $obj->status.$sep;
219 print
'"'.$obj->error_text.
'"'.$sep;
230if ($action ==
'delete' && $permissiontocreate) {
232 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"mailing_cibles WHERE rowid = ".((int) $rowid);
233 $resql = $db->query($sql);
237 $obj->update_nb($id);
241 header(
"Location: list.php");
249if ($action ==
"confirm_reset_target" && $permissiontocreate) {
254 foreach ($toselect as $toselectid) {
255 $result =
$object->resetTargetErrorStatus($user, $toselectid);
260 } elseif ($result > 0) {
277if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
278 $search_lastname =
'';
279 $search_firstname =
'';
282 $search_dest_status =
'';
287if (($action ==
'settitle' || $action ==
'setemail_from' || $action ==
'setreplyto' || $action ==
'setemail_errorsto' || $action ==
'setevenunsubscribe') && $permissiontocreate) {
290 if ($action ==
'settitle') {
292 } elseif ($action ==
'setemail_from') {
293 $object->email_from = trim(
GETPOST(
'email_from',
'alphawithlgt'));
294 } elseif ($action ==
'setemail_replyto') {
295 $object->email_replyto = trim(
GETPOST(
'email_replyto',
'alphawithlgt'));
296 } elseif ($action ==
'setemail_errorsto') {
297 $object->email_errorsto = trim(
GETPOST(
'email_errorsto',
'alphawithlgt'));
298 } elseif ($action ==
'settitle' && empty(
$object->title)) {
299 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTitle"));
300 } elseif ($action ==
'setfrom' && empty(
$object->email_from)) {
301 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailFrom"));
302 } elseif ($action ==
'setevenunsubscribe') {
307 $result =
$object->update($user);
309 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
324$form =
new Form($db);
327$help_url =
'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
328llxHeader(
'', $langs->trans(
"Mailing"), $help_url);
330$arrayofselected = is_array($toselect) ? $toselect : array();
340 $linkback =
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
342 $morehtmlref =
'<div class="refidno">';
344 $morehtmlref .= $form->editfieldkey(
"",
'title',
$object->title, $object, 0,
'string',
'', 0, 1);
345 $morehtmlref .= $form->editfieldval(
"",
'title',
$object->title, $object, 0,
'string',
'',
null,
null,
'', 1);
346 $morehtmlref .=
'</div>';
348 $morehtmlstatus =
'';
350 if (
$object->status == $object::STATUS_SENTPARTIALY ||
$object->status == $object::STATUS_SENTCOMPLETELY) {
351 $nbtry =
$object->countNbOfTargets(
'alreadysent');
352 $nbko =
$object->countNbOfTargets(
'alreadysentko');
353 $nbok = ($nbtry - $nbko);
355 $morehtmlstatus .=
' ('.$nbtry.
'/'.
$object->nbemail;
357 $morehtmlstatus .=
' - '.$nbko.
' '.$langs->trans(
"Error");
359 $morehtmlstatus .=
') ';
362 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'', $morehtmlstatus);
364 print
'<div class="fichecenter">';
365 print
'<div class="fichehalfleft">';
366 print
'<div class="underbanner clearboth"></div>';
368 print
'<table class="border centpercent tableforfield">'.
"\n";
371 print
'<tr><td class="titlefield">';
372 print $langs->trans(
"MailFrom").
'</td><td>';
374 foreach ($emailarray as $email => $name) {
375 if ($name && $name != $email) {
379 $langs->load(
"errors");
380 print
img_warning($langs->trans(
"ErrorBadEMail", $email));
390 if (
$object->messtype !=
'sms') {
391 print
'<tr><td>'.$langs->trans(
"MailErrorsTo").
'</td><td>';
393 foreach ($emailarray as $email => $name) {
394 if ($name != $email) {
398 $langs->load(
"errors");
399 print
img_warning($langs->trans(
"ErrorBadEMail", $email));
401 $langs->load(
"errors");
402 print
img_warning($langs->trans(
"ErrorBadMXDomain", $email));
412 if (
$object->messtype !=
'sms') {
414 print $form->editfieldkey(
"MailReply",
'email_replyto',
$object->email_replyto, $object, (
int) ($user->hasRight(
'mailing',
'creer') &&
$object->status < $object::STATUS_SENTCOMPLETELY),
'string');
416 print $form->editfieldval(
"MailReply",
'email_replyto',
$object->email_replyto, $object, $user->hasRight(
'mailing',
'creer') &&
$object->status < $object::STATUS_SENTCOMPLETELY,
'string');
418 if ($action !=
'editemail_replyto') {
420 $langs->load(
"errors");
421 print
img_warning($langs->trans(
"ErrorBadEMail", $email));
423 $langs->load(
"errors");
424 print
img_warning($langs->trans(
"ErrorBadMXDomain", $email));
434 print
'<div class="fichehalfright">';
435 print
'<div class="underbanner clearboth"></div>';
437 print
'<table class="border centpercent tableforfield">';
441 print $langs->trans(
"TotalNbOfDistinctRecipients");
444 if (is_numeric($nbemail)) {
448 $htmltooltip .= $langs->trans(
'LimitSendingEmailing',
getDolGlobalString(
'MAILING_LIMIT_SENDBYWEB'));
450 $htmltooltip .= $langs->trans(
'SendingFromWebInterfaceIsNotAllowed');
453 if (empty($nbemail)) {
454 $nbemail .=
' '.img_warning($langs->trans(
'ToAddRecipientsChooseHere'));
457 print $form->textwithpicto($nbemail, $htmltooltip, 1,
'info');
465 print $langs->trans(
"MAIN_MAIL_SENDMODE");
467 if (
$object->messtype !=
'sms') {
473 $text = $listofmethods[
'mail'];
478 print
' <span class="opacitymedium">('.getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER_EMAILING',
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER')).
')</span>';
481 print
' <span class="opacitymedium">('.getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER').
')</span>';
485 print
' <span class="opacitymedium">('.getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER').
')</span>';
490 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
496 print
'<div class="clearboth"></div>';
504 $allowaddtarget = (
$object->status == $object::STATUS_DRAFT);
505 if (
GETPOST(
'allowaddtarget')) {
508 if (!$allowaddtarget) {
509 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&allowaddtarget=1',
'', $user->hasRight(
'mailing',
'creer'));
513 if ($allowaddtarget && $user->hasRight(
'mailing',
'creer')) {
514 print
load_fiche_titre($langs->trans(
"ToAddRecipientsChooseHere").
'...', ($user->admin ?
info_admin($langs->trans(
"YouCanAddYourOwnPredefindedListHere"), 1) :
''),
'');
516 print
'<div class="div-table-responsive">';
517 print
'<div class="tagtable centpercentwithout1imp liste_titre_bydiv borderbottom" id="tablelines">';
519 print
'<div class="tagtr liste_titre">';
520 print
'<div class="tagtd"></div>';
521 print
'<div class="tagtd">'.$langs->trans(
"RecipientSelectionModules").
'</div>';
522 print
'<div class="tagtd center maxwidth150">';
523 if (
$object->messtype !=
'sms') {
524 print $langs->trans(
"NbOfUniqueEMails");
526 print $langs->trans(
"NbOfUniquePhones");
529 print
'<div class="tagtd left"><div class="inline-block">'.$langs->trans(
"Filters").
'</div>';
530 if (
$object->messtype !=
'sms') {
531 print
' <div class="inline-block valignmiddle">'.$langs->trans(
"EvenUnsubscribe").
' ';
532 print
ajax_object_onoff($object,
'evenunsubscribe',
'evenunsubscribe',
'EvenUnsubscribe:switch_on:warning',
'EvenUnsubscribe', array(),
'small valignmiddle reposition',
'', 1);
536 print
'<div class="tagtd"> </div>';
541 foreach ($modulesdir as $dir) {
542 $modulenames = array();
546 dol_syslog(
"Scan directory ".$dir.
" for modules");
547 $handle = @opendir($dir);
548 if (is_resource($handle)) {
549 while (($file = readdir($handle)) !==
false) {
550 if (substr($file, 0, 1) !=
'.' && substr($file, 0, 3) !=
'CVS') {
552 if (preg_match(
"/(.*)\.modules\.php$/i", $file, $reg)) {
553 if ($reg[1] ==
'example') {
556 $modulenames[] = $reg[1];
569 foreach ($modulenames as $modulename) {
571 $file = $dir.$modulename.
".modules.php";
572 $classname =
"mailing_".$modulename;
575 $obj =
new $classname($db);
576 '@phan-var-force MailingTargets $obj';
579 $qualified = (is_null($obj->enabled) ? 1 : (int)
dol_eval((
string) $obj->enabled, 1));
582 foreach ($obj->require_module as $key) {
583 if (empty(
$conf->$key->enabled) || (empty($user->admin) && $obj->require_admin)) {
592 if ($allowaddtarget) {
593 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">';
594 print
'<input type="hidden" name="token" value="'.newToken().
'">';
595 print
'<input type="hidden" name="action" value="add">';
596 print
'<input type="hidden" name="page_y" value="'.newToken().
'">';
598 print
'<div class="oddeven trforbreakperms trforbreaknobg impair tagtr">';
601 print
'<div class="tagtd paddingleftlarge marginleftonly paddingrightlarge marginrightonly valignmiddle center">';
602 if (empty($obj->picto)) {
603 $obj->picto =
'generic';
605 print
img_object($langs->trans(
"EmailingTargetSelector").
': '.get_class($obj), $obj->picto,
'class="valignmiddle width25 size15x"');
607 print
'<div class="tagtd valignmiddle">';
608 print $obj->getDesc();
614 $obj->evenunsubscribe =
$object->evenunsubscribe;
616 $nbofrecipient = $obj->getNbOfRecipients(
'');
621 print
'<div class="tagtd center valignmiddle">';
622 if ($nbofrecipient ===
'' || $nbofrecipient >= 0) {
623 print $nbofrecipient;
625 print $langs->trans(
"Error").
' '.
img_error($obj->error);
629 print
'<div class="tagtd left valignmiddle">';
630 if ($allowaddtarget) {
632 $filter = $obj->formFilter();
639 print $langs->trans(
"None");
644 print
'<div class="tagtd right valignmiddle">';
645 if ($allowaddtarget) {
646 print
'<input type="submit" class="button button-add small reposition" name="button_'.$modulename.
'" value="'.$langs->trans(
"Add").
'">';
648 print
'<input type="submit" class="button small disabled" disabled="disabled" name="button_'.$modulename.
'" value="'.$langs->trans(
"Add").
'">';
654 if ($allowaddtarget) {
663 $parameters = array();
664 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
665 print $hookmanager->resPrint;
672 if ($sqlmessage && $user->admin) {
673 print
info_admin($langs->trans(
"SQLUsedForExport").
':<br> '.$sqlmessage, 0, 0,
'1',
'',
'TechnicalInformation');
683 $sql =
"SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut as status, mc.date_envoi, mc.tms,";
684 $sql .=
" mc.source_url, mc.source_id, mc.source_type, mc.error_text,";
685 $sql .=
" COUNT(mu.rowid) as nb";
686 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
687 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"mailing_unsubscribe as mu ON mu.email = mc.email";
688 $sql .=
" WHERE mc.fk_mailing=".((int)
$object->id);
689 $asearchcriteriahasbeenset = 0;
690 if ($search_lastname) {
692 $asearchcriteriahasbeenset++;
694 if ($search_firstname) {
696 $asearchcriteriahasbeenset++;
700 $asearchcriteriahasbeenset++;
704 $asearchcriteriahasbeenset++;
706 if ($search_dest_status !=
'' && (
int) $search_dest_status >= -1) {
707 $sql .=
" AND mc.statut = ".((int) $search_dest_status);
708 $asearchcriteriahasbeenset++;
710 $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';
711 $sql .= $db->order($sortfield, $sortorder);
715 $nbtotalofrecords =
'';
717 $result = $db->query($sql);
718 $nbtotalofrecords = $db->num_rows($result);
719 if (($page * $limit) > $nbtotalofrecords) {
725 if (empty($asearchcriteriahasbeenset)) {
726 if ($nbtotalofrecords !=
$object->nbemail) {
727 dol_syslog(
"We found a difference in nb of record in target table and the property ->nbemail, we fix ->nbemail");
729 $resultrefresh =
$object->refreshNbOfTargets();
730 if ($resultrefresh < 0) {
738 $sql .= $db->plimit($limit + 1, $offset);
740 $resql = $db->query($sql);
742 $num = $db->num_rows($resql);
744 $param =
"&id=".$object->id;
746 if ($limit > 0 && $limit !=
$conf->liste_limit) {
747 $param .=
'&limit='.((int) $limit);
749 if ($search_lastname) {
750 $param .=
"&search_lastname=".urlencode($search_lastname);
752 if ($search_firstname) {
753 $param .=
"&search_firstname=".urlencode($search_firstname);
756 $param .=
"&search_email=".urlencode($search_email);
759 $param .=
"&search_other=".urlencode($search_other);
762 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
763 print
'<input type="hidden" name="token" value="'.newToken().
'">';
764 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
765 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
766 print
'<input type="hidden" name="page" value="'.$page.
'">';
767 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
768 print
'<input type="hidden" name="page_y" value="">';
770 $morehtmlcenter =
'';
771 $arrayofmassactions = array();
772 if ($permissiontocreate) {
773 $arrayofmassactions[
'reset_target'] =
img_picto(
'',
'refresh',
'class="pictofixedwidth"').$langs->trans(
"ResetMailingTargetMassaction");
775 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
776 $morehtmlcenter .= $massactionbutton .
'<br>';
778 if (
$object->status == $object::STATUS_DRAFT) {
779 $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>';
781 $morehtmlcenter .=
' <a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=exportcsv&token='.
newToken().
'&exportcsv=1&id='.
$object->id.
'">'.
img_picto(
'',
'download',
'class="pictofixedwidth"').$langs->trans(
"Download").
'</a>';
785 print
"\n<!-- List of selected targets -->\n";
786 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
787 print
'<input type="hidden" name="token" value="'.newToken().
'">';
788 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
789 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
790 print
'<input type="hidden" name="page" value="'.$page.
'">';
791 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
792 print
'<input type="hidden" name="limit" value="'.$limit.
'">';
793 print
'<input type="hidden" name="page_y" value="">';
796 print_barre_liste($langs->trans(
"MailSelectedRecipients"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords,
'generic', 0, $newcardbutton,
'', $limit, 0, 0, 1);
798 if ($massaction ==
'reset_target') {
800 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"ConfirmResetMailingTargetMassaction"), $langs->trans(
"ConfirmResetMailingTargetMassactionQuestion"),
"confirm_reset_target",
null,
'', 0, 0, 500, 1);
803 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
804 $htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column ?
'left' :
'');
805 $selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
806 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
808 print
'<div class="div-table-responsive">';
809 print
'<table class="noborder centpercent">';
812 print
'<tr class="liste_titre_filter">';
815 if (
$conf->main_checkbox_left_column) {
816 print
'<td class="liste_titre maxwidthsearch">';
817 $searchpicto = $form->showFilterButtons(
'left');
822 print
'<td class="liste_titre">';
823 print
'<input class="flat maxwidth75" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).
'">';
826 print
'<td class="liste_titre">';
827 print
'<input class="flat maxwidth50" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).
'">';
830 print
'<td class="liste_titre">';
831 print
'<input class="flat maxwidth50" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).
'">';
834 print
'<td class="liste_titre">';
835 print
'<input class="flat maxwidth100" type="text" name="search_other" value="'.dol_escape_htmltag($search_other).
'">';
838 print
'<td class="liste_titre">';
843 print
'<td class="liste_titre">';
848 print
'<td class="liste_titre">';
853 print
'<td class="liste_titre center parentonrightofpage">';
854 print $formmailing->selectDestinariesStatus($search_dest_status,
'search_dest_status', 1,
'width100 onrightofpage');
858 if (!
$conf->main_checkbox_left_column) {
859 print
'<td class="liste_titre maxwidthsearch">';
860 $searchpicto = $form->showFilterButtons();
868 $param .=
"&page=".urlencode((
string) ($page));
871 print
'<tr class="liste_titre">';
873 if (
$conf->main_checkbox_left_column) {
874 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
878 print_liste_field_titre(
"Lastname", $_SERVER[
"PHP_SELF"],
"mc.lastname",
'', $param,
"", $sortfield, $sortorder);
879 print_liste_field_titre(
"Firstname", $_SERVER[
"PHP_SELF"],
"mc.firstname",
'', $param,
"", $sortfield, $sortorder);
880 print_liste_field_titre(
"OtherInformations", $_SERVER[
"PHP_SELF"],
'',
"", $param,
"", $sortfield, $sortorder);
881 print_liste_field_titre(
"Source", $_SERVER[
"PHP_SELF"],
'',
"", $param,
'', $sortfield, $sortorder,
'center ');
883 print_liste_field_titre(
"DateLastModification", $_SERVER[
"PHP_SELF"],
"mc.tms",
'', $param,
'', $sortfield, $sortorder,
'center ');
885 print_liste_field_titre(
"DateSending", $_SERVER[
"PHP_SELF"],
"mc.date_envoi",
'', $param,
'', $sortfield, $sortorder,
'center ');
886 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"mc.statut",
'', $param,
'', $sortfield, $sortorder,
'center ');
888 if (!
$conf->main_checkbox_left_column) {
889 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
897 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
898 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
899 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
900 include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
901 include_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
903 $objectstaticmember =
new Adherent($db);
904 $objectstaticuser =
new User($db);
905 $objectstaticcompany =
new Societe($db);
906 $objectstaticcontact =
new Contact($db);
909 while ($i < min($num, $limit)) {
910 $obj = $db->fetch_object($resql);
912 print
'<tr class="oddeven">';
915 if (
$conf->main_checkbox_left_column) {
916 print
'<td class="center nowraponall">';
917 print
'<!-- ID mailing_cibles = '.$obj->rowid.
' -->';
918 if ($massactionbutton || $massaction) {
920 if (in_array($obj->rowid, $arrayofselected)) {
923 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
925 if ($obj->status == $object::STATUS_DRAFT) {
926 if ($user->hasRight(
'mailing',
'creer')) {
927 print
'<a class="reposition marginleftonly" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&rowid='.((int) $obj->rowid).$param.
'">'.
img_delete($langs->trans(
"RemoveRecipient")).
'</a>';
937 print
'<td class="tdoverflowmax150">';
938 print
img_picto($obj->email,
'email',
'class="paddingright"');
940 print
img_warning($langs->trans(
"EmailOptedOut"),
'warning',
'pictofixedwidth');
945 print
'<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($obj->lastname).
'">'.
dolPrintHTML($obj->lastname).
'</td>';
947 print
'<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($obj->firstname).
'">'.
dolPrintHTML($obj->firstname).
'</td>';
949 print
'<td class="tdoverflowmax300" title="'.dolPrintHTMLForAttribute($obj->other).
'"><span class="small">'.
dolPrintHTML($obj->other).
'</small></td>';
951 print
'<td class="center tdoverflowmax150">';
952 if (empty($obj->source_id) || empty($obj->source_type)) {
953 print empty($obj->source_url) ?
'' : $obj->source_url;
955 if ($obj->source_type ==
'member') {
956 $objectstaticmember->fetch($obj->source_id);
957 print $objectstaticmember->getNomUrl(1);
958 } elseif ($obj->source_type ==
'user') {
959 $objectstaticuser->fetch($obj->source_id);
960 print $objectstaticuser->getNomUrl(1);
961 } elseif ($obj->source_type ==
'thirdparty') {
962 $objectstaticcompany->fetch($obj->source_id);
963 print $objectstaticcompany->getNomUrl(1);
964 } elseif ($obj->source_type ==
'contact') {
965 $objectstaticcontact->fetch($obj->source_id);
966 print $objectstaticcontact->getNomUrl(1);
967 } elseif ($obj->source_type ==
'eventorganizationattendee') {
968 $objectstaticeventorganization->fetch($obj->source_id);
969 print $objectstaticeventorganization->getNomUrl(1);
971 print $obj->source_url;
977 print
'<td class="center nowraponall">';
978 print
dol_print_date($db->jdate($obj->tms),
'dayhour',
'tzuserrel');
982 print
'<td class="center nowraponall">';
983 if ($obj->status != $object::STATUS_DRAFT) {
985 print
dol_print_date($db->jdate($obj->date_envoi),
'dayhour',
'tzuserrel');
990 print
'<td class="nowrap center">';
991 if ($obj->status == $object::STATUS_DRAFT) {
992 print $object::libStatutDest((
int) $obj->status, 2,
'');
994 print $object::libStatutDest((
int) $obj->status, 2, $obj->error_text);
999 if (!
$conf->main_checkbox_left_column) {
1000 print
'<td class="center nowraponall">';
1001 print
'<!-- ID mailing_cibles = '.$obj->rowid.
' -->';
1002 if ($obj->status == $object::STATUS_DRAFT) {
1003 if ($user->hasRight(
'mailing',
'creer')) {
1004 print
'<a class="reposition marginleftonly" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&rowid='.((int) $obj->rowid).$param.
'">'.
img_delete($langs->trans(
"RemoveRecipient")).
'</a>';
1018 if (
$object->status < $object::STATUS_SENTPARTIALY) {
1019 print
'<tr><td colspan="9">';
1020 print
'<span class="opacitymedium">'.$langs->trans(
"NoTargetYet").
'</span>';
1023 print
'<tr><td colspan="9">';
1024 print
'<span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span>';
1028 print
"</table><br>";
1038 print
"\n<!-- End list of selected targets -->\n";
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array(), $morecss='', $htmlname='', $forcenojs=0, $moreparam='')
On/off button to change a property status of an object This uses the ajax service objectonoff....
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
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 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.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
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.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
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.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.