Merge pull request #22496 from FHenry/dev_fix_new_InvoiceRemindersEmailToInvoiceContact
new: on CronJob, sendEmailsRemindersOnInvoiceDueDate use billing contact email if exists
This commit is contained in:
commit
3fb7e1252d
@ -5526,12 +5526,20 @@ class Facture extends CommonInvoice
|
|||||||
$sendContent = make_substitutions($content, $substitutionarray, $outputlangs, 1);
|
$sendContent = make_substitutions($content, $substitutionarray, $outputlangs, 1);
|
||||||
|
|
||||||
// Recipient
|
// Recipient
|
||||||
$to = '';
|
$to = array();
|
||||||
$res = $tmpinvoice->fetch_thirdparty();
|
$res = $tmpinvoice->fetch_thirdparty();
|
||||||
$recipient = $tmpinvoice->thirdparty;
|
$recipient = $tmpinvoice->thirdparty;
|
||||||
if ($res > 0) {
|
if ($res > 0) {
|
||||||
if (!empty($recipient->email)) {
|
$tmparraycontact = $tmpinvoice->liste_contact(-1, 'external', 0, 'BILLING');
|
||||||
$to = $recipient->email;
|
if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
|
||||||
|
foreach ($tmparraycontact as $data_email) {
|
||||||
|
if (!empty($data_email['email'])) {
|
||||||
|
$to[] = $tmpinvoice->thirdparty->contact_get_property($data_email['id'], 'email');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($to) && !empty($recipient->email)) {
|
||||||
|
$to[] = $recipient->email;
|
||||||
} else {
|
} else {
|
||||||
$errormesg = "Failed to send remind to thirdparty id=".$tmpinvoice->socid.". No email defined for user.";
|
$errormesg = "Failed to send remind to thirdparty id=".$tmpinvoice->socid.". No email defined for user.";
|
||||||
$error++;
|
$error++;
|
||||||
@ -5548,9 +5556,11 @@ class Facture extends CommonInvoice
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error && $to) {
|
if (!$error && !empty($to)) {
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
|
$to = implode(',', $to);
|
||||||
|
|
||||||
// Errors Recipient
|
// Errors Recipient
|
||||||
$errors_to = $conf->global->MAIN_MAIL_ERRORS_TO;
|
$errors_to = $conf->global->MAIN_MAIL_ERRORS_TO;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user