From 94c8aed1b5a1601ced51177522aed8e27f940697 Mon Sep 17 00:00:00 2001 From: Edsel Date: Mon, 24 Jul 2017 18:54:52 +0530 Subject: [PATCH] CRM-20952 Refresh membership tab if contribution is membership payment ---------------------------------------- * CRM-20952: Refresh membership tab on edits to membership payments https://issues.civicrm.org/jira/browse/CRM-20952 --- CRM/Contribute/Form/AdditionalPayment.php | 6 ++++++ CRM/Contribute/Form/Contribution.php | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/CRM/Contribute/Form/AdditionalPayment.php b/CRM/Contribute/Form/AdditionalPayment.php index 900815e99d..15c4bb30d9 100644 --- a/CRM/Contribute/Form/AdditionalPayment.php +++ b/CRM/Contribute/Form/AdditionalPayment.php @@ -379,6 +379,12 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract $params = array('id' => $this->_contributionId); $contribution = CRM_Contribute_BAO_Contribution::retrieve($params, $defaults, $params); CRM_Contribute_BAO_Contribution::addPayments(array($contribution), $contributionStatusId); + if ($this->_contributionId && CRM_Core_Permission::access('CiviMember')) { + $membershipPayments = civicrm_api3('MembershipPayment', 'Get', array('contribution_id' => $this->_contributionId)); + if ($membershipPayments['count'] > 1) { + $this->ajaxResponse['updateTabs']['#tab_member'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactID); + } + } $statusMsg = ts('The payment record has been processed.'); // send email diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 2cc479ee79..c19f663837 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -1073,6 +1073,12 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP if (empty($this->_id) && !empty($contribution->id)) { $this->_id = $contribution->id; } + if (!empty($this->_id) && CRM_Core_Permission::access('CiviMember')) { + $membershipPayments = civicrm_api3('MembershipPayment', 'Get', array('contribution_id' => $this->_id)); + if ($membershipPayments['count'] > 1) { + $this->ajaxResponse['updateTabs']['#tab_member'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactID); + } + } } /** -- 2.25.1