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';
47$langs->loadLangs(array(
"mails",
"admin"));
49$action =
GETPOST(
'action',
'aZ09');
50$toselect =
GETPOST(
'toselect',
'array:int');
51$contextpage =
GETPOST(
'contextpage',
'aZ');
52$massaction =
GETPOST(
'massaction',
'alpha');
57$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
58$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
60if (empty($page) || $page == -1) {
63$offset = $limit * $page;
67 $sortfield =
"mc.statut,email";
70 $sortorder =
"DESC,ASC";
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');
88$hookmanager->initHooks(array(
'ciblescard',
'globalcard'));
94$listofmethods = array();
96$listofmethods[
'mail'] =
'PHP mail function';
98$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
99if (version_compare(phpversion(),
'7.0',
'>=')) {
100 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
103$arrayfields = array();
106if (!$user->hasRight(
'mailing',
'lire') || (!
getDolGlobalString(
'EXTERNAL_USERS_ARE_AUTHORIZED') && $user->socid > 0)) {
109if (empty($action) && empty(
$object->id)) {
113$permissiontoread = $user->hasRight(
'mailing',
'lire');
114$permissiontocreate = $user->hasRight(
'mailing',
'creer');
115$permissiontovalidatesend = $user->hasRight(
'mailing',
'valider');
116$permissiontodelete = $user->hasRight(
'mailing',
'supprimer');
122if (
GETPOST(
'cancel',
'alpha')) {
126if (!
GETPOST(
'confirmmassaction',
'alpha')) {
130if ($action ==
'add' && $permissiontocreate) {
131 $module =
GETPOST(
"module",
'alpha');
135 foreach ($modulesdir as $dir) {
138 dol_syslog(
"Scan directory ".$dir.
" for modules");
141 $file = $dir.
"/".$module.
".modules.php";
142 $classname =
"mailing_".$module;
144 if (file_exists($file)) {
148 dol_syslog(
"Call add_to_target() on class ".$classname.
" evenunsubscribe=".
$object->evenunsubscribe);
151 if (class_exists($classname)) {
152 $obj =
new $classname(
$db);
153 '@phan-var-force MailingTargets $obj';
154 $obj->evenunsubscribe =
$object->evenunsubscribe;
156 $result = $obj->add_to_target($id);
158 $sqlmessage = $obj->sql;
167 if (
$object->status == $object::STATUS_SENTCOMPLETELY) {
168 $object->setStatut($object::STATUS_SENTPARTIALY);
177 if ($result < 0 && is_object($obj)) {
178 setEventMessages($langs->trans(
"Error").($obj->error ?
' '.$obj->error :
''), null,
'errors');
182if (
GETPOSTINT(
'clearlist') && $permissiontocreate) {
185 $obj->clear_target($id);
192if (
GETPOSTINT(
'exportcsv') && $permissiontoread) {
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);
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);
204 $resql =
$db->query($sql);
206 $num =
$db->num_rows($resql);
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;
231if ($action ==
'delete' && $permissiontocreate) {
233 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"mailing_cibles WHERE rowid = ".((int) $rowid);
234 $resql =
$db->query($sql);
238 $obj->update_nb($id);
242 header(
"Location: list.php");
250if ($action ==
"confirm_reset_target" && $permissiontocreate) {
255 foreach ($toselect as $toselectid) {
256 $result =
$object->resetTargetErrorStatus($user, $toselectid);
261 } elseif ($result > 0) {
278if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
279 $search_lastname =
'';
280 $search_firstname =
'';
283 $search_dest_status =
'';
288if (($action ==
'settitle' || $action ==
'setemail_from' || $action ==
'setemail_replyto' || $action ==
'setemail_errorsto' || $action ==
'setevenunsubscribe') && $permissiontocreate) {
292 if ($action ==
'settitle') {
294 } elseif ($action ==
'setemail_from') {
295 $object->email_from = trim(
GETPOST(
'email_from',
'alphawithlgt'));
296 } elseif ($action ==
'setemail_replyto') {
297 $object->email_replyto = trim(
GETPOST(
'email_replyto',
'alphawithlgt'));
298 } elseif ($action ==
'setemail_errorsto') {
299 $object->email_errorsto = trim(
GETPOST(
'email_errorsto',
'alphawithlgt'));
300 } elseif ($action ==
'setevenunsubscribe') {
303 if ($action ==
'settitle' && empty(
$object->title)) {
304 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTitle"));
306 if ($action ==
'setemail_from' && empty(
$object->email_from)) {
307 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailFrom"));
311 $result =
$object->update($user);
313 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
331$help_url =
'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
332llxHeader(
'', $langs->trans(
"Mailing"), $help_url);
334$arrayofselected = is_array($toselect) ? $toselect : array();
344 $linkback =
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
346 $morehtmlref =
'<div class="refidno">';
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>';
352 $morehtmlstatus =
'';
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);
359 $morehtmlstatus .=
' ('.$nbtry.
'/'.
$object->nbemail;
361 $morehtmlstatus .=
' - '.$nbko.
' '.$langs->trans(
"Error");
363 $morehtmlstatus .=
') ';
366 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'', $morehtmlstatus);
368 print
'<div class="fichecenter">';
369 print
'<div class="fichehalfleft">';
370 print
'<div class="underbanner clearboth"></div>';
372 print
'<table class="border centpercent tableforfield">'.
"\n";
375 print
'<tr><td class="titlefield">';
376 print $langs->trans(
"MailFrom").
'</td><td>';
378 foreach ($emailarray as $email => $name) {
379 if ($name && $name != $email) {
383 $langs->load(
"errors");
384 print
img_warning($langs->trans(
"ErrorBadEMail", $email));
394 if (
$object->messtype !=
'sms') {
395 print
'<tr><td>'.$langs->trans(
"MailErrorsTo").
'</td><td>';
397 foreach ($emailarray as $email => $name) {
398 if ($name != $email) {
402 $langs->load(
"errors");
403 print
img_warning($langs->trans(
"ErrorBadEMail", $email));
405 $langs->load(
"errors");
406 print
img_warning($langs->trans(
"ErrorBadMXDomain", $email));
416 if (
$object->messtype !=
'sms') {
418 print $form->editfieldkey(
"MailReply",
'email_replyto',
$object->email_replyto, $object, (
int) ($user->hasRight(
'mailing',
'creer') &&
$object->status < $object::STATUS_SENTCOMPLETELY),
'string');
420 print $form->editfieldval(
"MailReply",
'email_replyto',
$object->email_replyto, $object, $user->hasRight(
'mailing',
'creer') &&
$object->status < $object::STATUS_SENTCOMPLETELY,
'string');
422 if ($action !=
'editemail_replyto') {
424 $langs->load(
"errors");
425 print
img_warning($langs->trans(
"ErrorBadEMail", $email));
427 $langs->load(
"errors");
428 print
img_warning($langs->trans(
"ErrorBadMXDomain", $email));
438 print
'<div class="fichehalfright">';
439 print
'<div class="underbanner clearboth"></div>';
441 print
'<table class="border centpercent tableforfield">';
445 print $langs->trans(
"TotalNbOfDistinctRecipients");
448 if (is_numeric($nbemail)) {
452 $htmltooltip .= $langs->trans(
'LimitSendingEmailing',
getDolGlobalString(
'MAILING_LIMIT_SENDBYWEB'));
454 $htmltooltip .= $langs->trans(
'SendingFromWebInterfaceIsNotAllowed');
457 if (empty($nbemail)) {
458 $nbemail .=
' '.img_warning($langs->trans(
'ToAddRecipientsChooseHere'));
461 print $form->textwithpicto($nbemail, $htmltooltip, 1,
'info');
469 print $langs->trans(
"MAIN_MAIL_SENDMODE");
471 if (
$object->messtype !=
'sms') {
477 $text = $listofmethods[
'mail'];
482 print
' <span class="opacitymedium">('.getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER_EMAILING',
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER')).
')</span>';
485 print
' <span class="opacitymedium">('.getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER').
')</span>';
489 print
' <span class="opacitymedium">('.getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER').
')</span>';
494 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
500 print
'<div class="clearboth"></div>';
506 $allowaddtarget = (
$object->status == $object::STATUS_DRAFT);
507 if (
GETPOST(
'allowaddtarget')) {
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'));
515 if ($allowaddtarget && $user->hasRight(
'mailing',
'creer')) {
516 print
'<div class="info">';
517 print $langs->trans(
"ToAddRecipientsChooseHere").
'...';
521 print
'<div class="div-table-responsive">';
522 print
'<div class="tagtable centpercentwithout1imp liste_titre_bydiv borderbottom" id="tablelines">';
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) :
'');
529 print
'<div class="tagtd center maxwidth150">';
530 if (
$object->messtype !=
'sms') {
531 print $langs->trans(
"NbOfUniqueEMails");
533 print $langs->trans(
"NbOfUniquePhones");
536 print
'<div class="tagtd left"><div class="inline-block">'.$langs->trans(
"Filters").
'</div>';
537 if (
$object->messtype !=
'sms') {
538 print
' <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');
556 print
'<div class="tagtd"> </div>';
561 foreach ($modulesdir as $dir) {
562 $modulenames = array();
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') {
572 if (preg_match(
"/(.*)\.modules\.php$/i", $file, $reg)) {
573 if ($reg[1] ==
'example') {
576 $modulenames[] = $reg[1];
587 foreach ($modulenames as $modulename) {
589 $file = $dir.$modulename.
".modules.php";
590 $classname =
"mailing_".$modulename;
593 $obj =
new $classname(
$db);
594 '@phan-var-force MailingTargets $obj';
597 $qualified = (is_null($obj->enabled) ? 1 : (int)
dol_eval((
string) $obj->enabled, 1));
600 foreach ($obj->require_module as $key) {
601 if (empty(
$conf->$key->enabled) || (empty($user->admin) && $obj->require_admin)) {
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().
'">';
617 print
'<div class="oddeven trforbreakperms trforbreaknobg impair tagtr">';
620 print
'<div class="tagtd paddingleftlarge marginleftonly paddingrightlarge marginrightonly valignmiddle center">';
621 if (empty($obj->picto)) {
622 $obj->picto =
'generic';
624 print
img_object($langs->trans(
"EmailingTargetSelector").
': '.get_class($obj), $obj->picto,
'class="valignmiddle width25 size15x"');
626 print
'<div class="tagtd valignmiddle">';
627 print $obj->getDesc();
633 $obj->evenunsubscribe =
$object->evenunsubscribe;
635 $nbofrecipient = $obj->getNbOfRecipients(
'');
640 print
'<div class="tagtd center valignmiddle">';
641 if ($nbofrecipient ===
'' || $nbofrecipient >= 0) {
642 if ($nbofrecipient !==
'') {
643 print
'<span class="badge badge-info">'.$nbofrecipient.
'</span>';
646 print $langs->trans(
"Error").
' '.
img_error($obj->error);
650 print
'<div class="tagtd left valignmiddle">';
651 if ($allowaddtarget) {
654 $filter = $obj->formFilter();
661 print $langs->trans(
"None");
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").
'">';
670 print
'<input type="submit" class="button small disabled" disabled="disabled" name="button_'.$modulename.
'" value="'.$langs->trans(
"Add").
'">';
676 if ($allowaddtarget) {
685 $parameters = array();
686 $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
687 print $hookmanager->resPrint;
694 if ($sqlmessage && $user->admin) {
695 print
info_admin($langs->trans(
"SQLUsedForExport").
':<br> '.$sqlmessage, 0, 0,
'1',
'',
'TechnicalInformation');
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) {
714 $asearchcriteriahasbeenset++;
716 if ($search_firstname) {
718 $asearchcriteriahasbeenset++;
722 $asearchcriteriahasbeenset++;
726 $asearchcriteriahasbeenset++;
728 if ($search_dest_status !=
'' && (
int) $search_dest_status >= -1) {
729 $sql .=
" AND mc.statut = ".((int) $search_dest_status);
730 $asearchcriteriahasbeenset++;
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);
737 $nbtotalofrecords =
'';
739 $result =
$db->query($sql);
740 $nbtotalofrecords =
$db->num_rows($result);
741 if (($page * $limit) > (int) $nbtotalofrecords) {
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");
751 $resultrefresh =
$object->refreshNbOfTargets();
752 if ($resultrefresh < 0) {
760 $sql .=
$db->plimit($limit + 1, $offset);
762 $resql =
$db->query($sql);
764 $num =
$db->num_rows($resql);
766 $param =
"&id=".$object->id;
768 if ($limit > 0 && $limit !=
$conf->liste_limit) {
769 $param .=
'&limit='.((int) $limit);
771 if ($search_lastname) {
772 $param .=
"&search_lastname=".urlencode($search_lastname);
774 if ($search_firstname) {
775 $param .=
"&search_firstname=".urlencode($search_firstname);
778 $param .=
"&search_email=".urlencode($search_email);
781 $param .=
"&search_other=".urlencode($search_other);
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="">';
792 $morehtmlcenter =
'';
793 $arrayofmassactions = array();
794 if ($permissiontocreate) {
795 $arrayofmassactions[
'reset_target'] =
img_picto(
'',
'refresh',
'class="pictofixedwidth"').$langs->trans(
"ResetMailingTargetMassaction");
797 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
798 $morehtmlcenter .= $massactionbutton .
'<br>';
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>';
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> ';
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="">';
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);
821 if ($massaction ==
'reset_target') {
823 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"ConfirmResetMailingTargetMassaction"), $langs->trans(
"ConfirmResetMailingTargetMassactionQuestion"),
"confirm_reset_target",
null,
'', 0, 0, 500, 1);
826 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
827 $htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column ?
'left' :
'');
828 $selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
829 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
831 print
'<div class="div-table-responsive">';
832 print
'<table class="noborder centpercent">';
835 print
'<tr class="liste_titre_filter">';
838 if (
$conf->main_checkbox_left_column) {
839 print
'<td class="liste_titre maxwidthsearch">';
840 $searchpicto = $form->showFilterButtons(
'left');
845 print
'<td class="liste_titre">';
846 print
'<input class="flat maxwidth75" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).
'">';
849 print
'<td class="liste_titre">';
850 print
'<input class="flat maxwidth50" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).
'">';
853 print
'<td class="liste_titre">';
854 print
'<input class="flat maxwidth50" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).
'">';
857 print
'<td class="liste_titre">';
858 print
'<input class="flat maxwidth100" type="text" name="search_other" value="'.dol_escape_htmltag($search_other).
'">';
861 print
'<td class="liste_titre">';
866 print
'<td class="liste_titre">';
871 print
'<td class="liste_titre">';
876 print
'<td class="liste_titre center parentonrightofpage">';
877 print $formmailing->selectDestinariesStatus($search_dest_status,
'search_dest_status', 1,
'width100 onrightofpage');
881 if (!
$conf->main_checkbox_left_column) {
882 print
'<td class="liste_titre maxwidthsearch">';
883 $searchpicto = $form->showFilterButtons();
891 $param .=
"&page=".urlencode((
string) ($page));
894 print
'<tr class="liste_titre">';
896 if (
$conf->main_checkbox_left_column) {
897 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
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 ');
906 print_liste_field_titre(
"DateLastModification", $_SERVER[
"PHP_SELF"],
"mc.tms",
'', $param,
'', $sortfield, $sortorder,
'center ');
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 ');
911 if (!
$conf->main_checkbox_left_column) {
912 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
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';
927 $objectstaticuser =
new User(
$db);
932 while ($i < min($num, $limit)) {
933 $obj =
$db->fetch_object($resql);
935 print
'<tr class="oddeven">';
938 if (
$conf->main_checkbox_left_column) {
939 print
'<td class="center nowraponall">';
940 print
'<!-- ID mailing_cibles = '.$obj->rowid.
' -->';
941 if ($massactionbutton || $massaction) {
943 if (in_array($obj->rowid, $arrayofselected)) {
946 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
948 if ($obj->status == $object::STATUS_DRAFT) {
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>';
960 print
'<td class="tdoverflowmax150">';
961 print
img_picto($obj->email,
'email',
'class="paddingright"');
963 print
img_warning($langs->trans(
"EmailOptedOut"),
'warning',
'pictofixedwidth');
968 print
'<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($obj->lastname).
'">'.
dolPrintHTML($obj->lastname).
'</td>';
970 print
'<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($obj->firstname).
'">'.
dolPrintHTML($obj->firstname).
'</td>';
972 print
'<td class="tdoverflowmax300" title="'.dolPrintHTMLForAttribute($obj->other).
'"><span class="small">'.
dolPrintHTML($obj->other).
'</small></td>';
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;
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);
994 print $obj->source_url;
1000 print
'<td class="center nowraponall">';
1005 print
'<td class="center nowraponall">';
1006 if ($obj->status != $object::STATUS_DRAFT) {
1013 print
'<td class="nowrap center">';
1014 if ($obj->status == $object::STATUS_DRAFT) {
1015 print $object::libStatutDest((
int) $obj->status, 2,
'');
1017 print $object::libStatutDest((
int) $obj->status, 2, $obj->error_text);
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) {
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>';
1041 if (
$object->status < $object::STATUS_SENTPARTIALY) {
1042 print
'<tr><td colspan="9">';
1043 print
'<span class="opacitymedium">'.$langs->trans(
"NoTargetYet").
'</span>';
1046 print
'<tr><td colspan="9">';
1047 print
'<span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span>';
1051 print
"</table><br>";
1061 print
"\n<!-- End list of selected targets -->\n";
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
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....
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.
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.
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.
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.
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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.