Move output formatting to the relevant functions
authoreileen <emcnaughton@wikimedia.org>
Sun, 17 Feb 2019 04:16:33 +0000 (17:16 +1300)
committereileen <emcnaughton@wikimedia.org>
Sun, 17 Feb 2019 22:43:03 +0000 (11:43 +1300)
CRM/Contact/BAO/Query.php

index add935859d3aba2d9d0022137f03a9fb05e85e65..5247434ab824ea3793a0b7e5ac44c2168b814b4d 100644 (file)
@@ -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(',&nbsp;', $summary['total']['amount']);
-      $summary['total']['avg'] = implode(',&nbsp;', $summary['total']['avg']);
-      $summary['total']['mode'] = implode(',&nbsp;', $summary['total']['mode']);
-      $summary['total']['median'] = implode(',&nbsp;', $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(',&nbsp;', $summary['total']['amount']);
+      $summary['total']['avg'] = implode(',&nbsp;', $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(',&nbsp;', (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(',&nbsp;', (array) $median);
   }
 
   /**