From c969cef731c9f772f8c86af73d5ce7d71ef1fd84 Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Wed, 27 Apr 2022 10:09:22 +0200 Subject: [PATCH] NEW : Send email to the supplier order contact Select the recipient defined in object contact (Vendor contact following-up order / Contact fournisseur suivi commande) in order to send email to the specific contact and not to generic company email (as for invoice/bill) --- htdocs/core/actions_massactions.inc.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 5ec011f5017..3b45cffd772 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -128,6 +128,14 @@ if (!$error && $massaction == 'confirm_presend') { $listofobjectcontacts[$toselectid][$data_email['id']] = $data_email['email']; } } + } elseif ($objectclass == 'CommandeFournisseur') { + $tmparraycontact = array(); + $tmparraycontact = $objecttmp->liste_contact(-1, 'external', 0, 'CUSTOMER'); + if (is_array($tmparraycontact) && count($tmparraycontact) > 0) { + foreach ($tmparraycontact as $data_email) { + $listofobjectcontacts[$toselectid][$data_email['id']] = $data_email['email']; + } + } } $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid; @@ -277,6 +285,19 @@ if (!$error && $massaction == 'confirm_presend') { if (count($emails_to_sends) > 0) { $sendto = implode(',', $emails_to_sends); } + } elseif ($objectobj->element == 'order_supplier' && !empty($listofobjectcontacts[$objectid])) { + $emails_to_sends = array(); + $objectobj->fetch_thirdparty(); + $contactidtosend = array(); + foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) { + $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid, 'email'); + if (!in_array($contactemailid, $contactidtosend)) { + $contactidtosend[] = $contactemailid; + } + } + if (count($emails_to_sends) > 0) { + $sendto = implode(',', $emails_to_sends); + } } else { $objectobj->fetch_thirdparty(); $sendto = $objectobj->thirdparty->email;