From 1ed8d7785101c3ca1ea2626bbeacedf41e5b6459 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 1 Feb 2021 18:41:59 +1300 Subject: [PATCH] dev/financial#162 Simplify isPdf code This makes the same simplification as https://github.com/civicrm/civicrm-core/pull/19165/files in another part of the code. The correct setting name has the invoice_ prefix (although I think our handling code was making the other work) --- CRM/Contribute/BAO/ContributionPage.php | 8 ++------ CRM/Contribute/Form/AdditionalInfo.php | 16 ++-------------- CRM/Event/BAO/Event.php | 6 ++---- CRM/Member/Form/Membership.php | 2 +- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/CRM/Contribute/BAO/ContributionPage.php b/CRM/Contribute/BAO/ContributionPage.php index 6b1854f0f3b9..346ca886ab16 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -436,15 +436,11 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes $sendTemplateParams['cc'] = $values['cc_receipt'] ?? NULL; $sendTemplateParams['bcc'] = $values['bcc_receipt'] ?? NULL; //send email with pdf invoice - $template = CRM_Core_Smarty::singleton(); - $taxAmt = $template->get_template_vars('dataArray'); - $isEmailPDF = Civi::settings()->get('invoice_is_email_pdf'); - $invoicing = Civi::settings()->get('invoicing'); - if ($invoicing && !empty($isEmailPDF)) { + if (Civi::settings()->get('invoicing') && Civi::settings()->get('invoice_is_email_pdf')) { $sendTemplateParams['isEmailPdf'] = TRUE; $sendTemplateParams['contributionId'] = $values['contribution_id']; } - list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); + list($sent, $subject, $message) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); } // send duplicate alert, if dupe match found during on-behalf-of processing. diff --git a/CRM/Contribute/Form/AdditionalInfo.php b/CRM/Contribute/Form/AdditionalInfo.php index f66501a2d375..117764dc3a1e 100644 --- a/CRM/Contribute/Form/AdditionalInfo.php +++ b/CRM/Contribute/Form/AdditionalInfo.php @@ -421,19 +421,7 @@ public static function emailReceipt(&$form, &$params, $ccContribution = FALSE) { $form->assign('receive_date', CRM_Utils_Date::processDate($params['receive_date'])); } - $template = CRM_Core_Smarty::singleton(); - $taxAmt = $template->get_template_vars('dataArray'); - $eventTaxAmt = $template->get_template_vars('totalTaxAmount'); - $prefixValue = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = $prefixValue['invoicing'] ?? NULL; - if ((!empty($taxAmt) || isset($eventTaxAmt)) && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) { - $isEmailPdf = TRUE; - } - else { - $isEmailPdf = FALSE; - } - - list($sendReceipt, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate( + [$sendReceipt] = CRM_Core_BAO_MessageTemplate::sendTemplate( [ 'groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'contribution_offline_receipt', @@ -444,7 +432,7 @@ public static function emailReceipt(&$form, &$params, $ccContribution = FALSE) { 'toEmail' => $contributorEmail, 'isTest' => $form->_mode == 'test', 'PDFFilename' => ts('receipt') . '.pdf', - 'isEmailPdf' => $isEmailPdf, + 'isEmailPdf' => Civi::settings()->get('invoicing') && Civi::settings()->get('invoice_is_email_pdf'), ] ); diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 750d2d372b22..015b2e96609c 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -1231,10 +1231,8 @@ public static function sendMail($contactID, $values, $participantId, $isTest = F $sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc_confirm', $values['event'] ); - // append invoice pdf to email - $prefixValue = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = $prefixValue['invoicing'] ?? NULL; - if (isset($invoicing) && isset($prefixValue['is_email_pdf']) && !empty($values['contributionId'])) { + + if (Civi::settings()->get('invoicing') && Civi::settings()->get('invoice_is_email_pdf') && !empty($values['contributionId'])) { $sendTemplateParams['isEmailPdf'] = TRUE; $sendTemplateParams['contributionId'] = $values['contributionId']; } diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index 9a18e3db5c27..e92a1810902e 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -986,7 +986,7 @@ public static function emailReceipt($form, &$formValues, $membership) { 'toName' => $form->_contributorDisplayName, 'toEmail' => $form->_contributorEmail, 'PDFFilename' => ts('receipt') . '.pdf', - 'isEmailPdf' => Civi::settings()->get('invoicing') && Civi::settings()->get('is_email_pdf'), + 'isEmailPdf' => Civi::settings()->get('invoicing') && Civi::settings()->get('invoice_is_email_pdf'), 'contributionId' => $formValues['contribution_id'], 'isTest' => (bool) ($form->_action & CRM_Core_Action::PREVIEW), ]