From abcf506a4b40168069a546debb30866a5e8f3aaf Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Mon, 1 Apr 2013 18:25:11 +0530 Subject: [PATCH] -- fixed for CRM-12233 --- CRM/Contribute/Form/Contribution/Confirm.php | 1 + CRM/Contribute/Form/Contribution/Main.php | 2 +- CRM/Member/BAO/Membership.php | 2 +- CRM/Price/BAO/Field.php | 10 +++++----- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 64d81a7971..2064bc3cba 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -163,6 +163,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } } // if seperate payment we set contribution amount to be null, so that it will not show contribution amount same as membership amount. elseif ((CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock)) + && CRM_Utils_Array::value($priceField->id, $this->_values['fee']) && ($this->_values['fee'][$priceField->id]['name'] == "other_amount") && CRM_Utils_Array::value("price_{$contriPriceId}", $this->_params) < 1 && !CRM_Utils_Array::value("price_{$priceField->id}", $this->_params)) { diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 49267838f3..59bd4a8739 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -1242,7 +1242,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu if ($fieldVal['name'] == 'other_amount') { $proceFieldAmount += $this->_submitValues['price_' . $fieldId]; } - else { + elseif ($fieldVal['name'] == 'contribution_amount' && $this->_submitValues['price_' . $fieldId] > 0) { $proceFieldAmount += $fieldVal['options'][$this->_submitValues['price_' . $fieldId]]['amount']; } unset($params['price_' . $fieldId]); diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index c1ad123c85..d01354651e 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -1245,7 +1245,7 @@ AND civicrm_membership.is_test = %2"; if (is_a($result[1], 'CRM_Core_Error')) { $errors[1] = CRM_Core_Error::getMessages($result[1]); } - else { + elseif (CRM_Utils_Array::value(1, $result)) { // Save the contribution ID so that I can be used in email receipts // For example, if you need to generate a tax receipt for the donation only. $form->_values['contribution_other_id'] = $result[1]->id; diff --git a/CRM/Price/BAO/Field.php b/CRM/Price/BAO/Field.php index 31b1d55744..c2c34a00d5 100644 --- a/CRM/Price/BAO/Field.php +++ b/CRM/Price/BAO/Field.php @@ -377,11 +377,11 @@ class CRM_Price_BAO_Field extends CRM_Price_DAO_Field { $choice[$opId]->freeze(); } } - if (property_exists($qf, '_membershipBlock') && CRM_Utils_Array::value('is_separate_payment', $qf->_membershipBlock) && $field->name == 'contribution_amount') { + if (property_exists($qf, '_membershipBlock') && $field->name == 'contribution_amount') { $choice[] = $qf->createElement('radio', NULL, '', ts('No thank you'), '-1', - array( - 'onclick' => 'clearAmountOther();', - ) + array( + 'onclick' => 'clearAmountOther();', + ) ); } @@ -405,7 +405,7 @@ class CRM_Price_BAO_Field extends CRM_Price_DAO_Field { $element = &$qf->addGroup($choice, $elementName, $label); // make contribution field required for quick config when membership block is enabled - if (($field->name == 'membership_amount' || ($field->name == 'contribution_amount' && CRM_Utils_Array::value('is_separate_payment', $qf->_membershipBlock))) + if (($field->name == 'membership_amount' || $field->name == 'contribution_amount') && property_exists($qf, '_membershipBlock') && !empty($qf->_membershipBlock) && !$field->is_required) { $useRequired = $field->is_required = TRUE; } -- 2.25.1