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';
41@phan-var-force array{0:string,1:string} $bctag From main.inc
44$langs->loadLangs(array(
"mails",
"admin"));
48$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
49$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
51if (empty($page) || $page == -1) {
54$offset = $limit * $page;
58 $sortfield =
"mc.statut,email";
61 $sortorder =
"DESC,ASC";
66$action =
GETPOST(
'action',
'aZ09');
67$toselect =
GETPOST(
'toselect',
'array');
68$massaction =
GETPOST(
'massaction',
'alpha');
69$search_lastname =
GETPOST(
"search_lastname",
'alphanohtml');
70$search_firstname =
GETPOST(
"search_firstname",
'alphanohtml');
71$search_email =
GETPOST(
"search_email",
'alphanohtml');
72$search_other =
GETPOST(
"search_other",
'alphanohtml');
73$search_dest_status =
GETPOST(
'search_dest_status',
'int');
82$hookmanager->initHooks(array(
'ciblescard',
'globalcard'));
87$listofmethods = array();
89$listofmethods[
'mail'] =
'PHP mail function';
91$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
92if (version_compare(phpversion(),
'7.0',
'>=')) {
93 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
97if (!$user->hasRight(
'mailing',
'lire') || (!
getDolGlobalString(
'EXTERNAL_USERS_ARE_AUTHORIZED') && $user->socid > 0)) {
100if (empty($action) && empty(
$object->id)) {
104$permissiontoread = $user->hasRight(
'maling',
'lire');
105$permissiontocreate = $user->hasRight(
'mailing',
'creer');
106$permissiontovalidatesend = $user->hasRight(
'mailing',
'valider');
107$permissiontodelete = $user->hasRight(
'mailing',
'supprimer');
113if (
GETPOST(
'cancel',
'alpha')) {
117if (!
GETPOST(
'confirmmassaction',
'alpha')) {
121if ($action ==
'add' && $permissiontocreate) {
122 $module =
GETPOST(
"module",
'alpha');
126 foreach ($modulesdir as $dir) {
129 dol_syslog(
"Scan directory ".$dir.
" for modules");
132 $file = $dir.
"/".$module.
".modules.php";
133 $classname =
"mailing_".$module;
135 if (file_exists($file)) {
139 dol_syslog(
"Call add_to_target() on class ".$classname.
" evenunsubscribe=".
$object->evenunsubscribe);
142 if (class_exists($classname)) {
143 $obj =
new $classname($db);
144 '@phan-var-force MailingTargets $obj';
145 $obj->evenunsubscribe =
$object->evenunsubscribe;
147 $result = $obj->add_to_target($id);
149 $sqlmessage = $obj->sql;
158 if (
$object->status == $object::STATUS_SENTCOMPLETELY) {
159 $object->setStatut($object::STATUS_SENTPARTIALY);
168 if ($result < 0 && is_object($obj)) {
169 setEventMessages($langs->trans(
"Error").($obj->error ?
' '.$obj->error :
''), null,
'errors');
173if (
GETPOSTINT(
'clearlist') && $permissiontocreate) {
176 $obj->clear_target($id);
183if (
GETPOSTINT(
'exportcsv') && $permissiontoread) {
184 $completefilename =
'targets_emailing'.$object->id.
'_'.
dol_print_date(
dol_now(),
'dayhourlog').
'.csv';
185 header(
'Content-Type: text/csv');
186 header(
'Content-Disposition: attachment;filename='.$completefilename);
189 $sql =
"SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut as status, mc.date_envoi, mc.tms,";
190 $sql .=
" mc.source_id, mc.source_type, mc.error_text";
191 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
192 $sql .=
" WHERE mc.fk_mailing = ".((int)
$object->id);
193 $sql .= $db->order($sortfield, $sortorder);
195 $resql = $db->query($sql);
197 $num = $db->num_rows($resql);
200 while ($obj = $db->fetch_object($resql)) {
201 print $obj->rowid.$sep;
202 print
'"'.$obj->lastname.
'"'.$sep;
203 print
'"'.$obj->firstname.
'"'.$sep;
204 print $obj->email.$sep;
205 print $obj->other.$sep;
206 print $obj->tms.$sep;
207 print $obj->source_type.$sep;
208 print $obj->source_id.$sep;
209 print $obj->date_envoi.$sep;
210 print $obj->status.$sep;
211 print
'"'.$obj->error_text.
'"'.$sep;
222if ($action ==
'delete' && $permissiontocreate) {
224 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"mailing_cibles WHERE rowid = ".((int) $rowid);
225 $resql = $db->query($sql);
229 $obj->update_nb($id);
233 header(
"Location: list.php");
241if ($action ==
"confirm_reset_target" && $permissiontocreate) {
246 foreach ($toselect as $toselectid) {
247 $result =
$object->resetTargetErrorStatus($user, $toselectid);
252 } elseif ($result > 0) {
269if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
270 $search_lastname =
'';
271 $search_firstname =
'';
274 $search_dest_status =
'';
279if (($action ==
'settitle' || $action ==
'setemail_from' || $action ==
'setreplyto' || $action ==
'setemail_errorsto' || $action ==
'setevenunsubscribe') && $permissiontocreate) {
280 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir(
$object->id, 2, 0, 1, $object,
'mailing');
282 if ($action ==
'settitle') {
284 } elseif ($action ==
'setemail_from') {
285 $object->email_from = trim(
GETPOST(
'email_from',
'alphawithlgt'));
286 } elseif ($action ==
'setemail_replyto') {
287 $object->email_replyto = trim(
GETPOST(
'email_replyto',
'alphawithlgt'));
288 } elseif ($action ==
'setemail_errorsto') {
289 $object->email_errorsto = trim(
GETPOST(
'email_errorsto',
'alphawithlgt'));
290 } elseif ($action ==
'settitle' && empty(
$object->title)) {
291 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTitle"));
292 } elseif ($action ==
'setfrom' && empty(
$object->email_from)) {
293 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailFrom"));
294 } elseif ($action ==
'setevenunsubscribe') {
299 $result =
$object->update($user);
301 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
316llxHeader(
'', $langs->trans(
"Mailing"),
'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing');
318$form =
new Form($db);
320$arrayofselected = is_array($toselect) ? $toselect : array();
327 $linkback =
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
329 $morehtmlref =
'<div class="refidno">';
331 $morehtmlref .= $form->editfieldkey(
"",
'title',
$object->title, $object, 0,
'string',
'', 0, 1);
332 $morehtmlref .= $form->editfieldval(
"",
'title',
$object->title, $object, 0,
'string',
'',
null,
null,
'', 1);
333 $morehtmlref .=
'</div>';
335 $morehtmlstatus =
'';
337 if (
$object->status == $object::STATUS_SENTPARTIALY ||
$object->status == $object::STATUS_SENTCOMPLETELY) {
338 $nbtry =
$object->countNbOfTargets(
'alreadysent');
339 $nbko =
$object->countNbOfTargets(
'alreadysentko');
340 $nbok = ($nbtry - $nbko);
342 $morehtmlstatus .=
' ('.$nbtry.
'/'.
$object->nbemail;
344 $morehtmlstatus .=
' - '.$nbko.
' '.$langs->trans(
"Error");
346 $morehtmlstatus .=
') ';
349 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'', $morehtmlstatus);
351 print
'<div class="fichecenter">';
352 print
'<div class="fichehalfleft">';
353 print
'<div class="underbanner clearboth"></div>';
355 print
'<table class="border centpercent tableforfield">';
358 print
'<tr><td class="titlefield">'.$langs->trans(
"MailFrom").
'</td><td>';
360 foreach ($emailarray as $email => $name) {
361 if ($name && $name != $email) {
365 $langs->load(
"errors");
366 print
img_warning($langs->trans(
"ErrorBadEMail", $email));
377 if (
$object->messtype !=
'sms') {
378 print
'<tr><td>'.$langs->trans(
"MailErrorsTo").
'</td><td>';
380 foreach ($emailarray as $email => $name) {
381 if ($name != $email) {
385 $langs->load(
"errors");
386 print
img_warning($langs->trans(
"ErrorBadEMail", $email));
388 $langs->load(
"errors");
389 print
img_warning($langs->trans(
"ErrorBadMXDomain", $email));
399 if (
$object->messtype !=
'sms') {
401 print $form->editfieldkey(
"MailReply",
'email_replyto',
$object->email_replyto, $object, $user->hasRight(
'mailing',
'creer') &&
$object->status < $object::STATUS_SENTCOMPLETELY,
'string');
403 print $form->editfieldval(
"MailReply",
'email_replyto',
$object->email_replyto, $object, $user->hasRight(
'mailing',
'creer') &&
$object->status < $object::STATUS_SENTCOMPLETELY,
'string');
405 if ($action !=
'editemail_replyto') {
407 $langs->load(
"errors");
408 print
img_warning($langs->trans(
"ErrorBadEMail", $email));
410 $langs->load(
"errors");
411 print
img_warning($langs->trans(
"ErrorBadMXDomain", $email));
421 print
'<div class="fichehalfright">';
422 print
'<div class="underbanner clearboth"></div>';
424 print
'<table class="border centpercent tableforfield">';
428 print $langs->trans(
"TotalNbOfDistinctRecipients");
431 if (is_numeric($nbemail)) {
435 $text .= $langs->trans(
'LimitSendingEmailing',
getDolGlobalString(
'MAILING_LIMIT_SENDBYWEB'));
437 $text .= $langs->trans(
'SendingFromWebInterfaceIsNotAllowed');
440 if (empty($nbemail)) {
441 $nbemail .=
' '.img_warning($langs->trans(
'ToAddRecipientsChooseHere'));
445 print $form->textwithpicto($nbemail, $text, 1,
'warning');
453 print $langs->trans(
"MAIN_MAIL_SENDMODE");
455 if (
$object->messtype !=
'sms') {
461 $text = $listofmethods[
'mail'];
466 print
' <span class="opacitymedium">('.getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER_EMAILING',
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER')).
')</span>';
469 print
' <span class="opacitymedium">('.getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER').
')</span>';
473 print
' <span class="opacitymedium">('.getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER').
')</span>';
478 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
484 print
'<div class="clearboth"></div>';
492 $allowaddtarget = (
$object->status == $object::STATUS_DRAFT);
493 if (
GETPOST(
'allowaddtarget')) {
496 if (!$allowaddtarget) {
497 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&allowaddtarget=1',
'', $user->hasRight(
'mailing',
'creer'));
501 if ($allowaddtarget && $user->hasRight(
'mailing',
'creer')) {
502 print
load_fiche_titre($langs->trans(
"ToAddRecipientsChooseHere"), ($user->admin ?
info_admin($langs->trans(
"YouCanAddYourOwnPredefindedListHere"), 1) :
''),
'generic');
504 print
'<div class="div-table-responsive">';
505 print
'<div class="tagtable centpercentwithout1imp liste_titre_bydiv borderbottom" id="tablelines">';
507 print
'<div class="tagtr liste_titre">';
508 print
'<div class="tagtd"></div>';
509 print
'<div class="tagtd">'.$langs->trans(
"RecipientSelectionModules").
'</div>';
510 print
'<div class="tagtd center maxwidth150">';
511 if (
$object->messtype !=
'sms') {
512 print $langs->trans(
"NbOfUniqueEMails");
514 print $langs->trans(
"NbOfUniquePhones");
517 print
'<div class="tagtd left"><div class="inline-block">'.$langs->trans(
"Filters").
'</div>';
518 if (
$object->messtype !=
'sms') {
519 print
' <div class=" inline-block">'.$langs->trans(
"EvenUnsubscribe").
' ';
520 print
ajax_object_onoff($object,
'evenunsubscribe',
'evenunsubscribe',
'EvenUnsubscribe:switch_on:warning',
'EvenUnsubscribe', array(),
'small valignmiddle',
'', 1);
524 print
'<div class="tagtd"> </div>';
529 foreach ($modulesdir as $dir) {
530 $modulenames = array();
534 dol_syslog(
"Scan directory ".$dir.
" for modules");
535 $handle = @opendir($dir);
536 if (is_resource($handle)) {
537 while (($file = readdir($handle)) !==
false) {
538 if (substr($file, 0, 1) !=
'.' && substr($file, 0, 3) !=
'CVS') {
540 if (preg_match(
"/(.*)\.modules\.php$/i", $file, $reg)) {
541 if ($reg[1] ==
'example') {
544 $modulenames[] = $reg[1];
557 foreach ($modulenames as $modulename) {
559 $file = $dir.$modulename.
".modules.php";
560 $classname =
"mailing_".$modulename;
563 $obj =
new $classname($db);
564 '@phan-var-force MailingTargets $obj';
567 $qualified = (is_null($obj->enabled) ? 1 : (int)
dol_eval($obj->enabled, 1));
570 foreach ($obj->require_module as $key) {
571 if (empty($conf->$key->enabled) || (empty($user->admin) && $obj->require_admin)) {
582 if ($allowaddtarget) {
583 print
'<form '.$bctag[$var].
' name="'.$modulename.
'" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&module='.$modulename.
'" method="POST" enctype="multipart/form-data">';
584 print
'<input type="hidden" name="token" value="'.newToken().
'">';
585 print
'<input type="hidden" name="action" value="add">';
586 print
'<input type="hidden" name="page_y" value="'.newToken().
'">';
588 print
'<div '.$bctag[$var].
'>';
591 print
'<div class="tagtd paddingleftimp marginleftonly paddingrightimp marginrightonly valignmiddle center">';
592 if (empty($obj->picto)) {
593 $obj->picto =
'generic';
595 print
img_object($langs->trans(
"EmailingTargetSelector").
': '.get_class($obj), $obj->picto,
'class="valignmiddle width25 size15x"');
597 print
'<div class="tagtd valignmiddle">';
598 print $obj->getDesc();
604 $obj->evenunsubscribe =
$object->evenunsubscribe;
606 $nbofrecipient = $obj->getNbOfRecipients(
'');
611 print
'<div class="tagtd center valignmiddle">';
612 if ($nbofrecipient ===
'' || $nbofrecipient >= 0) {
613 print $nbofrecipient;
615 print $langs->trans(
"Error").
' '.
img_error($obj->error);
619 print
'<div class="tagtd left valignmiddle">';
620 if ($allowaddtarget) {
622 $filter = $obj->formFilter();
629 print $langs->trans(
"None");
634 print
'<div class="tagtd right valignmiddle">';
635 if ($allowaddtarget) {
636 print
'<input type="submit" class="button button-add small reposition" name="button_'.$modulename.
'" value="'.$langs->trans(
"Add").
'">';
638 print
'<input type="submit" class="button small disabled" disabled="disabled" name="button_'.$modulename.
'" value="'.$langs->trans(
"Add").
'">';
644 if ($allowaddtarget) {
653 $parameters = array();
654 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
655 print $hookmanager->resPrint;
662 if ($sqlmessage && $user->admin) {
663 print
info_admin($langs->trans(
"SQLUsedForExport").
':<br> '.$sqlmessage, 0, 0,
'1',
'',
'TechnicalInformation');
671 $sql =
"SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut as status, mc.date_envoi, mc.tms,";
672 $sql .=
" mc.source_url, mc.source_id, mc.source_type, mc.error_text,";
673 $sql .=
" COUNT(mu.rowid) as nb";
674 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
675 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"mailing_unsubscribe as mu ON mu.email = mc.email";
676 $sql .=
" WHERE mc.fk_mailing=".((int)
$object->id);
677 $asearchcriteriahasbeenset = 0;
678 if ($search_lastname) {
680 $asearchcriteriahasbeenset++;
682 if ($search_firstname) {
684 $asearchcriteriahasbeenset++;
688 $asearchcriteriahasbeenset++;
692 $asearchcriteriahasbeenset++;
694 if ($search_dest_status !=
'' && (
int) $search_dest_status >= -1) {
695 $sql .=
" AND mc.statut = ".((int) $search_dest_status);
696 $asearchcriteriahasbeenset++;
698 $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';
699 $sql .= $db->order($sortfield, $sortorder);
703 $nbtotalofrecords =
'';
705 $result = $db->query($sql);
706 $nbtotalofrecords = $db->num_rows($result);
707 if (($page * $limit) > $nbtotalofrecords) {
713 if (empty($asearchcriteriahasbeenset)) {
714 if ($nbtotalofrecords !=
$object->nbemail) {
715 dol_syslog(
"We found a difference in nb of record in target table and the property ->nbemail, we fix ->nbemail");
717 $resultrefresh =
$object->refreshNbOfTargets();
718 if ($resultrefresh < 0) {
726 $sql .= $db->plimit($limit + 1, $offset);
728 $resql = $db->query($sql);
730 $num = $db->num_rows($resql);
732 $param =
"&id=".$object->id;
734 if ($limit > 0 && $limit != $conf->liste_limit) {
735 $param .=
'&limit='.((int) $limit);
737 if ($search_lastname) {
738 $param .=
"&search_lastname=".urlencode($search_lastname);
740 if ($search_firstname) {
741 $param .=
"&search_firstname=".urlencode($search_firstname);
744 $param .=
"&search_email=".urlencode($search_email);
747 $param .=
"&search_other=".urlencode($search_other);
750 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
751 print
'<input type="hidden" name="token" value="'.newToken().
'">';
752 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
753 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
754 print
'<input type="hidden" name="page" value="'.$page.
'">';
755 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
756 print
'<input type="hidden" name="page_y" value="">';
758 $morehtmlcenter =
'';
759 $arrayofmassactions = array();
760 if ($permissiontocreate) {
761 $arrayofmassactions[
'reset_target'] =
img_picto(
'',
'refresh',
'class="pictofixedwidth"').$langs->trans(
"ResetMailingTargetMassaction");
763 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
764 $morehtmlcenter .= $massactionbutton .
'<br>';
766 if (
$object->status == $object::STATUS_DRAFT) {
767 $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>';
769 $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>';
773 print
"\n<!-- Liste destinataires selectionnes -->\n";
774 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
775 print
'<input type="hidden" name="token" value="'.newToken().
'">';
776 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
777 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
778 print
'<input type="hidden" name="page" value="'.$page.
'">';
779 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
780 print
'<input type="hidden" name="limit" value="'.$limit.
'">';
781 print
'<input type="hidden" name="page_y" value="">';
784 print_barre_liste($langs->trans(
"MailSelectedRecipients"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords,
'generic', 0, $newcardbutton,
'', $limit, 0, 0, 1);
786 if ($massaction ==
'reset_target') {
788 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"ConfirmResetMailingTargetMassaction"), $langs->trans(
"ConfirmResetMailingTargetMassactionQuestion"),
"confirm_reset_target",
null,
'', 0, 0, 500, 1);
791 print
'<div class="div-table-responsive">';
792 print
'<table class="noborder centpercent">';
795 print
'<tr class="liste_titre_filter">';
799 print
'<td class="liste_titre maxwidthsearch">';
800 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
805 print
'<td class="liste_titre">';
806 print
'<input class="flat maxwidth75" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).
'">';
809 print
'<td class="liste_titre">';
810 print
'<input class="flat maxwidth50" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).
'">';
813 print
'<td class="liste_titre">';
814 print
'<input class="flat maxwidth50" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).
'">';
817 print
'<td class="liste_titre">';
818 print
'<input class="flat maxwidth100" type="text" name="search_other" value="'.dol_escape_htmltag($search_other).
'">';
821 print
'<td class="liste_titre">';
826 print
'<td class="liste_titre">';
831 print
'<td class="liste_titre">';
836 print
'<td class="liste_titre center parentonrightofpage">';
837 print $formmailing->selectDestinariesStatus($search_dest_status,
'search_dest_status', 1,
'width100 onrightofpage');
842 print
'<td class="liste_titre maxwidthsearch">';
843 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
851 $param .=
"&page=".urlencode((
string) ($page));
854 print
'<tr class="liste_titre">';
860 print_liste_field_titre(
"Lastname", $_SERVER[
"PHP_SELF"],
"mc.lastname", $param,
"",
"", $sortfield, $sortorder);
861 print_liste_field_titre(
"Firstname", $_SERVER[
"PHP_SELF"],
"mc.firstname", $param,
"",
"", $sortfield, $sortorder);
862 print_liste_field_titre(
"OtherInformations", $_SERVER[
"PHP_SELF"],
"", $param,
"",
"", $sortfield, $sortorder);
863 print_liste_field_titre(
"Source", $_SERVER[
"PHP_SELF"],
"", $param,
"",
'', $sortfield, $sortorder,
'center ');
865 print_liste_field_titre(
"DateLastModification", $_SERVER[
"PHP_SELF"],
"mc.tms", $param,
"",
'', $sortfield, $sortorder,
'center ');
867 print_liste_field_titre(
"DateSending", $_SERVER[
"PHP_SELF"],
"mc.date_envoi", $param,
'',
'', $sortfield, $sortorder,
'center ');
868 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"mc.statut", $param,
'',
'', $sortfield, $sortorder,
'center ');
878 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
879 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
880 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
881 include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
882 include_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
884 $objectstaticmember =
new Adherent($db);
885 $objectstaticuser =
new User($db);
886 $objectstaticcompany =
new Societe($db);
887 $objectstaticcontact =
new Contact($db);
890 while ($i < min($num, $limit)) {
891 $obj = $db->fetch_object($resql);
893 print
'<tr class="oddeven">';
897 print
'<td class="center">';
898 print
'<!-- ID mailing_cibles = '.$obj->rowid.
' -->';
899 if ($massactionbutton || $massaction) {
901 if (in_array($obj->rowid, $arrayofselected)) {
904 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
906 if ($obj->status == $object::STATUS_DRAFT) {
907 if ($user->hasRight(
'mailing',
'creer')) {
908 print
'<a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&rowid='.((int) $obj->rowid).$param.
'">'.
img_delete($langs->trans(
"RemoveRecipient")).
'</a>';
918 print
'<td class="tdoverflowmax150">';
919 print
img_picto($obj->email,
'email',
'class="paddingright"');
921 print
img_warning($langs->trans(
"EmailOptedOut"),
'warning',
'pictofixedwidth');
926 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->lastname).
'">'.
dol_escape_htmltag($obj->lastname).
'</td>';
928 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->firstname).
'">'.
dol_escape_htmltag($obj->firstname).
'</td>';
930 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($obj->other).
'"><span class="small">'.
dol_escape_htmltag($obj->other).
'</small></td>';
932 print
'<td class="center tdoverflowmax150">';
933 if (empty($obj->source_id) || empty($obj->source_type)) {
934 print empty($obj->source_url) ?
'' : $obj->source_url;
936 if ($obj->source_type ==
'member') {
937 $objectstaticmember->fetch($obj->source_id);
938 print $objectstaticmember->getNomUrl(1);
939 } elseif ($obj->source_type ==
'user') {
940 $objectstaticuser->fetch($obj->source_id);
941 print $objectstaticuser->getNomUrl(1);
942 } elseif ($obj->source_type ==
'thirdparty') {
943 $objectstaticcompany->fetch($obj->source_id);
944 print $objectstaticcompany->getNomUrl(1);
945 } elseif ($obj->source_type ==
'contact') {
946 $objectstaticcontact->fetch($obj->source_id);
947 print $objectstaticcontact->getNomUrl(1);
948 } elseif ($obj->source_type ==
'eventorganizationattendee') {
949 $objectstaticeventorganization->fetch($obj->source_id);
950 print $objectstaticeventorganization->getNomUrl(1);
952 print $obj->source_url;
958 print
'<td class="center nowraponall">';
963 print
'<td class="center nowraponall">';
964 if ($obj->status != $object::STATUS_DRAFT) {
966 print $obj->date_envoi;
971 print
'<td class="nowrap center">';
972 if ($obj->status == $object::STATUS_DRAFT) {
973 print $object::libStatutDest((
int) $obj->status, 2,
'');
975 print $object::libStatutDest((
int) $obj->status, 2, $obj->error_text);
981 print
'<td class="center">';
982 print
'<!-- ID mailing_cibles = '.$obj->rowid.
' -->';
983 if ($obj->status == $object::STATUS_DRAFT) {
984 if ($user->hasRight(
'mailing',
'creer')) {
985 print
'<a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&rowid='.((int) $obj->rowid).$param.
'">'.
img_delete($langs->trans(
"RemoveRecipient")).
'</a>';
999 if (
$object->status < $object::STATUS_SENTPARTIALY) {
1000 print
'<tr><td colspan="9">';
1001 print
'<span class="opacitymedium">'.$langs->trans(
"NoTargetYet").
'</span>';
1004 print
'<tr><td colspan="9">';
1005 print
'<span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span>';
1009 print
"</table><br>";
1019 print
"\n<!-- Fin liste destinataires selectionnes -->\n";
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....
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.
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
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.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.
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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.