NEW scheduled job to send unpaid invoice reminder can use the cc and bcc
of template.
This commit is contained in:
parent
506a9de384
commit
055627e248
@ -5550,7 +5550,10 @@ class Facture extends CommonInvoice
|
||||
}
|
||||
|
||||
// Sender
|
||||
$from = $conf->global->MAIN_MAIL_EMAIL_FROM;
|
||||
$from = getDolGlobalString('MAIN_MAIL_EMAIL_FROM');
|
||||
if (!empty($arraymessage->email_from)) { // If a sender is defined into template, we use it in priority
|
||||
$from = $arraymessage->email_from;
|
||||
}
|
||||
if (empty($from)) {
|
||||
$errormesg = "Failed to get sender into global setup MAIN_MAIL_EMAIL_FROM";
|
||||
$error++;
|
||||
@ -5560,6 +5563,9 @@ class Facture extends CommonInvoice
|
||||
$this->db->begin();
|
||||
|
||||
$to = implode(',', $to);
|
||||
if (!empty($arraymessage->email_to)) { // If a recipient is defined into template, we add it
|
||||
$to = $to.','.$arraymessage->email_to;
|
||||
}
|
||||
|
||||
// Errors Recipient
|
||||
$errors_to = $conf->global->MAIN_MAIL_ERRORS_TO;
|
||||
@ -5567,8 +5573,18 @@ class Facture extends CommonInvoice
|
||||
$trackid = 'inv'.$tmpinvoice->id;
|
||||
$sendcontext = 'standard';
|
||||
|
||||
$email_tocc = '';
|
||||
if (!empty($arraymessage->email_tocc)) { // If a CC is defined into template, we use it
|
||||
$email_tocc = $arraymessage->email_tocc;
|
||||
}
|
||||
|
||||
$email_tobcc = '';
|
||||
if (!empty($arraymessage->email_tobcc)) { // If a BCC is defined into template, we use it
|
||||
$email_tobcc = $arraymessage->email_tobcc;
|
||||
}
|
||||
|
||||
// Mail Creation
|
||||
$cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', $trackid, '', $sendcontext, '');
|
||||
$cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), $email_tocc, $email_tobcc, 0, 1, $errors_to, '', $trackid, '', $sendcontext, '');
|
||||
|
||||
// Sending Mail
|
||||
if ($cMailFile->sendfile()) {
|
||||
|
||||
@ -1305,9 +1305,9 @@ class FormMail extends Form
|
||||
$languagetosearchmain = '';
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid, module, label, type_template, topic, joinfiles, content, content_lines, lang";
|
||||
$sql = "SELECT rowid, module, label, type_template, topic, joinfiles, content, content_lines, lang, email_from, email_to, email_tocc, email_tobcc";
|
||||
$sql .= " FROM ".$dbs->prefix().'c_email_templates';
|
||||
$sql .= " WHERE (type_template='".$dbs->escape($type_template)."' OR type_template='all')";
|
||||
$sql .= " WHERE (type_template = '".$dbs->escape($type_template)."' OR type_template = 'all')";
|
||||
$sql .= " AND entity IN (".getEntity('c_email_templates').")";
|
||||
$sql .= " AND (private = 0 OR fk_user = ".((int) $user->id).")"; // Get all public or private owned
|
||||
if ($active >= 0) {
|
||||
@ -1728,6 +1728,11 @@ class ModelMail
|
||||
public $lang;
|
||||
public $joinfiles;
|
||||
|
||||
public $email_from;
|
||||
public $email_to;
|
||||
public $email_tocc;
|
||||
public $email_tobcc;
|
||||
|
||||
/**
|
||||
* @var string Module the template is dedicated for
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user