• Модуль: report
  • Путь к файлу: ~/bitrix/modules/report/classes/general/report_helper.php
  • Класс: CReportHelper
  • Вызов: CReportHelper::formatResultsTotal
static function formatResultsTotal(&$total, &$columnInfo, &$customChartTotal = null)
{
	foreach ($total as $k => $v)
	{
		// remove prefix TOTAL_
		$original_k = mb_substr($k, 6);

		$cInfo = $columnInfo[$original_k];
		$field = $cInfo['field'];

		$dataType = self::getFieldDataType($field);

		$isUF = false;
		$ufInfo = null;
		if (isset($cInfo['isUF']) && $cInfo['isUF'])
		{
			$isUF = true;
			$ufInfo = $cInfo['ufInfo'];
		}

		if ($field->getName() == 'ID' && empty($cInfo['aggr']) && $cInfo['prcnt'] == '')
		{
			unset($total[$k]);
		}
		elseif($cInfo['prcnt'] <> '')
		{
			if($cInfo['prcnt'] == 'self_column')
			{
				if(array_key_exists($k, $total) && $v > 0)
				{
					$v = round($v / $total[$k] * 100, 2);
				}
				else
				{
					$v = '--';
				}
			}
			else
			{
				$v = round($v, 2);
			}

			$total[$k] = $v.'%';
		}
		elseif (mb_substr($k, -6) == '_PRCNT' && !mb_strlen($cInfo['prcnt']))
		{
			$total[$k] = round($v, 2). '%';
		}
		elseif ($isUF && $dataType == 'float')
		{
			$precision = $defaultPrecision = 1;
			if (is_array($ufInfo) && is_array($ufInfo['SETTINGS']) && isset($ufInfo['SETTINGS']['PRECISION']))
				$precision = (int)$ufInfo['SETTINGS']['PRECISION'];
			if ($precision < 0)
				$precision = $defaultPrecision;

			$total[$k] = round($v, $precision);
		}
	}
}