From 858f70966e3eab0bc78cb642d9b6cdaf1fdb4d45 Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Fri, 27 Nov 2015 11:53:19 +1300 Subject: [PATCH] CRM-17539 fix "C:/Program Files (x86)/Git/bin/sh.exe" receipts & more fixes on CRM-17519 to facilitate this --- CRM/Contribute/BAO/Contribution.php | 10 +++++----- CRM/Contribute/BAO/ContributionPage.php | 15 +++++++++++++-- CRM/Contribute/Form/Contribution/Confirm.php | 19 ++++++++++++++++--- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index a7ed28a68e..7c8b246c7b 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2386,9 +2386,9 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac foreach ($this->_relatedObjects['membership'] as $membership) { if ($membership->id) { $values['isMembership'] = TRUE; + $values['membership_assign'] = TRUE; // need to set the membership values here - $template->assign('membership_assign', 1); $template->assign('membership_name', CRM_Member_PseudoConstant::membershipType($membership->membership_type_id) ); @@ -2688,11 +2688,11 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac $template->assign('sku', $productDAO->sku); } $template->assign('title', CRM_Utils_Array::value('title', $values)); - $amount = CRM_Utils_Array::value('total_amount', $input, (CRM_Utils_Array::value('amount', $input)), NULL); - if (empty($amount) && isset($this->total_amount)) { - $amount = $this->total_amount; + $values['amount'] = CRM_Utils_Array::value('total_amount', $input, (CRM_Utils_Array::value('amount', $input)), NULL); + if (!$values['amount'] && isset($this->total_amount)) { + $values['amount'] = $this->total_amount; } - $template->assign('amount', $amount); + // add the new contribution values if (strtolower($this->_component) == 'contribute') { //PCP Info diff --git a/CRM/Contribute/BAO/ContributionPage.php b/CRM/Contribute/BAO/ContributionPage.php index 1656bc485a..f7d87eff2a 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -157,8 +157,17 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio // We are trying to fight the good fight against leaky variables (CRM-17519) so let's get really explicit // about ensuring the variables we want for the template are defined. // @todo add to this until all tpl params are explicit in this function and not waltzing around the codebase. - $valuesRequiredForTemplate = array('customPre', 'customPost', 'customPre_grouptitle', 'customPost_grouptitle', - 'useForMember'); + // Next stage is to remove this & ensure there are no e-notices - ie. all are set before they hit this fn. + $valuesRequiredForTemplate = array( + 'customPre', + 'customPost', + 'customPre_grouptitle', + 'customPost_grouptitle', + 'useForMember', + 'membership_assign', + 'amount', + ); + foreach ($valuesRequiredForTemplate as $valueRequiredForTemplate) { if (!isset($values[$valueRequiredForTemplate])) { $values[$valueRequiredForTemplate] = NULL; @@ -369,6 +378,8 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio 'customPost' => $values['customPost'], 'customPost_grouptitle' => $values['customPost_grouptitle'], 'useForMember' => $values['useForMember'], + 'membership_assign' => $values['membership_assign'], + 'amount' => $values['amount'], ); if ($contributionTypeId = CRM_Utils_Array::value('financial_type_id', $values)) { diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 9b4b31a9d7..db1bf2686d 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -1419,8 +1419,9 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $membershipContribution = NULL; $isTest = CRM_Utils_Array::value('is_test', $membershipParams, FALSE); $errors = $createdMemberships = $paymentResults = array(); - + $form->_values['isMembership'] = TRUE; $isRecurForFirstTransaction = CRM_Utils_Array::value('is_recur', $form->_values, CRM_Utils_Array::value('is_recur', $membershipParams)); + $totalAmount = $membershipParams['amount']; if ($isPaidMembership) { if ($isProcessSeparateMembershipTransaction) { @@ -1602,9 +1603,16 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr return; } - //finally send an email receipt + $emailValues = $form->_values; + // Finally send an email receipt for pay-later scenario (although it might sometimes be caught above!) + if ($totalAmount == 0) { + // This feels like a bizarre hack as the variable name doesn't seem to be directly connected to it's use in the template. + $emailValues['useForMember'] = 0; + $emailValues['membership_assign'] = 1; + $emailValues['amount'] = 0; + } CRM_Contribute_BAO_ContributionPage::sendMail($contactID, - $form->_values, + $emailValues, $isTest, FALSE, $includeFieldTypes ); @@ -1914,6 +1922,11 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr */ protected function processFormSubmission($contactID) { $isPayLater = $this->_params['is_pay_later']; + if (!isset($this->_params['payment_processor_id'])) { + // If there is no processor we are using the pay-later manual pseudo-processor. + // (note it might make sense to make this a row in the processor table in the db). + $this->_params['payment_processor_id'] = 0; + } if (isset($this->_params['payment_processor_id']) && $this->_params['payment_processor_id'] == 0) { $this->_params['is_pay_later'] = $isPayLater = TRUE; } -- 2.25.1