From 93406a82e04c44c4be8ca08d9002c12840b9f0ae Mon Sep 17 00:00:00 2001 From: Dave Greenberg Date: Wed, 12 Mar 2014 15:40:12 -0700 Subject: [PATCH] CRM-14133 - Fix add2Group query when Show No. of Top Donors field has a value (e.g. limit). Prior version was returning empty result set. ---------------------------------------- * CRM-14133: Top Donor Report Results "Add to Group" Doesn't Work if "Show no." Filter Used http://issues.civicrm.org/jira/browse/CRM-14133 --- CRM/Report/Form/Contribute/TopDonor.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CRM/Report/Form/Contribute/TopDonor.php b/CRM/Report/Form/Contribute/TopDonor.php index cca2b3e7e4..e79f3d25a0 100644 --- a/CRM/Report/Form/Contribute/TopDonor.php +++ b/CRM/Report/Form/Contribute/TopDonor.php @@ -274,7 +274,7 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { function where() { $clauses = array(); - $this->_tempClause = $this->_outerCluase = ''; + $this->_tempClause = $this->_outerCluase = $this->_groupLimit = ''; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { @@ -304,6 +304,7 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { if ($fieldName == 'total_range') { $value = CRM_Utils_Array::value("total_range_value", $this->_params); $this->_outerCluase = " WHERE (( @rows := @rows + 1) <= {$value}) "; + $this->_groupLimit = " LIMIT {$value}"; } else { $clauses[] = $clause; @@ -379,7 +380,7 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { $sql = " {$this->_select} {$this->_from} {$this->_where} {$this->_groupBy} ORDER BY civicrm_contribution_total_amount_sum DESC -) as abc {$this->_outerCluase}"; +) as abc {$this->_groupLimit}"; $dao = CRM_Core_DAO::executeQuery($sql); $contact_ids = array(); -- 2.25.1