From bb06e9ed2ac02927b52ce8847537a820a99aae7a Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sun, 10 May 2015 21:44:39 +1200 Subject: [PATCH] CRM-16357 towards passing pledge id from calling function & extracting on the form it thethe form --- CRM/Contribute/Form/Contribution/Confirm.php | 24 +++++++++++++------- CRM/Core/BAO/CustomField.php | 2 +- CRM/Pledge/BAO/Pledge.php | 7 ++---- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 090a6fd6fd..8f548a05b8 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -1295,6 +1295,19 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $contributeMode = $form->_contributeMode; $isMonetary = !empty($form->_values['is_monetary']); $isEmailReceipt = !empty($form->_values['is_email_receipt']); + // How do these vary from params? These are currently passed to + // - custom data function.... + $formParams = $form->_params; + $isSeparateMembershipPayment = empty($formParams['separate_membership_payment']) ? FALSE : TRUE; + $pledgeID = empty($formParams['pledge_id']) ? NULL : $formParams['pledge_id']; + if (!$isSeparateMembershipPayment && !empty($form->_values['pledge_block_id']) && + (!empty($formParams['is_pledge']) || $pledgeID)) { + $isPledge = TRUE; + } + else { + $isPledge = FALSE; + } + // add these values for the recurringContrib function ,CRM-10188 $params['financial_type_id'] = $financialType->id; @@ -1366,7 +1379,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings'); $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); if ($invoicing) { - $totalTaxAmount = 0; $dataArray = array(); foreach ($form->_lineItem as $lineItemKey => $lineItemValue) { foreach ($lineItemValue as $key => $value) { @@ -1400,12 +1412,8 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr CRM_Contribute_Form_Contribution_Confirm::processPcpSoft($params, $contribution); //handle pledge stuff. - if (empty($form->_params['separate_membership_payment']) && !empty($form->_values['pledge_block_id']) && - (!empty($form->_params['is_pledge']) || !empty($form->_values['pledge_id'])) - ) { - - if (!empty($form->_values['pledge_id'])) { - + if ($isPledge) { + if ($pledgeID) { //when user doing pledge payments. //update the schedule when payment(s) are made foreach ($form->_params['pledge_amount'] as $paymentId => $dontCare) { @@ -1427,7 +1435,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } //update pledge status according to the new payment statuses - CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($form->_values['pledge_id']); + CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeID); } else { //when user creating pledge record. diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 5c20bf5b9e..4ff7deed1f 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -1565,7 +1565,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { * Custom field id. * @param array $customFormatted * Formatted array. - * @param mix $value + * @param mixed $value * Value of custom field. * @param string $customFieldExtend * Custom field extends. diff --git a/CRM/Pledge/BAO/Pledge.php b/CRM/Pledge/BAO/Pledge.php index f46f201e14..f7197b0d32 100644 --- a/CRM/Pledge/BAO/Pledge.php +++ b/CRM/Pledge/BAO/Pledge.php @@ -98,8 +98,7 @@ class CRM_Pledge_BAO_Pledge extends CRM_Pledge_DAO_Pledge { // set currency for CRM-1496 if (!isset($pledge->currency)) { - $config = CRM_Core_Config::singleton(); - $pledge->currency = $config->defaultCurrency; + $pledge->currency = CRM_Core_Config::singleton()->defaultCurrency; } $result = $pledge->save(); @@ -621,7 +620,6 @@ GROUP BY currency ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($params['contact_id']); //check for online pledge. - $session = CRM_Core_Session::singleton(); if (!empty($params['receipt_from_email'])) { $userName = CRM_Utils_Array::value('receipt_from_name', $params); $userEmail = CRM_Utils_Array::value('receipt_from_email', $params); @@ -629,7 +627,7 @@ GROUP BY currency elseif (!empty($params['from_email_id'])) { $receiptFrom = $params['from_email_id']; } - elseif ($userID = $session->get('userID')) { + elseif ($userID = CRM_Core_Session::singleton()->get('userID')) { //check for logged in user. list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID); } @@ -663,7 +661,6 @@ GROUP BY currency $activityType, 'name' ); - $config = CRM_Core_Config::singleton(); // FIXME: Translate $details = 'Total Amount ' . CRM_Utils_Money::format($params['total_pledge_amount'], CRM_Utils_Array::value('currency', $params)) . ' To be paid in ' . $params['installments'] . ' installments of ' . CRM_Utils_Money::format($params['scheduled_amount'], CRM_Utils_Array::value('currency', $params)) . ' every ' . $params['frequency_interval'] . ' ' . $params['frequency_unit'] . '(s)'; -- 2.25.1