Skip to content

Commit

Permalink
make pager work
Browse files Browse the repository at this point in the history
  • Loading branch information
demeritcowboy committed Mar 2, 2023
1 parent 29800f8 commit b573156
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions CRM/Report/Form/Contribute/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,14 +608,19 @@ public function buildRows($sql, &$rows) {
$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)) {
Expand Down

0 comments on commit b573156

Please sign in to comment.