From 763c86144e0de457235f23a7640d16f7bc36ab8c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 May 2022 15:51:24 +0200 Subject: [PATCH] Fix add invoice to email --- htdocs/public/payment/paymentok.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 303b3236472..c9b8f13c877 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -1278,7 +1278,6 @@ if ($ispaymentok) { $msg = $outputlangs->trans("OrganizationEventPaymentOfRegistrationWasReceived"); } - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty); complete_substitutions_array($substitutionarray, $outputlangs, $object); @@ -1291,7 +1290,22 @@ if ($ispaymentok) { $ishtml = dol_textishtml($texttosend); // May contain urls - $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml); + // Attach a file ? + $file = ''; + $listofpaths = array(); + $listofnames = array(); + $listofmimes = array(); + if (is_object($object)) { + $invoicediroutput = $conf->facture->dir_output; + $fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->ref, preg_quote($object->ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; + + $listofpaths = array($file); + $listofnames = array(basename($file)); + $listofmimes = array(dol_mimetype($file)); + } + + $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, '', '', 0, $ishtml); $result = $mailfile->sendfile(); if ($result) {