From 207373d37d844c250e9624ee04d552c208532feb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 May 2022 20:07:21 +0200 Subject: [PATCH] FIX sending email on payment of registration of event --- htdocs/admin/eventorganization.php | 2 +- htdocs/core/class/html.formmail.class.php | 4 ++-- htdocs/public/payment/paymentok.php | 26 +++++++++++++++-------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index 254f7d3c8d4..f5b1fd0a4db 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -220,7 +220,7 @@ if ($action == 'edit') { foreach ($arrayofparameters as $constname => $val) { if ($val['enabled']==1) { $setupnotempty++; - print 'aa'; + print ''; $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); $tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '

'."\n".$langs->trans($constname . 'Tooltip2') : ''); print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).''; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 818c3b19c7b..807c643e7be 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1257,9 +1257,9 @@ class FormMail extends Form * @param string $type_template Get message for model/type=$type_template, type='all' also included. * @param User $user Get template public or limited to this user * @param Translate $outputlangs Output lang object - * @param int $id Id of template to find, or -1 for first found with position 0, or 0 for first found whatever is position (priority order depends on lang provided or not) or -2 for exact match with label (no answer if not found) + * @param int $id Id of template to get, or -1 for first found with position 0, or 0 for first found whatever is position (priority order depends on lang provided or not) or -2 for exact match with label (no answer if not found) * @param int $active 1=Only active template, 0=Only disabled, -1=All - * @param string $label Label of template + * @param string $label Label of template to get * @return ModelMail|integer One instance of ModelMail or -1 if error */ public function getEMailTemplate($dbs, $type_template, $user, $outputlangs, $id = 0, $active = 1, $label = '') diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 0ee6fa10bc7..43ee8889131 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -1271,17 +1271,21 @@ if ($ispaymentok) { // Get email content from template $arraydefaultmessage = null; - $labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT; + $idoftemplatetouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT; // Email to send for Event organization registration - if (!empty($labeltouse)) { - $arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $labeltouse, 1, ''); + if (!empty($idoftemplatetouse)) { + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1, ''); } - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; $msg = $arraydefaultmessage->content; + } else { + $subject = '['.$object->ref.' - '.$outputlangs->trans("NewRegistration").']'; + $msg = $outputlangs->trans("OrganizationEventPaymentOfRegistrationWasReceived"); } + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty); complete_substitutions_array($substitutionarray, $outputlangs, $object); @@ -1300,7 +1304,7 @@ if ($ispaymentok) { if ($result) { dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); } else { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); + dol_syslog("Failed to send EMail to ".$sendto.' - '.$mailfile->error, LOG_ERR, 0, '_payment'); } } } @@ -1456,14 +1460,18 @@ if ($ispaymentok) { // Get email content from template $arraydefaultmessage = null; - $labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT; - if (!empty($labeltouse)) { - $arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $labeltouse, 1, ''); + $idoftemplatetouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH; // Email sent after registration for a Booth + + if (!empty($idoftemplatetouse)) { + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1, ''); } - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; $msg = $arraydefaultmessage->content; + } else { + $subject = '['.$booth->ref.' - '.$outputlangs->trans("NewRegistration").']'; + $msg = $outputlangs->trans("OrganizationEventPaymentOfBoothWasReceived"); } $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty);