27 if (!defined(
'NOSTYLECHECK')) {
28 define(
'NOSTYLECHECK',
'1');
32 require
'../../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/emailing.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/comm/mailing/class/mailing.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
43 $langs->load(
"mails");
46 $action =
GETPOST(
'action',
'aZ09');
48 $confirm =
GETPOST(
'confirm',
'alpha');
53 $result = $object->fetch($id);
58 $extrafields->fetch_name_optionals_label($object->table_element);
61 $hookmanager->initHooks(array(
'mailingcard',
'globalcard'));
68 $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature :
'');
75 $object->substitutionarrayfortest = $substitutionarray;
78 $listofmethods = array();
79 $listofmethods[
'mail'] =
'PHP mail function';
80 $listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
83 if (empty($user->rights->mailing->lire) || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) {
87 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
95 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
100 if (empty($reshook)) {
102 if ($action ==
'confirm_clone' && $confirm ==
'yes') {
103 if (!
GETPOST(
"clone_content",
'alpha') && !
GETPOST(
"clone_receivers",
'alpha')) {
106 $result = $object->createFromClone($user, $object->id,
GETPOST(
"clone_content",
'alpha'),
GETPOST(
"clone_receivers",
'alpha'));
108 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
118 if ($action ==
'sendallconfirmed' && $confirm ==
'yes') {
119 if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) {
122 setEventMessages(
'<textarea cols="70" rows="'.ROWS_2.
'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.
'</textarea>',
null,
'warnings');
125 } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) {
129 if ($object->statut == 0) {
135 $subject = $object->sujet;
136 $message = $object->body;
137 $from = $object->email_from;
138 $replyto = $object->email_replyto;
139 $errorsto = $object->email_errorsto;
142 if (preg_match(
'/[\s\t]*<html>/i', $message)) {
149 $nbok = 0; $nbko = 0;
153 $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";
154 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
155 $sql .=
" WHERE mc.statut < 1 AND mc.fk_mailing = ".((int) $object->id);
156 $sql .=
" ORDER BY mc.statut DESC";
158 dol_syslog(
"card.php: select targets", LOG_DEBUG);
159 $resql = $db->query($sql);
161 $num = $db->num_rows(
$resql);
164 dol_syslog(
"comm/mailing/card.php: nb of targets = ".$num, LOG_DEBUG);
169 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing SET date_envoi='".$db->idate($now).
"' WHERE rowid=".((int) $object->id);
170 $resql2 = $db->query($sql);
175 $thirdpartystatic =
new Societe($db);
179 while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB) {
184 $obj = $db->fetch_object(
$resql);
187 $sendto = str_replace(
',',
' ',
dolGetFirstLastname($obj->firstname, $obj->lastname)).
" <".$obj->email.
">";
190 $other = explode(
';', $obj->other);
191 $tmpfield = explode(
'=', $other[0], 2); $other1 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
192 $tmpfield = explode(
'=', $other[1], 2); $other2 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
193 $tmpfield = explode(
'=', $other[2], 2); $other3 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
194 $tmpfield = explode(
'=', $other[3], 2); $other4 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
195 $tmpfield = explode(
'=', $other[4], 2); $other5 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
197 $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature :
'');
199 $targetobject =
null;
204 $substitutionarray[
'__ID__'] = $obj->source_id;
205 if ($obj->source_type ==
"thirdparty") {
206 $result = $thirdpartystatic->fetch($obj->source_id);
209 $substitutionarray[
'__THIRDPARTY_CUSTOMER_CODE__'] = $thirdpartystatic->code_client;
211 $substitutionarray[
'__THIRDPARTY_CUSTOMER_CODE__'] =
'';
214 $substitutionarray[
'__EMAIL__'] = $obj->email;
215 $substitutionarray[
'__LASTNAME__'] = $obj->lastname;
216 $substitutionarray[
'__FIRSTNAME__'] = $obj->firstname;
217 $substitutionarray[
'__MAILTOEMAIL__'] =
'<a href="mailto:'.$obj->email.
'">'.$obj->email.
'</a>';
218 $substitutionarray[
'__OTHER1__'] = $other1;
219 $substitutionarray[
'__OTHER2__'] = $other2;
220 $substitutionarray[
'__OTHER3__'] = $other3;
221 $substitutionarray[
'__OTHER4__'] = $other4;
222 $substitutionarray[
'__OTHER5__'] = $other5;
223 $substitutionarray[
'__USER_SIGNATURE__'] = $signature;
224 $substitutionarray[
'__SENDEREMAIL_SIGNATURE__'] = $signature;
225 $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"/>';
226 $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>';
227 $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;
229 $onlinepaymentenabled = 0;
231 $onlinepaymentenabled++;
234 $onlinepaymentenabled++;
237 $onlinepaymentenabled++;
239 if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
240 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
241 $substitutionarray[
'__ONLINEPAYMENTLINK_MEMBER__'] = getHtmlOnlinePaymentLink(
'member', $obj->source_id);
242 $substitutionarray[
'__ONLINEPAYMENTLINK_DONATION__'] = getHtmlOnlinePaymentLink(
'donation', $obj->source_id);
243 $substitutionarray[
'__ONLINEPAYMENTLINK_ORDER__'] = getHtmlOnlinePaymentLink(
'order', $obj->source_id);
244 $substitutionarray[
'__ONLINEPAYMENTLINK_INVOICE__'] = getHtmlOnlinePaymentLink(
'invoice', $obj->source_id);
245 $substitutionarray[
'__ONLINEPAYMENTLINK_CONTRACTLINE__'] = getHtmlOnlinePaymentLink(
'contractline', $obj->source_id);
247 $substitutionarray[
'__SECUREKEYPAYMENT__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
248 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
249 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
250 $substitutionarray[
'__SECUREKEYPAYMENT_DONATION__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
251 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
252 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
253 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
255 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.
'member'.$obj->source_id, 2);
256 $substitutionarray[
'__SECUREKEYPAYMENT_DONATION__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.
'donation'.$obj->source_id, 2);
257 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.
'order'.$obj->source_id, 2);
258 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.
'invoice'.$obj->source_id, 2);
259 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.
'contractline'.$obj->source_id, 2);
262 if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
263 $substitutionarray[
'__PUBLICLINK_NEWMEMBERFORM__'] =
'<a target="_blank" rel="noopener noreferrer" href="'.DOL_MAIN_URL_ROOT.
'/public/members/new.php'.((
isModEnabled(
'multicompany')) ?
'?entity='.$conf->entity :
'').
'">'.$langs->trans(
'BlankSubscriptionForm').
'</a>';
266 if (
isModEnabled(
'paypal') && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) {
267 $substitutionarray[
'__SECUREKEYPAYPAL__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
269 if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
270 $substitutionarray[
'__SECUREKEYPAYPAL_MEMBER__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
272 $substitutionarray[
'__SECUREKEYPAYPAL_MEMBER__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.
'membersubscription'.$obj->source_id, 2);
275 if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
276 $substitutionarray[
'__SECUREKEYPAYPAL_ORDER__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
278 $substitutionarray[
'__SECUREKEYPAYPAL_ORDER__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.
'order'.$obj->source_id, 2);
281 if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
282 $substitutionarray[
'__SECUREKEYPAYPAL_INVOICE__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
284 $substitutionarray[
'__SECUREKEYPAYPAL_INVOICE__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.
'invoice'.$obj->source_id, 2);
287 if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
288 $substitutionarray[
'__SECUREKEYPAYPAL_CONTRACTLINE__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
290 $substitutionarray[
'__SECUREKEYPAYPAL_CONTRACTLINE__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.
'contractline'.$obj->source_id, 2);
300 if (preg_match(
'/__UNSUBSCRIBE__/', $message)) {
301 $moreinheader =
"List-Unsubscribe: <__UNSUBSCRIBE_URL__>\n";
310 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
311 if (count($listofpaths)) {
312 foreach ($listofpaths as $key => $val) {
313 $arr_file[] = $listofpaths[$key][
'fullname'];
315 $arr_name[] = $listofpaths[$key][
'name'];
320 $trackid =
'emailing-'.$obj->fk_mailing.
'-'.$obj->rowid;
321 $upload_dir_tmp = $upload_dir;
322 $mail =
new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name,
'',
'', 0, $msgishtml, $errorsto, $arr_css, $trackid, $moreinheader,
'emailing',
'', $upload_dir_tmp);
335 $res = $mail->sendfile();
342 dol_syslog(
"comm/mailing/card.php: ok for #".$i.($mail->error ?
' - '.$mail->error :
''), LOG_DEBUG);
344 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing_cibles";
345 $sql .=
" SET statut=1, date_envoi = '".$db->idate($now).
"' WHERE rowid=".((int) $obj->rowid);
346 $resql2 = $db->query($sql);
351 if (strpos($message,
'__CHECK_READ__') !==
false) {
353 $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).
")";
354 dol_syslog(
"card.php: set prospect thirdparty status", LOG_DEBUG);
355 $resql2 = $db->query($sql);
361 $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)";
362 dol_syslog(
"card.php: set prospect contact status", LOG_DEBUG);
364 $resql2 = $db->query($sql);
371 if (!empty($conf->global->MAILING_DELAY)) {
372 dol_syslog(
"Wait a delay of MAILING_DELAY=".((
float) $conf->global->MAILING_DELAY));
373 usleep((
float) $conf->global->MAILING_DELAY * 1000000);
381 dol_syslog(
"comm/mailing/card.php: error for #".$i.($mail->error ?
' - '.$mail->error :
''), LOG_WARNING);
383 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing_cibles";
384 $sql .=
" SET statut=-1, error_text='".$db->escape($mail->error).
"', date_envoi='".$db->idate($now).
"' WHERE rowid=".((int) $obj->rowid);
385 $resql2 = $db->query($sql);
394 setEventMessages($langs->transnoentitiesnoconv(
"NoMoreRecipientToSendTo"),
null,
'mesgs');
401 setEventMessages($langs->transnoentitiesnoconv(
"EMailSentToNRecipients", $nbok),
null,
'mesgs');
403 setEventMessages($langs->transnoentitiesnoconv(
"EMailSentToNRecipients", $nbok),
null,
'mesgs');
408 setEventMessages($langs->transnoentitiesnoconv(
"EMailSentToNRecipients", $nbok),
null,
'mesgs');
411 setEventMessages($langs->transnoentitiesnoconv(
"EMailSentToNRecipients", $nbok),
null,
'mesgs');
415 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing SET statut=".((int) $statut).
" WHERE rowid = ".((int) $object->id);
416 dol_syslog(
"comm/mailing/card.php: update global status", LOG_DEBUG);
417 $resql2 = $db->query($sql);
431 if ($action ==
'send' && ! $cancel) {
434 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
436 $object->sendto =
GETPOST(
"sendto",
'alphawithlgt');
437 if (!$object->sendto) {
438 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTo")),
null,
'errors');
445 if (preg_match(
'/[\s\t]*<html>/i', $object->body)) {
450 $object->substitutionarrayfortest[
'__EMAIL__'] = $object->sendto;
451 $object->substitutionarrayfortest[
'__MAILTOEMAIL__'] =
'<a href="mailto:'.$object->sendto.
'">'.$object->sendto.
'</a>';
464 if (!empty($object->bgcolor)) {
465 $arr_css[
'bgcolor'] = (preg_match(
'/^#/', $object->bgcolor) ?
'' :
'#').$object->bgcolor;
467 if (!empty($object->bgimage)) {
468 $arr_css[
'bgimage'] = $object->bgimage;
472 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
473 if (count($listofpaths)) {
474 foreach ($listofpaths as $key => $val) {
475 $arr_file[] = $listofpaths[$key][
'fullname'];
477 $arr_name[] = $listofpaths[$key][
'name'];
481 $trackid =
'emailing-test';
482 $upload_dir_tmp = $upload_dir;
483 $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',
'', $upload_dir_tmp);
485 $result = $mailfile->sendfile();
487 setEventMessages($langs->trans(
"MailSuccessfulySent", $mailfile->getValidAddress($object->email_from, 2), $mailfile->getValidAddress($object->sendto, 2)),
null,
'mesgs');
490 setEventMessages($langs->trans(
"ResultKo").
'<br>'.$mailfile->error.
' '.$result,
null,
'errors');
497 if ($action ==
'add') {
500 $object->email_from = (string)
GETPOST(
"from",
'alphawithlgt');
501 $object->email_replyto = (string)
GETPOST(
"replyto",
'alphawithlgt');
502 $object->email_errorsto = (string)
GETPOST(
"errorsto",
'alphawithlgt');
503 $object->title = (string)
GETPOST(
"title");
504 $object->sujet = (string)
GETPOST(
"sujet");
505 $object->body = (string)
GETPOST(
"bodyemail",
'restricthtml');
506 $object->bgcolor = (string)
GETPOST(
"bgcolor");
507 $object->bgimage = (string)
GETPOST(
"bgimage");
509 if (!$object->title) {
510 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTitle"));
512 if (!$object->sujet) {
513 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTopic"));
515 if (!$object->body) {
516 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailMessage"));
519 if (!count($mesgs)) {
520 if ($object->create($user) >= 0) {
521 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
524 $mesgs[] = $object->error;
525 $mesgs = array_merge($mesgs, $object->errors);
533 if ($action ==
'settitle' || $action ==
'setemail_from' || $action ==
'setreplyto' || $action ==
'setemail_errorsto') {
534 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
536 if ($action ==
'settitle') {
537 $object->title = trim(
GETPOST(
'title',
'alpha'));
538 } elseif ($action ==
'setemail_from') {
539 $object->email_from = trim(
GETPOST(
'email_from',
'alphawithlgt'));
540 } elseif ($action ==
'setemail_replyto') {
541 $object->email_replyto = trim(
GETPOST(
'email_replyto',
'alphawithlgt'));
542 } elseif ($action ==
'setemail_errorsto') {
543 $object->email_errorsto = trim(
GETPOST(
'email_errorsto',
'alphawithlgt'));
544 } elseif ($action ==
'settitle' && empty($object->title)) {
545 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTitle"));
546 } elseif ($action ==
'setfrom' && empty($object->email_from)) {
547 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailFrom"));
551 if ($object->update($user) >= 0) {
552 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
555 $mesg = $object->error;
566 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
568 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
578 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
580 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
588 if ($action ==
'update' && !
GETPOST(
"removedfile") && !$cancel) {
589 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
595 $object->sujet = (string)
GETPOST(
"sujet");
596 $object->body = (string)
GETPOST(
"bodyemail",
'restricthtml');
597 $object->bgcolor = (string)
GETPOST(
"bgcolor");
598 $object->bgimage = (string)
GETPOST(
"bgimage");
600 if (!$object->sujet) {
601 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTopic"));
603 if (!$object->body) {
604 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailMessage"));
607 if (!count($mesgs)) {
608 if ($object->update($user) >= 0) {
609 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
612 $mesgs[] = $object->error;
613 $mesgs = array_merge($mesgs, $object->errors);
624 if ($action ==
'confirm_valid' && $confirm ==
'yes') {
625 if ($object->id > 0) {
626 $object->valid($user);
627 setEventMessages($langs->trans(
"MailingSuccessfullyValidated"),
null,
'mesgs');
628 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
636 if ($action ==
'confirm_settodraft' && $confirm ==
'yes') {
637 if ($object->id > 0) {
638 $result = $object->setStatut(0);
641 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
652 if ($action ==
'confirm_reset' && $confirm ==
'yes') {
653 if ($object->id > 0) {
656 $result = $object->valid($user);
658 $result = $object->reset_targets_status($user);
663 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
675 if ($action ==
'confirm_delete' && $confirm ==
'yes') {
676 if ($object->delete($object->id)) {
677 $url = (!empty($urlfrom) ? $urlfrom :
'list.php');
678 header(
"Location: ".$url);
696 $help_url =
'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
699 $langs->trans(
"Mailing"),
705 '/includes/ace/src/ace.js',
706 '/includes/ace/src/ext-statusbar.js',
707 '/includes/ace/src/ext-language_tools.js',
713 if ($action ==
'create') {
715 print
'<form name="new_mailing" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">'.
"\n";
716 print
'<input type="hidden" name="token" value="'.newToken().
'">';
717 print
'<input type="hidden" name="action" value="add">';
719 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
720 foreach ($object->substitutionarray as $key => $val) {
721 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
726 $availablelink =
$form->textwithpicto($langs->trans(
"AvailableVariables"), $htmltext, 1,
'help',
'', 0, 2,
'availvar');
731 print
load_fiche_titre($langs->trans(
"NewMailing"), $availablelink,
'object_email');
735 print
'<table class="border centpercent">';
737 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>';
739 print
'<tr><td class="fieldrequired">'.$langs->trans(
"MailFrom").
'</td><td><input class="flat minwidth200" name="from" value="'.$conf->global->MAILING_EMAIL_FROM.
'"></td></tr>';
741 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>';
745 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
746 print $hookmanager->resPrint;
747 if (empty($reshook)) {
748 print $object->showOptionals($extrafields,
'create');
754 print
'<table class="border centpercent">';
755 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>';
756 print
'<tr><td>'.$langs->trans(
"BackgroundColorByDefault").
'</td><td colspan="3">';
757 print $htmlother->selectColor(
GETPOST(
'bgcolor'),
'bgcolor',
'', 0);
762 print
'<div style="padding-top: 10px">';
764 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
765 $doleditor =
new DolEditor(
'bodyemail',
GETPOST(
'bodyemail',
'restricthtmlallowunvalid'),
'', 600,
'dolibarr_mailings',
'',
true,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_MAILING'), 20,
'90%');
766 $doleditor->Create();
771 print
$form->buttonsSaveCancel(
"CreateMailing",
'Cancel');
775 if ($object->id > 0) {
776 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
780 if ($action ==
'settodraft') {
782 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"SetToDraft"), $langs->trans(
"ConfirmUnvalidateEmailing"),
"confirm_settodraft",
'',
'', 1);
783 } elseif ($action ==
'valid') {
785 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"ValidMailing"), $langs->trans(
"ConfirmValidMailing"),
"confirm_valid",
'',
'', 1);
786 } elseif ($action ==
'reset') {
788 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"ResetMailing"), $langs->trans(
"ConfirmResetMailing", $object->ref),
"confirm_reset",
'',
'', 2);
789 } elseif ($action ==
'delete') {
791 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id.(!empty($urlfrom) ?
'&urlfrom='.urlencode($urlfrom) :
''), $langs->trans(
"DeleteAMailing"), $langs->trans(
"ConfirmDeleteMailing"),
"confirm_delete",
'',
'', 1);
794 if ($action !=
'edit' && $action !=
'edithtml') {
800 if ($action ==
'sendall') {
802 $sendingmode = $conf->global->EMAILING_MAIL_SENDMODE;
803 if (empty($sendingmode)) {
804 $sendingmode = $conf->global->MAIN_MAIL_SENDMODE;
806 if (empty($sendingmode)) {
807 $sendingmode =
'mail';
814 if (!empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode ==
'mail') {
817 $linktoadminemailbefore =
'<a href="'.DOL_URL_ROOT.
'/admin/mails_emailing.php">';
818 $linktoadminemailend =
'</a>';
819 setEventMessages($langs->trans(
"MailSendSetupIs", $listofmethods[$sendingmode]),
null,
'warnings');
820 $messagetoshow = $langs->trans(
"MailSendSetupIs2",
'{s1}',
'{s2}',
'{s3}',
'{s4}');
821 $messagetoshow = str_replace(
'{s1}', $linktoadminemailbefore, $messagetoshow);
822 $messagetoshow = str_replace(
'{s2}', $linktoadminemailend, $messagetoshow);
823 $messagetoshow = str_replace(
'{s3}', $langs->transnoentitiesnoconv(
"MAIN_MAIL_SENDMODE"), $messagetoshow);
824 $messagetoshow = str_replace(
'{s4}', $listofmethods[
'smtps'], $messagetoshow);
827 if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) {
828 setEventMessages($langs->trans(
"MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS),
null,
'warnings');
830 $_GET[
"action"] =
'';
831 } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) {
832 if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode ==
'mail') {
833 setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL),
null,
'warnings');
835 if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode !=
'mail') {
836 setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL),
null,
'warnings');
841 setEventMessages(
'<textarea cols="60" rows="'.ROWS_1.
'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.
'</textarea>',
null,
'warnings');
842 if ($conf->file->mailing_limit_sendbyweb !=
'-1') {
845 $_GET[
"action"] =
'';
847 if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode ==
'mail') {
848 setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL),
null,
'warnings');
850 if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode !=
'mail') {
851 setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL),
null,
'warnings');
856 if (isset($conf->global->MAILING_LIMIT_SENDBYDAY) && $conf->global->MAILING_LIMIT_SENDBYDAY >= 0) {
857 $text .= $langs->trans(
'WarningLimitSendByDay', $conf->global->MAILING_LIMIT_SENDBYDAY);
860 $text .= $langs->trans(
'ConfirmSendingEmailing').
'<br>';
861 $text .= $langs->trans(
'LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
863 if (!isset($conf->global->MAILING_LIMIT_SENDBYCLI) || $conf->global->MAILING_LIMIT_SENDBYCLI >= 0) {
865 $text .= $langs->trans(
"MailingNeedCommand");
866 $text .=
'<br><textarea cols="60" rows="'.ROWS_2.
'" wrap="soft" disabled>php ./scripts/emailings/mailing-send.php '.$object->id.
' '.$user->login.
'</textarea>';
869 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
'SendMailing'), $text,
'sendallconfirmed',
'',
'', 1, 330, 600, 0, $langs->trans(
"Confirm"), $langs->trans(
"Cancel"));
873 $linkback =
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
877 if ($object->statut == 2 || $object->statut == 3) {
878 $nbtry = $object->countNbOfTargets(
'alreadysent');
879 $nbko = $object->countNbOfTargets(
'alreadysentko');
881 $morehtmlright .=
' ('.$nbtry.
'/'.$object->nbemail;
883 $morehtmlright .=
' - '.$nbko.
' '.$langs->trans(
"Error");
885 $morehtmlright .=
') ';
888 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref',
'',
'', 0,
'', $morehtmlright);
890 print
'<div class="fichecenter">';
891 print
'<div class="underbanner clearboth"></div>';
893 print
'<table class="border centpercent tableforfield">';
896 print
'<tr><td class="titlefield">';
897 print
$form->editfieldkey(
"MailTitle",
'title', $object->title, $object, $user->hasRight(
'mailing',
'creer'),
'string');
899 print
$form->editfieldval(
"MailTitle",
'title', $object->title, $object, $user->hasRight(
'mailing',
'creer'),
'string');
904 print
$form->editfieldkey(
"MailFrom",
'email_from', $object->email_from, $object, $user->hasRight(
'mailing',
'creer') && $object->statut < 3,
'string');
906 print
$form->editfieldval(
"MailFrom",
'email_from', $object->email_from, $object, $user->hasRight(
'mailing',
'creer') && $object->statut < 3,
'string');
909 $langs->load(
"errors");
910 print
img_warning($langs->trans(
"ErrorBadEMail", $email));
912 $langs->load(
"errors");
913 print
img_warning($langs->trans(
"ErrorBadMXDomain", $email));
920 print
$form->editfieldkey(
"MailErrorsTo",
'email_errorsto', $object->email_errorsto, $object, $user->hasRight(
'mailing',
'creer') && $object->statut < 3,
'string');
922 print
$form->editfieldval(
"MailErrorsTo",
'email_errorsto', $object->email_errorsto, $object, $user->hasRight(
'mailing',
'creer') && $object->statut < 3,
'string');
925 $langs->load(
"errors");
926 print
img_warning($langs->trans(
"ErrorBadEMail", $email));
928 $langs->load(
"errors");
929 print
img_warning($langs->trans(
"ErrorBadMXDomain", $email));
935 print $langs->trans(
"TotalNbOfDistinctRecipients");
936 print
'</td><td colspan="3">';
937 $nbemail = ($object->nbemail ? $object->nbemail : 0);
938 if (is_numeric($nbemail)) {
940 if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) {
941 if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) {
942 $text .= $langs->trans(
'LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
944 $text .= $langs->trans(
'SendingFromWebInterfaceIsNotAllowed');
947 if (empty($nbemail)) {
948 $nbemail .=
' '.img_warning(
'').
' <span class="warning">'.$langs->trans(
"NoTargetYet").
'</span>';
951 print
$form->textwithpicto($nbemail, $text, 1,
'warning');
959 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
969 if ($action ==
'clone') {
971 $formquestion = array(
972 'text' => $langs->trans(
"ConfirmClone"),
973 array(
'type' =>
'checkbox',
'name' =>
'clone_content',
'label' => $langs->trans(
"CloneContent"),
'value' => 1),
974 array(
'type' =>
'checkbox',
'name' =>
'clone_receivers',
'label' => $langs->trans(
"CloneReceivers"),
'value' => 0)
977 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEMailing', $object->ref),
'confirm_clone', $formquestion,
'yes', 2, 240);
984 if (
GETPOST(
'cancel',
'alpha') || $confirm ==
'no' || $action ==
'' || in_array($action, array(
'settodraft',
'valid',
'delete',
'sendall',
'clone',
'test'))) {
985 print
"\n\n<div class=\"tabsAction\">\n";
987 if (($object->statut == 1) && ($user->hasRight(
'mailing',
'valider') || $object->user_validation == $user->id)) {
988 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=settodraft&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"SetToDraft").
'</a>';
991 if (($object->statut == 0 || $object->statut == 1 || $object->statut == 2) && $user->hasRight(
'mailing',
'creer')) {
992 if (
isModEnabled(
'fckeditor') && !empty($conf->global->FCKEDITOR_ENABLE_MAILING)) {
993 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"EditWithEditor").
'</a>';
995 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"EditWithTextEditor").
'</a>';
998 if (!empty($conf->use_javascript_ajax)) {
999 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edithtml&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"EditHTMLSource").
'</a>';
1005 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) {
1006 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"TestMailing").
'</a>';
1008 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=test&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"TestMailing").
'</a>';
1011 if ($object->statut == 0) {
1012 if ($object->nbemail <= 0) {
1013 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NoTargetYet")).
'">'.$langs->trans(
"ValidMailing").
'</a>';
1014 } elseif (empty($user->rights->mailing->valider)) {
1015 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"ValidMailing").
'</a>';
1017 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=valid&id='.$object->id.
'">'.$langs->trans(
"ValidMailing").
'</a>';
1021 if (($object->statut == 1 || $object->statut == 2) && $object->nbemail > 0 && $user->hasRight(
'mailing',
'valider')) {
1022 if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) {
1023 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"SendingFromWebInterfaceIsNotAllowed")).
'">'.$langs->trans(
"SendMailing").
'</a>';
1024 } elseif (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) {
1025 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"SendMailing").
'</a>';
1027 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=sendall&id='.$object->id.
'">'.$langs->trans(
"SendMailing").
'</a>';
1031 if ($user->hasRight(
'mailing',
'creer')) {
1032 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=clone&object=emailing&id='.$object->id.
'">'.$langs->trans(
"ToClone").
'</a>';
1035 if (($object->statut == 2 || $object->statut == 3) && $user->hasRight(
'mailing',
'valider')) {
1036 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) {
1037 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"ResetMailing").
'</a>';
1039 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=reset&id='.$object->id.
'">'.$langs->trans(
"ResetMailing").
'</a>';
1043 if (($object->statut <= 1 && $user->hasRight(
'mailing',
'creer')) || $user->hasRight(
'mailing',
'supprimer')) {
1044 if ($object->statut > 0 && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->delete)) {
1045 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"DeleteMailing").
'</a>';
1047 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&id='.$object->id.(!empty($urlfrom) ?
'&urlfrom='.$urlfrom :
'').
'">'.$langs->trans(
"DeleteMailing").
'</a>';
1055 if ($action ==
'test') {
1056 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
1062 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1064 $formmail->fromname = $object->email_from;
1065 $formmail->frommail = $object->email_from;
1066 $formmail->withsubstit = 1;
1067 $formmail->withfrom = 0;
1068 $formmail->withto = $user->email ? $user->email : 1;
1069 $formmail->withtocc = 0;
1070 $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
1071 $formmail->withtopic = 0;
1072 $formmail->withtopicreadonly = 1;
1073 $formmail->withfile = 0;
1074 $formmail->withbody = 0;
1075 $formmail->withbodyreadonly = 1;
1076 $formmail->withcancel = 1;
1077 $formmail->withdeliveryreceipt = 0;
1079 $formmail->substit = $object->substitutionarrayfortest;
1081 $formmail->param[
"action"] =
"send";
1082 $formmail->param[
"models"] =
'none';
1083 $formmail->param[
"mailid"] = $object->id;
1084 $formmail->param[
"returnurl"] = $_SERVER[
'PHP_SELF'].
"?id=".$object->id;
1086 print $formmail->get_form();
1096 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br><br><span class="small">';
1097 foreach ($object->substitutionarray as $key => $val) {
1098 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
1100 $htmltext .=
'</span></i>';
1103 print
load_fiche_titre($langs->trans(
"EMail"),
$form->textwithpicto(
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"AvailableVariables").
'</span>', $htmltext, 1,
'helpclickable',
'', 0, 3,
'emailsubstitionhelp'),
'generic');
1107 print
'<table class="bordernooddeven tableforfield centpercent">';
1110 print
'<tr><td class="titlefield">'.$langs->trans(
"MailTopic").
'</td><td colspan="3">'.$object->sujet.
'</td></tr>';
1113 print
'<tr><td>'.$langs->trans(
"MailFile").
'</td><td colspan="3">';
1115 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
1116 if (count($listofpaths)) {
1117 foreach ($listofpaths as $key => $val) {
1118 print
img_mime($listofpaths[$key][
'name']).
' '.$listofpaths[$key][
'name'];
1122 print
'<span class="opacitymedium">'.$langs->trans(
"NoAttachedFiles").
'</span><br>';
1134 print
'<div style="padding-top: 10px; background: '.($object->bgcolor ? (preg_match(
'/^#/', $object->bgcolor) ?
'' :
'#').$object->bgcolor :
'white').
'">';
1135 if (empty($object->bgcolor) || strtolower($object->bgcolor) ==
'ffffff') {
1138 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1139 $doleditor =
new DolEditor(
'bodyemail', $object->body,
'', 600,
'dolibarr_mailings',
'',
false,
true, empty($conf->global->FCKEDITOR_ENABLE_MAILING) ? 0 : 1, 20,
'90%', $readonly);
1140 $doleditor->Create();
1154 $linkback =
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1156 $morehtmlright =
'';
1157 if ($object->statut == 2) {
1158 $morehtmlright .=
' ('.$object->countNbOfTargets(
'alreadysent').
'/'.$object->nbemail.
') ';
1161 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref',
'',
'', 0,
'', $morehtmlright);
1163 print
'<div class="fichecenter">';
1164 print
'<div class="underbanner clearboth"></div>';
1166 print
'<table class="border centpercent">';
1176 print
'<tr><td class="titlefield">'.$langs->trans(
"MailTitle").
'</td><td colspan="3">'.$object->title.
'</td></tr>';
1178 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>';
1180 print
'<tr><td>'.$langs->trans(
"MailErrorsTo").
'</td><td colspan="3">'.
dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1).
'</td></tr>';
1184 print $langs->trans(
"TotalNbOfDistinctRecipients");
1185 print
'</td><td colspan="3">';
1186 $nbemail = ($object->nbemail ? $object->nbemail : 0);
1187 if (is_numeric($nbemail)) {
1189 if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2)) {
1190 if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) {
1191 $text .= $langs->trans(
'LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
1193 $text .= $langs->trans(
'SendingFromWebInterfaceIsNotAllowed');
1196 if (empty($nbemail)) {
1197 $nbemail .=
' '.img_warning(
'').
' <span class="warning">'.$langs->trans(
"NoTargetYet").
'</span>';
1200 print
$form->textwithpicto($nbemail, $text, 1,
'warning');
1209 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
1210 print $hookmanager->resPrint;
1211 if (empty($reshook)) {
1212 print $object->showOptionals($extrafields,
'edit',
$parameters);
1224 print
'<form name="edit_mailing" action="card.php" method="post" enctype="multipart/form-data">'.
"\n";
1225 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1226 print
'<input type="hidden" name="action" value="update">';
1227 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1229 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
1230 foreach ($object->substitutionarray as $key => $val) {
1231 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
1233 $htmltext .=
'</i>';
1236 print
load_fiche_titre($langs->trans(
"EMail"),
$form->textwithpicto($langs->trans(
"AvailableVariables"), $htmltext, 1,
'help',
'', 0, 2,
'emailsubstitionhelp'),
'generic');
1240 print
'<table class="bordernooddeven" width="100%">';
1243 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>';
1249 $addfileaction =
'addfile';
1250 print
'<tr><td>'.$langs->trans(
"MailFile").
'</td>';
1251 print
'<td colspan="3">';
1253 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
1256 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1257 $out .=
'<script type="text/javascript">';
1258 $out .=
'jQuery(document).ready(function () {';
1259 $out .=
' jQuery(".removedfile").click(function() {';
1260 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1263 $out .=
'</script>'.
"\n";
1264 if (count($listofpaths)) {
1265 foreach ($listofpaths as $key => $val) {
1266 $out .=
'<div id="attachfile_'.$key.
'">';
1267 $out .=
img_mime($listofpaths[$key][
'name']).
' '.$listofpaths[$key][
'name'];
1268 $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.
'" />';
1269 $out .=
'<br></div>';
1277 $maxmin = $maxfilesizearray[
'maxmin'];
1279 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
1281 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
1283 $out .=
'<input type="submit" class="button smallpaddingimp" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
1288 print
'<tr><td>'.$langs->trans(
"BackgroundColorByDefault").
'</td><td colspan="3">';
1289 print $htmlother->selectColor($object->bgcolor,
'bgcolor',
'', 0);
1295 print
'<div style="padding-top: 10px">';
1297 if ($action ==
'edit') {
1299 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1300 $doleditor =
new DolEditor(
'bodyemail', $object->body,
'', 600,
'dolibarr_mailings',
'',
true,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_MAILING'), 20,
'90%');
1301 $doleditor->Create();
1303 if ($action ==
'edithtml') {
1305 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1306 $doleditor =
new DolEditor(
'bodyemail', $object->body,
'', 600,
'dolibarr_mailings',
'',
true,
true,
'ace', 20,
'90%');
1307 $doleditor->Create(0,
'',
false,
'HTML Source',
'php');
1315 print
'<div class="center">';
1316 print
'<input type="submit" class="button buttonforacesave button-save" value="'.$langs->trans(
"Save").
'" name="save">';
1317 print
' ';
1318 print
'<input type="submit" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'" name="cancel">';
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.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
static getValidAddress($address, $format, $encode=0, $maxnumberofemail=0)
Return a formatted address string for SMTP protocol.
Class to manage a WYSIWYG editor.
Class to manage emailings module.
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
emailing_prepare_head(Mailing $object)
Prepare array with list of tabs.
dol_init_file_process($pathtoscan='', $trackid='')
Scan a directory and init $_SESSION to manage uploaded files with list of all found files.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
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_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).
isValidMailDomain($mail)
Return true if email has a domain name that can be resolved to MX type.
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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
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.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
dol_now($mode='auto')
Return date for now.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
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...
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
isModEnabled($module)
Is Dolibarr module enabled.
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.
getMaxFileSizeArray()
Return the max allowed for file upload.
dol_hash($chain, $type='0')
Returns a hash (non reversible encryption) of a string.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.