CRM-17539 fix "C:/Program Files (x86)/Git/bin/sh.exe" receipts & more fixes on CRM...
authoreileenmcnaugton <eileen@fuzion.co.nz>
Thu, 26 Nov 2015 22:53:19 +0000 (11:53 +1300)
committereileenmcnaugton <eileen@fuzion.co.nz>
Thu, 26 Nov 2015 22:53:19 +0000 (11:53 +1300)
CRM/Contribute/BAO/Contribution.php
CRM/Contribute/BAO/ContributionPage.php
CRM/Contribute/Form/Contribution/Confirm.php

index a7ed28a68e4f889d22f1713a64fd413969c30d62..7c8b246c7b911662e153bc57e1760962bee75941 100644 (file)
@@ -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
index 1656bc485a37b218cac42be9738bf01395f12d51..f7d87eff2a8800af75bc0165e94819b1e1c18e69 100644 (file)
@@ -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)) {
index 9b4b31a9d738073a83a4b8670cbc7f6151b92a41..db1bf2686dbcefda88d8d07c406539ca97330c5c 100644 (file)
@@ -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;
     }