protected function resolveExportClassNameForListViewColumnAdapter(DisplayAttributeForReportForm $displayAttribute) { $displayElementType = $displayAttribute->getDisplayElementType(); if (@class_exists($displayElementType . 'ForReportToExportValueAdapter')) { return $displayElementType . 'ForReportToExportValueAdapter'; } else { return $displayElementType . 'RedBeanModelAttributeValueToExportValueAdapter'; } }
/** * @param DisplayAttributeForReportForm $displayAttribute * @return string */ protected function resolveColumnClassNameForListViewColumnAdapter(DisplayAttributeForReportForm $displayAttribute) { $displayElementType = $displayAttribute->getDisplayElementType(); if (@class_exists($displayElementType . 'ForReportListViewColumnAdapter')) { return $displayElementType . 'ForReportListViewColumnAdapter'; } else { return $displayElementType . 'ListViewColumnAdapter'; } }
public function testGetDisplayElementTypeDisplayCalculationsAndGroupModifiers() { $displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION); $displayAttribute->attributeIndexOrDerivedType = 'integer__Minimum'; $this->assertEquals('Decimal', $displayAttribute->getDisplayElementType()); $displayAttribute->attributeIndexOrDerivedType = 'float__Minimum'; $this->assertEquals('Decimal', $displayAttribute->getDisplayElementType()); $displayAttribute->attributeIndexOrDerivedType = 'date__Minimum'; $this->assertEquals('Date', $displayAttribute->getDisplayElementType()); $displayAttribute->attributeIndexOrDerivedType = 'dateTime__Minimum'; $this->assertEquals('DateTime', $displayAttribute->getDisplayElementType()); $displayAttribute->attributeIndexOrDerivedType = 'currencyValue__Minimum'; $this->assertEquals('CalculatedCurrencyValue', $displayAttribute->getDisplayElementType()); $displayAttribute->attributeIndexOrDerivedType = 'dateTime__Day'; $this->assertEquals('Text', $displayAttribute->getDisplayElementType()); $displayAttribute->attributeIndexOrDerivedType = 'dateTime__Week'; $this->assertEquals('Text', $displayAttribute->getDisplayElementType()); $displayAttribute->attributeIndexOrDerivedType = 'dateTime__Month'; $this->assertEquals('GroupByModifierMonth', $displayAttribute->getDisplayElementType()); $displayAttribute->attributeIndexOrDerivedType = 'dateTime__Quarter'; $this->assertEquals('Text', $displayAttribute->getDisplayElementType()); $displayAttribute->attributeIndexOrDerivedType = 'dateTime__Year'; $this->assertEquals('Text', $displayAttribute->getDisplayElementType()); }
/** * @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; } }
/** * @param DisplayAttributeForReportForm $displayAttribute * @param RedBeanModel $model * @return mixed $value */ protected function resolveRawValueByModel(DisplayAttributeForReportForm $displayAttribute, RedBeanModel $model) { $type = $displayAttribute->getDisplayElementType(); $attribute = $displayAttribute->getResolvedAttribute(); if ($type == 'CurrencyValue') { return $model->{$attribute}->value; } elseif ($type == 'User') { $realAttributeName = $displayAttribute->getResolvedAttributeRealAttributeName(); return $model->{$realAttributeName}->id; } elseif ($type == 'DropDown') { return $model->{$attribute}->value; } elseif (null != ($rawValueRelatedAttribute = $displayAttribute->getRawValueRelatedAttribute())) { return $model->{$attribute}->{$rawValueRelatedAttribute}; } else { return $this->resolveModelAttributeValueForPenultimateRelation($model, $attribute, $displayAttribute); } }