From 94c8aed1b5a1601ced51177522aed8e27f940697 Mon Sep 17 00:00:00 2001 From: Edsel Date: Mon, 24 Jul 2017 18:54:52 +0530 Subject: [PATCH 1/3] 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 900815e99d75..15c4bb30d9d6 100644 --- a/CRM/Contribute/Form/AdditionalPayment.php +++ b/CRM/Contribute/Form/AdditionalPayment.php @@ -379,6 +379,12 @@ public function submit($submittedValues) { $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 2cc479ee792e..c19f6638373f 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -1073,6 +1073,12 @@ public function postProcess() { 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); + } + } } /** From 1c06685dc3df16c371bb7f8de7fb6c85bfefa41c Mon Sep 17 00:00:00 2001 From: Edsel Date: Wed, 26 Jul 2017 12:34:31 +0530 Subject: [PATCH 2/3] CRM-20952 Bug fixes ---------------------------------------- * CRM-20952: Refresh membership tab on edits to membership payments https://issues.civicrm.org/jira/browse/CRM-20952 --- CRM/Contribute/Form/AdditionalPayment.php | 4 ++-- CRM/Contribute/Form/Contribution.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CRM/Contribute/Form/AdditionalPayment.php b/CRM/Contribute/Form/AdditionalPayment.php index 15c4bb30d9d6..84fbcc5be126 100644 --- a/CRM/Contribute/Form/AdditionalPayment.php +++ b/CRM/Contribute/Form/AdditionalPayment.php @@ -380,8 +380,8 @@ public function submit($submittedValues) { $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) { + $memPaymentCount = civicrm_api3('MembershipPayment', 'getCount', array('contribution_id' => $this->_contributionId)); + if ($memPaymentCount > 0) { $this->ajaxResponse['updateTabs']['#tab_member'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactID); } } diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index c19f6638373f..9f53559b77ef 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -1074,8 +1074,8 @@ public function postProcess() { $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) { + $memPaymentCount = civicrm_api3('MembershipPayment', 'getCount', array('contribution_id' => $this->_id)); + if ($memPaymentCount > 0) { $this->ajaxResponse['updateTabs']['#tab_member'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactID); } } From 5a53dd1fe163afcffc0ce9187fcf62fe5dad5b05 Mon Sep 17 00:00:00 2001 From: Edsel Date: Wed, 26 Jul 2017 16:55:32 +0530 Subject: [PATCH 3/3] CRM-20952 Refreshed event tab on payment made to contribution ---------------------------------------- * CRM-20952: Refresh membership tab on edits to membership payments https://issues.civicrm.org/jira/browse/CRM-20952 --- CRM/Contribute/Form/AdditionalPayment.php | 10 ++++++++-- CRM/Contribute/Form/Contribution.php | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CRM/Contribute/Form/AdditionalPayment.php b/CRM/Contribute/Form/AdditionalPayment.php index 84fbcc5be126..5b2f0cebf094 100644 --- a/CRM/Contribute/Form/AdditionalPayment.php +++ b/CRM/Contribute/Form/AdditionalPayment.php @@ -380,11 +380,17 @@ public function submit($submittedValues) { $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')) { - $memPaymentCount = civicrm_api3('MembershipPayment', 'getCount', array('contribution_id' => $this->_contributionId)); - if ($memPaymentCount > 0) { + $membershipPaymentCount = civicrm_api3('MembershipPayment', 'getCount', array('contribution_id' => $this->_contributionId)); + if ($membershipPaymentCount) { $this->ajaxResponse['updateTabs']['#tab_member'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactID); } } + if ($this->_contributionId && CRM_Core_Permission::access('CiviEvent')) { + $participantPaymentCount = civicrm_api3('ParticipantPayment', 'getCount', array('contribution_id' => $this->_contributionId)); + if ($participantPaymentCount) { + $this->ajaxResponse['updateTabs']['#tab_participant'] = CRM_Contact_BAO_Contact::getCountComponent('participant', $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 9f53559b77ef..7f2be11723b5 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -1074,11 +1074,17 @@ public function postProcess() { $this->_id = $contribution->id; } if (!empty($this->_id) && CRM_Core_Permission::access('CiviMember')) { - $memPaymentCount = civicrm_api3('MembershipPayment', 'getCount', array('contribution_id' => $this->_id)); - if ($memPaymentCount > 0) { + $membershipPaymentCount = civicrm_api3('MembershipPayment', 'getCount', array('contribution_id' => $this->_id)); + if ($membershipPaymentCount) { $this->ajaxResponse['updateTabs']['#tab_member'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactID); } } + if (!empty($this->_id) && CRM_Core_Permission::access('CiviEvent')) { + $participantPaymentCount = civicrm_api3('ParticipantPayment', 'getCount', array('contribution_id' => $this->_id)); + if ($participantPaymentCount) { + $this->ajaxResponse['updateTabs']['#tab_participant'] = CRM_Contact_BAO_Contact::getCountComponent('participant', $this->_contactID); + } + } } /**