Skip to content

Commit

Permalink
Attempt to fix paging on contact summary
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Oct 16, 2019
1 parent f2a37c0 commit 02d0f41
Showing 1 changed file with 22 additions and 70 deletions.
92 changes: 22 additions & 70 deletions CRM/Report/Form/Contribute/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,75 +733,6 @@ public function postProcess() {
parent::postProcess();
}

/**
* Build table rows for output.
*
* @param string $sql
* @param array $rows
*/
public function buildRows($sql, &$rows) {
CRM_Core_DAO::disableFullGroupByMode();
$dao = CRM_Core_DAO::executeQuery($sql);
CRM_Core_DAO::reenableFullGroupByMode();
$this->addToDeveloperTab($sql);
if (!is_array($rows)) {
$rows = array();
}

// use this method to modify $this->_columnHeaders
$this->modifyColumnHeaders();
$contriRows = array();
$unselectedSectionColumns = $this->unselectedSectionColumns();

//CRM-16338 if both soft-credit and contribution are enabled then process the contribution's
//total amount's average, count and sum separately and add it to the respective result list
$softCredit = (!empty($this->_params['fields']['soft_amount']) && !empty($this->_params['fields']['total_amount'])) ? TRUE : FALSE;
if ($softCredit) {
$this->from('contribution');
$this->customDataFrom();
$contriSQL = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy} {$this->_having} {$this->_orderBy} {$this->_limit}";
$contriDAO = CRM_Core_DAO::executeQuery($contriSQL);
$this->addToDeveloperTab($contriSQL);
$contriFields = array(
'civicrm_contribution_total_amount_sum',
'civicrm_contribution_total_amount_avg',
'civicrm_contribution_total_amount_count',
);
$contriRows = array();
while ($contriDAO->fetch()) {
$contriRow = array();
foreach ($contriFields as $column) {
$contriRow[$column] = $contriDAO->$column;
}
$contriRows[] = $contriRow;
}
}

$count = 0;
while ($dao->fetch()) {
$row = array();
foreach ($this->_columnHeaders as $key => $value) {
if ($softCredit && array_key_exists($key, $contriRows[$count])) {
$row[$key] = $contriRows[$count][$key];
}
elseif (property_exists($dao, $key)) {
$row[$key] = $dao->$key;
}
}

// section headers not selected for display need to be added to row
foreach ($unselectedSectionColumns as $key => $values) {
if (property_exists($dao, $key)) {
$row[$key] = $dao->$key;
}
}

$count++;
$rows[] = $row;
}

}

/**
* Build chart.
*
Expand Down Expand Up @@ -868,7 +799,28 @@ public function alterDisplay(&$rows) {
$entryFound = FALSE;
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label');
$contributionPages = CRM_Contribute_PseudoConstant::contributionPage();

//CRM-16338 if both soft-credit and contribution are enabled then process the contribution's
//total amount's average, count and sum separately and add it to the respective result list
$softCredit = (!empty($this->_params['fields']['soft_amount']) && !empty($this->_params['fields']['total_amount'])) ? TRUE : FALSE;
if ($softCredit) {
$this->from('contribution');
$this->customDataFrom();
$contriSQL = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy} {$this->_having} {$this->_orderBy} {$this->_limit}";
$contriDAO = CRM_Core_DAO::executeQuery($contriSQL);
$this->addToDeveloperTab($contriSQL);
$contriFields = array(
'civicrm_contribution_total_amount_sum',
'civicrm_contribution_total_amount_avg',
'civicrm_contribution_total_amount_count',
);
$count = 0;
while ($contriDAO->fetch()) {
foreach ($contriFields as $column) {
$rows[$count][$column] = $contriDAO->$column;
}
$count++;
}
}
foreach ($rows as $rowNum => $row) {
// make count columns point to detail report
if (!empty($this->_params['group_bys']['receive_date']) &&
Expand Down

0 comments on commit 02d0f41

Please sign in to comment.