From f14e76869f59fa59e42fe17dbe6e0a8b1f4dd3f4 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 30 Jan 2020 08:20:03 +1100 Subject: [PATCH] [REF] Ensure that the from is correctly modified in both the main query and in the statistics section of the Contribute Summary Report --- CRM/Report/Form/Contribute/Summary.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CRM/Report/Form/Contribute/Summary.php b/CRM/Report/Form/Contribute/Summary.php index fe273cd31a..ab65d97d30 100644 --- a/CRM/Report/Form/Contribute/Summary.php +++ b/CRM/Report/Form/Contribute/Summary.php @@ -611,8 +611,14 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { $group = "\nGROUP BY {$this->_aliases['civicrm_contribution']}.currency"; $this->from('contribution'); + if ($softCredit) { + $this->from(); + } $this->customDataFrom(); + // Ensure that Extensions that modify the from statement in the sql also modify it in the statistics. + CRM_Utils_Hook::alterReportVar('sql', $this, $this); + $contriQuery = " COUNT({$this->_aliases['civicrm_contribution']}.total_amount ) as civicrm_contribution_total_amount_count, SUM({$this->_aliases['civicrm_contribution']}.total_amount ) as civicrm_contribution_total_amount_sum, @@ -621,8 +627,6 @@ ROUND(AVG({$this->_aliases['civicrm_contribution']}.total_amount), 2) as civicrm {$this->_from} {$this->_where}"; if ($softCredit) { - $this->from(); - $this->customDataFrom(); $select = " COUNT({$this->_aliases['civicrm_contribution_soft']}.amount ) as civicrm_contribution_soft_soft_amount_count, SUM({$this->_aliases['civicrm_contribution_soft']}.amount ) as civicrm_contribution_soft_soft_amount_sum, -- 2.25.1