From b57315652dcc9de9b38bd9b8f0c8ed97a1ca96cc Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Thu, 2 Mar 2023 17:02:39 -0500 Subject: [PATCH] make pager work --- CRM/Report/Form/Contribute/History.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CRM/Report/Form/Contribute/History.php b/CRM/Report/Form/Contribute/History.php index b97f1adb5c..4b310b05b0 100644 --- a/CRM/Report/Form/Contribute/History.php +++ b/CRM/Report/Form/Contribute/History.php @@ -608,14 +608,19 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $addWhere .= " AND {$this->_aliases['civicrm_contact']}.id IN ( SELECT DISTINCT cont.id FROM civicrm_contact cont, civicrm_contribution contri WHERE cont.id = contri.contact_id AND {$receive_date} = {$this->_referenceYear['this_year']} AND contri.is_test = 0 AND contri.is_template = 0 ) "; } $this->limit(); - $getContacts = "SELECT {$this->_aliases['civicrm_contact']}.id as cid, SUM({$this->_aliases['civicrm_contribution']}.total_amount) as civicrm_contribution_total_amount_sum {$this->_from} {$this->_where} {$addWhere} GROUP BY {$this->_aliases['civicrm_contact']}.id {$this->_having} {$this->_limit}"; + $getContacts = "SELECT {$this->_aliases['civicrm_contact']}.id as cid, SUM({$this->_aliases['civicrm_contribution']}.total_amount) as civicrm_contribution_total_amount_sum {$this->_from} {$this->_where} {$addWhere} GROUP BY {$this->_aliases['civicrm_contact']}.id {$this->_having}"; + // Run it without limit/offset first to get the right number of rows for + // the pager. + CRM_Core_DAO::executeQuery($getContacts); + $this->setPager(); + + $getContacts .= ' ' . $this->_limit; $dao = CRM_Core_DAO::executeQuery($getContacts); while ($dao->fetch()) { $contactIds[] = $dao->cid; } - $this->setPager(); $relationshipRows = []; if (empty($contactIds)) { -- 2.25.1