diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-10-16 19:23:58 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2015-10-19 17:22:51 +0300 |
commit | 7cb8055ae0e5c709383fe855850376a8cd5ed306 (patch) | |
tree | 98f87c37d0b2992f678ba05877c1c7ef35ae1176 /plugins/Goals | |
parent | 62fc5558bb5211eccfffec40b2723ed49121ac70 (diff) |
Apply number formatting changes from master to 3.X branch
Diffstat (limited to 'plugins/Goals')
-rw-r--r-- | plugins/Goals/Reports/Get.php | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/plugins/Goals/Reports/Get.php b/plugins/Goals/Reports/Get.php index 66f167fb24..d5a2afca78 100644 --- a/plugins/Goals/Reports/Get.php +++ b/plugins/Goals/Reports/Get.php @@ -11,6 +11,7 @@ namespace Piwik\Plugins\Goals\Reports; use Piwik\Common; use Piwik\DataTable; use Piwik\Metrics\Formatter; +use Piwik\NumberFormatter; use Piwik\Piwik; use Piwik\Plugin; use Piwik\Plugin\ViewDataTable; @@ -21,6 +22,7 @@ use Piwik\Plugins\Goals\Goals; use Piwik\Plugins\Goals\Pages; use Piwik\Report\ReportWidgetFactory; use Piwik\Site; +use Piwik\Tracker\GoalManager; use Piwik\Widget\WidgetsList; class Get extends Base @@ -82,12 +84,30 @@ class Get extends Base $idGoal = Common::getRequestVar('idGoal', 0, 'int'); - $formatter = new Formatter(); - $view->config->filters[] = function (DataTable $table) use ($formatter, $idSite) { + $numberFormatter = NumberFormatter::getInstance(); + $view->config->filters[] = function (DataTable $table) use ($numberFormatter, $idSite) { $firstRow = $table->getFirstRow(); if ($firstRow) { + $revenue = $firstRow->getColumn('revenue'); - $firstRow->setColumn('revenue', $formatter->getPrettyMoney($revenue, $idSite)); + $currencySymbol = Formatter::getCurrencySymbol($idSite); + $revenue = $numberFormatter->formatCurrency($revenue, $currencySymbol, GoalManager::REVENUE_PRECISION); + $firstRow->setColumn('revenue', $revenue); + + $conversionRate = $firstRow->getColumn('conversion_rate'); + if (false !== $conversionRate) { + $firstRow->setColumn('conversion_rate', $numberFormatter->formatPercent($conversionRate, $precision = 1)); + } + + $conversions = $firstRow->getColumn('nb_conversions'); + if (false !== $conversions) { + $firstRow->setColumn('nb_conversions', $numberFormatter->formatNumber($conversions)); + } + + $visitsConverted = $firstRow->getColumn('nb_visits_converted'); + if (false !== $visitsConverted) { + $firstRow->setColumn('nb_visits_converted', $numberFormatter->formatNumber($visitsConverted)); + } } }; |