From 97b4dc6b5d298e9e62d8cfd9131be28c9019ed68 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 4 Aug 2016 20:42:10 +1200 Subject: [PATCH] CRM-19170 update Contribution Detail & Repeat reports to use optimised group filter --- CRM/Report/Form/Contribute/Detail.php | 28 ++++++++++++++------------- CRM/Report/Form/Contribute/Repeat.php | 5 +++-- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/CRM/Report/Form/Contribute/Detail.php b/CRM/Report/Form/Contribute/Detail.php index 8454545467..f5f4509087 100644 --- a/CRM/Report/Form/Contribute/Detail.php +++ b/CRM/Report/Form/Contribute/Detail.php @@ -391,10 +391,11 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { * Set the FROM clause for the report. */ public function from() { - $this->_from = " - FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom} - INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} - ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id AND {$this->_aliases['civicrm_contribution']}.is_test = 0"; + $this->setFromBase('civicrm_contact'); + $this->_from .= " + INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} + ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id + AND {$this->_aliases['civicrm_contribution']}.is_test = 0"; if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == 'both' @@ -939,15 +940,16 @@ WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribu */ public function softCreditFrom() { - $this->_from = " - FROM civireport_contribution_detail_temp1 temp1_civireport - INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} - ON temp1_civireport.civicrm_contribution_contribution_id = {$this->_aliases['civicrm_contribution']}.id - INNER JOIN civicrm_contribution_soft contribution_soft_civireport - ON contribution_soft_civireport.contribution_id = {$this->_aliases['civicrm_contribution']}.id - INNER JOIN civicrm_contact {$this->_aliases['civicrm_contact']} - ON {$this->_aliases['civicrm_contact']}.id = contribution_soft_civireport.contact_id - {$this->_aclFrom}"; + $this->_from = " + FROM civireport_contribution_detail_temp1 temp1_civireport + INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} + ON temp1_civireport.civicrm_contribution_contribution_id = {$this->_aliases['civicrm_contribution']}.id + INNER JOIN civicrm_contribution_soft contribution_soft_civireport + ON contribution_soft_civireport.contribution_id = {$this->_aliases['civicrm_contribution']}.id + INNER JOIN civicrm_contact {$this->_aliases['civicrm_contact']} + ON {$this->_aliases['civicrm_contact']}.id = contribution_soft_civireport.contact_id + {$this->_aclFrom} + "; $this->appendAdditionalFromJoins(); } diff --git a/CRM/Report/Form/Contribute/Repeat.php b/CRM/Report/Form/Contribute/Repeat.php index 27027a9cf7..e90ba421a9 100644 --- a/CRM/Report/Form/Contribute/Repeat.php +++ b/CRM/Report/Form/Contribute/Repeat.php @@ -408,10 +408,11 @@ LEFT JOIN $this->tempTableRepeat2 {$this->_aliases['civicrm_contribution']}2 * @return mixed|string */ public function fromContribution($replaceAliasWith = 'contribution1') { - $from = " FROM civicrm_contribution {$replaceAliasWith} "; + $this->setFromBase('civicrm_contribution', 'contact_id', $replaceAliasWith); + $temp = $this->_aliases['civicrm_contribution']; $this->_aliases['civicrm_contribution'] = $replaceAliasWith; - $this->_from = $from; + $from = $this->_from; $from .= (string) $this->getPermissionedFTQuery($this, 'civicrm_line_item_report', TRUE); $this->_aliases['civicrm_contribution'] = $temp; $this->_where = ''; -- 2.25.1