26 if (!defined(
'NOSTYLECHECK')) define(
'NOSTYLECHECK',
'1');
28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/emailing.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/comm/mailing/class/mailing.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
39 $langs->load(
"mails");
41 if (!$user->rights->mailing->lire || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0))
accessforbidden();
44 $action =
GETPOST(
'action',
'aZ09');
45 $confirm =
GETPOST(
'confirm',
'alpha');
49 $result = $object->fetch($id);
54 $extrafields->fetch_name_optionals_label($object->table_element);
57 $hookmanager->initHooks(array(
'mailingcard',
'globalcard'));
64 $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature :
'');
68 $parameters = array(
'mode'=>
'emailing');
71 $object->substitutionarrayfortest = $substitutionarray;
74 $listofmethods = array();
75 $listofmethods[
'mail'] =
'PHP mail function';
76 $listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
84 $parameters = array();
85 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
86 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
91 if ($action ==
'confirm_clone' && $confirm ==
'yes')
93 if (!
GETPOST(
"clone_content",
'alpha') && !
GETPOST(
"clone_receivers",
'alpha'))
97 $result = $object->createFromClone($user, $object->id,
GETPOST(
"clone_content",
'alpha'),
GETPOST(
"clone_receivers",
'alpha'));
100 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
'?id='.$result);
110 if ($action ==
'sendallconfirmed' && $confirm ==
'yes')
112 if (empty($conf->global->MAILING_LIMIT_SENDBYWEB))
116 setEventMessages(
'<textarea cols="70" rows="'.ROWS_2.
'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.
'</textarea>', null,
'warnings');
119 } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0)
124 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
126 if ($object->statut == 0)
133 $subject = $object->sujet;
134 $message = $object->body;
135 $from = $object->email_from;
136 $replyto = $object->email_replyto;
137 $errorsto = $object->email_errorsto;
140 if (preg_match(
'/[\s\t]*<html>/i', $message)) $msgishtml = 1;
145 $nbok = 0; $nbko = 0;
149 $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";
150 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
151 $sql .=
" WHERE mc.statut < 1 AND mc.fk_mailing = ".$object->id;
152 $sql .=
" ORDER BY mc.statut DESC";
154 dol_syslog(
"card.php: select targets", LOG_DEBUG);
155 $resql = $db->query($sql);
158 $num = $db->num_rows(
$resql);
162 dol_syslog(
"comm/mailing/card.php: nb of targets = ".$num, LOG_DEBUG);
167 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing SET date_envoi='".$db->idate($now).
"' WHERE rowid=".$object->id;
168 $resql2 = $db->query($sql);
177 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 $substitutionarray[
'__EMAIL__'] = $obj->email;
205 $substitutionarray[
'__LASTNAME__'] = $obj->lastname;
206 $substitutionarray[
'__FIRSTNAME__'] = $obj->firstname;
207 $substitutionarray[
'__MAILTOEMAIL__'] =
'<a href="mailto:'.$obj->email.
'">'.$obj->email.
'</a>';
208 $substitutionarray[
'__OTHER1__'] = $other1;
209 $substitutionarray[
'__OTHER2__'] = $other2;
210 $substitutionarray[
'__OTHER3__'] = $other3;
211 $substitutionarray[
'__OTHER4__'] = $other4;
212 $substitutionarray[
'__OTHER5__'] = $other5;
213 $substitutionarray[
'__USER_SIGNATURE__'] = $signature;
214 $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"/>';
215 $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">'.$langs->trans(
"MailUnsubcribe").
'</a>';
217 $onlinepaymentenabled = 0;
218 if (!empty($conf->paypal->enabled)) $onlinepaymentenabled++;
219 if (!empty($conf->paybox->enabled)) $onlinepaymentenabled++;
220 if (!empty($conf->stripe->enabled)) $onlinepaymentenabled++;
221 if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN))
223 $substitutionarray[
'__SECUREKEYPAYMENT__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
224 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
226 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
227 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
228 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
229 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
231 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.
'membersubscription'.$obj->source_id, 2);
232 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.
'order'.$obj->source_id, 2);
233 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.
'invoice'.$obj->source_id, 2);
234 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.
'contractline'.$obj->source_id, 2);
238 if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN))
240 $substitutionarray[
'__SECUREKEYPAYPAL__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
242 if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray[
'__SECUREKEYPAYPAL_MEMBER__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
243 else $substitutionarray[
'__SECUREKEYPAYPAL_MEMBER__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.
'membersubscription'.$obj->source_id, 2);
245 if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray[
'__SECUREKEYPAYPAL_ORDER__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
246 else $substitutionarray[
'__SECUREKEYPAYPAL_ORDER__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.
'order'.$obj->source_id, 2);
248 if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray[
'__SECUREKEYPAYPAL_INVOICE__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
249 else $substitutionarray[
'__SECUREKEYPAYPAL_INVOICE__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.
'invoice'.$obj->source_id, 2);
251 if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray[
'__SECUREKEYPAYPAL_CONTRACTLINE__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
252 else $substitutionarray[
'__SECUREKEYPAYPAL_CONTRACTLINE__'] =
dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.
'contractline'.$obj->source_id, 2);
265 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
266 if (count($listofpaths))
268 foreach ($listofpaths as $key => $val)
270 $arr_file[] = $listofpaths[$key][
'fullname'];
272 $arr_name[] = $listofpaths[$key][
'name'];
277 $trackid =
'emailing-'.$obj->fk_mailing.
'-'.$obj->rowid;
278 $mail =
new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name,
'',
'', 0, $msgishtml, $errorsto, $arr_css, $trackid,
'',
'emailing');
293 $res = $mail->sendfile();
301 dol_syslog(
"comm/mailing/card.php: ok for #".$i.($mail->error ?
' - '.$mail->error :
''), LOG_DEBUG);
303 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing_cibles";
304 $sql .=
" SET statut=1, date_envoi='".$db->idate($now).
"' WHERE rowid=".$obj->rowid;
305 $resql2 = $db->query($sql);
311 if (strpos($message,
'__CHECK_READ__') !==
false)
314 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX.
"mailing_cibles WHERE rowid=".$obj->rowid.
")";
315 dol_syslog(
"card.php: set prospect thirdparty status", LOG_DEBUG);
316 $resql2 = $db->query($sql);
323 $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=".$obj->rowid.
" AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)";
324 dol_syslog(
"card.php: set prospect contact status", LOG_DEBUG);
326 $resql2 = $db->query($sql);
334 if (!empty($conf->global->MAILING_DELAY)) {
335 dol_syslog(
"Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY);
336 usleep((
float) $conf->global->MAILING_DELAY * 1000000);
344 dol_syslog(
"comm/mailing/card.php: error for #".$i.($mail->error ?
' - '.$mail->error :
''), LOG_WARNING);
346 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing_cibles";
347 $sql .=
" SET statut=-1, error_text='".$db->escape($mail->error).
"', date_envoi='".$db->idate($now).
"' WHERE rowid=".$obj->rowid;
348 $resql2 = $db->query($sql);
358 setEventMessages($langs->transnoentitiesnoconv(
"NoMoreRecipientToSendTo"), null,
'mesgs');
365 if ($nbok > 0)
setEventMessages($langs->transnoentitiesnoconv(
"EMailSentToNRecipients", $nbok), null,
'mesgs');
366 else setEventMessages($langs->transnoentitiesnoconv(
"EMailSentToNRecipients", $nbok), null,
'mesgs');
371 setEventMessages($langs->transnoentitiesnoconv(
"EMailSentToNRecipients", $nbok), null,
'mesgs');
374 setEventMessages($langs->transnoentitiesnoconv(
"EMailSentToNRecipients", $nbok), null,
'mesgs');
378 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing SET statut=".$statut.
" WHERE rowid=".$object->id;
379 dol_syslog(
"comm/mailing/card.php: update global status", LOG_DEBUG);
380 $resql2 = $db->query($sql);
395 if ($action ==
'send' && empty($_POST[
"cancel"]))
399 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
401 $object->sendto = $_POST[
"sendto"];
402 if (!$object->sendto)
404 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTo")), null,
'errors');
412 if (preg_match(
'/[\s\t]*<html>/i', $object->body)) $msgishtml = 1;
415 $object->substitutionarrayfortest[
'__EMAIL__'] = $object->sendto;
416 $object->substitutionarrayfortest[
'__MAILTOEMAIL__'] =
'<a href="mailto:'.$object->sendto.
'">'.$object->sendto.
'</a>';
429 if (!empty($object->bgcolor)) $arr_css[
'bgcolor'] = (preg_match(
'/^#/', $object->bgcolor) ?
'' :
'#').$object->bgcolor;
430 if (!empty($object->bgimage)) $arr_css[
'bgimage'] = $object->bgimage;
433 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
434 if (count($listofpaths))
436 foreach ($listofpaths as $key => $val)
438 $arr_file[] = $listofpaths[$key][
'fullname'];
440 $arr_name[] = $listofpaths[$key][
'name'];
444 $trackid =
'emailingtest';
445 $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');
447 $result = $mailfile->sendfile();
450 setEventMessages($langs->trans(
"MailSuccessfulySent", $mailfile->getValidAddress($object->email_from, 2), $mailfile->getValidAddress($object->sendto, 2)), null,
'mesgs');
453 setEventMessages($langs->trans(
"ResultKo").
'<br>'.$mailfile->error.
' '.$result, null,
'errors');
460 if ($action ==
'add')
464 $object->email_from =
GETPOST(
"from",
"none");
465 $object->email_replyto =
GETPOST(
"replyto",
"none");
466 $object->email_errorsto =
GETPOST(
"errorsto",
"none");
467 $object->title =
GETPOST(
"title");
468 $object->sujet =
GETPOST(
"sujet");
469 $object->body =
GETPOST(
"bodyemail",
'restricthtml');
470 $object->bgcolor =
GETPOST(
"bgcolor");
471 $object->bgimage =
GETPOST(
"bgimage");
473 if (!$object->title) {
474 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTitle"));
476 if (!$object->sujet) {
477 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTopic"));
479 if (!$object->body) {
480 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailMessage"));
485 if ($object->create($user) >= 0)
487 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
490 $mesgs[] = $object->error;
498 if ($action ==
'settitle' || $action ==
'setemail_from' || $action ==
'setreplyto' || $action ==
'setemail_errorsto')
500 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
502 if ($action ==
'settitle') $object->title = trim(
GETPOST(
'title',
'alpha'));
503 elseif ($action ==
'setemail_from') $object->email_from = trim(
GETPOST('email_from', 'none'));
504 elseif ($action == 'setemail_replyto') $object->email_replyto = trim(
GETPOST('email_replyto', 'none'));
505 elseif ($action == 'setemail_errorsto') $object->email_errorsto = trim(
GETPOST('email_errorsto', 'none'));
506 elseif ($action == 'settitle' && empty($object->title)) {
507 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTitle"));
508 } elseif ($action ==
'setfrom' && empty($object->email_from)) {
509 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailFrom"));
514 if ($object->update($user) >= 0)
516 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
519 $mesg = $object->error;
529 if (!empty($_POST[
'addfile']))
531 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
533 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
542 if (!empty($_POST[
"removedfile"]))
544 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
546 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
554 if ($action ==
'update' && empty($_POST[
"removedfile"]) && empty($_POST[
"cancel"]))
556 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
564 $object->sujet =
GETPOST(
"sujet");
565 $object->body =
GETPOST(
"bodyemail",
'restricthtml');
566 $object->bgcolor =
GETPOST(
"bgcolor");
567 $object->bgimage =
GETPOST(
"bgimage");
569 if (!$object->sujet) {
570 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTopic"));
572 if (!$object->body) {
573 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailMessage"));
578 if ($object->update($user) >= 0)
580 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
583 $mesgs[] = $object->error;
594 if ($action ==
'confirm_valid' && $confirm ==
'yes')
598 $object->valid($user);
599 setEventMessages($langs->trans(
"MailingSuccessfullyValidated"), null,
'mesgs');
600 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
608 if ($action ==
'confirm_settodraft' && $confirm ==
'yes')
612 $result = $object->setStatut(0);
616 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
627 if ($action ==
'confirm_reset' && $confirm ==
'yes')
633 $result = $object->valid($user);
636 $result = $object->reset_targets_status($user);
642 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
654 if ($action ==
'confirm_delete' && $confirm ==
'yes')
656 if ($object->delete($object->id))
658 $url = (!empty($urlfrom) ? $urlfrom :
'list.php');
659 header(
"Location: ".$url);
664 if (!empty($_POST[
"cancel"]))
675 $form =
new Form($db);
678 $help_url =
'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
679 llxHeader(
'', $langs->trans(
"Mailing"), $help_url,
'', 0, 0,
681 '/includes/ace/src/ace.js',
682 '/includes/ace/src/ext-statusbar.js',
683 '/includes/ace/src/ext-language_tools.js',
687 if ($action ==
'create')
690 print '<form name="new_mailing" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">'.
"\n";
691 print '<input type="hidden" name="token" value="'.newToken().
'">';
692 print '<input type="hidden" name="action" value="add">';
694 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
695 foreach ($object->substitutionarray as $key => $val)
697 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
702 $availablelink = $form->textwithpicto($langs->trans(
"AvailableVariables"), $htmltext, 1,
'help',
'', 0, 2,
'availvar');
711 print '<table class="border centpercent">';
712 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>';
713 print '<tr><td class="fieldrequired">'.$langs->trans(
"MailFrom").
'</td><td><input class="flat minwidth200" name="from" value="'.$conf->global->MAILING_EMAIL_FROM.
'"></td></tr>';
714 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>';
717 $parameters = array();
718 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
719 print $hookmanager->resPrint;
722 print $object->showOptionals($extrafields,
'edit');
728 print '<table class="border centpercent">';
729 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>';
730 print '<tr><td>'.$langs->trans(
"BackgroundColorByDefault").
'</td><td colspan="3">';
731 print $htmlother->selectColor($_POST[
'bgcolor'],
'bgcolor',
'', 0);
736 print '<div style="padding-top: 10px">';
738 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
739 $doleditor =
new DolEditor(
'bodyemail',
GETPOST(
'bodyemail',
'restricthtml'),
'', 600,
'dolibarr_mailings',
'',
true,
true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20,
'90%');
740 $doleditor->Create();
745 print '<div class="center"><input type="submit" class="button" value="'.$langs->trans(
"CreateMailing").
'"></div>';
751 $upload_dir = $conf->mailing->dir_output.
"/".
get_exdir($object->id, 2, 0, 1, $object,
'mailing');
756 if ($action ==
'settodraft')
758 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"SetToDraft"), $langs->trans(
"ConfirmUnvalidateEmailing"),
"confirm_settodraft",
'',
'', 1);
761 if ($action ==
'valid')
763 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"ValidMailing"), $langs->trans(
"ConfirmValidMailing"),
"confirm_valid",
'',
'', 1);
765 elseif ($action ==
'reset')
767 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"ResetMailing"), $langs->trans(
"ConfirmResetMailing", $object->ref),
"confirm_reset",
'',
'', 2);
769 elseif ($action ==
'delete')
771 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?id=".$object->id.(!empty($urlfrom) ?
'&urlfrom='.urlencode($urlfrom) :
''), $langs->trans(
"DeleteAMailing"), $langs->trans(
"ConfirmDeleteMailing"),
"confirm_delete",
'',
'', 1);
775 if ($action !=
'edit' && $action !=
'edithtml')
782 if ($action ==
'sendall')
785 $sendingmode = $conf->global->EMAILING_MAIL_SENDMODE;
786 if (empty($sendingmode)) $sendingmode = $conf->global->MAIN_MAIL_SENDMODE;
787 if (empty($sendingmode)) $sendingmode =
'mail';
792 if (!empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode ==
'mail')
796 $linktoadminemailbefore =
'<a href="'.DOL_URL_ROOT.
'/admin/mails_emailing.php">';
797 $linktoadminemailend =
'</a>';
798 setEventMessages($langs->trans(
"MailSendSetupIs", $listofmethods[$sendingmode]), null,
'warnings');
799 setEventMessages($langs->trans(
"MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv(
"MAIN_MAIL_SENDMODE"), $listofmethods[
'smtps']), null,
'warnings');
800 if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS))
setEventMessages($langs->trans(
"MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), null,
'warnings');
801 $_GET[
"action"] =
'';
802 } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) {
803 if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode ==
'mail')
setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null,
'warnings');
804 if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode !=
'mail')
setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null,
'warnings');
808 setEventMessages(
'<textarea cols="60" rows="'.ROWS_1.
'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.
'</textarea>', null,
'warnings');
809 if ($conf->file->mailing_limit_sendbyweb !=
'-1')
813 $_GET[
"action"] =
'';
815 if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode ==
'mail')
setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null,
'warnings');
816 if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode !=
'mail')
setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null,
'warnings');
819 if (!isset($conf->global->MAILING_LIMIT_SENDBYCLI) || $conf->global->MAILING_LIMIT_SENDBYCLI >= 0)
821 $text .= $langs->trans(
"MailingNeedCommand");
822 $text .=
'<br><textarea cols="60" rows="'.ROWS_2.
'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.
' '.$user->login.
'</textarea>';
825 $text .= $langs->trans(
'ConfirmSendingEmailing').
'<br>';
826 $text .= $langs->trans(
'LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
827 print $form->formconfirm(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
'SendMailing'), $text,
'sendallconfirmed',
'',
'', 1, 330, 600);
831 $linkback =
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
835 if ($object->statut == 2 || $object->statut == 3)
837 $nbtry = $object->countNbOfTargets(
'alreadysent');
838 $nbko = $object->countNbOfTargets(
'alreadysentko');
840 $morehtmlright .=
' ('.$nbtry.
'/'.$object->nbemail;
841 if ($nbko) $morehtmlright .=
' - '.$nbko.
' '.$langs->trans(
"Error");
842 $morehtmlright .=
') ';
845 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref',
'',
'', 0,
'', $morehtmlright);
847 print '<div class="fichecenter">';
848 print '<div class="underbanner clearboth"></div>';
850 print '<table class="border centpercent tableforfield">';
853 print '<tr><td class="titlefield">';
854 print $form->editfieldkey(
"MailTitle",
'title', $object->title, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
856 print $form->editfieldval(
"MailTitle",
'title', $object->title, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
861 print $form->editfieldkey(
"MailFrom",
'email_from', $object->email_from, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
863 print $form->editfieldval(
"MailFrom",
'email_from', $object->email_from, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
866 $langs->load(
"errors");
869 $langs->load(
"errors");
877 print $form->editfieldkey(
"MailErrorsTo",
'email_errorsto', $object->email_errorsto, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
879 print $form->editfieldval(
"MailErrorsTo",
'email_errorsto', $object->email_errorsto, $object, $user->rights->mailing->creer && $object->statut < 3,
'string');
882 $langs->load(
"errors");
885 $langs->load(
"errors");
892 print $langs->trans(
"TotalNbOfDistinctRecipients");
893 print '</td><td colspan="3">';
894 $nbemail = ($object->nbemail ? $object->nbemail : 0);
895 if (is_numeric($nbemail))
898 if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail)))
900 if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0)
902 $text .= $langs->trans(
'LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
904 $text .= $langs->trans(
'SendingFromWebInterfaceIsNotAllowed');
907 if (empty($nbemail)) $nbemail .=
' '.img_warning(
'').
' <font class="warning">'.$langs->trans(
"NoTargetYet").
'</font>';
910 print $form->textwithpicto($nbemail, $text, 1,
'warning');
918 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
928 if ($action ==
'clone')
931 $formquestion = array(
932 'text' => $langs->trans(
"ConfirmClone"),
933 array(
'type' =>
'checkbox',
'name' =>
'clone_content',
'label' => $langs->trans(
"CloneContent"),
'value' => 1),
934 array(
'type' =>
'checkbox',
'name' =>
'clone_receivers',
'label' => $langs->trans(
"CloneReceivers"),
'value' => 0)
937 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEMailing', $object->ref),
'confirm_clone', $formquestion,
'yes', 2, 240);
944 if (
GETPOST(
'cancel',
'alpha') || $confirm ==
'no' || $action ==
'' || in_array($action, array(
'settodraft',
'valid',
'delete',
'sendall',
'clone',
'test')))
946 print "\n\n<div class=\"tabsAction\">\n";
948 if (($object->statut == 1) && ($user->rights->mailing->valider || $object->fk_user_valid == $user->id))
950 print '<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=settodraft&id='.$object->id.
'">'.$langs->trans(
"SetToDraft").
'</a>';
953 if (($object->statut == 0 || $object->statut == 1 || $object->statut == 2) && $user->rights->mailing->creer)
955 if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_MAILING))
957 print '<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&id='.$object->id.
'">'.$langs->trans(
"EditWithEditor").
'</a>';
959 print '<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&id='.$object->id.
'">'.$langs->trans(
"EditWithTextEditor").
'</a>';
962 if (!empty($conf->use_javascript_ajax))
print '<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edithtml&id='.$object->id.
'">'.$langs->trans(
"EditHTMLSource").
'</a>';
967 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send)
969 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"TestMailing").
'</a>';
971 print '<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=test&id='.$object->id.
'">'.$langs->trans(
"TestMailing").
'</a>';
974 if ($object->statut == 0)
976 if ($object->nbemail <= 0)
978 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NoTargetYet")).
'">'.$langs->trans(
"ValidMailing").
'</a>';
979 } elseif (empty($user->rights->mailing->valider))
981 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"ValidMailing").
'</a>';
983 print '<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=valid&id='.$object->id.
'">'.$langs->trans(
"ValidMailing").
'</a>';
987 if (($object->statut == 1 || $object->statut == 2) && $object->nbemail > 0 && $user->rights->mailing->valider)
989 if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0)
991 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"SendingFromWebInterfaceIsNotAllowed")).
'">'.$langs->trans(
"SendMailing").
'</a>';
992 } elseif (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send)
994 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"SendMailing").
'</a>';
996 print '<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=sendall&id='.$object->id.
'">'.$langs->trans(
"SendMailing").
'</a>';
1000 if ($user->rights->mailing->creer)
1002 print '<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=clone&object=emailing&id='.$object->id.
'">'.$langs->trans(
"ToClone").
'</a>';
1005 if (($object->statut == 2 || $object->statut == 3) && $user->rights->mailing->valider)
1007 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send)
1009 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"ResetMailing").
'</a>';
1011 print '<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=reset&id='.$object->id.
'">'.$langs->trans(
"ResetMailing").
'</a>';
1015 if (($object->statut <= 1 && $user->rights->mailing->creer) || $user->rights->mailing->supprimer)
1017 if ($object->statut > 0 && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->delete))
1019 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"DeleteMailing").
'</a>';
1021 print '<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&id='.$object->id.(!empty($urlfrom) ?
'&urlfrom='.$urlfrom :
'').
'">'.$langs->trans(
"DeleteMailing").
'</a>';
1029 if ($action ==
'test')
1031 print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
1037 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1039 $formmail->fromname = $object->email_from;
1040 $formmail->frommail = $object->email_from;
1041 $formmail->withsubstit = 1;
1042 $formmail->withfrom = 0;
1043 $formmail->withto = $user->email ? $user->email : 1;
1044 $formmail->withtocc = 0;
1045 $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
1046 $formmail->withtopic = 0;
1047 $formmail->withtopicreadonly = 1;
1048 $formmail->withfile = 0;
1049 $formmail->withbody = 0;
1050 $formmail->withbodyreadonly = 1;
1051 $formmail->withcancel = 1;
1052 $formmail->withdeliveryreceipt = 0;
1054 $formmail->substit = $object->substitutionarrayfortest;
1056 $formmail->param[
"action"] =
"send";
1057 $formmail->param[
"models"] =
'none';
1058 $formmail->param[
"mailid"] = $object->id;
1059 $formmail->param[
"returnurl"] =
$_SERVER[
'PHP_SELF'].
"?id=".$object->id;
1061 print $formmail->get_form();
1071 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
1072 foreach ($object->substitutionarray as $key => $val)
1074 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
1076 $htmltext .=
'</i>';
1079 print load_fiche_titre($langs->trans(
"EMail"), $form->textwithpicto(
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"AvailableVariables").
'</span>', $htmltext, 1,
'helpclickable',
'', 0, 2,
'emailsubstitionhelp'),
'generic');
1083 print '<table class="bordernooddeven" width="100%">';
1086 print '<tr><td class="titlefield">'.$langs->trans(
"MailTopic").
'</td><td colspan="3">'.$object->sujet.
'</td></tr>';
1089 print '<tr><td>'.$langs->trans(
"MailFile").
'</td><td colspan="3">';
1091 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
1092 if (count($listofpaths))
1094 foreach ($listofpaths as $key => $val)
1096 print img_mime($listofpaths[$key][
'name']).
' '.$listofpaths[$key][
'name'];
1100 print '<span class="opacitymedium">'.$langs->trans(
"NoAttachedFiles").
'</span><br>';
1112 print '<div style="padding-top: 10px; background: '.($object->bgcolor ? (preg_match(
'/^#/', $object->bgcolor) ?
'' :
'#').$object->bgcolor :
'white').
'">';
1113 if (empty($object->bgcolor) || strtolower($object->bgcolor) ==
'ffffff')
1117 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1118 $doleditor =
new DolEditor(
'bodyemail', $object->body,
'', 600,
'dolibarr_mailings',
'',
false,
true, empty($conf->global->FCKEDITOR_ENABLE_MAILING) ? 0 : 1, 20,
'90%', $readonly);
1119 $doleditor->Create();
1131 $linkback =
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1133 $morehtmlright =
'';
1134 if ($object->statut == 2) $morehtmlright .=
' ('.$object->countNbOfTargets(
'alreadysent').
'/'.$object->nbemail.
') ';
1136 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref',
'',
'', 0,
'', $morehtmlright);
1138 print '<div class="fichecenter">';
1139 print '<div class="underbanner clearboth"></div>';
1141 print '<table class="border centpercent">';
1151 print '<tr><td class="titlefield">'.$langs->trans(
"MailTitle").
'</td><td colspan="3">'.$object->title.
'</td></tr>';
1153 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>';
1155 print '<tr><td>'.$langs->trans(
"MailErrorsTo").
'</td><td colspan="3">'.
dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1).
'</td></tr>';
1159 print $langs->trans(
"TotalNbOfDistinctRecipients");
1160 print '</td><td colspan="3">';
1161 $nbemail = ($object->nbemail ? $object->nbemail : 0);
1162 if (is_numeric($nbemail))
1165 if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2))
1167 if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0)
1169 $text .= $langs->trans(
'LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
1171 $text .= $langs->trans(
'SendingFromWebInterfaceIsNotAllowed');
1174 if (empty($nbemail)) $nbemail .=
' '.img_warning(
'').
' <font class="warning">'.$langs->trans(
"NoTargetYet").
'</font>';
1177 print $form->textwithpicto($nbemail, $text, 1,
'warning');
1185 $parameters = array();
1186 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1187 print $hookmanager->resPrint;
1188 if (empty($reshook))
1190 print $object->showOptionals($extrafields,
'edit', $parameters);
1202 print '<form name="edit_mailing" action="card.php" method="post" enctype="multipart/form-data">'.
"\n";
1203 print '<input type="hidden" name="token" value="'.newToken().
'">';
1204 print '<input type="hidden" name="action" value="update">';
1205 print '<input type="hidden" name="id" value="'.$object->id.
'">';
1207 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
1208 foreach ($object->substitutionarray as $key => $val)
1210 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
1212 $htmltext .=
'</i>';
1215 print load_fiche_titre($langs->trans(
"EMail"), $form->textwithpicto($langs->trans(
"AvailableVariables"), $htmltext, 1,
'help',
'', 0, 2,
'emailsubstitionhelp'),
'generic');
1219 print '<table class="bordernooddeven" width="100%">';
1222 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>';
1228 $addfileaction =
'addfile';
1229 print '<tr><td>'.$langs->trans(
"MailFile").
'</td>';
1230 print '<td colspan="3">';
1232 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
1235 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1236 $out .=
'<script type="text/javascript" language="javascript">';
1237 $out .=
'jQuery(document).ready(function () {';
1238 $out .=
' jQuery(".removedfile").click(function() {';
1239 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1242 $out .=
'</script>'.
"\n";
1243 if (count($listofpaths))
1245 foreach ($listofpaths as $key => $val)
1247 $out .=
'<div id="attachfile_'.$key.
'">';
1248 $out .=
img_mime($listofpaths[$key][
'name']).
' '.$listofpaths[$key][
'name'];
1249 $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.
'" />';
1250 $out .=
'<br></div>';
1253 $out .= $langs->trans(
"NoAttachedFiles").
'<br>';
1256 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
1258 $out .=
'<input type="submit" class="button" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
1263 print '<tr><td>'.$langs->trans(
"BackgroundColorByDefault").
'</td><td colspan="3">';
1264 print $htmlother->selectColor($object->bgcolor,
'bgcolor',
'', 0);
1270 print '<div style="padding-top: 10px">';
1272 if ($action ==
'edit')
1275 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1276 $doleditor =
new DolEditor(
'bodyemail', $object->body,
'', 600,
'dolibarr_mailings',
'',
true,
true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20,
'90%');
1277 $doleditor->Create();
1279 if ($action ==
'edithtml')
1282 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1283 $doleditor =
new DolEditor(
'bodyemail', $object->body,
'', 600,
'dolibarr_mailings',
'',
true,
true,
'ace', 20,
'90%');
1284 $doleditor->Create(0,
'',
false,
'HTML Source',
'php');
1292 print '<div class="center">';
1293 print '<input type="submit" class="button buttonforacesave button-save" value="'.$langs->trans(
"Save").
'" name="save">';
1294 print ' ';
1295 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.
dol_hash($chain, $type= '0')
Returns a hash of a string.
dol_now($mode= 'auto')
Return date for now.
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...
img_mime($file, $titlealt= '', $morecss= '')
Show MIME img of a file.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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.
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.
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.
dol_remove_file_process($filenb, $donotupdatesession=0, $donotdeletefile=1, $trackid= '')
Remove an uploaded file (for example after submitting a new file a mail form).
print $_SERVER["PHP_SELF"]
Edit parameters.
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.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
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)
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.
isValidEmail($address, $acceptsupervisorkey=0)
Return true if email syntax is ok.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
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...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...