From 388b7f79eca4715d58a7c2345be257b91c479c38 Mon Sep 17 00:00:00 2001 From: Sudha Bisht Date: Fri, 11 Dec 2015 13:57:46 +0530 Subject: [PATCH] Fix for contribution repeat statistic bug --- CRM/Report/Form/Contribute/Repeat.php | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/CRM/Report/Form/Contribute/Repeat.php b/CRM/Report/Form/Contribute/Repeat.php index bdf432343a..4adb3cc61d 100644 --- a/CRM/Report/Form/Contribute/Repeat.php +++ b/CRM/Report/Form/Contribute/Repeat.php @@ -634,32 +634,15 @@ LEFT JOIN civicrm_temp_civireport_repeat2 {$this->_aliases['civicrm_contribution */ public function statistics(&$rows) { $statistics = parent::statistics($rows); - - //fetch contributions for both date ranges from pre-existing temp tables - $sql = " -CREATE TEMPORARY TABLE civicrm_temp_civireport_repeat3 -SELECT contact_id FROM civicrm_temp_civireport_repeat1 UNION SELECT contact_id FROM civicrm_temp_civireport_repeat2;"; + $sql = "{$this->_select} {$this->_from} {$this->_where}"; $dao = CRM_Core_DAO::executeQuery($sql); - - $sql = " -SELECT civicrm_temp_civireport_repeat3.contact_id, - civicrm_temp_civireport_repeat1.total_amount_sum as contribution1_total_amount_sum, - civicrm_temp_civireport_repeat2.total_amount_sum as contribution2_total_amount_sum -FROM civicrm_temp_civireport_repeat3 -LEFT JOIN civicrm_temp_civireport_repeat1 - ON civicrm_temp_civireport_repeat3.contact_id = civicrm_temp_civireport_repeat1.contact_id -LEFT JOIN civicrm_temp_civireport_repeat2 - ON civicrm_temp_civireport_repeat3.contact_id = civicrm_temp_civireport_repeat2.contact_id"; - $dao = CRM_Core_DAO::executeQuery($sql); - //store contributions in array 'contact_sums' for comparison $contact_sums = array(); while ($dao->fetch()) { - $contact_sums[$dao->contact_id] - = array( - 'contribution1_total_amount_sum' => $dao->contribution1_total_amount_sum, - 'contribution2_total_amount_sum' => $dao->contribution2_total_amount_sum, - ); + $contact_sums[$dao->contact_civireport_id] = array( + 'contribution1_total_amount_sum' => $dao->contribution1_total_amount_sum, + 'contribution2_total_amount_sum' => $dao->contribution2_total_amount_sum, + ); } $total_distinct_contacts = count($contact_sums); -- 2.25.1