Skip to content

Commit

Permalink
dev/financial#162 Simplify isPdf code
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
eileenmcnaughton committed Feb 1, 2021
1 parent 6fa44b7 commit 1ed8d77
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 25 deletions.
8 changes: 2 additions & 6 deletions CRM/Contribute/BAO/ContributionPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 2 additions & 14 deletions CRM/Contribute/Form/AdditionalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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'),
]
);

Expand Down
6 changes: 2 additions & 4 deletions CRM/Event/BAO/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Member/Form/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
]
Expand Down

0 comments on commit 1ed8d77

Please sign in to comment.