/** * @param DisplayAttributeForReportForm $displayAttribute * @param array $params */ protected function resolveParamsForCurrencyTypes(DisplayAttributeForReportForm $displayAttribute, &$params) { assert('is_array($params)'); if ($displayAttribute->isATypeOfCurrencyValue()) { $params['currencyValueConversionType'] = $this->report->getCurrencyConversionType(); $params['spotConversionCurrencyCode'] = $this->report->getSpotConversionCurrencyCode(); $params['fromBaseToSpotRate'] = $this->report->getFromBaseToSpotRate(); } }
/** * @param DisplayAttributeForReportForm $displayAttribute * @return array */ protected function resolveParamsForColumnElement(DisplayAttributeForReportForm $displayAttribute) { $params = array(); if ($displayAttribute->isALinkableAttribute() == 'name') { $params['isLink'] = true; } elseif ($displayAttribute->isATypeOfCurrencyValue()) { $params['currencyValueConversionType'] = $this->dataProvider->getReport()->getCurrencyConversionType(); $params['spotConversionCurrencyCode'] = $this->dataProvider->getReport()->getSpotConversionCurrencyCode(); $params['fromBaseToSpotRate'] = $this->dataProvider->getReport()->getFromBaseToSpotRate(); } return $params; }
/** * @param DisplayAttributeForReportForm $displayAttribute * @param mixed $value * @return mixed * @throws NotSupportedException if the currencyConversionType is invalid or null, when the displayAttribute * is a currency type */ protected function formatValue(DisplayAttributeForReportForm $displayAttribute, $value) { if ($displayAttribute->isATypeOfCurrencyValue()) { if ($this->report->getCurrencyConversionType() == Report::CURRENCY_CONVERSION_TYPE_ACTUAL) { return Yii::app()->numberFormatter->formatDecimal((double) $value); } elseif ($this->report->getCurrencyConversionType() == Report::CURRENCY_CONVERSION_TYPE_BASE) { return Yii::app()->numberFormatter->formatCurrency((double) $value, Yii::app()->currencyHelper->getBaseCode()); } elseif ($this->report->getCurrencyConversionType() == Report::CURRENCY_CONVERSION_TYPE_SPOT) { return Yii::app()->numberFormatter->formatCurrency((double) $value * $this->report->getFromBaseToSpotRate(), $this->report->getSpotConversionCurrencyCode()); } else { throw new NotSupportedException(); } } elseif ($displayAttribute->getDisplayElementType() == 'Decimal') { return Yii::app()->numberFormatter->formatDecimal((double) $value); } elseif ($displayAttribute->getDisplayElementType() == 'Integer') { return Yii::app()->numberFormatter->formatDecimal((int) $value); } elseif ($displayAttribute->getDisplayElementType() == 'Date') { return DateTimeUtil::resolveValueForDateLocaleFormattedDisplay($value); } elseif ($displayAttribute->getDisplayElementType() == 'DateTime') { return DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($value); } else { return $value; } }