27 if (!defined(
'NOSTYLECHECK')) {
28 define(
'NOSTYLECHECK',
'1');
31 require
'../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/emailing.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/comm/mailing/class/mailing.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
42 $langs->load(
"mails");
45 $action =
GETPOST(
'action',
'aZ09');
47 $confirm =
GETPOST(
'confirm',
'alpha');
52 $result = $object->fetch($id);
57 $extrafields->fetch_name_optionals_label($object->table_element);
60 $hookmanager->initHooks(array(
'mailingcard',
'globalcard'));
67 $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature :
'');
71 $parameters = array(
'mode'=>
'emailing');
74 $object->substitutionarrayfortest = $substitutionarray;
77 $listofmethods = array();
78 $listofmethods[
'mail'] =
'PHP mail function';
79 $listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
82 if (empty($user->rights->mailing->lire) || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) {
91 $parameters = array();
92 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
97 if (empty($reshook)) {
99 if ($action ==
'confirm_clone' && $confirm ==
'yes') {
100 if (!
GETPOST(
"clone_content",
'alpha') && !
GETPOST(
"clone_receivers",
'alpha')) {
103 $result = $object->createFromClone($user, $object->id,
GETPOST(
"clone_content",
'alpha'),
GETPOST(
"clone_receivers",
'alpha'));
105 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
115 if ($action ==
'sendallconfirmed' && $confirm ==
'yes') {
116 if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) {
119 setEventMessages(
'<textarea cols="70" rows="'.ROWS_2.
'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.
'</textarea>', null,
'warnings');
122 } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) {
126 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
128 if ($object->statut == 0) {
134 $subject = $object->sujet;
135 $message = $object->body;
136 $from = $object->email_from;
137 $replyto = $object->email_replyto;
138 $errorsto = $object->email_errorsto;
141 if (preg_match(
'/[\s\t]*<html>/i', $message)) {
148 $nbok = 0; $nbko = 0;
152 $sql =
"SELECT mc.rowid, mc.fk_mailing, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag";
153 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
154 $sql .=
" WHERE mc.statut < 1 AND mc.fk_mailing = ".((int) $object->id);
155 $sql .=
" ORDER BY mc.statut DESC";
157 dol_syslog(
"card.php: select targets", LOG_DEBUG);
158 $resql = $db->query($sql);
160 $num = $db->num_rows(
$resql);
163 dol_syslog(
"comm/mailing/card.php: nb of targets = ".$num, LOG_DEBUG);
168 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing SET date_envoi='".$db->idate($now).
"' WHERE rowid=".((int) $object->id);
169 $resql2 = $db->query($sql);
174 $thirdpartystatic =
new Societe($db);
178 while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB) {
183 $obj = $db->fetch_object(
$resql);
186 $sendto = str_replace(
',',
' ',
dolGetFirstLastname($obj->firstname, $obj->lastname)).
" <".$obj->email.
">";
189 $other = explode(
';', $obj->other);
190 $tmpfield = explode(
'=', $other[0], 2); $other1 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
191 $tmpfield = explode(
'=', $other[1], 2); $other2 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
192 $tmpfield = explode(
'=', $other[2], 2); $other3 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
193 $tmpfield = explode(
'=', $other[3], 2); $other4 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
194 $tmpfield = explode(
'=', $other[4], 2); $other5 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
196 $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature :
'');
198 $targetobject = null;
199 $parameters = array(
'mode'=>
'emailing');
203 $substitutionarray[
'__ID__'] = $obj->source_id;
204 if ($obj->source_type ==
"thirdparty") {
205 $result = $thirdpartystatic->fetch($obj->source_id);
208 $substitutionarray[
'__THIRDPARTY_CUSTOMER_CODE__'] = $thirdpartystatic->code_client;
210 $substitutionarray[
'__THIRDPARTY_CUSTOMER_CODE__'] =
'';
213 $substitutionarray[
'__EMAIL__'] = $obj->email;
214 $substitutionarray[
'__LASTNAME__'] = $obj->lastname;
215 $substitutionarray[
'__FIRSTNAME__'] = $obj->firstname;
216 $substitutionarray[
'__MAILTOEMAIL__'] =
'<a href="mailto:'.$obj->email.
'">'.$obj->email.
'</a>';
217 $substitutionarray[
'__OTHER1__'] = $other1;
218 $substitutionarray[
'__OTHER2__'] = $other2;
219 $substitutionarray[
'__OTHER3__'] = $other3;
220 $substitutionarray[
'__OTHER4__'] = $other4;
221 $substitutionarray[
'__OTHER5__'] = $other5;
222 $substitutionarray[
'__USER_SIGNATURE__'] = $signature;
223 $substitutionarray[
'__CHECK_READ__'] =
'<img src="'.DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-read.php?tag='.urlencode($obj->tag).
'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).
'&email='.urlencode($obj->email).
'&mtid='.$obj->rowid.
'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
224 $substitutionarray[
'__UNSUBSCRIBE__'] =
'<a href="'.DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-unsubscribe.php?tag='.urlencode($obj->tag).
'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).
'&email='.urlencode($obj->email).
'&mtid='.$obj->rowid.
'" target="_blank" rel="noopener noreferrer">'.$langs->trans(
"MailUnsubcribe").
'</a>';
225 $substitutionarray[
'__UNSUBSCRIBE_URL__'] = DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-unsubscribe.php?tag='.urlencode($obj->tag).
'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).
'&email='.urlencode($obj->email).
'&mtid='.$obj->rowid;
227 $onlinepaymentenabled = 0;
228 if (!empty($conf->paypal->enabled)) {
229 $onlinepaymentenabled++;
231 if (!empty($conf->paybox->enabled)) {
232 $onlinepaymentenabled++;
234 if (!empty($conf->stripe->enabled)) {
235 $onlinepaymentenabled++;
237 if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
238 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
239 $substitutionarray[
'__ONLINEPAYMENTLINK_MEMBER__'] = getHtmlOnlinePaymentLink(
'member', $obj->source_id);
240 $substitutionarray[
'__ONLINEPAYMENTLINK_DONATION__'] = getHtmlOnlinePaymentLink(
'donation', $obj->source_id);
241 $substitutionarray[
'__ONLINEPAYMENTLINK_ORDER__'] = getHtmlOnlinePaymentLink(
'order', $obj->source_id);
242 $substitutionarray[
'__ONLINEPAYMENTLINK_INVOICE__'] = getHtmlOnlinePaymentLink(
'invoice', $obj->source_id);
243 $substitutionarray[
'__ONLINEPAYMENTLINK_CONTRACTLINE__'] = getHtmlOnlinePaymentLink(
'contractline', $obj->source_id);
245 $substitutionarray[
'__SECUREKEYPAYMENT__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
246 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
247 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
248 $substitutionarray[
'__SECUREKEYPAYMENT_DONATION__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
249 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
250 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
251 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
253 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.
'member'.$obj->source_id, 2);
254 $substitutionarray[
'__SECUREKEYPAYMENT_DONATION__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.
'donation'.$obj->source_id, 2);
255 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.
'order'.$obj->source_id, 2);
256 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.
'invoice'.$obj->source_id, 2);
257 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.
'contractline'.$obj->source_id, 2);
260 if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
261 $substitutionarray[
'__PUBLICLINK_NEWMEMBERFORM__'] =
'<a target="_blank" rel="noopener noreferrer" href="'.DOL_MAIN_URL_ROOT.
'/public/members/new.php'.((!empty($conf->multicompany->enabled)) ?
'?entity='.$conf->entity :
'').
'">'.$langs->trans(
'BlankSubscriptionForm').
'</a>';
264 if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) {
265 $substitutionarray[
'__SECUREKEYPAYPAL__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
267 if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
268 $substitutionarray[
'__SECUREKEYPAYPAL_MEMBER__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
270 $substitutionarray[
'__SECUREKEYPAYPAL_MEMBER__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.
'membersubscription'.$obj->source_id, 2);
273 if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
274 $substitutionarray[
'__SECUREKEYPAYPAL_ORDER__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
276 $substitutionarray[
'__SECUREKEYPAYPAL_ORDER__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.
'order'.$obj->source_id, 2);
279 if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
280 $substitutionarray[
'__SECUREKEYPAYPAL_INVOICE__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
282 $substitutionarray[
'__SECUREKEYPAYPAL_INVOICE__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.
'invoice'.$obj->source_id, 2);
285 if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
286 $substitutionarray[
'__SECUREKEYPAYPAL_CONTRACTLINE__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
288 $substitutionarray[
'__SECUREKEYPAYPAL_CONTRACTLINE__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.
'contractline'.$obj->source_id, 2);
298 if (preg_match(
'/__UNSUBSCRIBE__/', $message)) {
299 $moreinheader =
"List-Unsubscribe: <__UNSUBSCRIBE_URL__>\n";
308 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
309 if (count($listofpaths)) {
310 foreach ($listofpaths as $key => $val) {
311 $arr_file[] = $listofpaths[$key][
'fullname'];
313 $arr_name[] = $listofpaths[$key][
'name'];
318 $trackid =
'emailing-'.$obj->fk_mailing.
'-'.$obj->rowid;
319 $mail =
new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name,
'',
'', 0, $msgishtml, $errorsto, $arr_css, $trackid, $moreinheader,
'emailing');
332 $res = $mail->sendfile();
339 dol_syslog(
"comm/mailing/card.php: ok for #".$i.($mail->error ?
' - '.$mail->error :
''), LOG_DEBUG);
341 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing_cibles";
342 $sql .=
" SET statut=1, date_envoi = '".$db->idate($now).
"' WHERE rowid=".((int) $obj->rowid);
343 $resql2 = $db->query($sql);
348 if (strpos($message,
'__CHECK_READ__') !==
false) {
350 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX.
"mailing_cibles WHERE rowid=".((int) $obj->rowid).
")";
351 dol_syslog(
"card.php: set prospect thirdparty status", LOG_DEBUG);
352 $resql2 = $db->query($sql);
358 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX.
"mailing_cibles AS mc ON mc.rowid=".((int) $obj->rowid).
" AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)";
359 dol_syslog(
"card.php: set prospect contact status", LOG_DEBUG);
361 $resql2 = $db->query($sql);
368 if (!empty($conf->global->MAILING_DELAY)) {
369 dol_syslog(
"Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY);
370 usleep((
float) $conf->global->MAILING_DELAY * 1000000);
378 dol_syslog(
"comm/mailing/card.php: error for #".$i.($mail->error ?
' - '.$mail->error :
''), LOG_WARNING);
380 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing_cibles";
381 $sql .=
" SET statut=-1, error_text='".$db->escape($mail->error).
"', date_envoi='".$db->idate($now).
"' WHERE rowid=".((int) $obj->rowid);
382 $resql2 = $db->query($sql);
391 setEventMessages($langs->transnoentitiesnoconv(
"NoMoreRecipientToSendTo"), null,
'mesgs');
398 setEventMessages($langs->transnoentitiesnoconv(
"EMailSentToNRecipients", $nbok), null,
'mesgs');
400 setEventMessages($langs->transnoentitiesnoconv(
"EMailSentToNRecipients", $nbok), null,
'mesgs');
405 setEventMessages($langs->transnoentitiesnoconv(
"EMailSentToNRecipients", $nbok), null,
'mesgs');
408 setEventMessages($langs->transnoentitiesnoconv(
"EMailSentToNRecipients", $nbok), null,
'mesgs');
412 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing SET statut=".((int) $statut).
" WHERE rowid = ".((int) $object->id);
413 dol_syslog(
"comm/mailing/card.php: update global status", LOG_DEBUG);
414 $resql2 = $db->query($sql);
428 if ($action ==
'send' && ! $cancel) {
431 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
433 $object->sendto =
GETPOST(
"sendto",
'alphawithlgt');
434 if (!$object->sendto) {
435 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTo")), null,
'errors');
442 if (preg_match(
'/[\s\t]*<html>/i', $object->body)) {
447 $object->substitutionarrayfortest[
'__EMAIL__'] = $object->sendto;
448 $object->substitutionarrayfortest[
'__MAILTOEMAIL__'] =
'<a href="mailto:'.$object->sendto.
'">'.$object->sendto.
'</a>';
461 if (!empty($object->bgcolor)) {
462 $arr_css[
'bgcolor'] = (preg_match(
'/^#/', $object->bgcolor) ?
'' :
'#').$object->bgcolor;
464 if (!empty($object->bgimage)) {
465 $arr_css[
'bgimage'] = $object->bgimage;
469 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
470 if (count($listofpaths)) {
471 foreach ($listofpaths as $key => $val) {
472 $arr_file[] = $listofpaths[$key][
'fullname'];
474 $arr_name[] = $listofpaths[$key][
'name'];
478 $trackid =
'emailing-test';
479 $mailfile =
new CMailFile($tmpsujet, $object->sendto, $object->email_from, $tmpbody, $arr_file, $arr_mime, $arr_name,
'',
'', 0, $msgishtml, $object->email_errorsto, $arr_css, $trackid,
'',
'emailing');
481 $result = $mailfile->sendfile();
483 setEventMessages($langs->trans(
"MailSuccessfulySent", $mailfile->getValidAddress($object->email_from, 2), $mailfile->getValidAddress($object->sendto, 2)), null,
'mesgs');
486 setEventMessages($langs->trans(
"ResultKo").
'<br>'.$mailfile->error.
' '.$result, null,
'errors');
493 if ($action ==
'add') {
496 $object->email_from = (string)
GETPOST(
"from",
'alphawithlgt');
497 $object->email_replyto = (string)
GETPOST(
"replyto",
'alphawithlgt');
498 $object->email_errorsto = (string)
GETPOST(
"errorsto",
'alphawithlgt');
499 $object->title = (string)
GETPOST(
"title");
500 $object->sujet = (string)
GETPOST(
"sujet");
501 $object->body = (string)
GETPOST(
"bodyemail",
'restricthtml');
502 $object->bgcolor = (string)
GETPOST(
"bgcolor");
503 $object->bgimage = (string)
GETPOST(
"bgimage");
505 if (!$object->title) {
506 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTitle"));
508 if (!$object->sujet) {
509 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTopic"));
511 if (!$object->body) {
512 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailMessage"));
515 if (!count($mesgs)) {
516 if ($object->create($user) >= 0) {
517 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
520 $mesgs[] = $object->error;
528 if ($action ==
'settitle' || $action ==
'setemail_from' || $action ==
'setreplyto' || $action ==
'setemail_errorsto') {
529 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
531 if ($action ==
'settitle') {
532 $object->title = trim(
GETPOST(
'title',
'alpha'));
533 } elseif ($action ==
'setemail_from') {
534 $object->email_from = trim(
GETPOST(
'email_from',
'alphawithlgt'));
535 } elseif ($action ==
'setemail_replyto') {
536 $object->email_replyto = trim(
GETPOST(
'email_replyto',
'alphawithlgt'));
537 } elseif ($action ==
'setemail_errorsto') {
538 $object->email_errorsto = trim(
GETPOST(
'email_errorsto',
'alphawithlgt'));
539 } elseif ($action ==
'settitle' && empty($object->title)) {
540 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTitle"));
541 } elseif ($action ==
'setfrom' && empty($object->email_from)) {
542 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailFrom"));
546 if ($object->update($user) >= 0) {
547 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
550 $mesg = $object->error;
561 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
563 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
573 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
575 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
583 if ($action ==
'update' && !
GETPOST(
"removedfile") && !$cancel) {
584 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
590 $object->sujet = (string)
GETPOST(
"sujet");
591 $object->body = (string)
GETPOST(
"bodyemail",
'restricthtml');
592 $object->bgcolor = (string)
GETPOST(
"bgcolor");
593 $object->bgimage = (string)
GETPOST(
"bgimage");
595 if (!$object->sujet) {
596 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTopic"));
598 if (!$object->body) {
599 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailMessage"));
602 if (!count($mesgs)) {
603 if ($object->update($user) >= 0) {
604 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
607 $mesgs[] = $object->error;
618 if ($action ==
'confirm_valid' && $confirm ==
'yes') {
619 if ($object->id > 0) {
620 $object->valid($user);
621 setEventMessages($langs->trans(
"MailingSuccessfullyValidated"), null,
'mesgs');
622 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
630 if ($action ==
'confirm_settodraft' && $confirm ==
'yes') {
631 if ($object->id > 0) {
632 $result = $object->setStatut(0);
635 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
646 if ($action ==
'confirm_reset' && $confirm ==
'yes') {
647 if ($object->id > 0) {
650 $result = $object->valid($user);
652 $result = $object->reset_targets_status($user);
657 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
669 if ($action ==
'confirm_delete' && $confirm ==
'yes') {
670 if ($object->delete($object->id)) {
671 $url = (!empty($urlfrom) ? $urlfrom :
'list.php');
672 header(
"Location: ".$url);
690 $help_url =
'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
693 $langs->trans(
"Mailing"),
699 '/includes/ace/src/ace.js',
700 '/includes/ace/src/ext-statusbar.js',
701 '/includes/ace/src/ext-language_tools.js',
707 if ($action ==
'create') {
709 print
'<form name="new_mailing" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">'.
"\n";
710 print
'<input type="hidden" name="token" value="'.newToken().
'">';
711 print
'<input type="hidden" name="action" value="add">';
713 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
714 foreach ($object->substitutionarray as $key => $val) {
715 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
720 $availablelink =
$form->textwithpicto($langs->trans(
"AvailableVariables"), $htmltext, 1,
'help',
'', 0, 2,
'availvar');
725 print
load_fiche_titre($langs->trans(
"NewMailing"), $availablelink,
'object_email');
729 print
'<table class="border centpercent">';
730 print
'<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans(
"MailTitle").
'</td><td><input class="flat minwidth300" name="title" value="'.
dol_escape_htmltag(
GETPOST(
'title')).
'" autofocus="autofocus"></td></tr>';
731 print
'<tr><td class="fieldrequired">'.$langs->trans(
"MailFrom").
'</td><td><input class="flat minwidth200" name="from" value="'.$conf->global->MAILING_EMAIL_FROM.
'"></td></tr>';
732 print
'<tr><td>'.$langs->trans(
"MailErrorsTo").
'</td><td><input class="flat minwidth200" name="errorsto" value="'.(!empty($conf->global->MAILING_EMAIL_ERRORSTO) ? $conf->global->MAILING_EMAIL_ERRORSTO : $conf->global->MAIN_MAIL_ERRORS_TO).
'"></td></tr>';
735 $parameters = array();
736 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
737 print $hookmanager->resPrint;
738 if (empty($reshook)) {
739 print $object->showOptionals($extrafields,
'create');
745 print
'<table class="border centpercent">';
746 print
'<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans(
"MailTopic").
'</td><td><input class="flat minwidth200 quatrevingtpercent" name="sujet" value="'.
dol_escape_htmltag(
GETPOST(
'sujet',
'alphanohtml')).
'"></td></tr>';
747 print
'<tr><td>'.$langs->trans(
"BackgroundColorByDefault").
'</td><td colspan="3">';
748 print $htmlother->selectColor(
GETPOST(
'bgcolor'),
'bgcolor',
'', 0);
753 print
'<div style="padding-top: 10px">';
755 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
756 $doleditor =
new DolEditor(
'bodyemail',
GETPOST(
'bodyemail',
'restricthtmlallowunvalid'),
'', 600,
'dolibarr_mailings',
'',
true,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_MAILING'), 20,
'90%');
757 $doleditor->Create();
762 print
$form->buttonsSaveCancel(
"CreateMailing",
'');
766 if ($object->id > 0) {
767 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
771 if ($action ==
'settodraft') {
773 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"SetToDraft"), $langs->trans(
"ConfirmUnvalidateEmailing"),
"confirm_settodraft",
'',
'', 1);
774 } elseif ($action ==
'valid') {
776 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"ValidMailing"), $langs->trans(
"ConfirmValidMailing"),
"confirm_valid",
'',
'', 1);
777 } elseif ($action ==
'reset') {
779 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"ResetMailing"), $langs->trans(
"ConfirmResetMailing", $object->ref),
"confirm_reset",
'',
'', 2);
780 } elseif ($action ==
'delete') {
782 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id.(!empty($urlfrom) ?
'&urlfrom='.urlencode($urlfrom) :
''), $langs->trans(
"DeleteAMailing"), $langs->trans(
"ConfirmDeleteMailing"),
"confirm_delete",
'',
'', 1);
785 if ($action !=
'edit' && $action !=
'edithtml') {
791 if ($action ==
'sendall') {
793 $sendingmode = $conf->global->EMAILING_MAIL_SENDMODE;
794 if (empty($sendingmode)) {
795 $sendingmode = $conf->global->MAIN_MAIL_SENDMODE;
797 if (empty($sendingmode)) {
798 $sendingmode =
'mail';
805 if (!empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode ==
'mail') {
808 $linktoadminemailbefore =
'<a href="'.DOL_URL_ROOT.
'/admin/mails_emailing.php">';
809 $linktoadminemailend =
'</a>';
810 setEventMessages($langs->trans(
"MailSendSetupIs", $listofmethods[$sendingmode]), null,
'warnings');
811 $messagetoshow = $langs->trans(
"MailSendSetupIs2",
'{s1}',
'{s2}',
'{s3}',
'{s4}');
812 $messagetoshow = str_replace(
'{s1}', $linktoadminemailbefore, $messagetoshow);
813 $messagetoshow = str_replace(
'{s2}', $linktoadminemailend, $messagetoshow);
814 $messagetoshow = str_replace(
'{s3}', $langs->transnoentitiesnoconv(
"MAIN_MAIL_SENDMODE"), $messagetoshow);
815 $messagetoshow = str_replace(
'{s4}', $listofmethods[
'smtps'], $messagetoshow);
818 if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) {
819 setEventMessages($langs->trans(
"MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), null,
'warnings');
821 $_GET[
"action"] =
'';
822 } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) {
823 if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode ==
'mail') {
824 setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null,
'warnings');
826 if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode !=
'mail') {
827 setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null,
'warnings');
832 setEventMessages(
'<textarea cols="60" rows="'.ROWS_1.
'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.
'</textarea>', null,
'warnings');
833 if ($conf->file->mailing_limit_sendbyweb !=
'-1') {
836 $_GET[
"action"] =
'';
838 if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode ==
'mail') {
839 setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null,
'warnings');
841 if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode !=
'mail') {
842 setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null,
'warnings');
847 if (isset($conf->global->MAILING_LIMIT_SENDBYDAY) && $conf->global->MAILING_LIMIT_SENDBYDAY >= 0) {
848 $text .= $langs->trans(
'WarningLimitSendByDay', $conf->global->MAILING_LIMIT_SENDBYDAY);
851 $text .= $langs->trans(
'ConfirmSendingEmailing').
'<br>';
852 $text .= $langs->trans(
'LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
854 if (!isset($conf->global->MAILING_LIMIT_SENDBYCLI) || $conf->global->MAILING_LIMIT_SENDBYCLI >= 0) {
856 $text .= $langs->trans(
"MailingNeedCommand");
857 $text .=
'<br><textarea cols="60" rows="'.ROWS_2.
'" wrap="soft" disabled>php ./scripts/emailings/mailing-send.php '.$object->id.
' '.$user->login.
'</textarea>';
860 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
'SendMailing'), $text,
'sendallconfirmed',
'',
'', 1, 330, 600, 0, $langs->trans(
"Confirm"), $langs->trans(
"Cancel"));
864 $linkback =
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
868 if ($object->statut == 2 || $object->statut == 3) {
869 $nbtry = $object->countNbOfTargets(
'alreadysent');
870 $nbko = $object->countNbOfTargets(
'alreadysentko');
872 $morehtmlright .=
' ('.$nbtry.
'/'.$object->nbemail;
874 $morehtmlright .=
' - '.$nbko.
' '.$langs->trans(
"Error");
876 $morehtmlright .=
') ';
879 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref',
'',
'', 0,
'', $morehtmlright);
881 print
'<div class="fichecenter">';
882 print
'<div class="underbanner clearboth"></div>';
884 print
'<table class="border centpercent tableforfield">';
887 print
'<tr><td class="titlefield">';
888 print
$form->editfieldkey(
"MailTitle",
'title', $object->title, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
890 print
$form->editfieldval(
"MailTitle",
'title', $object->title, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
895 print
$form->editfieldkey(
"MailFrom",
'email_from', $object->email_from, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
897 print
$form->editfieldval(
"MailFrom",
'email_from', $object->email_from, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
900 $langs->load(
"errors");
901 print
img_warning($langs->trans(
"ErrorBadEMail", $email));
903 $langs->load(
"errors");
904 print
img_warning($langs->trans(
"ErrorBadMXDomain", $email));
911 print
$form->editfieldkey(
"MailErrorsTo",
'email_errorsto', $object->email_errorsto, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
913 print
$form->editfieldval(
"MailErrorsTo",
'email_errorsto', $object->email_errorsto, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
916 $langs->load(
"errors");
917 print
img_warning($langs->trans(
"ErrorBadEMail", $email));
919 $langs->load(
"errors");
920 print
img_warning($langs->trans(
"ErrorBadMXDomain", $email));
926 print $langs->trans(
"TotalNbOfDistinctRecipients");
927 print
'</td><td colspan="3">';
928 $nbemail = ($object->nbemail ? $object->nbemail : 0);
929 if (is_numeric($nbemail)) {
931 if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) {
932 if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) {
933 $text .= $langs->trans(
'LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
935 $text .= $langs->trans(
'SendingFromWebInterfaceIsNotAllowed');
938 if (empty($nbemail)) {
939 $nbemail .=
' '.img_warning(
'').
' <span class="warning">'.$langs->trans(
"NoTargetYet").
'</span>';
942 print
$form->textwithpicto($nbemail, $text, 1,
'warning');
950 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
960 if ($action ==
'clone') {
962 $formquestion = array(
963 'text' => $langs->trans(
"ConfirmClone"),
964 array(
'type' =>
'checkbox',
'name' =>
'clone_content',
'label' => $langs->trans(
"CloneContent"),
'value' => 1),
965 array(
'type' =>
'checkbox',
'name' =>
'clone_receivers',
'label' => $langs->trans(
"CloneReceivers"),
'value' => 0)
968 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEMailing', $object->ref),
'confirm_clone', $formquestion,
'yes', 2, 240);
975 if (
GETPOST(
'cancel',
'alpha') || $confirm ==
'no' || $action ==
'' || in_array($action, array(
'settodraft',
'valid',
'delete',
'sendall',
'clone',
'test'))) {
976 print
"\n\n<div class=\"tabsAction\">\n";
978 if (($object->statut == 1) && ($user->rights->mailing->valider || $object->user_validation == $user->id)) {
979 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=settodraft&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"SetToDraft").
'</a>';
982 if (($object->statut == 0 || $object->statut == 1 || $object->statut == 2) && $user->rights->mailing->creer) {
983 if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_MAILING)) {
984 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"EditWithEditor").
'</a>';
986 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"EditWithTextEditor").
'</a>';
989 if (!empty($conf->use_javascript_ajax)) {
990 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edithtml&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"EditHTMLSource").
'</a>';
996 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) {
997 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"TestMailing").
'</a>';
999 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=test&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"TestMailing").
'</a>';
1002 if ($object->statut == 0) {
1003 if ($object->nbemail <= 0) {
1004 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NoTargetYet")).
'">'.$langs->trans(
"ValidMailing").
'</a>';
1005 } elseif (empty($user->rights->mailing->valider)) {
1006 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"ValidMailing").
'</a>';
1008 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=valid&id='.$object->id.
'">'.$langs->trans(
"ValidMailing").
'</a>';
1012 if (($object->statut == 1 || $object->statut == 2) && $object->nbemail > 0 && $user->rights->mailing->valider) {
1013 if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) {
1014 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"SendingFromWebInterfaceIsNotAllowed")).
'">'.$langs->trans(
"SendMailing").
'</a>';
1015 } elseif (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) {
1016 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"SendMailing").
'</a>';
1018 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=sendall&id='.$object->id.
'">'.$langs->trans(
"SendMailing").
'</a>';
1022 if ($user->rights->mailing->creer) {
1023 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=clone&object=emailing&id='.$object->id.
'">'.$langs->trans(
"ToClone").
'</a>';
1026 if (($object->statut == 2 || $object->statut == 3) && $user->rights->mailing->valider) {
1027 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) {
1028 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"ResetMailing").
'</a>';
1030 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=reset&id='.$object->id.
'">'.$langs->trans(
"ResetMailing").
'</a>';
1034 if (($object->statut <= 1 && $user->rights->mailing->creer) || $user->rights->mailing->supprimer) {
1035 if ($object->statut > 0 && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->delete)) {
1036 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"DeleteMailing").
'</a>';
1038 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&id='.$object->id.(!empty($urlfrom) ?
'&urlfrom='.$urlfrom :
'').
'">'.$langs->trans(
"DeleteMailing").
'</a>';
1046 if ($action ==
'test') {
1047 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
1053 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1055 $formmail->fromname = $object->email_from;
1056 $formmail->frommail = $object->email_from;
1057 $formmail->withsubstit = 1;
1058 $formmail->withfrom = 0;
1059 $formmail->withto = $user->email ? $user->email : 1;
1060 $formmail->withtocc = 0;
1061 $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
1062 $formmail->withtopic = 0;
1063 $formmail->withtopicreadonly = 1;
1064 $formmail->withfile = 0;
1065 $formmail->withbody = 0;
1066 $formmail->withbodyreadonly = 1;
1067 $formmail->withcancel = 1;
1068 $formmail->withdeliveryreceipt = 0;
1070 $formmail->substit = $object->substitutionarrayfortest;
1072 $formmail->param[
"action"] =
"send";
1073 $formmail->param[
"models"] =
'none';
1074 $formmail->param[
"mailid"] = $object->id;
1075 $formmail->param[
"returnurl"] = $_SERVER[
'PHP_SELF'].
"?id=".$object->id;
1077 print $formmail->get_form();
1087 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
1088 foreach ($object->substitutionarray as $key => $val) {
1089 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
1091 $htmltext .=
'</i>';
1094 print
load_fiche_titre($langs->trans(
"EMail"),
$form->textwithpicto(
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"AvailableVariables").
'</span>', $htmltext, 1,
'helpclickable',
'', 0, 2,
'emailsubstitionhelp'),
'generic');
1098 print
'<table class="bordernooddeven" width="100%">';
1101 print
'<tr><td class="titlefield">'.$langs->trans(
"MailTopic").
'</td><td colspan="3">'.$object->sujet.
'</td></tr>';
1104 print
'<tr><td>'.$langs->trans(
"MailFile").
'</td><td colspan="3">';
1106 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
1107 if (count($listofpaths)) {
1108 foreach ($listofpaths as $key => $val) {
1109 print
img_mime($listofpaths[$key][
'name']).
' '.$listofpaths[$key][
'name'];
1113 print
'<span class="opacitymedium">'.$langs->trans(
"NoAttachedFiles").
'</span><br>';
1125 print
'<div style="padding-top: 10px; background: '.($object->bgcolor ? (preg_match(
'/^#/', $object->bgcolor) ?
'' :
'#').$object->bgcolor :
'white').
'">';
1126 if (empty($object->bgcolor) || strtolower($object->bgcolor) ==
'ffffff') {
1129 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1130 $doleditor =
new DolEditor(
'bodyemail', $object->body,
'', 600,
'dolibarr_mailings',
'',
false,
true, empty($conf->global->FCKEDITOR_ENABLE_MAILING) ? 0 : 1, 20,
'90%', $readonly);
1131 $doleditor->Create();
1145 $linkback =
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1147 $morehtmlright =
'';
1148 if ($object->statut == 2) {
1149 $morehtmlright .=
' ('.$object->countNbOfTargets(
'alreadysent').
'/'.$object->nbemail.
') ';
1152 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref',
'',
'', 0,
'', $morehtmlright);
1154 print
'<div class="fichecenter">';
1155 print
'<div class="underbanner clearboth"></div>';
1157 print
'<table class="border centpercent">';
1167 print
'<tr><td class="titlefield">'.$langs->trans(
"MailTitle").
'</td><td colspan="3">'.$object->title.
'</td></tr>';
1169 print
'<tr><td class="titlefield">'.$langs->trans(
"MailFrom").
'</td><td colspan="3">'.
dol_print_email($object->email_from, 0, 0, 0, 0, 1).
'</td></tr>';
1171 print
'<tr><td>'.$langs->trans(
"MailErrorsTo").
'</td><td colspan="3">'.
dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1).
'</td></tr>';
1175 print $langs->trans(
"TotalNbOfDistinctRecipients");
1176 print
'</td><td colspan="3">';
1177 $nbemail = ($object->nbemail ? $object->nbemail : 0);
1178 if (is_numeric($nbemail)) {
1180 if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2)) {
1181 if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) {
1182 $text .= $langs->trans(
'LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
1184 $text .= $langs->trans(
'SendingFromWebInterfaceIsNotAllowed');
1187 if (empty($nbemail)) {
1188 $nbemail .=
' '.img_warning(
'').
' <span class="warning">'.$langs->trans(
"NoTargetYet").
'</span>';
1191 print
$form->textwithpicto($nbemail, $text, 1,
'warning');
1199 $parameters = array();
1200 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1201 print $hookmanager->resPrint;
1202 if (empty($reshook)) {
1203 print $object->showOptionals($extrafields,
'edit', $parameters);
1215 print
'<form name="edit_mailing" action="card.php" method="post" enctype="multipart/form-data">'.
"\n";
1216 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1217 print
'<input type="hidden" name="action" value="update">';
1218 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1220 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
1221 foreach ($object->substitutionarray as $key => $val) {
1222 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
1224 $htmltext .=
'</i>';
1227 print
load_fiche_titre($langs->trans(
"EMail"),
$form->textwithpicto($langs->trans(
"AvailableVariables"), $htmltext, 1,
'help',
'', 0, 2,
'emailsubstitionhelp'),
'generic');
1231 print
'<table class="bordernooddeven" width="100%">';
1234 print
'<tr><td class="fieldrequired titlefield">'.$langs->trans(
"MailTopic").
'</td><td colspan="3"><input class="flat quatrevingtpercent" type="text" name="sujet" value="'.$object->sujet.
'"></td></tr>';
1240 $addfileaction =
'addfile';
1241 print
'<tr><td>'.$langs->trans(
"MailFile").
'</td>';
1242 print
'<td colspan="3">';
1244 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
1247 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1248 $out .=
'<script type="text/javascript">';
1249 $out .=
'jQuery(document).ready(function () {';
1250 $out .=
' jQuery(".removedfile").click(function() {';
1251 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1254 $out .=
'</script>'.
"\n";
1255 if (count($listofpaths)) {
1256 foreach ($listofpaths as $key => $val) {
1257 $out .=
'<div id="attachfile_'.$key.
'">';
1258 $out .=
img_mime($listofpaths[$key][
'name']).
' '.$listofpaths[$key][
'name'];
1259 $out .=
' <input type="image" style="border: 0px;" src="'.img_picto($langs->trans(
"Search"),
'delete.png',
'',
'', 1).
'" value="'.($key + 1).
'" class="removedfile" id="removedfile_'.$key.
'" name="removedfile_'.$key.
'" />';
1260 $out .=
'<br></div>';
1263 $out .=
'<span class="opacitymedium">'.$langs->trans(
"NoAttachedFiles").
'</span><br>';
1267 $maxmin = $maxfilesizearray[
'maxmin'];
1269 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
1271 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
1273 $out .=
'<input type="submit" class="button" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
1278 print
'<tr><td>'.$langs->trans(
"BackgroundColorByDefault").
'</td><td colspan="3">';
1279 print $htmlother->selectColor($object->bgcolor,
'bgcolor',
'', 0);
1285 print
'<div style="padding-top: 10px">';
1287 if ($action ==
'edit') {
1289 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1290 $doleditor =
new DolEditor(
'bodyemail', $object->body,
'', 600,
'dolibarr_mailings',
'',
true,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_MAILING'), 20,
'90%');
1291 $doleditor->Create();
1293 if ($action ==
'edithtml') {
1295 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1296 $doleditor =
new DolEditor(
'bodyemail', $object->body,
'', 600,
'dolibarr_mailings',
'',
true,
true,
'ace', 20,
'90%');
1297 $doleditor->Create(0,
'',
false,
'HTML Source',
'php');
1305 print
'<div class="center">';
1306 print
'<input type="submit" class="button buttonforacesave button-save" value="'.$langs->trans(
"Save").
'" name="save">';
1307 print
' ';
1308 print
'<input type="submit" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'" name="cancel">';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
getMaxFileSizeArray()
Return the max allowed for file upload.
dol_hash($chain, $type= '0')
Returns a hash of a string.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
dol_now($mode= 'auto')
Return date for now.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom= 'UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $help_url
View.
img_mime($file, $titlealt= '', $morecss= '')
Show MIME img of a file.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage third parties objects (customers, suppliers, prospects...)
emailing_prepare_head(Mailing $object)
Prepare array with list of tabs.
dol_mimetype($file, $default= 'application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
static getValidAddress($address, $format, $encode=0, $maxnumberofemail=0)
Return a formatted address string for SMTP protocol.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to,$css,$trackid,$moreinheader,$sendcontext,$replyto); $mailfile->sendfile();.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Class to manage emailings module.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_remove_file_process($filenb, $donotupdatesession=0, $donotdeletefile=1, $trackid= '')
Remove an uploaded file (for example after submitting a new file a mail form).
dol_init_file_process($pathtoscan= '', $trackid= '')
Scan a directory and init $_SESSION to manage uploaded files with list of all found files...
isValidMailDomain($mail)
Return true if email has a domain name that can be resolved to MX type.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage a WYSIWYG editor.
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesession=0, $varfiles= 'addedfile', $savingdocmask= '', $link=null, $trackid= '', $generatethumbs=1, $object=null)
Get and save an upload file (for example after submitting a new file a mail form).
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...