[REF] Ensure that the from is correctly modified in both the main query and in the...
authorSeamus Lee <seamuslee001@gmail.com>
Wed, 29 Jan 2020 21:20:03 +0000 (08:20 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Wed, 29 Jan 2020 21:20:03 +0000 (08:20 +1100)
CRM/Report/Form/Contribute/Summary.php

index fe273cd31a5acf0df9c231b6bbdeaabdc894101c..ab65d97d302abc0a2c9bd766e108c737c6c56197 100644 (file)
@@ -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,