30if (!defined(
'NOSTYLECHECK')) {
31 define(
'NOSTYLECHECK',
'1');
35require
'../../main.inc.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/emailing.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/comm/mailing/class/mailing.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
54 require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
55 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
59$langs->loadLangs(array(
"mails",
"admin"));
63$action =
GETPOST(
'action',
'aZ09');
64$confirm =
GETPOST(
'confirm',
'alpha');
65$cancel =
GETPOST(
'cancel',
'alpha');
68$backtopage =
GETPOST(
'backtopage');
69$backtopageforcancel =
GETPOST(
'backtopageforcancel');
73$hookmanager->initHooks(array(
'mailingcard',
'globalcard'));
76$extrafields->fetch_name_optionals_label(
$object->table_element);
79include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
97$signature = ((!empty($user->signature) && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $user->signature :
'');
101$parameters = array(
'mode' =>
'emailing');
104$object->substitutionarrayfortest = $substitutionarray;
107$listofmethods = array();
109$listofmethods[
'mail'] =
'PHP mail function';
111$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
112if (version_compare(phpversion(),
'7.0',
'>=')) {
113 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
117if (!$user->hasRight(
'mailing',
'lire') || (!
getDolGlobalString(
'EXTERNAL_USERS_ARE_AUTHORIZED') && $user->socid > 0)) {
120if (empty($action) && empty(
$object->id)) {
127$permissiontocreate = $user->hasRight(
'mailing',
'creer');
128$permissiontovalidatesend = $user->hasRight(
'mailing',
'valider');
129$permissiontodelete = $user->hasRight(
'mailing',
'supprimer');
136$parameters = array();
137$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
139 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
142if (empty($reshook)) {
145 $backurlforlist = DOL_URL_ROOT.
'/comm/mailing/list.php';
147 if (empty($backtopage) || ($cancel && empty($id))) {
148 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
149 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
150 $backtopage = $backurlforlist;
152 $backtopage = DOL_URL_ROOT.
'/comm/mailing/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
159 if (!empty($backtopageforcancel)) {
160 header(
"Location: ".$backtopageforcancel);
162 } elseif (!empty($backtopage)) {
163 header(
"Location: ".$backtopage);
170 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontocreate) {
171 if (!
GETPOST(
"clone_content",
'alpha') && !
GETPOST(
"clone_receivers",
'alpha')) {
172 setEventMessages($langs->trans(
"NoCloneOptionsSpecified"),
null,
'errors');
176 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
186 if ($action ==
'sendallconfirmed' && $confirm ==
'yes' && $permissiontovalidatesend) {
189 setEventMessages($langs->trans(
"MailingNeedCommand"),
null,
'warnings');
190 setEventMessages(
'<textarea cols="70" rows="'.ROWS_2.
'" wrap="soft">php ./scripts/emailings/mailing-send.php '.
$object->id.
'</textarea>',
null,
'warnings');
191 setEventMessages($langs->trans(
"MailingNeedCommand2"),
null,
'warnings');
194 setEventMessages($langs->trans(
"NotEnoughPermissions"),
null,
'warnings');
198 dol_print_error(
null,
'ErrorMailIsNotValidated');
205 $email_from =
$object->email_from;
206 $replyto =
$object->email_replyto;
207 $errorsto =
$object->email_errorsto;
210 if (preg_match(
'/[\s\t]*<html>/i', $message)) {
222 $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";
223 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
224 $sql .=
" WHERE mc.statut < 1 AND mc.fk_mailing = ".((int)
$object->id);
225 $sql .=
" ORDER BY mc.statut DESC";
227 dol_syslog(
"card.php: select targets", LOG_DEBUG);
228 $resql = $db->query($sql);
230 $num = $db->num_rows($resql);
233 dol_syslog(
"comm/mailing/card.php: nb of targets = ".$num, LOG_DEBUG);
238 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing SET date_envoi='".$db->idate($now).
"' WHERE rowid=".((int)
$object->id);
239 $resql2 = $db->query($sql);
241 dol_print_error($db);
244 $thirdpartystatic =
new Societe($db);
248 while ($iforemailloop < $num && $iforemailloop < $conf->global->MAILING_LIMIT_SENDBYWEB) {
253 $obj = $db->fetch_object($resql);
256 $sendto = str_replace(
',',
' ',
dolGetFirstLastname($obj->firstname, $obj->lastname)).
" <".$obj->email.
">";
259 $other = explode(
';', $obj->other);
260 $tmpfield = explode(
'=', $other[0], 2);
261 $other1 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
262 $tmpfield = explode(
'=', $other[1], 2);
263 $other2 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
264 $tmpfield = explode(
'=', $other[2], 2);
265 $other3 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
266 $tmpfield = explode(
'=', $other[3], 2);
267 $other4 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
268 $tmpfield = explode(
'=', $other[4], 2);
269 $other5 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]);
271 $signature = ((!empty($user->signature) && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $user->signature :
'');
273 $parameters = array(
'mode' =>
'emailing');
274 $substitutionarray = getCommonSubstitutionArray($langs, 0, array(
'object',
'objectamount'), $targetobject);
277 $substitutionarray[
'__ID__'] = $obj->source_id;
278 $substitutionarray[
'__EMAIL__'] = $obj->email;
279 $substitutionarray[
'__LASTNAME__'] = $obj->lastname;
280 $substitutionarray[
'__FIRSTNAME__'] = $obj->firstname;
281 $substitutionarray[
'__MAILTOEMAIL__'] =
'<a href="mailto:'.$obj->email.
'">'.$obj->email.
'</a>';
282 $substitutionarray[
'__OTHER1__'] = $other1;
283 $substitutionarray[
'__OTHER2__'] = $other2;
284 $substitutionarray[
'__OTHER3__'] = $other3;
285 $substitutionarray[
'__OTHER4__'] = $other4;
286 $substitutionarray[
'__OTHER5__'] = $other5;
288 if ($obj->source_type ==
"thirdparty") {
289 $result = $thirdpartystatic->fetch($obj->source_id);
291 $substitutionarray[
'__THIRDPARTY_CUSTOMER_CODE__'] = $thirdpartystatic->code_client;
293 $substitutionarray[
'__THIRDPARTY_CUSTOMER_CODE__'] =
'';
297 $substitutionarray[
'__USER_SIGNATURE__'] = $signature;
298 $substitutionarray[
'__SENDEREMAIL_SIGNATURE__'] = $signature;
299 $substitutionarray[
'__CHECK_READ__'] =
'<img src="'.DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-read.php?tag='.urlencode($obj->tag).
'&securitykey='.
dol_hash(
getDolGlobalString(
'MAILING_EMAIL_UNSUBSCRIBE_KEY').
'-'.$obj->tag.
'-'.$obj->email.
'-'.$obj->rowid,
"md5").
'&email='.urlencode($obj->email).
'&mtid='.((int) $obj->rowid).
'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
300 $substitutionarray[
'__UNSUBSCRIBE__'] =
'<a href="'.DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-unsubscribe.php?tag='.urlencode($obj->tag).
'&unsuscrib=1&securitykey='.
dol_hash(
getDolGlobalString(
'MAILING_EMAIL_UNSUBSCRIBE_KEY').
'-'.$obj->tag.
'-'.$obj->email.
'-'.$obj->rowid,
"md5").
'&email='.urlencode($obj->email).
'&mtid='.((int) $obj->rowid).
'" target="_blank" rel="noopener noreferrer">'.$langs->trans(
"MailUnsubcribe").
'</a>';
301 $substitutionarray[
'__UNSUBSCRIBE_URL__'] = DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-unsubscribe.php?tag='.urlencode($obj->tag).
'&unsuscrib=1&securitykey='.
dol_hash(
getDolGlobalString(
'MAILING_EMAIL_UNSUBSCRIBE_KEY').
'-'.$obj->tag.
'-'.$obj->email.
'-'.$obj->rowid,
"md5").
'&email='.urlencode($obj->email).
'&mtid='.((int) $obj->rowid);
303 $onlinepaymentenabled = 0;
305 $onlinepaymentenabled++;
308 $onlinepaymentenabled++;
311 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
312 $substitutionarray[
'__ONLINEPAYMENTLINK_MEMBER__'] = getHtmlOnlinePaymentLink(
'member', $obj->source_id);
313 $substitutionarray[
'__ONLINEPAYMENTLINK_DONATION__'] = getHtmlOnlinePaymentLink(
'donation', $obj->source_id);
314 $substitutionarray[
'__ONLINEPAYMENTLINK_ORDER__'] = getHtmlOnlinePaymentLink(
'order', $obj->source_id);
315 $substitutionarray[
'__ONLINEPAYMENTLINK_INVOICE__'] = getHtmlOnlinePaymentLink(
'invoice', $obj->source_id);
316 $substitutionarray[
'__ONLINEPAYMENTLINK_CONTRACTLINE__'] = getHtmlOnlinePaymentLink(
'contractline', $obj->source_id);
319 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
dol_hash(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN') .
'member'.$obj->source_id,
'2');
320 $substitutionarray[
'__SECUREKEYPAYMENT_DONATION__'] =
dol_hash(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN') .
'donation'.$obj->source_id,
'2');
321 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
dol_hash(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN') .
'order'.$obj->source_id,
'2');
322 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
dol_hash(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN') .
'invoice'.$obj->source_id,
'2');
323 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
dol_hash(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN') .
'contractline'.$obj->source_id,
'2');
326 $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>';
335 $substitutionarray[
'__SECUREKEYPAYPAL_MEMBER__'] =
dol_hash(
getDolGlobalString(
'PAYPAL_SECURITY_TOKEN') .
'membersubscription'.$obj->source_id,
'2');
341 $substitutionarray[
'__SECUREKEYPAYPAL_ORDER__'] =
dol_hash(
getDolGlobalString(
'PAYPAL_SECURITY_TOKEN') .
'order'.$obj->source_id,
'2');
347 $substitutionarray[
'__SECUREKEYPAYPAL_INVOICE__'] =
dol_hash(
getDolGlobalString(
'PAYPAL_SECURITY_TOKEN') .
'invoice'.$obj->source_id,
'2');
353 $substitutionarray[
'__SECUREKEYPAYPAL_CONTRACTLINE__'] =
dol_hash(
getDolGlobalString(
'PAYPAL_SECURITY_TOKEN') .
'contractline'.$obj->source_id,
'2');
363 if (preg_match(
'/__UNSUBSCRIBE_(_|URL_)/', $message)) {
364 $moreinheader =
"List-Unsubscribe: <__UNSUBSCRIBE_URL__>\n";
373 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
374 if (count($listofpaths)) {
375 foreach ($listofpaths as $key => $val) {
376 $arr_file[] = $listofpaths[$key][
'fullname'];
378 $arr_name[] = $listofpaths[$key][
'name'];
383 $trackid =
'emailing-'.$obj->fk_mailing.
'-'.$obj->rowid;
384 $upload_dir_tmp = $upload_dir;
385 $mail =
new CMailFile($newsubject, $sendto, $email_from, $newmessage, $arr_file, $arr_mime, $arr_name,
'',
'', 0, $msgishtml, $errorsto, $arr_css, $trackid, $moreinheader,
'emailing', $replyto, $upload_dir_tmp);
398 $res = $mail->sendfile();
405 dol_syslog(
"comm/mailing/card.php: ok for #".$iforemailloop.($mail->error ?
' - '.$mail->error :
''), LOG_DEBUG);
407 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing_cibles";
408 $sql .=
" SET statut=1, date_envoi = '".$db->idate($now).
"' WHERE rowid=".((int) $obj->rowid);
409 $resql2 = $db->query($sql);
411 dol_print_error($db);
414 if (strpos($message,
'__CHECK_READ__') !==
false) {
416 $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).
")";
417 dol_syslog(
"card.php: set prospect thirdparty status", LOG_DEBUG);
418 $resql2 = $db->query($sql);
420 dol_print_error($db);
424 $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)";
425 dol_syslog(
"card.php: set prospect contact status", LOG_DEBUG);
427 $resql2 = $db->query($sql);
429 dol_print_error($db);
435 dol_syslog(
"Wait a delay of MAILING_DELAY=".((
float)
$conf->global->MAILING_DELAY));
436 usleep((
int) ((
float)
$conf->global->MAILING_DELAY * 1000000));
444 dol_syslog(
"comm/mailing/card.php: error for #".$iforemailloop.($mail->error ?
' - '.$mail->error :
''), LOG_WARNING);
446 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing_cibles";
447 $sql .=
" SET statut=-1, error_text='".$db->escape(
dol_trunc($mail->error, 250)).
"', date_envoi='".$db->idate($now).
"' WHERE rowid=".((int) $obj->rowid);
448 $resql2 = $db->query($sql);
450 dol_print_error($db);
457 setEventMessages($langs->transnoentitiesnoconv(
"NoMoreRecipientToSendTo"),
null,
'mesgs');
463 setEventMessages($langs->transnoentitiesnoconv(
"EMailSentToNRecipients", (
string) $nbok),
null,
'mesgs');
470 setEventMessages($langs->transnoentitiesnoconv(
"EMailSentToNRecipients", (
string) $nbok),
null,
'mesgs');
473 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing SET statut=".((int) $statut).
" WHERE rowid = ".((int)
$object->id);
474 dol_syslog(
"comm/mailing/card.php: update global status", LOG_DEBUG);
475 $resql2 = $db->query($sql);
477 dol_print_error($db);
481 dol_print_error($db);
489 if ($action ==
'send' && ! $cancel && $permissiontovalidatesend) {
496 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTo")),
null,
'errors');
503 if (preg_match(
'/[\s\t]*<html>/i',
$object->body)) {
507 $signature = ((!empty($user->signature) && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $user->signature :
'');
509 $parameters = array(
'mode' =>
'emailing');
510 $substitutionarray = getCommonSubstitutionArray($langs, 0, array(
'object',
'objectamount'), $targetobject);
513 $substitutionarray[
'__EMAIL__'] =
$object->sendto;
514 $substitutionarray[
'__MAILTOEMAIL__'] =
'<a href="mailto:'.$object->sendto.
'">'.
$object->sendto.
'</a>';
515 $substitutionarray[
'__CHECK_READ__'] =
'<img src="'.DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-read.php?tag=undefinedintestmode&securitykey='.
dol_hash(
getDolGlobalString(
'MAILING_EMAIL_UNSUBSCRIBE_KEY').
"-undefinedintestmode-".
$object->sendto.
"-0",
'md5').
'&email='.urlencode(
$object->sendto).
'&mtid=0" width="1" height="1" style="width:1px;height:1px" border="0"/>';
516 $substitutionarray[
'__UNSUBSCRIBE__'] =
'<a href="'.DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-unsubscribe.php?tag=undefinedintestmode&unsuscrib=1&securitykey='.
dol_hash(
getDolGlobalString(
'MAILING_EMAIL_UNSUBSCRIBE_KEY').
"-undefinedintestmode-".
$object->sendto.
"-0",
'md5').
'&email='.urlencode(
$object->sendto).
'&mtid=0" target="_blank" rel="noopener noreferrer">'.$langs->trans(
"MailUnsubcribe").
'</a>';
517 $substitutionarray[
'__UNSUBSCRIBE_URL__'] = DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-unsubscribe.php?tag=undefinedintestmode&unsuscrib=1&securitykey='.
dol_hash(
getDolGlobalString(
'MAILING_EMAIL_UNSUBSCRIBE_KEY').
"-undefinedintestmode-".
$object->sendto.
"-0",
'md5').
'&email='.urlencode(
$object->sendto).
'&mtid=0';
531 if (!empty(
$object->bgcolor)) {
532 $arr_css[
'bgcolor'] = (preg_match(
'/^#/',
$object->bgcolor) ?
'' :
'#').
$object->bgcolor;
534 if (!empty(
$object->bgimage)) {
535 $arr_css[
'bgimage'] =
$object->bgimage;
539 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
540 if (count($listofpaths)) {
541 foreach ($listofpaths as $key => $val) {
542 $arr_file[] = $listofpaths[$key][
'fullname'];
544 $arr_name[] = $listofpaths[$key][
'name'];
548 $trackid =
'emailing-test';
549 $upload_dir_tmp = $upload_dir;
550 $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',
$object->email_replyto, $upload_dir_tmp);
552 $result = $mailfile->sendfile();
554 setEventMessages($langs->trans(
"MailSuccessfulySent", $mailfile->getValidAddress(
$object->email_from, 2), $mailfile->getValidAddress(
$object->sendto, 2)),
null,
'mesgs');
557 setEventMessages($langs->trans(
"ResultKo").
'<br>'.$mailfile->error.
' '.json_encode($result),
null,
'errors');
565 if ($action ==
'add' && $permissiontocreate) {
567 if (
$object->messtype ==
'sms') {
568 $object->email_from = (string)
GETPOST(
"from_phone",
'alphawithlgt');
572 $object->email_replyto = (string)
GETPOST(
"replyto",
'alphawithlgt');
573 $object->email_errorsto = (string)
GETPOST(
"errorsto",
'alphawithlgt');
577 $object->bgcolor = preg_replace(
'/^#/',
'', (
string)
GETPOST(
"bgcolor"));
582 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTitle"));
585 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTopic"));
588 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailMessage"));
591 if (!count($mesgs)) {
592 if (
$object->create($user) >= 0) {
593 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
597 $mesgs = array_merge($mesgs,
$object->errors);
600 setEventMessages(
'', $mesgs,
'errors');
604 if ($action ==
'classin' && $permissiontocreate) {
607 dol_syslog(
'Mailing card, action classin, setProject', LOG_DEBUG);
609 $result =
$object->update($user);
611 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
615 setEventMessages($mesg, $mesgs,
'errors');
617 setEventMessages(
null, $mesgs,
'errors');
624 if (($action ==
'settitle' || $action ==
'setemail_from' || $action ==
'setemail_replyto' || $action ==
'setreplyto' || $action ==
'setemail_errorsto' || $action ==
'setevenunsubscribe') && $permissiontovalidatesend) {
627 if ($action ==
'settitle') {
630 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTitle"));
632 } elseif ($action ==
'setemail_from') {
633 $object->email_from = trim(
GETPOST(
'email_from',
'alphawithlgt'));
634 if (empty(
$object->email_from)) {
635 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailFrom"));
637 } elseif ($action ==
'setemail_replyto') {
638 $object->email_replyto = trim(
GETPOST(
'email_replyto',
'alphawithlgt'));
639 } elseif ($action ==
'setemail_errorsto') {
640 $object->email_errorsto = trim(
GETPOST(
'email_errorsto',
'alphawithlgt'));
641 } elseif ($action ==
'setevenunsubscribe') {
646 $result =
$object->update($user);
648 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
653 setEventMessages($mesg, $mesgs,
'errors');
660 if (
GETPOST(
'addfile') && $permissiontocreate) {
663 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
672 if (
GETPOSTINT(
"removedfile") && $permissiontocreate) {
675 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
683 if ($action ==
'update' && !
GETPOSTINT(
"removedfile") && !$cancel && $permissiontocreate) {
684 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
694 $object->bgcolor = preg_replace(
'/^#/',
'', (
string)
GETPOST(
"bgcolor"));
698 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailTopic"));
701 $mesgs[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"MailMessage"));
704 if (!count($mesgs)) {
705 if (
$object->update($user) >= 0) {
706 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
710 $mesgs = array_merge($mesgs,
$object->errors);
713 setEventMessages(
'', $mesgs,
'errors');
721 if ($action ==
'confirm_valid' && $confirm ==
'yes' && $permissiontovalidatesend) {
724 setEventMessages($langs->trans(
"MailingSuccessfullyValidated"),
null,
'mesgs');
725 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
728 dol_print_error($db);
733 if ($action ==
'confirm_settodraft' && $confirm ==
'yes' && $permissiontocreate) {
735 $result =
$object->setStatut(0);
738 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
744 dol_print_error($db);
749 if ($action ==
'confirm_reset' && $confirm ==
'yes' && $permissiontocreate) {
753 $result =
$object->valid($user);
755 $result =
$object->reset_targets_status($user);
760 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
767 dol_print_error($db);
772 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
774 if (
$object->delete($user) > 0) {
775 $url = (!empty($urlfrom) ? $urlfrom :
'list.php');
776 header(
"Location: ".$url);
793$form =
new Form($db);
804$help_url =
'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
807 $langs->trans(
"Mailing"),
813 '/includes/ace/src/ace.js',
814 '/includes/ace/src/ext-statusbar.js',
815 '/includes/ace/src/ext-language_tools.js',
822if ($action ==
'create') {
824 print
'<form name="new_mailing" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">'.
"\n";
825 print
'<input type="hidden" name="token" value="'.newToken().
'">';
826 print
'<input type="hidden" name="action" value="add">';
828 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br><br><span class="small">';
829 foreach (
$object->substitutionarray as $key => $val) {
830 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
832 $htmltext .=
'</span></i>';
834 $availablelink =
'<span class="opacitymedium hideonsmartphone small">'.$form->textwithpicto($langs->trans(
"AvailableVariables"), $htmltext, 1,
'helpclickable',
'', 0, 2,
'availvar').
'</span>';
837 print
load_fiche_titre($langs->trans(
"NewMailing"), $availablelink,
'object_email');
841 print
'<table class="border centpercent">';
847 print
'<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans(
"MailTitle").
'</td><td><input class="flat minwidth300" id="title" name="title" value="'.dolPrintHTMLForAttribute($title).
'" autofocus="autofocus" spellcheck="false"></td></tr>';
852 if (
GETPOST(
'origin',
'alpha') ==
'project') {
857 if ($projectid > 0) {
858 $object->setProject($projectid);
860 $langs->load(
"projects");
861 print
'<tr class="field_projectid">';
862 print
'<td class="titlefieldcreate">' . $langs->trans(
"Project") .
'</td><td class="valuefieldcreate">';
863 print img_picto(
'',
'project',
'class="pictofixedwidth"') . $formproject->select_projects(-1, (
string) $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx');
864 print
' <a href="' . DOL_URL_ROOT .
'/projet/card.php?action=create&status=1&backtopage=' . urlencode($_SERVER[
"PHP_SELF"] .
'?action=create') .
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs->trans(
"AddProject") .
'"></span></a>';
870 $arrayoftypes = array(
"email" =>
"Email",
"sms" =>
"SMS");
871 print
'<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans(
"Type").
'</td><td>';
872 print $form->selectarray(
'messtype', $arrayoftypes, (
GETPOSTISSET(
'messtype') ?
GETPOST(
'messtype') :
'email'), 0, 0);
875 $( document ).ready(function() {
876 jQuery("#messtype").on("change", function() {
877 console.log("We change the message ttpe");
878 if (jQuery("#messtype").val() == "email") {
879 jQuery(".fieldsforsms").hide();
880 jQuery(".fieldsforemail").show();
882 if (jQuery("#messtype").val() == "sms") {
883 jQuery(".fieldsforsms").show();
884 jQuery(".fieldsforemail").hide();
887 jQuery("#messtype").change();
897 print
'<table class="border centpercent">';
899 print
'<tr class="fieldsforemail"><td class="fieldrequired titlefieldcreate">'.$langs->trans(
"MailFrom").
'</td>';
900 print
'<td>'.img_picto(
'',
'email',
'class="pictofixedwidth"').
'<input class="flat minwidth200" name="from" value="'.(
GETPOSTISSET(
'from') ?
GETPOST(
'from') :
getDolGlobalString(
'MAILING_EMAIL_FROM')).
'" spellcheck="false"></td></tr>';
902 print
'<tr class="fieldsforsms hidden"><td class="fieldrequired titlefieldcreate">'.$langs->trans(
"PhoneFrom").
'</td>';
903 print
'<td>'.img_picto(
'',
'email',
'class="pictofixedwidth"').
'<input class="flat minwidth200" name="fromphone" value="'.(
GETPOSTISSET(
'fromphone') ?
GETPOST(
'fromphone') :
getDolGlobalString(
'MAILING_SMS_FROM')).
'" placeholder="+123..."></td></tr>';
905 print
'<tr class="fieldsforemail"><td>'.$langs->trans(
"MailErrorsTo").
'</td>';
906 print
'<td>'.img_picto(
'',
'email',
'class="pictofixedwidth"').
'<input class="flat minwidth200" name="errorsto" value="'.
getDolGlobalString(
'MAILING_EMAIL_ERRORSTO',
getDolGlobalString(
'MAIN_MAIL_ERRORS_TO')).
'"></td></tr>';
908 print
'<tr class="fieldsforemail"><td>'.$langs->trans(
"MailReply").
'</td>';
909 print
'<td>'.img_picto(
'',
'email',
'class="pictofixedwidth"').
'<input class="flat minwidth200" name="replyto" value="'.
getDolGlobalString(
'MAILING_EMAIL_REPLYTO',
getDolGlobalString(
'MAIN_MAIL_REPLY_TO')).
'"></td></tr>';
912 $parameters = array();
913 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
914 print $hookmanager->resPrint;
915 if (empty($reshook)) {
916 print
$object->showOptionals($extrafields,
'create');
923 print
'<table class="border centpercent">';
926 if (empty($subject)) {
927 $subject =
'['.$mysoc->name.
'] '.$langs->trans(
"Information");
930 print
'<tr class="fieldsforemail"><td class="fieldrequired titlefieldcreate">'.$langs->trans(
"MailTopic").
'</td>';
931 print
'<td><input id="subject" class="flat minwidth200 quatrevingtpercent" name="subject" id="subject" value="'.dolPrintHTMLForAttributeUrl($subject).
'" spellcheck="false"></td></tr>';
941 $formmail->withfckeditor = 1;
942 $formmail->withlayout =
'emailing';
943 $formmail->withaiprompt =
'html';
945 print
'<tr class="fieldsforemail"><td></td><td class="tdtop"></td></tr>';
947 print
'<tr class="fieldsforemail"><td class="tdtop" colspan="2">';
950 $showlinktolayout = ($formmail->withfckeditor ? $formmail->withlayout :
'');
951 $showlinktolayoutlabel = $langs->trans(
"FillMessageWithALayout");
952 $showlinktoai = ($formmail->withaiprompt &&
isModEnabled(
'ai')) ?
'textgenerationemail' :
'';
953 $showlinktoailabel = $langs->trans(
"FillMessageWithAIContent");
954 $formatforouput =
'html';
955 $htmlname =
'bodyemail';
958 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
966 print
'<div style="padding-top: 10px">';
968 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
969 $doleditor =
new DolEditor(
'bodyemail',
GETPOST(
'bodyemail',
'restricthtmlallowunvalid'),
'', 600,
'dolibarr_mailings',
'',
true, $acceptlocallinktomedia,
getDolGlobalInt(
'FCKEDITOR_ENABLE_MAILING'), 20,
'100%');
970 $doleditor->Create();
975 print $form->buttonsSaveCancel(
"Create",
'Cancel');
984 if ($action ==
'settodraft') {
986 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"SetToDraft"), $langs->trans(
"ConfirmUnvalidateEmailing"),
"confirm_settodraft",
'',
'', 1);
987 } elseif ($action ==
'valid') {
989 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"ValidMailing"), $langs->trans(
"ConfirmValidMailing"),
"confirm_valid",
'',
'', 1);
990 } elseif ($action ==
'reset') {
992 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"ResetMailing"), $langs->trans(
"ConfirmResetMailing",
$object->ref),
"confirm_reset",
'',
'', 2);
993 } elseif ($action ==
'delete') {
995 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id.(!empty($urlfrom) ?
'&urlfrom='.urlencode($urlfrom) :
''), $langs->trans(
"DeleteMailing"), $langs->trans(
"ConfirmDeleteMailing"),
"confirm_delete",
'',
'', 1);
998 if ($action !=
'edit' && $action !=
'edittxt' && $action !=
'edithtml') {
1002 if ($action ==
'sendall') {
1005 if (empty($sendingmode)) {
1008 if (empty($sendingmode)) {
1009 $sendingmode =
'mail';
1019 $linktoadminemailbefore =
'<a href="'.DOL_URL_ROOT.
'/admin/mails_emailing.php">';
1020 $linktoadminemailend =
'</a>';
1021 setEventMessages($langs->trans(
"MailSendSetupIs", $listofmethods[$sendingmode]),
null,
'warnings');
1022 $messagetoshow = $langs->trans(
"MailSendSetupIs2",
'{s1}',
'{s2}',
'{s3}',
'{s4}');
1023 $messagetoshow = str_replace(
'{s1}', $linktoadminemailbefore, $messagetoshow);
1024 $messagetoshow = str_replace(
'{s2}', $linktoadminemailend, $messagetoshow);
1025 $messagetoshow = str_replace(
'{s3}', $langs->transnoentitiesnoconv(
"MAIN_MAIL_SENDMODE"), $messagetoshow);
1026 $messagetoshow = str_replace(
'{s4}', $listofmethods[
'smtps'], $messagetoshow);
1027 setEventMessages($messagetoshow,
null,
'warnings');
1030 setEventMessages($langs->trans(
"MailSendSetupIs3",
getDolGlobalString(
'MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS')),
null,
'warnings');
1035 setEventMessages($langs->transnoentitiesnoconv(
$conf->global->MAILING_LIMIT_WARNING_PHPMAIL),
null,
'warnings');
1037 if (
getDolGlobalString(
'MAILING_LIMIT_WARNING_NOPHPMAIL') && $sendingmode !=
'mail') {
1038 setEventMessages($langs->transnoentitiesnoconv(
$conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL),
null,
'warnings');
1042 setEventMessages($langs->trans(
"MailingNeedCommand"),
null,
'warnings');
1043 setEventMessages(
'<textarea cols="60" rows="'.ROWS_1.
'" wrap="soft">php ./scripts/emailings/mailing-send.php '.
$object->id.
'</textarea>',
null,
'warnings');
1044 if (
$conf->file->mailing_limit_sendbyweb !=
'-1') {
1045 setEventMessages($langs->trans(
"MailingNeedCommand2"),
null,
'warnings');
1050 setEventMessages($langs->transnoentitiesnoconv(
$conf->global->MAILING_LIMIT_WARNING_PHPMAIL),
null,
'warnings');
1052 if (
getDolGlobalString(
'MAILING_LIMIT_WARNING_NOPHPMAIL') && $sendingmode !=
'mail') {
1053 setEventMessages($langs->transnoentitiesnoconv(
$conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL),
null,
'warnings');
1059 $text .= $langs->trans(
'WarningLimitSendByDay',
getDolGlobalInt(
'MAILING_LIMIT_SENDBYDAY'));
1060 $text .=
'<br><br>';
1062 $text .= $langs->trans(
'ConfirmSendingEmailing').
'<br>';
1063 $text .= $langs->trans(
'LimitSendingEmailing',
getDolGlobalString(
'MAILING_LIMIT_SENDBYWEB'));
1065 if (!isset(
$conf->global->MAILING_LIMIT_SENDBYCLI) ||
getDolGlobalInt(
'MAILING_LIMIT_SENDBYCLI') >= 0) {
1066 $text .=
'<br><br>';
1067 $text .=
'<u>'.$langs->trans(
"AdvancedAlternative").
':</u> '.$langs->trans(
"MailingNeedCommand");
1068 $text .=
'<br><textarea class="quatrevingtpercent" rows="'.ROWS_2.
'" wrap="soft" disabled>php ./scripts/emailings/mailing-send.php '.
$object->id.
' '.$user->login.
'</textarea>';
1071 $labelbuttonyes = $langs->transnoentities(
'Confirm');
1072 $labelbuttonno = $langs->transnoentities(
'Cancel');
1074 print $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'SendMailing'), $text,
'sendallconfirmed',
'',
'', 1, 380, 660, 0, $labelbuttonyes, $labelbuttonno);
1078 $linkback =
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1080 $morehtmlref =
'<div class="refidno">';
1082 $morehtmlref .= $form->editfieldkey(
"",
'title',
$object->title, $object, $user->hasRight(
'mailing',
'creer'),
'string',
'', 0, 1);
1083 $morehtmlref .= $form->editfieldval(
"",
'title',
$object->title, $object, $user->hasRight(
'mailing',
'creer'),
'string',
'',
null,
null,
'', 1);
1085 $morehtmlstatus =
'';
1087 if (
$object->status == $object::STATUS_SENTPARTIALY ||
$object->status == $object::STATUS_SENTCOMPLETELY) {
1088 $nbtry =
$object->countNbOfTargets(
'alreadysent');
1089 $nbko =
$object->countNbOfTargets(
'alreadysentko');
1091 $morehtmlstatus .=
' ('.$nbtry.
'/'.
$object->nbemail;
1093 $morehtmlstatus .=
' - '.$nbko.
' '.$langs->trans(
"Error");
1095 $morehtmlstatus .=
') ';
1099 $langs->load(
"projects");
1100 $morehtmlref .=
'<br>';
1101 if ($permissiontocreate) {
1102 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
1103 if ($action !=
'classify') {
1104 $morehtmlref .=
'<a class="editfielda" href="' . $_SERVER[
'PHP_SELF'] .
'?action=classify&token=' .
newToken() .
'&id=' .
$object->id .
'">' . img_edit($langs->transnoentitiesnoconv(
'SetProject')) .
'</a> ';
1106 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, -1, (
string)
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300',
'');
1108 if (!empty(
$object->fk_project)) {
1110 $proj->fetch(
$object->fk_project);
1111 $morehtmlref .= $proj->getNomUrl(1,
'mailing');
1113 $morehtmlref .=
'<span class="opacitymedium"> - ' .
dol_escape_htmltag($proj->title) .
'</span>';
1119 $proj->fetch(
$object->fk_project);
1120 $morehtmlref .=
' <small>(<a href="' . DOL_URL_ROOT .
'/comm/mailing/list.php?projectid='.$object->fk_project.
'">'.$langs->trans(
"OtherEMailingsForProject").
'</a>)</small>';
1123 $morehtmlref .=
'</div>';
1125 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'', $morehtmlstatus);
1127 print
'<div class="fichecenter">';
1128 print
'<div class="fichehalfleft">';
1129 print
'<div class="underbanner clearboth"></div>';
1131 print
'<table class="border centpercent tableforfield">'.
"\n";
1134 print
'<tr><td class="titlefield">';
1135 print $form->editfieldkey(
"MailFrom",
'email_from',
$object->email_from, $object, (
int) ($user->hasRight(
'mailing',
'creer') &&
$object->status < $object::STATUS_SENTCOMPLETELY),
'string');
1137 print $form->editfieldval(
"MailFrom",
'email_from',
$object->email_from, $object, $user->hasRight(
'mailing',
'creer') &&
$object->status < $object::STATUS_SENTCOMPLETELY,
'string');
1138 if ($action !=
'editemail_from') {
1141 $langs->load(
"errors");
1142 print img_warning($langs->transnoentitiesnoconv(
"ErrorBadEMail", $email));
1144 $langs->load(
"errors");
1145 print img_warning($langs->transnoentitiesnoconv(
"ErrorBadMXDomain", $email));
1151 if (
$object->messtype !=
'sms') {
1153 print $form->editfieldkey(
"MailErrorsTo",
'email_errorsto',
$object->email_errorsto, $object, (
int) ($user->hasRight(
'mailing',
'creer') &&
$object->status < $object::STATUS_SENTCOMPLETELY),
'string');
1155 print $form->editfieldval(
"MailErrorsTo",
'email_errorsto',
$object->email_errorsto, $object, $user->hasRight(
'mailing',
'creer') &&
$object->status < $object::STATUS_SENTCOMPLETELY,
'string');
1158 foreach ($emailarray as $email => $name) {
1159 if ($name != $email) {
1160 if ($action !=
'editemail_errorsto') {
1162 $langs->load(
"errors");
1163 print img_warning($langs->transnoentitiesnoconv(
"ErrorBadEMail", $email));
1165 $langs->load(
"errors");
1166 print img_warning($langs->transnoentitiesnoconv(
"ErrorBadMXDomain", $email));
1170 if (
$object->email_errorsto) {
1179 if (
$object->messtype !=
'sms') {
1181 print $form->editfieldkey(
"MailReply",
'email_replyto',
$object->email_replyto, $object, (
int) ($user->hasRight(
'mailing',
'creer') &&
$object->status < $object::STATUS_SENTCOMPLETELY),
'string');
1183 print $form->editfieldval(
"MailReply",
'email_replyto',
$object->email_replyto, $object, $user->hasRight(
'mailing',
'creer') &&
$object->status < $object::STATUS_SENTCOMPLETELY,
'string');
1185 if ($action !=
'editemail_replyto') {
1187 $langs->load(
"errors");
1188 print img_warning($langs->trans(
"ErrorBadEMail", $email));
1190 $langs->load(
"errors");
1191 print img_warning($langs->trans(
"ErrorBadMXDomain", $email));
1200 print
'<div class="fichehalfright">';
1201 print
'<div class="underbanner clearboth"></div>';
1203 print
'<table class="border centpercent tableforfield">';
1207 print $langs->trans(
"TotalNbOfDistinctRecipients");
1210 if (is_numeric($nbemail)) {
1214 $htmltooltip .= $langs->trans(
'LimitSendingEmailing',
getDolGlobalString(
'MAILING_LIMIT_SENDBYWEB'));
1216 $htmltooltip .= $langs->trans(
'SendingFromWebInterfaceIsNotAllowed');
1219 if (empty($nbemail)) {
1220 $nbemail .=
' '.img_warning(
'').
' <span class="warning">'.$langs->trans(
"NoTargetYet").
'</span>';
1223 print $form->textwithpicto($nbemail, $htmltooltip, 1,
'info');
1231 print $langs->trans(
"MAIN_MAIL_SENDMODE");
1233 if (
$object->messtype !=
'sms') {
1239 $text = $listofmethods[
'mail'];
1244 print
' <span class="opacitymedium">('.getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER_EMAILING',
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER')).
')</span>';
1247 print
' <span class="opacitymedium">('.getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER').
')</span>';
1251 print
' <span class="opacitymedium">('.getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER').
')</span>';
1256 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1262 print
'<div class="clearboth"></div>';
1268 if ($action ==
'clone') {
1270 $formquestion = array(
1271 'text' => $langs->trans(
"ConfirmClone"),
1272 0 => array(
'type' =>
'checkbox',
'name' =>
'clone_content',
'label' => $langs->trans(
"CloneContent"),
'value' => 1),
1273 1 => array(
'type' =>
'checkbox',
'name' =>
'clone_receivers',
'label' => $langs->trans(
"CloneReceivers"),
'value' => 0)
1276 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEMailing',
$object->ref),
'confirm_clone', $formquestion,
'yes', 2, 0);
1280 if (
GETPOST(
'cancel',
'alpha') || $confirm ==
'no' || $action ==
'' || in_array($action, array(
'settodraft',
'valid',
'delete',
'sendall',
'clone',
'test',
'editevenunsubscribe'))) {
1281 print
"\n\n<div class=\"tabsAction\">\n";
1283 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1286 if ((
$object->status == 1) && ($user->hasRight(
'mailing',
'valider') ||
$object->user_validation_id == $user->id)) {
1287 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=settodraft&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"SetToDraft").
'</a>';
1290 if ((
$object->status == 0 ||
$object->status == 1 ||
$object->status == 2) && $user->hasRight(
'mailing',
'creer')) {
1292 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Edit").
'</a>';
1294 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edittxt&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"EditWithTextEditor").
'</a>';
1298 if (!empty(
$conf->use_javascript_ajax)) {
1299 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edithtml&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"EditHTMLSource").
'</a>';
1306 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'mailing',
'mailing_advance',
'send')) {
1307 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"TestMailing").
'</a>';
1309 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=test&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"TestMailing").
'</a>';
1314 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NoTargetYet")).
'">'.$langs->trans(
"Validate").
'</a>';
1315 } elseif (!$user->hasRight(
'mailing',
'valider')) {
1316 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"Validate").
'</a>';
1318 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=valid&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Validate").
'</a>';
1322 if ((
$object->status == 1 ||
$object->status == 2) &&
$object->nbemail > 0 && $user->hasRight(
'mailing',
'valider')) {
1324 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"SendingFromWebInterfaceIsNotAllowed")).
'">'.$langs->trans(
"SendMailing").
'</a>';
1325 } elseif (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'mailing',
'mailing_advance',
'send')) {
1326 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"SendMailing").
'</a>';
1328 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=sendall&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"SendMailing").
'</a>';
1332 if ($user->hasRight(
'mailing',
'creer')) {
1333 print dolGetButtonAction($langs->trans(
"ToClone"), $langs->trans(
"ToClone"),
'clone', $_SERVER[
'PHP_SELF'].
'?action=clone&token='.
newToken().
'&object=emailing&id='.
$object->id,
'',
true, array(
'attr' => array(
'class' =>
'reposition')));
1336 if ((
$object->status == 2 ||
$object->status == 3) && $user->hasRight(
'mailing',
'valider')) {
1337 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'mailing',
'mailing_advance',
'send')) {
1338 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"ResetMailing").
'</a>';
1340 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=reset&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"ResetMailing").
'</a>';
1344 if ((
$object->status <= 1 && $user->hasRight(
'mailing',
'creer')) || $user->hasRight(
'mailing',
'supprimer')) {
1345 if (
$object->status > 0 && (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'mailing',
'mailing_advance',
'delete'))) {
1346 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"Delete").
'</a>';
1348 print dolGetButtonAction($langs->trans(
"Delete"), $langs->trans(
"Delete"),
'delete', $_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&id='.
$object->id.(!empty($urlfrom) ?
'&urlfrom='.$urlfrom :
''),
'', true, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
1356 if ($action ==
'test') {
1357 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
1363 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1365 $formmail->fromname =
$object->email_from;
1366 $formmail->frommail =
$object->email_from;
1367 $formmail->withsubstit = 0;
1368 $formmail->withfrom = 0;
1369 $formmail->withto = $user->email ? $user->email : 1;
1370 $formmail->withtocc = 0;
1372 $formmail->withtopic = 0;
1373 $formmail->withtopicreadonly = 1;
1374 $formmail->withfile = 0;
1375 $formmail->withlayout =
'';
1376 $formmail->withaiprompt =
'';
1377 $formmail->withbody = 0;
1378 $formmail->withbodyreadonly = 1;
1379 $formmail->withcancel = 1;
1380 $formmail->withdeliveryreceipt = 0;
1382 $formmail->substit =
$object->substitutionarrayfortest;
1384 $formmail->param[
"action"] =
"send";
1385 $formmail->param[
"models"] =
'none';
1386 $formmail->param[
"mailid"] =
$object->id;
1387 $formmail->param[
"returnurl"] = $_SERVER[
'PHP_SELF'].
"?id=".
$object->id;
1389 print $formmail->get_form();
1399 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br><br><span class="small">';
1400 foreach (
$object->substitutionarray as $key => $val) {
1401 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
1403 $htmltext .=
'</span></i>';
1405 $availablelink =
'<span class="opacitymedium hideonsmartphone">'.$form->textwithpicto($langs->trans(
"AvailableVariables"), $htmltext, 1,
'helpclickable',
'', 0, 3,
'emailsubstitionhelp').
'</span>';
1412 print
'<table class="bordernooddeven tableforfield centpercent">';
1415 if (
$object->messtype !=
'sms') {
1416 print
'<tr><td class="titlefield">'.$langs->trans(
"MailTopic").
'</td><td colspan="3">'.
$object->sujet.
'</td></tr>';
1420 if (
$object->messtype !=
'sms') {
1421 print
'<tr><td>'.$langs->trans(
"MailFile").
'</td><td colspan="3">';
1423 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
1424 if (count($listofpaths)) {
1425 foreach ($listofpaths as $key => $val) {
1426 print
img_mime($listofpaths[$key][
'name']).
' '.$listofpaths[$key][
'name'];
1430 print
'<span class="opacitymedium">'.$langs->trans(
"NoAttachedFiles").
'</span><br>';
1445 print
'<div class="previewemail" style="padding-top: 10px; background: '.($object->bgcolor ? (preg_match(
'/^#/',
$object->bgcolor) ?
'' :
'#').
$object->bgcolor :
'white').
'">';
1446 if (empty(
$object->bgcolor) || strtolower(
$object->bgcolor) ==
'ffffff') {
1449 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1450 $doleditor =
new DolEditor(
'bodyemail',
$object->body,
'', 600,
'dolibarr_mailings',
'',
false, $acceptlocallinktomedia,
getDolGlobalInt(
'FCKEDITOR_ENABLE_MAILING'), 20,
'100%', $readonly);
1451 $doleditor->Create();
1465 $linkback =
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1467 $morehtmlref =
'<div class="refidno">';
1469 $morehtmlref .= $form->editfieldkey(
"",
'title',
$object->title, $object, $user->hasRight(
'mailing',
'creer'),
'string',
'', 0, 1);
1470 $morehtmlref .= $form->editfieldval(
"",
'title',
$object->title, $object, $user->hasRight(
'mailing',
'creer'),
'string',
'',
null,
null,
'', 1);
1472 $morehtmlstatus =
'';
1475 $nbtry =
$object->countNbOfTargets(
'alreadysent');
1476 $nbko =
$object->countNbOfTargets(
'alreadysentko');
1478 $morehtmlstatus .=
' ('.$nbtry.
'/'.
$object->nbemail;
1480 $morehtmlstatus .=
' - '.$nbko.
' '.$langs->trans(
"Error");
1482 $morehtmlstatus .=
') ';
1487 $langs->load(
"projects");
1488 $morehtmlref .=
'<br>';
1489 if ($permissiontocreate) {
1490 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
1491 $morehtmlref .=
'<a class="editfielda" href="' . $_SERVER[
'PHP_SELF'] .
'?action=classify&token=' .
newToken() .
'&id=' .
$object->id .
'">' . img_edit($langs->transnoentitiesnoconv(
'SetProject')) .
'</a> ';
1492 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, -1, (
string)
$object->fk_project,
'none', 0, 0, 0, 1,
'',
'maxwidth300',
'');
1494 if (!empty(
$object->fk_project)) {
1496 $proj->fetch(
$object->fk_project);
1497 $morehtmlref .= $proj->getNomUrl(1,
'mailing');
1499 $morehtmlref .=
'<span class="opacitymedium"> - ' .
dol_escape_htmltag($proj->title) .
'</span>';
1505 $proj->fetch(
$object->fk_project);
1506 $morehtmlref .=
'<!-- Edit mode, so we open url in new window -->';
1507 $morehtmlref .=
' <small>(<a href="' . DOL_URL_ROOT .
'/comm/mailing/list.php?projectid='.$object->fk_project.
'" target="_blank">' .$langs->trans(
"Other").
' '.$langs->trans(
"EMailings").
' for '.$langs->trans(
"Project").
': '. $proj->title.
'</a>)</small>';
1510 $morehtmlref .=
'</div>';
1512 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'', $morehtmlstatus);
1514 print
'<div class="fichecenter">';
1515 print
'<div class="fichehalfleft">';
1516 print
'<div class="underbanner clearboth"></div>';
1518 print
'<table class="border centpercent tableforfield">';
1528 print
'<tr><td class="titlefield">';
1529 print $langs->trans(
"MailFrom");
1530 print
'</td><td>'.dol_print_email(
$object->email_from, 0, 0, 0, 0, 1).
'</td></tr>';
1532 if (
$object->messtype !=
'sms') {
1533 print
'<tr><td>'.$langs->trans(
"MailErrorsTo").
'</td><td>'.
dol_print_email(
$object->email_errorsto, 0, 0, 0, 0, 1).
'</td></tr>';
1534 print
'<tr><td>'.$langs->trans(
"MailReply").
'</td><td>'.
dol_print_email(
$object->email_replyto, 0, 0, 0, 0, 1).
'</td></tr>';
1541 print
'<div class="fichehalfright">';
1542 print
'<div class="underbanner clearboth"></div>';
1544 print
'<table class="border centpercent tableforfield">';
1548 print $langs->trans(
"TotalNbOfDistinctRecipients");
1551 if (is_numeric($nbemail)) {
1556 $htmltooltip .= $langs->trans(
'LimitSendingEmailing',
getDolGlobalString(
'MAILING_LIMIT_SENDBYWEB'));
1558 $htmltooltip .= $langs->trans(
'SendingFromWebInterfaceIsNotAllowed');
1561 if (empty($nbemail)) {
1562 $nbemail .=
' '.img_warning(
'').
' <span class="warning">'.$langs->trans(
"NoTargetYet").
'</span>';
1565 print $form->textwithpicto($nbemail, $htmltooltip, 1,
'warning');
1573 print $langs->trans(
"MAIN_MAIL_SENDMODE");
1575 if (
$object->messtype !=
'sms') {
1581 $text = $listofmethods[
'mail'];
1586 print
' <span class="opacitymedium">('.getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER_EMAILING',
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER')).
')</span>';
1589 print
' <span class="opacitymedium">('.getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER').
')</span>';
1593 print
' <span class="opacitymedium">('.getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER').
')</span>';
1599 $parameters = array();
1600 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1601 print $hookmanager->resPrint;
1602 if (empty($reshook)) {
1603 print
$object->showOptionals($extrafields,
'edit', $parameters);
1610 print
'<div class="clearboth"></div>';
1617 print
'<form name="edit_mailing" action="card.php" method="post" enctype="multipart/form-data">'.
"\n";
1618 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1619 print
'<input type="hidden" name="action" value="update">';
1620 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1621 print
'<input type="hidden" name="page_y" value="">';
1623 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br><br><span class="small">';
1624 foreach (
$object->substitutionarray as $key => $val) {
1625 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
1627 $htmltext .=
'</span></i>';
1629 $availablelink =
'<span class="opacitymedium small">'.$form->textwithpicto($langs->trans(
"AvailableVariables"), $htmltext, 1,
'helpclickable',
'', 0, 2,
'emailsubstitionhelp').
'</span>';
1636 print
'<table class="bordernooddeven centpercent">';
1639 if (
$object->messtype !=
'sms') {
1640 print
'<tr><td class="fieldrequired titlefield">';
1641 print $form->textwithpicto($langs->trans(
"MailTopic"), $htmltext, 1,
'help',
'', 0, 2,
'emailsubstitionhelp');
1642 print
'</td><td colspan="3"><input class="flat quatrevingtpercent" type="text" id="subject" name="subject" value="'.$object->sujet.
'" spellcheck="false"></td></tr>';
1649 if (
$object->messtype !=
'sms') {
1650 $addfileaction =
'addfile';
1651 print
'<tr><td>'.$langs->trans(
"MailFile").
'</td>';
1652 print
'<td colspan="3">';
1654 $listofpaths =
dol_dir_list($upload_dir,
'all', 0,
'',
'',
'name', SORT_ASC, 0);
1658 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1659 $out .=
'<script type="text/javascript">';
1660 $out .=
'jQuery(document).ready(function () {';
1661 $out .=
' jQuery(".removedfile").click(function() {';
1662 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1665 $out .=
'</script>'.
"\n";
1666 if (count($listofpaths)) {
1667 foreach ($listofpaths as $key => $val) {
1668 $out .=
'<div id="attachfile_'.$key.
'">';
1669 $out .=
img_mime($listofpaths[$key][
'name']).
' '.$listofpaths[$key][
'name'];
1670 $out .=
' <input type="image" style="border: 0px;" src="'.img_picto($langs->trans(
"Search"),
'delete',
'', 0, 1).
'" value="'.($key + 1).
'" class="removedfile" id="removedfile_'.$key.
'" name="removedfile_'.$key.
'" />';
1671 $out .=
'<br></div>';
1679 $maxmin = $maxfilesizearray[
'maxmin'];
1681 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
1683 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
1685 $out .=
'<input type="submit" class="button smallpaddingimp" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
1690 print
'<tr><td>'.$langs->trans(
"BackgroundColorByDefault").
'</td><td colspan="3">';
1691 print $htmlother->selectColor(
$object->bgcolor,
'bgcolor',
'', 0);
1699 $out .=
'<td class="tdtop">';
1700 $out .= $form->textwithpicto($langs->trans(
'MailText'), $htmltext, 1,
'help',
'', 0, 2,
'substittooltipfrombody');
1702 $out .=
'<td class="tdtop">';
1705 $showlinktolayout =
getDolGlobalInt(
'MAIN_EMAIL_USE_LAYOUT') ?
'emailing' :
'';
1706 $showlinktolayoutlabel = $langs->trans(
"FillMessageWithALayout");
1707 $showlinktoai =
isModEnabled(
'ai') ?
'textgenerationemail' :
'';
1708 $showlinktoailabel = $langs->trans(
"AIEnhancements");
1709 $formatforouput =
'';
1710 $htmlname =
'bodyemail';
1715 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
1726 print
'<div style="padding-top: 10px">';
1728 if ($action ==
'edit') {
1730 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1732 if (!preg_match(
'/^<div style="background-color: #'.
$object->bgcolor.
'">/',
$object->body)) {
1733 $object->body =
'<div style="background-color: #'.$object->bgcolor.
'; margin-bottom:-20px; margin-left:-10px; margin-right:-10px; margin-top:-10px; padding: 10px;">'.
$object->body.
'</div>';
1736 $doleditor =
new DolEditor(
'bodyemail',
$object->body,
'', 600,
'dolibarr_mailings',
'',
true, $acceptlocallinktomedia,
getDolGlobalInt(
'FCKEDITOR_ENABLE_MAILING'), 20,
'100%');
1737 $doleditor->Create();
1739 if ($action ==
'edittxt') {
1741 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1742 $doleditor =
new DolEditor(
'bodyemail',
$object->body,
'', 600,
'dolibarr_mailings',
'',
true, $acceptlocallinktomedia, 0, 20,
'100%');
1743 $doleditor->Create();
1745 if ($action ==
'edithtml') {
1747 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1748 $doleditor =
new DolEditor(
'bodyemail',
$object->body,
'', 600,
'dolibarr_mailings',
'',
true, $acceptlocallinktomedia,
'ace', 20,
'100%');
1749 $doleditor->Create(0,
'',
false,
'HTML Source',
'php');
1756 print
'<div class="center">';
1757 print
'<input type="submit" class="button buttonforacesave button-save" value="'.$langs->trans(
"Save").
'" name="save">';
1758 print
' ';
1759 print
'<input type="submit" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'" name="cancel">';
1766 dol_print_error($db,
$object->error);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to 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.
static getArrayAddress($address)
Return a formatted array of address string for SMTP protocol.
Class to manage a WYSIWYG editor.
Class to manage emailings module.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
emailing_prepare_head(Mailing $object)
Prepare array with list of tabs.
dol_add_file_process($upload_dir, $allowoverwrite=0, $updatesessionordb=0, $keyforsourcefile='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1, $object=null, $forceFullTextIndexation='', $mode=0)
Get and save an upload file (for example after submitting a new file in a mail form).
dol_init_file_process($pathtoscan='', $trackid='')
Scan a directory and init $_SESSION to manage uploaded files with list of all found files.
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_dir_list($utf8_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.
acceptLocalLinktoMedia()
Check the syntax of some PHP code.
isValidMailDomain($mail)
Return true if email has a domain name that can be resolved to MX type.
dol_now($mode='gmt')
Return date for now.
dol_print_email($email, $contactid=0, $socid=0, $addlink=0, $max=0, $showinvalid=2, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
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...
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
getMaxFileSizeArray()
Return the max allowed for file upload.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.