From 67dd7d544838a82009af2f76c7a4081ef602875e Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 17 Oct 2019 12:19:01 +1300 Subject: [PATCH] Attempt to fix paging on contact summary --- CRM/Report/Form/Contribute/Summary.php | 104 ++++++++----------------- 1 file changed, 31 insertions(+), 73 deletions(-) diff --git a/CRM/Report/Form/Contribute/Summary.php b/CRM/Report/Form/Contribute/Summary.php index bffb359186..3e39c7b270 100644 --- a/CRM/Report/Form/Contribute/Summary.php +++ b/CRM/Report/Form/Contribute/Summary.php @@ -65,6 +65,13 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { */ protected $groupFilterNotOptimised = FALSE; + /** + * Indicate that report is not fully FGB compliant. + * + * @var bool + */ + public $optimisedForOnlyFullGroupBy; + /** * Class constructor. */ @@ -584,12 +591,9 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { $this->_groupBy = "GROUP BY " . implode(', ', $groupBy); } else { - $groupBy = "{$this->_aliases['civicrm_contact']}.id"; $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_contact']}.id"; } $this->_groupBy .= $this->_rollup; - // append select with ANY_VALUE() keyword - $this->_select = CRM_Contact_BAO_Query::appendAnyValueToSelect($this->_selectClauses, $groupBy); } /** @@ -733,75 +737,6 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_ 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. * @@ -868,7 +803,30 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_ $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}"; + CRM_Core_DAO::disableFullGroupByMode(); + $contriDAO = CRM_Core_DAO::executeQuery($contriSQL); + CRM_Core_DAO::reenableFullGroupByMode(); + $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']) && -- 2.25.1