From 664ba283bc3b7a6fafc8114aa073bbb00e0de104 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 6 Oct 2022 09:49:17 +0200 Subject: [PATCH] fix/feat: on CronJob sendEmailsRemindersOnInvoiceDueDate use billing contact email if exists --- htdocs/compta/facture/class/facture.class.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 67d5568e438..b781cc15961 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5530,7 +5530,16 @@ class Facture extends CommonInvoice $res = $tmpinvoice->fetch_thirdparty(); $recipient = $tmpinvoice->thirdparty; if ($res > 0) { - if (!empty($recipient->email)) { + $tmparraycontact = $tmpinvoice->liste_contact(-1, 'external', 0, 'BILLING'); + if (is_array($tmparraycontact) && count($tmparraycontact) > 0) { + foreach ($tmparraycontact as $data_email) { + if (!empty($data_email['email'])) { + $to = $data_email['email']; + break; + } + } + } + if (empty($to) && !empty($recipient->email)) { $to = $recipient->email; } else { $errormesg = "Failed to send remind to thirdparty id=".$tmpinvoice->socid.". No email defined for user.";