From 8a2bee47cef116bebd205ac73856529900cbdccb Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 20 Jan 2016 08:47:59 +1300 Subject: [PATCH] CRM-17837 store rollup result grand total on the class rather than discarding it This makes it available for re-use in the statistics --- CRM/Report/Form.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index c3a2cb6f84..93b813de40 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -398,6 +398,13 @@ class CRM_Report_Form extends CRM_Core_Form { */ protected $_createNew; + /** + * When a grand total row has calculated the status we pop it off to here. + * + * This allows us to access it from the stats function and avoid recalculating. + */ + protected $rollupRow = array(); + /** * SQL being run in this report. * @@ -2122,26 +2129,27 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND * @return bool */ public function grandTotal(&$rows) { - if (!$this->_rollup || ($this->_rollup == '') || + if (!$this->_rollup || ($this->_rollup == '' || count($rows) == 1) || ($this->_limit && count($rows) >= self::ROW_COUNT_LIMIT) ) { return FALSE; } - $lastRow = array_pop($rows); + + $this->rollupRow = array_pop($rows); foreach ($this->_columnHeaders as $fld => $val) { if (!in_array($fld, $this->_statFields)) { if (!$this->_grandFlag) { - $lastRow[$fld] = "Grand Total"; + $this->rollupRow[$fld] = "Grand Total"; $this->_grandFlag = TRUE; } else { - $lastRow[$fld] = ""; + $this->rollupRow[$fld] = ""; } } } - $this->assign('grandStat', $lastRow); + $this->assign('grandStat', $this->rollupRow); return TRUE; } @@ -2871,7 +2879,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $statistics = array(); $count = count($rows); - + // Why do we increment the count for rollup seems to artificially inflate the count. if ($this->_rollup && ($this->_rollup != '') && $this->_grandFlag) { $count++; } -- 2.25.1