From fedcd5edff8bbc2be1c0e10ef41fab48d8b8f3ae Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Sat, 20 Aug 2016 21:24:11 +0530 Subject: [PATCH] CRM-16189, changed code to return participant id in query ---------------------------------------- * CRM-16189: Improve support for Accrual Method bookkeeping https://issues.civicrm.org/jira/browse/CRM-16189 --- CRM/Contribute/BAO/Query.php | 5 +++++ CRM/Contribute/Selector/Search.php | 8 ++++---- CRM/Event/BAO/Query.php | 11 ----------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/CRM/Contribute/BAO/Query.php b/CRM/Contribute/BAO/Query.php index b152dedf5c..1cd6eb9277 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -236,6 +236,11 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { $query->_element['contribution_campaign_title'] = $query->_tables['civicrm_campaign'] = 1; } + if (!empty($query->_returnProperties['contribution_participant_id'])) { + $query->_select['contribution_participant_id'] = "civicrm_participant.id as contribution_participant_id"; + $query->_whereTables['contribution_participant'] = $query->_tables['contribution_participant'] = 1; + } + // Adding address_id in a way that is more easily extendable since the above is a bit ... wordy. $supportedBasicReturnValues = array('address_id'); foreach ($supportedBasicReturnValues as $fieldName) { diff --git a/CRM/Contribute/Selector/Search.php b/CRM/Contribute/Selector/Search.php index b3ed957edd..79155fd50b 100644 --- a/CRM/Contribute/Selector/Search.php +++ b/CRM/Contribute/Selector/Search.php @@ -82,7 +82,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C 'contribution_soft_credit_contact_id', 'contribution_soft_credit_amount', 'contribution_soft_credit_type', - 'participant_contribution_id', + 'contribution_participant_id', ); /** @@ -185,7 +185,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C // type of selector $this->_action = $action; $returnProperties = CRM_Contribute_BAO_Query::selectorReturnProperties(); - $returnProperties['participant_contribution_id'] = 1; + $returnProperties['contribution_participant_id'] = 1; $this->_includeSoftCredits = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($this->_queryParams); $this->_query = new CRM_Contact_BAO_Query( $this->_queryParams, @@ -441,9 +441,9 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C 'id' => $result->contribution_id, 'cid' => $result->contact_id, 'cxt' => $this->_context, - 'pid' => $result->participant_id, + 'pid' => $result->contribution_participant_id, ); - if (!empty($row['participant_contribution_id'])) { + if (!empty($row['contribution_participant_id'])) { if ($row['contribution_status_name'] == 'Partially paid') { $links[CRM_Core_Action::ADD] = array( 'name' => ts('Record Payment'), diff --git a/CRM/Event/BAO/Query.php b/CRM/Event/BAO/Query.php index 019e368d52..ba13d92bf0 100644 --- a/CRM/Event/BAO/Query.php +++ b/CRM/Event/BAO/Query.php @@ -90,13 +90,6 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_Query { $query->_element['participant_fee_amount'] = 1; } - if (!empty($query->_returnProperties['participant_contribution_id'])) { - $query->_select['participant_contribution_id'] = "civicrm_participant_payment.participant_id as participant_contribution_id"; - $query->_element['participant_contribution_id'] = 1; - $query->_tables['civicrm_contribution_participant_payment'] = 1; - $query->_whereTables['civicrm_contribution_participant_payment'] = 1; - } - //add fee currency if (!empty($query->_returnProperties['participant_fee_currency'])) { $query->_select['participant_fee_currency'] = "civicrm_participant.fee_currency as participant_fee_currency"; @@ -488,10 +481,6 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_Query { $from = " LEFT JOIN civicrm_participant ON civicrm_participant.contact_id = contact_a.id "; break; - case 'civicrm_contribution_participant_payment': - $from = " $side JOIN civicrm_participant_payment ON civicrm_contribution.id = civicrm_participant_payment.contribution_id "; - break; - case 'civicrm_event': //CRM-17121 $from = " LEFT JOIN civicrm_event ON civicrm_participant.event_id = civicrm_event.id "; -- 2.25.1