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 :
'');
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)) {
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;
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;
521 $mesgs = array_merge($mesgs, $object->errors);
529 if ($action ==
'settitle' || $action ==
'setemail_from' || $action ==
'setreplyto' || $action ==
'setemail_errorsto') {
530 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
532 if ($action ==
'settitle') {
533 $object->title = trim(
GETPOST(
'title',
'alpha'));
534 } elseif ($action ==
'setemail_from') {
535 $object->email_from = trim(
GETPOST(
'email_from',
'alphawithlgt'));
536 } elseif ($action ==
'setemail_replyto') {
537 $object->email_replyto = trim(
GETPOST(
'email_replyto',
'alphawithlgt'));
538 } elseif ($action ==
'setemail_errorsto') {
539 $object->email_errorsto = trim(
GETPOST(
'email_errorsto',
'alphawithlgt'));
540 } elseif ($action ==
'settitle' && empty($object->title)) {
541 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTitle"));
542 } elseif ($action ==
'setfrom' && empty($object->email_from)) {
543 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailFrom"));
547 if ($object->update($user) >= 0) {
548 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
551 $mesg = $object->error;
562 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
564 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
574 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
576 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
584 if ($action ==
'update' && !
GETPOST(
"removedfile") && !$cancel) {
585 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
591 $object->sujet = (string)
GETPOST(
"sujet");
592 $object->body = (string)
GETPOST(
"bodyemail",
'restricthtml');
593 $object->bgcolor = (string)
GETPOST(
"bgcolor");
594 $object->bgimage = (string)
GETPOST(
"bgimage");
596 if (!$object->sujet) {
597 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTopic"));
599 if (!$object->body) {
600 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailMessage"));
603 if (!count($mesgs)) {
604 if ($object->update($user) >= 0) {
605 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
608 $mesgs[] = $object->error;
609 $mesgs = array_merge($mesgs, $object->errors);
620 if ($action ==
'confirm_valid' && $confirm ==
'yes') {
621 if ($object->id > 0) {
622 $object->valid($user);
623 setEventMessages($langs->trans(
"MailingSuccessfullyValidated"),
null,
'mesgs');
624 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
632 if ($action ==
'confirm_settodraft' && $confirm ==
'yes') {
633 if ($object->id > 0) {
634 $result = $object->setStatut(0);
637 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
648 if ($action ==
'confirm_reset' && $confirm ==
'yes') {
649 if ($object->id > 0) {
652 $result = $object->valid($user);
654 $result = $object->reset_targets_status($user);
659 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
671 if ($action ==
'confirm_delete' && $confirm ==
'yes') {
672 if ($object->delete($object->id)) {
673 $url = (!empty($urlfrom) ? $urlfrom :
'list.php');
674 header(
"Location: ".$url);
692 $help_url =
'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
695 $langs->trans(
"Mailing"),
701 '/includes/ace/src/ace.js',
702 '/includes/ace/src/ext-statusbar.js',
703 '/includes/ace/src/ext-language_tools.js',
709 if ($action ==
'create') {
711 print
'<form name="new_mailing" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">'.
"\n";
712 print
'<input type="hidden" name="token" value="'.newToken().
'">';
713 print
'<input type="hidden" name="action" value="add">';
715 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
716 foreach ($object->substitutionarray as $key => $val) {
717 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
722 $availablelink =
$form->textwithpicto($langs->trans(
"AvailableVariables"), $htmltext, 1,
'help',
'', 0, 2,
'availvar');
727 print
load_fiche_titre($langs->trans(
"NewMailing"), $availablelink,
'object_email');
731 print
'<table class="border centpercent">';
732 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>';
733 print
'<tr><td class="fieldrequired">'.$langs->trans(
"MailFrom").
'</td><td><input class="flat minwidth200" name="from" value="'.$conf->global->MAILING_EMAIL_FROM.
'"></td></tr>';
734 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>';
738 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
739 print $hookmanager->resPrint;
740 if (empty($reshook)) {
741 print $object->showOptionals($extrafields,
'create');
747 print
'<table class="border centpercent">';
748 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>';
749 print
'<tr><td>'.$langs->trans(
"BackgroundColorByDefault").
'</td><td colspan="3">';
750 print $htmlother->selectColor(
GETPOST(
'bgcolor'),
'bgcolor',
'', 0);
755 print
'<div style="padding-top: 10px">';
757 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
758 $doleditor =
new DolEditor(
'bodyemail',
GETPOST(
'bodyemail',
'restricthtmlallowunvalid'),
'', 600,
'dolibarr_mailings',
'',
true,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_MAILING'), 20,
'90%');
759 $doleditor->Create();
764 print
$form->buttonsSaveCancel(
"CreateMailing",
'');
768 if ($object->id > 0) {
769 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
773 if ($action ==
'settodraft') {
775 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"SetToDraft"), $langs->trans(
"ConfirmUnvalidateEmailing"),
"confirm_settodraft",
'',
'', 1);
776 } elseif ($action ==
'valid') {
778 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"ValidMailing"), $langs->trans(
"ConfirmValidMailing"),
"confirm_valid",
'',
'', 1);
779 } elseif ($action ==
'reset') {
781 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"ResetMailing"), $langs->trans(
"ConfirmResetMailing", $object->ref),
"confirm_reset",
'',
'', 2);
782 } elseif ($action ==
'delete') {
784 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id.(!empty($urlfrom) ?
'&urlfrom='.urlencode($urlfrom) :
''), $langs->trans(
"DeleteAMailing"), $langs->trans(
"ConfirmDeleteMailing"),
"confirm_delete",
'',
'', 1);
787 if ($action !=
'edit' && $action !=
'edithtml') {
793 if ($action ==
'sendall') {
795 $sendingmode = $conf->global->EMAILING_MAIL_SENDMODE;
796 if (empty($sendingmode)) {
797 $sendingmode = $conf->global->MAIN_MAIL_SENDMODE;
799 if (empty($sendingmode)) {
800 $sendingmode =
'mail';
807 if (!empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode ==
'mail') {
810 $linktoadminemailbefore =
'<a href="'.DOL_URL_ROOT.
'/admin/mails_emailing.php">';
811 $linktoadminemailend =
'</a>';
812 setEventMessages($langs->trans(
"MailSendSetupIs", $listofmethods[$sendingmode]),
null,
'warnings');
813 $messagetoshow = $langs->trans(
"MailSendSetupIs2",
'{s1}',
'{s2}',
'{s3}',
'{s4}');
814 $messagetoshow = str_replace(
'{s1}', $linktoadminemailbefore, $messagetoshow);
815 $messagetoshow = str_replace(
'{s2}', $linktoadminemailend, $messagetoshow);
816 $messagetoshow = str_replace(
'{s3}', $langs->transnoentitiesnoconv(
"MAIN_MAIL_SENDMODE"), $messagetoshow);
817 $messagetoshow = str_replace(
'{s4}', $listofmethods[
'smtps'], $messagetoshow);
820 if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) {
821 setEventMessages($langs->trans(
"MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS),
null,
'warnings');
823 $_GET[
"action"] =
'';
824 } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) {
825 if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode ==
'mail') {
826 setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL),
null,
'warnings');
828 if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode !=
'mail') {
829 setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL),
null,
'warnings');
834 setEventMessages(
'<textarea cols="60" rows="'.ROWS_1.
'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.
'</textarea>',
null,
'warnings');
835 if ($conf->file->mailing_limit_sendbyweb !=
'-1') {
838 $_GET[
"action"] =
'';
840 if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode ==
'mail') {
841 setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL),
null,
'warnings');
843 if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode !=
'mail') {
844 setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL),
null,
'warnings');
849 if (isset($conf->global->MAILING_LIMIT_SENDBYDAY) && $conf->global->MAILING_LIMIT_SENDBYDAY >= 0) {
850 $text .= $langs->trans(
'WarningLimitSendByDay', $conf->global->MAILING_LIMIT_SENDBYDAY);
853 $text .= $langs->trans(
'ConfirmSendingEmailing').
'<br>';
854 $text .= $langs->trans(
'LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
856 if (!isset($conf->global->MAILING_LIMIT_SENDBYCLI) || $conf->global->MAILING_LIMIT_SENDBYCLI >= 0) {
858 $text .= $langs->trans(
"MailingNeedCommand");
859 $text .=
'<br><textarea cols="60" rows="'.ROWS_2.
'" wrap="soft" disabled>php ./scripts/emailings/mailing-send.php '.$object->id.
' '.$user->login.
'</textarea>';
862 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
'SendMailing'), $text,
'sendallconfirmed',
'',
'', 1, 330, 600, 0, $langs->trans(
"Confirm"), $langs->trans(
"Cancel"));
866 $linkback =
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
870 if ($object->statut == 2 || $object->statut == 3) {
871 $nbtry = $object->countNbOfTargets(
'alreadysent');
872 $nbko = $object->countNbOfTargets(
'alreadysentko');
874 $morehtmlright .=
' ('.$nbtry.
'/'.$object->nbemail;
876 $morehtmlright .=
' - '.$nbko.
' '.$langs->trans(
"Error");
878 $morehtmlright .=
') ';
881 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref',
'',
'', 0,
'', $morehtmlright);
883 print
'<div class="fichecenter">';
884 print
'<div class="underbanner clearboth"></div>';
886 print
'<table class="border centpercent tableforfield">';
889 print
'<tr><td class="titlefield">';
890 print
$form->editfieldkey(
"MailTitle",
'title', $object->title, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
892 print
$form->editfieldval(
"MailTitle",
'title', $object->title, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
897 print
$form->editfieldkey(
"MailFrom",
'email_from', $object->email_from, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
899 print
$form->editfieldval(
"MailFrom",
'email_from', $object->email_from, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
902 $langs->load(
"errors");
903 print
img_warning($langs->trans(
"ErrorBadEMail", $email));
905 $langs->load(
"errors");
906 print
img_warning($langs->trans(
"ErrorBadMXDomain", $email));
913 print
$form->editfieldkey(
"MailErrorsTo",
'email_errorsto', $object->email_errorsto, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
915 print
$form->editfieldval(
"MailErrorsTo",
'email_errorsto', $object->email_errorsto, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
918 $langs->load(
"errors");
919 print
img_warning($langs->trans(
"ErrorBadEMail", $email));
921 $langs->load(
"errors");
922 print
img_warning($langs->trans(
"ErrorBadMXDomain", $email));
928 print $langs->trans(
"TotalNbOfDistinctRecipients");
929 print
'</td><td colspan="3">';
930 $nbemail = ($object->nbemail ? $object->nbemail : 0);
931 if (is_numeric($nbemail)) {
933 if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) {
934 if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) {
935 $text .= $langs->trans(
'LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
937 $text .= $langs->trans(
'SendingFromWebInterfaceIsNotAllowed');
940 if (empty($nbemail)) {
941 $nbemail .=
' '.img_warning(
'').
' <span class="warning">'.$langs->trans(
"NoTargetYet").
'</span>';
944 print
$form->textwithpicto($nbemail, $text, 1,
'warning');
952 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
962 if ($action ==
'clone') {
964 $formquestion = array(
965 'text' => $langs->trans(
"ConfirmClone"),
966 array(
'type' =>
'checkbox',
'name' =>
'clone_content',
'label' => $langs->trans(
"CloneContent"),
'value' => 1),
967 array(
'type' =>
'checkbox',
'name' =>
'clone_receivers',
'label' => $langs->trans(
"CloneReceivers"),
'value' => 0)
970 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEMailing', $object->ref),
'confirm_clone', $formquestion,
'yes', 2, 240);
977 if (
GETPOST(
'cancel',
'alpha') || $confirm ==
'no' || $action ==
'' || in_array($action, array(
'settodraft',
'valid',
'delete',
'sendall',
'clone',
'test'))) {
978 print
"\n\n<div class=\"tabsAction\">\n";
980 if (($object->statut == 1) && ($user->rights->mailing->valider || $object->user_validation == $user->id)) {
981 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=settodraft&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"SetToDraft").
'</a>';
984 if (($object->statut == 0 || $object->statut == 1 || $object->statut == 2) && $user->rights->mailing->creer) {
985 if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_MAILING)) {
986 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"EditWithEditor").
'</a>';
988 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"EditWithTextEditor").
'</a>';
991 if (!empty($conf->use_javascript_ajax)) {
992 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edithtml&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"EditHTMLSource").
'</a>';
998 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) {
999 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"TestMailing").
'</a>';
1001 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=test&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"TestMailing").
'</a>';
1004 if ($object->statut == 0) {
1005 if ($object->nbemail <= 0) {
1006 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NoTargetYet")).
'">'.$langs->trans(
"ValidMailing").
'</a>';
1007 } elseif (empty($user->rights->mailing->valider)) {
1008 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"ValidMailing").
'</a>';
1010 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=valid&id='.$object->id.
'">'.$langs->trans(
"ValidMailing").
'</a>';
1014 if (($object->statut == 1 || $object->statut == 2) && $object->nbemail > 0 && $user->rights->mailing->valider) {
1015 if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) {
1016 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"SendingFromWebInterfaceIsNotAllowed")).
'">'.$langs->trans(
"SendMailing").
'</a>';
1017 } elseif (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) {
1018 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"SendMailing").
'</a>';
1020 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=sendall&id='.$object->id.
'">'.$langs->trans(
"SendMailing").
'</a>';
1024 if ($user->rights->mailing->creer) {
1025 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=clone&object=emailing&id='.$object->id.
'">'.$langs->trans(
"ToClone").
'</a>';
1028 if (($object->statut == 2 || $object->statut == 3) && $user->rights->mailing->valider) {
1029 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) {
1030 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"ResetMailing").
'</a>';
1032 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=reset&id='.$object->id.
'">'.$langs->trans(
"ResetMailing").
'</a>';
1036 if (($object->statut <= 1 && $user->rights->mailing->creer) || $user->rights->mailing->supprimer) {
1037 if ($object->statut > 0 && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->delete)) {
1038 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"DeleteMailing").
'</a>';
1040 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&id='.$object->id.(!empty($urlfrom) ?
'&urlfrom='.$urlfrom :
'').
'">'.$langs->trans(
"DeleteMailing").
'</a>';
1048 if ($action ==
'test') {
1049 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
1055 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1057 $formmail->fromname = $object->email_from;
1058 $formmail->frommail = $object->email_from;
1059 $formmail->withsubstit = 1;
1060 $formmail->withfrom = 0;
1061 $formmail->withto = $user->email ? $user->email : 1;
1062 $formmail->withtocc = 0;
1063 $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
1064 $formmail->withtopic = 0;
1065 $formmail->withtopicreadonly = 1;
1066 $formmail->withfile = 0;
1067 $formmail->withbody = 0;
1068 $formmail->withbodyreadonly = 1;
1069 $formmail->withcancel = 1;
1070 $formmail->withdeliveryreceipt = 0;
1072 $formmail->substit = $object->substitutionarrayfortest;
1074 $formmail->param[
"action"] =
"send";
1075 $formmail->param[
"models"] =
'none';
1076 $formmail->param[
"mailid"] = $object->id;
1077 $formmail->param[
"returnurl"] = $_SERVER[
'PHP_SELF'].
"?id=".$object->id;
1079 print $formmail->get_form();
1089 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
1090 foreach ($object->substitutionarray as $key => $val) {
1091 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
1093 $htmltext .=
'</i>';
1096 print
load_fiche_titre($langs->trans(
"EMail"),
$form->textwithpicto(
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"AvailableVariables").
'</span>', $htmltext, 1,
'helpclickable',
'', 0, 2,
'emailsubstitionhelp'),
'generic');
1100 print
'<table class="bordernooddeven" width="100%">';
1103 print
'<tr><td class="titlefield">'.$langs->trans(
"MailTopic").
'</td><td colspan="3">'.$object->sujet.
'</td></tr>';
1106 print
'<tr><td>'.$langs->trans(
"MailFile").
'</td><td colspan="3">';
1108 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
1109 if (count($listofpaths)) {
1110 foreach ($listofpaths as $key => $val) {
1111 print
img_mime($listofpaths[$key][
'name']).
' '.$listofpaths[$key][
'name'];
1115 print
'<span class="opacitymedium">'.$langs->trans(
"NoAttachedFiles").
'</span><br>';
1127 print
'<div style="padding-top: 10px; background: '.($object->bgcolor ? (preg_match(
'/^#/', $object->bgcolor) ?
'' :
'#').$object->bgcolor :
'white').
'">';
1128 if (empty($object->bgcolor) || strtolower($object->bgcolor) ==
'ffffff') {
1131 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1132 $doleditor =
new DolEditor(
'bodyemail', $object->body,
'', 600,
'dolibarr_mailings',
'',
false,
true, empty($conf->global->FCKEDITOR_ENABLE_MAILING) ? 0 : 1, 20,
'90%', $readonly);
1133 $doleditor->Create();
1147 $linkback =
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1149 $morehtmlright =
'';
1150 if ($object->statut == 2) {
1151 $morehtmlright .=
' ('.$object->countNbOfTargets(
'alreadysent').
'/'.$object->nbemail.
') ';
1154 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref',
'',
'', 0,
'', $morehtmlright);
1156 print
'<div class="fichecenter">';
1157 print
'<div class="underbanner clearboth"></div>';
1159 print
'<table class="border centpercent">';
1169 print
'<tr><td class="titlefield">'.$langs->trans(
"MailTitle").
'</td><td colspan="3">'.$object->title.
'</td></tr>';
1171 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>';
1173 print
'<tr><td>'.$langs->trans(
"MailErrorsTo").
'</td><td colspan="3">'.
dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1).
'</td></tr>';
1177 print $langs->trans(
"TotalNbOfDistinctRecipients");
1178 print
'</td><td colspan="3">';
1179 $nbemail = ($object->nbemail ? $object->nbemail : 0);
1180 if (is_numeric($nbemail)) {
1182 if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2)) {
1183 if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) {
1184 $text .= $langs->trans(
'LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
1186 $text .= $langs->trans(
'SendingFromWebInterfaceIsNotAllowed');
1189 if (empty($nbemail)) {
1190 $nbemail .=
' '.img_warning(
'').
' <span class="warning">'.$langs->trans(
"NoTargetYet").
'</span>';
1193 print
$form->textwithpicto($nbemail, $text, 1,
'warning');
1202 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
1203 print $hookmanager->resPrint;
1204 if (empty($reshook)) {
1205 print $object->showOptionals($extrafields,
'edit',
$parameters);
1217 print
'<form name="edit_mailing" action="card.php" method="post" enctype="multipart/form-data">'.
"\n";
1218 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1219 print
'<input type="hidden" name="action" value="update">';
1220 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1222 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
1223 foreach ($object->substitutionarray as $key => $val) {
1224 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
1226 $htmltext .=
'</i>';
1229 print
load_fiche_titre($langs->trans(
"EMail"),
$form->textwithpicto($langs->trans(
"AvailableVariables"), $htmltext, 1,
'help',
'', 0, 2,
'emailsubstitionhelp'),
'generic');
1233 print
'<table class="bordernooddeven" width="100%">';
1236 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>';
1242 $addfileaction =
'addfile';
1243 print
'<tr><td>'.$langs->trans(
"MailFile").
'</td>';
1244 print
'<td colspan="3">';
1246 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
1249 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1250 $out .=
'<script type="text/javascript">';
1251 $out .=
'jQuery(document).ready(function () {';
1252 $out .=
' jQuery(".removedfile").click(function() {';
1253 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1256 $out .=
'</script>'.
"\n";
1257 if (count($listofpaths)) {
1258 foreach ($listofpaths as $key => $val) {
1259 $out .=
'<div id="attachfile_'.$key.
'">';
1260 $out .=
img_mime($listofpaths[$key][
'name']).
' '.$listofpaths[$key][
'name'];
1261 $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.
'" />';
1262 $out .=
'<br></div>';
1265 $out .=
'<span class="opacitymedium">'.$langs->trans(
"NoAttachedFiles").
'</span><br>';
1269 $maxmin = $maxfilesizearray[
'maxmin'];
1271 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
1273 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
1275 $out .=
'<input type="submit" class="button" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
1280 print
'<tr><td>'.$langs->trans(
"BackgroundColorByDefault").
'</td><td colspan="3">';
1281 print $htmlother->selectColor($object->bgcolor,
'bgcolor',
'', 0);
1287 print
'<div style="padding-top: 10px">';
1289 if ($action ==
'edit') {
1291 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1292 $doleditor =
new DolEditor(
'bodyemail', $object->body,
'', 600,
'dolibarr_mailings',
'',
true,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_MAILING'), 20,
'90%');
1293 $doleditor->Create();
1295 if ($action ==
'edithtml') {
1297 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1298 $doleditor =
new DolEditor(
'bodyemail', $object->body,
'', 600,
'dolibarr_mailings',
'',
true,
true,
'ace', 20,
'90%');
1299 $doleditor->Create(0,
'',
false,
'HTML Source',
'php');
1307 print
'<div class="center">';
1308 print
'<input type="submit" class="button buttonforacesave button-save" value="'.$langs->trans(
"Save").
'" name="save">';
1309 print
' ';
1310 print
'<input type="submit" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'" name="cancel">';