From: eileen Date: Sun, 17 Feb 2019 04:16:33 +0000 (+1300) Subject: Move output formatting to the relevant functions X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=261b72cfac72fc50859de497261012e945e2d0b6;p=civicrm-core.git Move output formatting to the relevant functions --- diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index add935859d..5247434ab8 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -5109,16 +5109,6 @@ civicrm_relationship.start_date > {$today} $summary['total']['currencyCount'] = count($summary['total']['median']); - if (!empty($summary['total']['amount'])) { - $summary['total']['amount'] = implode(', ', $summary['total']['amount']); - $summary['total']['avg'] = implode(', ', $summary['total']['avg']); - $summary['total']['mode'] = implode(', ', $summary['total']['mode']); - $summary['total']['median'] = implode(', ', $summary['total']['median']); - } - else { - $summary['total']['amount'] = $summary['total']['avg'] = $summary['total']['median'] = 0; - } - $this->addBasicCancelStatsToSummary($summary, $where, $from); return $summary; @@ -6568,6 +6558,13 @@ AND displayRelType.is_active = 1 $summary['total']['amount'][] = CRM_Utils_Money::format($dao->total_amount, $dao->currency); $summary['total']['avg'][] = CRM_Utils_Money::format($dao->total_avg, $dao->currency); } + if (!empty($summary['total']['amount'])) { + $summary['total']['amount'] = implode(', ', $summary['total']['amount']); + $summary['total']['avg'] = implode(', ', $summary['total']['avg']); + } + else { + $summary['total']['amount'] = $summary['total']['avg'] = $summary['total']['median'] = 0; + } return $summary; } @@ -6602,7 +6599,8 @@ AND displayRelType.is_active = 1 ) as conts GROUP BY currency"; - $summary['total']['mode'] = CRM_Contribute_BAO_Contribution::computeStats('mode', $modeSQL); + $mode = CRM_Contribute_BAO_Contribution::computeStats('mode', $modeSQL); + $summary['total']['mode'] = implode(', ', (array) $mode); } /** @@ -6620,7 +6618,8 @@ AND displayRelType.is_active = 1 */ protected function addMedianToStats(&$summary, $where, $from) { $medianSQL = "{$from} {$where} AND civicrm_contribution.contribution_status_id = 1 "; - $summary['total']['median'] = CRM_Contribute_BAO_Contribution::computeStats('median', $medianSQL, 'civicrm_contribution'); + $median = CRM_Contribute_BAO_Contribution::computeStats('median', $medianSQL, 'civicrm_contribution'); + $summary['total']['median'] = implode(', ', (array) $median); } /**