Skip to content

Commit

Permalink
NFC cleanup to Membership/Renewal form classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire authored and eileenmcnaughton committed Aug 20, 2018
1 parent 77727ea commit 92665ac
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions CRM/Member/Form/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -1106,8 +1106,6 @@ public function submit() {
$formValues = $this->setPriceSetParameters($formValues);
$params = $softParams = $ids = array();

$allMemberStatus = CRM_Member_PseudoConstant::membershipStatus();
$allContributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$this->processBillingAddress();

if ($this->_id) {
Expand Down Expand Up @@ -1178,7 +1176,6 @@ public function submit() {
$params['tax_amount'] = $formValues['tax_amount'];
}
$params['total_amount'] = CRM_Utils_Array::value('amount', $formValues);
$submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $formValues);
if (!empty($lineItem[$this->_priceSetId])) {
foreach ($lineItem[$this->_priceSetId] as &$li) {
if (!empty($li['membership_type_id'])) {
Expand All @@ -1190,6 +1187,7 @@ public function submit() {
///CRM-11529 for quick config backoffice transactions
//when financial_type_id is passed in form, update the
//lineitems with the financial type selected in form
$submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $formValues);
if ($isQuickConfig && $submittedFinancialType) {
$li['financial_type_id'] = $submittedFinancialType;
}
Expand Down Expand Up @@ -1251,9 +1249,9 @@ public function submit() {
}
}

// max related memberships - take from form or inherit from membership type
foreach ($this->_memTypeSelected as $memType) {
if (array_key_exists('max_related', $formValues)) {
// max related memberships - take from form or inherit from membership type
$membershipTypeValues[$memType]['max_related'] = CRM_Utils_Array::value('max_related', $formValues);
}
$membershipTypeValues[$memType]['custom'] = CRM_Core_BAO_CustomField::postProcess($formValues,
Expand All @@ -1278,6 +1276,9 @@ public function submit() {
$softParams['contact_id'] = $this->_contactID;
}
}

$pendingMembershipStatusId = CRM_Core_PseudoConstant::getKey('CRM_Member_BAO_Membership', 'status_id', 'Pending');

if (!empty($formValues['record_contribution'])) {
$recordContribution = array(
'total_amount',
Expand Down Expand Up @@ -1308,10 +1309,11 @@ public function submit() {
}
}

$completedContributionStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
if (empty($params['is_override']) &&
CRM_Utils_Array::value('contribution_status_id', $params) != array_search('Completed', $allContributionStatus)
CRM_Utils_Array::value('contribution_status_id', $params) != $completedContributionStatusId
) {
$params['status_id'] = array_search('Pending', $allMemberStatus);
$params['status_id'] = $pendingMembershipStatusId;
$params['skipStatusCal'] = TRUE;
$params['is_pay_later'] = 1;
$this->assign('is_pay_later', 1);
Expand Down Expand Up @@ -1456,8 +1458,8 @@ public function submit() {
}
}

if ($formValues['payment_status_id'] != array_search('Completed', $allContributionStatus)) {
$params['status_id'] = array_search('Pending', $allMemberStatus);
if ($formValues['payment_status_id'] != $completedContributionStatusId) {
$params['status_id'] = $pendingMembershipStatusId;
$params['skipStatusCal'] = TRUE;
// unset send-receipt option, since receipt will be sent when ipn is received.
unset($formValues['send_receipt'], $formValues['send_receipt']);
Expand All @@ -1475,7 +1477,7 @@ public function submit() {
}
}
$now = date('YmdHis');
$params['receive_date'] = $now;
$params['receive_date'] = date('YmdHis');
$params['invoice_id'] = $formValues['invoiceID'];
$params['contribution_source'] = ts('%1 Membership Signup: Credit card or direct debit (by %2)',
array(1 => $membershipType, 2 => $userName)
Expand Down

0 comments on commit 92665ac

Please sign in to comment.