CRM-19170 update Contribution Detail & Repeat reports to use optimised group filter
authoreileen <emcnaughton@wikimedia.org>
Thu, 4 Aug 2016 08:42:10 +0000 (20:42 +1200)
committereileen <emcnaughton@wikimedia.org>
Tue, 16 Aug 2016 04:09:48 +0000 (16:09 +1200)
CRM/Report/Form/Contribute/Detail.php
CRM/Report/Form/Contribute/Repeat.php

index 84545454673dfb97df0a79ef7459409a63d0928c..f5f4509087e1a65cec5597ffc01be821f5e86529 100644 (file)
@@ -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();
   }
index 27027a9cf77902b2c6545a19f120e2fc8b34e488..e90ba421a99f8634659b8f766a5798632ed1ab5b 100644 (file)
@@ -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 = '';