本文整理汇总了PHP中Report::setCurrencyConversionType方法的典型用法代码示例。如果您正苦于以下问题:PHP Report::setCurrencyConversionType方法的具体用法?PHP Report::setCurrencyConversionType怎么用?PHP Report::setCurrencyConversionType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Report
的用法示例。
在下文中一共展示了Report::setCurrencyConversionType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeReportBySavedReport
/**
* @param $savedReport
* @return Report
*/
public static function makeReportBySavedReport($savedReport)
{
$report = new Report();
if ($savedReport->id > 0) {
$report->setId((int) $savedReport->id);
}
$report->setDescription($savedReport->description);
$report->setModuleClassName($savedReport->moduleClassName);
$report->setName($savedReport->name);
$report->setOwner($savedReport->owner);
$report->setType($savedReport->type);
$explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($savedReport);
$report->setExplicitReadWriteModelPermissions($explicitReadWriteModelPermissions);
if ($savedReport->serializedData != null) {
$unserializedData = unserialize($savedReport->serializedData);
if (isset($unserializedData['filtersStructure'])) {
$report->setFiltersStructure($unserializedData['filtersStructure']);
}
if (isset($unserializedData['currencyConversionType'])) {
$report->setCurrencyConversionType((int) $unserializedData['currencyConversionType']);
}
if (isset($unserializedData['spotConversionCurrencyCode'])) {
$report->setSpotConversionCurrencyCode($unserializedData['spotConversionCurrencyCode']);
}
self::makeComponentFormAndPopulateReportFromData($unserializedData[ComponentForReportForm::TYPE_FILTERS], $report, 'Filter');
self::makeComponentFormAndPopulateReportFromData($unserializedData[ComponentForReportForm::TYPE_ORDER_BYS], $report, 'OrderBy');
self::makeComponentFormAndPopulateReportFromData($unserializedData[ComponentForReportForm::TYPE_GROUP_BYS], $report, 'GroupBy');
self::makeComponentFormAndPopulateReportFromData($unserializedData[ComponentForReportForm::TYPE_DISPLAY_ATTRIBUTES], $report, 'DisplayAttribute');
self::makeComponentFormAndPopulateReportFromData($unserializedData[ComponentForReportForm::TYPE_DRILL_DOWN_DISPLAY_ATTRIBUTES], $report, 'DrillDownDisplayAttribute');
if (isset($unserializedData['chart'])) {
$moduleClassName = $report->getModuleClassName();
$modelClassName = $moduleClassName::getPrimaryModelName();
$adapter = ModelRelationsAndAttributesToSummationReportAdapter::make($moduleClassName, $modelClassName, $report->getType());
$chart = new ChartForReportForm(ReportUtil::makeDataAndLabelsForSeriesOrRange($adapter->getAttributesForChartSeries($report->getGroupBys(), $report->getDisplayAttributes())), ReportUtil::makeDataAndLabelsForSeriesOrRange($adapter->getAttributesForChartRange($report->getDisplayAttributes())));
$chart->setAttributes($unserializedData['chart']);
$report->setChart($chart);
}
}
return $report;
}
示例2: resolveReportByWizardPostData
/**
* @param Report $report
* @param array $postData
* @param string $wizardFormClassName
*/
public static function resolveReportByWizardPostData(Report $report, $postData, $wizardFormClassName)
{
assert('is_array($postData)');
assert('is_string($wizardFormClassName)');
$data = ArrayUtil::getArrayValue($postData, $wizardFormClassName);
if (isset($data['description'])) {
$report->setDescription($data['description']);
}
if (isset($data['moduleClassName'])) {
$report->setModuleClassName($data['moduleClassName']);
}
if (isset($data['name'])) {
$report->setName($data['name']);
}
if (isset($data['filtersStructure'])) {
$report->setFiltersStructure($data['filtersStructure']);
}
if (null != ArrayUtil::getArrayValue($data, 'ownerId')) {
$owner = User::getById((int) $data['ownerId']);
$report->setOwner($owner);
} else {
$report->setOwner(new User());
}
if (isset($data['currencyConversionType'])) {
$report->setCurrencyConversionType((int) $data['currencyConversionType']);
}
if (isset($data['spotConversionCurrencyCode'])) {
$report->setSpotConversionCurrencyCode($data['spotConversionCurrencyCode']);
}
self::resolveFilters($data, $report);
self::resolveOrderBys($data, $report);
self::resolveDisplayAttributes($data, $report);
self::resolveDrillDownDisplayAttributes($data, $report);
self::resolveGroupBys($data, $report);
self::resolveChart($data, $report);
}
示例3: makeMeetingsCategoryAndMonthStartTimeByOwner
public static function makeMeetingsCategoryAndMonthStartTimeByOwner()
{
$report = new Report();
$report->setModuleClassName('MeetingsModule');
$report->setName('Meettings Category And Month Start Time By Owner');
$report->setType(Report::TYPE_MATRIX);
$report->setOwner(Yii::app()->user->userModel);
$report->setFiltersStructure('');
$report->setCurrencyConversionType(Report::CURRENCY_CONVERSION_TYPE_BASE);
$groupBy = new GroupByForReportForm('MeetingsModule', 'Meeting', $report->getType());
$groupBy->attributeIndexOrDerivedType = 'startDateTime__Month';
$groupBy->axis = 'x';
$report->addGroupBy($groupBy);
$groupBy = new GroupByForReportForm('MeetingsModule', 'Meeting', $report->getType());
$groupBy->attributeIndexOrDerivedType = 'category';
$groupBy->axis = 'x';
$report->addGroupBy($groupBy);
$groupBy = new GroupByForReportForm('MeetingsModule', 'Meeting', $report->getType());
$groupBy->attributeIndexOrDerivedType = 'owner__User';
$groupBy->axis = 'y';
$report->addGroupBy($groupBy);
$displayAttribute = new DisplayAttributeForReportForm('MeetingsModule', 'Meeting', $report->getType());
$displayAttribute->attributeIndexOrDerivedType = 'Count';
$report->addDisplayAttribute($displayAttribute);
$savedReport = new SavedReport();
SavedReportToReportAdapter::resolveReportToSavedReport($report, $savedReport);
//set explicit
$saved = $savedReport->save();
assert('$saved');
$explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($savedReport);
$explicitReadWriteModelPermissions->addReadWritePermitable(Group::getByName(Group::EVERYONE_GROUP_NAME));
$success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($savedReport, $explicitReadWriteModelPermissions);
assert('$success');
$saved = $savedReport->save();
assert('$saved');
}
示例4: makeOpportunitiesByStage
public static function makeOpportunitiesByStage()
{
$report = new Report();
$report->setModuleClassName('OpportunitiesModule');
$report->setName('Opportunities by Stage');
$report->setType(Report::TYPE_SUMMATION);
$report->setOwner(Yii::app()->user->userModel);
$report->setFiltersStructure('');
$report->setCurrencyConversionType(Report::CURRENCY_CONVERSION_TYPE_BASE);
$groupBy = new GroupByForReportForm('OpportunitiesModule', 'Opportunity', $report->getType());
$groupBy->attributeIndexOrDerivedType = 'stage';
$groupBy->axis = 'x';
$report->addGroupBy($groupBy);
$displayAttribute = new DisplayAttributeForReportForm('OpportunitiesModule', 'Opportunity', $report->getType());
$displayAttribute->attributeIndexOrDerivedType = 'stage';
$report->addDisplayAttribute($displayAttribute);
$displayAttribute = new DisplayAttributeForReportForm('OpportunitiesModule', 'Opportunity', $report->getType());
$displayAttribute->attributeIndexOrDerivedType = 'Count';
$report->addDisplayAttribute($displayAttribute);
$displayAttribute = new DisplayAttributeForReportForm('OpportunitiesModule', 'Opportunity', $report->getType());
$displayAttribute->attributeIndexOrDerivedType = 'amount__Summation';
$report->addDisplayAttribute($displayAttribute);
$chart = new ChartForReportForm();
$chart->type = 'Column2D';
$chart->firstSeries = 'stage';
$chart->firstRange = 'amount__Summation';
$report->setChart($chart);
$savedReport = new SavedReport();
SavedReportToReportAdapter::resolveReportToSavedReport($report, $savedReport);
//set explicit
$saved = $savedReport->save();
assert('$saved');
$explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($savedReport);
$explicitReadWriteModelPermissions->addReadWritePermitable(Group::getByName(Group::EVERYONE_GROUP_NAME));
$success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($savedReport, $explicitReadWriteModelPermissions);
assert('$success');
$saved = $savedReport->save();
assert('$saved');
}
示例5: testResolveReportToSavedReport
public function testResolveReportToSavedReport()
{
$billy = User::getByUsername('billy');
$report = new Report();
$report->setDescription('aDescription');
$report->setModuleClassName('ReportsTestModule');
$report->setName('myFirstReport');
$report->setType(Report::TYPE_ROWS_AND_COLUMNS);
$report->setOwner($billy);
$report->setFiltersStructure('1 and 2 or 3');
$report->setCurrencyConversionType(Report::CURRENCY_CONVERSION_TYPE_SPOT);
$report->setSpotConversionCurrencyCode('CAD');
$filter = new FilterForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
$filter->attributeIndexOrDerivedType = 'string';
$filter->value = 'aValue';
$filter->operator = 'equals';
$filter->availableAtRunTime = true;
$report->addFilter($filter);
$filter = new FilterForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
$filter->attributeIndexOrDerivedType = 'currencyValue';
$filter->value = 'aValue';
$filter->secondValue = 'bValue';
$filter->operator = 'between';
$filter->currencyIdForValue = '4';
$filter->availableAtRunTime = true;
$report->addFilter($filter);
$filter = new FilterForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
$filter->attributeIndexOrDerivedType = 'owner__User';
$filter->value = 'aValue';
$filter->stringifiedModelForValue = 'someName';
$filter->availableAtRunTime = false;
$report->addFilter($filter);
$filter = new FilterForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
$filter->attributeIndexOrDerivedType = 'createdDateTime';
$filter->value = 'aValue';
$filter->secondValue = 'bValue';
$filter->operator = null;
$filter->currencyIdForValue = null;
$filter->availableAtRunTime = true;
$filter->valueType = 'Between';
$report->addFilter($filter);
$groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
$groupBy->attributeIndexOrDerivedType = 'lastName';
$groupBy->axis = 'y';
$report->addGroupBy($groupBy);
$orderBy = new OrderByForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
$orderBy->attributeIndexOrDerivedType = 'url';
$orderBy->order = 'desc';
$report->addOrderBy($orderBy);
$displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
$displayAttribute->attributeIndexOrDerivedType = 'phone';
$displayAttribute->label = 'someNewLabel';
$report->addDisplayAttribute($displayAttribute);
$drillDownDisplayAttribute = new DrillDownDisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
$drillDownDisplayAttribute->attributeIndexOrDerivedType = 'firstName';
$drillDownDisplayAttribute->label = 'someNewLabel';
$report->addDrillDownDisplayAttribute($drillDownDisplayAttribute);
$savedReport = new SavedReport();
$this->assertNull($savedReport->serializedData);
SavedReportToReportAdapter::resolveReportToSavedReport($report, $savedReport);
$this->assertEquals('ReportsTestModule', $savedReport->moduleClassName);
$this->assertEquals('myFirstReport', $savedReport->name);
$this->assertEquals('aDescription', $savedReport->description);
$this->assertEquals(Report::TYPE_ROWS_AND_COLUMNS, $savedReport->type);
$this->assertEquals('1 and 2 or 3', $report->getFiltersStructure());
$this->assertTrue($savedReport->owner->isSame($billy));
$compareData = array('Filters' => array(array('availableAtRunTime' => true, 'currencyIdForValue' => null, 'value' => 'aValue', 'secondValue' => null, 'stringifiedModelForValue' => null, 'valueType' => null, 'attributeIndexOrDerivedType' => 'string', 'operator' => 'equals'), array('availableAtRunTime' => true, 'currencyIdForValue' => '4', 'value' => 'aValue', 'secondValue' => 'bValue', 'stringifiedModelForValue' => null, 'valueType' => null, 'attributeIndexOrDerivedType' => 'currencyValue', 'operator' => 'between'), array('availableAtRunTime' => false, 'currencyIdForValue' => null, 'value' => 'aValue', 'secondValue' => null, 'stringifiedModelForValue' => 'someName', 'valueType' => null, 'attributeIndexOrDerivedType' => 'owner__User', 'operator' => null), array('availableAtRunTime' => true, 'value' => 'aValue', 'secondValue' => 'bValue', 'stringifiedModelForValue' => null, 'valueType' => 'Between', 'attributeIndexOrDerivedType' => 'createdDateTime', 'operator' => null, 'currencyIdForValue' => null)), 'OrderBys' => array(array('order' => 'desc', 'attributeIndexOrDerivedType' => 'url')), 'GroupBys' => array(array('axis' => 'y', 'attributeIndexOrDerivedType' => 'lastName')), 'DisplayAttributes' => array(array('label' => 'someNewLabel', 'attributeIndexOrDerivedType' => 'phone', 'columnAliasName' => 'col0', 'queryOnly' => false, 'valueUsedAsDrillDownFilter' => false, 'madeViaSelectInsteadOfViaModel' => false)), 'DrillDownDisplayAttributes' => array(array('label' => 'someNewLabel', 'attributeIndexOrDerivedType' => 'firstName', 'columnAliasName' => 'col0', 'queryOnly' => false, 'valueUsedAsDrillDownFilter' => false, 'madeViaSelectInsteadOfViaModel' => false)));
$unserializedData = unserialize($savedReport->serializedData);
$this->assertEquals($compareData['Filters'], $unserializedData['Filters']);
$this->assertEquals($compareData['OrderBys'], $unserializedData['OrderBys']);
$this->assertEquals($compareData['GroupBys'], $unserializedData['GroupBys']);
$this->assertEquals($compareData['DisplayAttributes'], $unserializedData['DisplayAttributes']);
$this->assertEquals($compareData['DrillDownDisplayAttributes'], $unserializedData['DrillDownDisplayAttributes']);
$this->assertEquals('1 and 2 or 3', $unserializedData['filtersStructure']);
$this->assertEquals(Report::CURRENCY_CONVERSION_TYPE_SPOT, $unserializedData['currencyConversionType']);
$this->assertEquals('CAD', $unserializedData['spotConversionCurrencyCode']);
$saved = $savedReport->save();
$this->assertTrue($saved);
}
示例6: testGetDataWithNoRelationsSet
//.........这里部分代码省略.........
//for float summation
$displayAttribute9 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$displayAttribute9->attributeIndexOrDerivedType = 'float__Minimum';
$this->assertTrue($displayAttribute9->columnAliasName == 'col8');
$report->addDisplayAttribute($displayAttribute9);
$displayAttribute10 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$displayAttribute10->attributeIndexOrDerivedType = 'float__Maximum';
$this->assertTrue($displayAttribute10->columnAliasName == 'col9');
$report->addDisplayAttribute($displayAttribute10);
$displayAttribute11 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$displayAttribute11->attributeIndexOrDerivedType = 'float__Summation';
$this->assertTrue($displayAttribute11->columnAliasName == 'col10');
$report->addDisplayAttribute($displayAttribute11);
$displayAttribute12 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$displayAttribute12->attributeIndexOrDerivedType = 'float__Average';
$this->assertTrue($displayAttribute12->columnAliasName == 'col11');
$report->addDisplayAttribute($displayAttribute12);
//for integer summation
$displayAttribute13 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$displayAttribute13->attributeIndexOrDerivedType = 'integer__Minimum';
$this->assertTrue($displayAttribute13->columnAliasName == 'col12');
$report->addDisplayAttribute($displayAttribute13);
$displayAttribute14 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$displayAttribute14->attributeIndexOrDerivedType = 'integer__Maximum';
$this->assertTrue($displayAttribute14->columnAliasName == 'col13');
$report->addDisplayAttribute($displayAttribute14);
$displayAttribute15 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$displayAttribute15->attributeIndexOrDerivedType = 'integer__Summation';
$this->assertTrue($displayAttribute15->columnAliasName == 'col14');
$report->addDisplayAttribute($displayAttribute15);
$displayAttribute16 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$displayAttribute16->attributeIndexOrDerivedType = 'integer__Average';
$this->assertTrue($displayAttribute16->columnAliasName == 'col15');
$report->addDisplayAttribute($displayAttribute16);
//for currency summation
$displayAttribute17 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$displayAttribute17->attributeIndexOrDerivedType = 'currencyValue__Minimum';
$this->assertTrue($displayAttribute17->columnAliasName == 'col16');
$report->addDisplayAttribute($displayAttribute17);
$displayAttribute18 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$displayAttribute18->attributeIndexOrDerivedType = 'currencyValue__Maximum';
$this->assertTrue($displayAttribute18->columnAliasName == 'col17');
$report->addDisplayAttribute($displayAttribute18);
$displayAttribute19 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$displayAttribute19->attributeIndexOrDerivedType = 'currencyValue__Summation';
$this->assertTrue($displayAttribute19->columnAliasName == 'col18');
$report->addDisplayAttribute($displayAttribute19);
$displayAttribute20 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$displayAttribute20->attributeIndexOrDerivedType = 'currencyValue__Average';
$this->assertTrue($displayAttribute20->columnAliasName == 'col19');
$report->addDisplayAttribute($displayAttribute20);
$displayAttribute21 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$displayAttribute21->attributeIndexOrDerivedType = 'Count';
$this->assertTrue($displayAttribute21->columnAliasName == 'col20');
$report->addDisplayAttribute($displayAttribute21);
$groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$groupBy->attributeIndexOrDerivedType = 'firstName';
$report->addGroupBy($groupBy);
$groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$groupBy->attributeIndexOrDerivedType = 'lastName';
$groupBy->axis = 'y';
$report->addGroupBy($groupBy);
$dataProvider = new MatrixReportDataProvider($report);
$adapter = ReportToExportAdapterFactory::createReportToExportAdapter($report, $dataProvider);
$compareRowData = array(array(null, 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'Total'), array('Last Name', 'New Label For Date -(Max)', 'Date -(Min)', 'Date Time -(Max)', 'Date Time -(Min)', 'Created Date Time -(Max)', 'Created Date Time -(Min)', 'Modified Date Time -(Max)', 'Modified Date Time -(Min)', 'Float -(Min)', 'Float -(Max)', 'Float -(Sum)', 'Float -(Avg)', 'Integer -(Min)', 'Integer -(Max)', 'Integer -(Sum)', 'Integer -(Avg)', 'Currency Value -(Min)', 'Currency Value -(Min) Currency', 'Currency Value -(Max)', 'Currency Value -(Max) Currency', 'Currency Value -(Sum)', 'Currency Value -(Sum) Currency', 'Currency Value -(Avg)', 'Currency Value -(Avg) Currency', 'Count', 'New Label For Date -(Max)', 'Date -(Min)', 'Date Time -(Max)', 'Date Time -(Min)', 'Created Date Time -(Max)', 'Created Date Time -(Min)', 'Modified Date Time -(Max)', 'Modified Date Time -(Min)', 'Float -(Min)', 'Float -(Max)', 'Float -(Sum)', 'Float -(Avg)', 'Integer -(Min)', 'Integer -(Max)', 'Integer -(Sum)', 'Integer -(Avg)', 'Currency Value -(Min)', 'Currency Value -(Max)', 'Currency Value -(Sum)', 'Currency Value -(Avg)', 'Count'), array('xLast', '2013-02-14', '2013-02-12', '2013-02-14 23:15:00', '2013-02-12 10:15:00', $reportModelTestItem2->createdDateTime, $reportModelTestItem1->createdDateTime, $reportModelTestItem2->modifiedDateTime, $reportModelTestItem1->modifiedDateTime, '10.5', '200.5', '211', '105.5', '10', '1010', '1020', '510.0000', '100', 'Mixed Currency', '100', 'Mixed Currency', '200', 'Mixed Currency', '100', 'Mixed Currency', '2', '2013-02-14', '2013-02-12', '2013-02-14 23:15:00', '2013-02-12 10:15:00', $reportModelTestItem2->createdDateTime, $reportModelTestItem1->createdDateTime, $reportModelTestItem2->modifiedDateTime, $reportModelTestItem1->modifiedDateTime, '10.5', '200.5', '211', '105.5', '10', '1010', '1020', '510.0000', '100', '100', '200', '100', '2'), array('Total', '2013-02-14', '2013-02-12', '2013-02-14 23:15:00', '2013-02-12 10:15:00', $reportModelTestItem2->createdDateTime, $reportModelTestItem1->createdDateTime, $reportModelTestItem2->modifiedDateTime, $reportModelTestItem1->modifiedDateTime, '10.5', '200.5', '211', '105.5', '10', '1010', '1020', '510.0000', '100', null, '100', null, '200', null, '100', null, '2'));
$this->assertEmpty($adapter->getHeaderData());
$this->assertEquals($compareRowData, $adapter->getData());
$groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$groupBy->attributeIndexOrDerivedType = 'boolean';
$report->addGroupBy($groupBy);
$groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$groupBy->attributeIndexOrDerivedType = 'phone';
$groupBy->axis = 'y';
$report->addGroupBy($groupBy);
$dataProvider = new MatrixReportDataProvider($report);
$adapter = ReportToExportAdapterFactory::createReportToExportAdapter($report, $dataProvider);
$compareRowData = array(array(null, null, 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'xFirst', 'Total'), array('', '', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Yes', 'Total'), array('Last Name', 'Phone', 'New Label For Date -(Max)', 'Date -(Min)', 'Date Time -(Max)', 'Date Time -(Min)', 'Created Date Time -(Max)', 'Created Date Time -(Min)', 'Modified Date Time -(Max)', 'Modified Date Time -(Min)', 'Float -(Min)', 'Float -(Max)', 'Float -(Sum)', 'Float -(Avg)', 'Integer -(Min)', 'Integer -(Max)', 'Integer -(Sum)', 'Integer -(Avg)', 'Currency Value -(Min)', 'Currency Value -(Min) Currency', 'Currency Value -(Max)', 'Currency Value -(Max) Currency', 'Currency Value -(Sum)', 'Currency Value -(Sum) Currency', 'Currency Value -(Avg)', 'Currency Value -(Avg) Currency', 'Count', 'New Label For Date -(Max)', 'Date -(Min)', 'Date Time -(Max)', 'Date Time -(Min)', 'Created Date Time -(Max)', 'Created Date Time -(Min)', 'Modified Date Time -(Max)', 'Modified Date Time -(Min)', 'Float -(Min)', 'Float -(Max)', 'Float -(Sum)', 'Float -(Avg)', 'Integer -(Min)', 'Integer -(Max)', 'Integer -(Sum)', 'Integer -(Avg)', 'Currency Value -(Min)', 'Currency Value -(Max)', 'Currency Value -(Sum)', 'Currency Value -(Avg)', 'Count'), array('xLast', '7842151012', '2013-02-14', '2013-02-12', '2013-02-14 23:15:00', '2013-02-12 10:15:00', $reportModelTestItem2->createdDateTime, $reportModelTestItem1->createdDateTime, $reportModelTestItem2->modifiedDateTime, $reportModelTestItem1->modifiedDateTime, '10.5', '200.5', '211', '105.5', '10', '1010', '1020', '510.0000', '100', 'Mixed Currency', '100', 'Mixed Currency', '200', 'Mixed Currency', '100', 'Mixed Currency', '2', '2013-02-14', '2013-02-12', '2013-02-14 23:15:00', '2013-02-12 10:15:00', $reportModelTestItem2->createdDateTime, $reportModelTestItem1->createdDateTime, $reportModelTestItem2->modifiedDateTime, $reportModelTestItem1->modifiedDateTime, '10.5', '200.5', '211', '105.5', '10', '1010', '1020', '510.0000', '100', '100', '200', '100', '2'), array('Total', 'Total', '2013-02-14', '2013-02-12', '2013-02-14 23:15:00', '2013-02-12 10:15:00', $reportModelTestItem2->createdDateTime, $reportModelTestItem1->createdDateTime, $reportModelTestItem2->modifiedDateTime, $reportModelTestItem1->modifiedDateTime, '10.5', '200.5', '211', '105.5', '10', '1010', '1020', '510.0000', '100', null, '100', null, '200', null, '100', null, '2'));
$this->assertEmpty($adapter->getHeaderData());
$this->assertEquals($compareRowData, $adapter->getData());
//Test currency type is resolved
$report = new Report();
$report->setType(Report::TYPE_MATRIX);
$report->setModuleClassName('ReportsTestModule');
$report->setFiltersStructure('');
$report->setCurrencyConversionType(Report::CURRENCY_CONVERSION_TYPE_BASE);
$displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$displayAttribute->attributeIndexOrDerivedType = 'currencyValue__Summation';
$report->addDisplayAttribute($displayAttribute);
$groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$groupBy->attributeIndexOrDerivedType = 'firstName';
$report->addGroupBy($groupBy);
$groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$groupBy->attributeIndexOrDerivedType = 'lastName';
$groupBy->axis = 'y';
$report->addGroupBy($groupBy);
$dataProvider = new MatrixReportDataProvider($report);
$adapter = ReportToExportAdapterFactory::createReportToExportAdapter($report, $dataProvider);
$compareRowData = array(array(null, 'xFirst', 'xFirst', 'Total'), array('Last Name', 'Currency Value -(Sum)', 'Currency Value -(Sum) Currency', 'Currency Value -(Sum)', 'Currency Value -(Sum) Currency'), array('xLast', 200, 'USD', 200, 'USD'), array('Total', 200, null));
$this->assertEquals($compareRowData, $adapter->getData());
}
示例7: makeSimpleContactRowsAndColumnsReport
public static function makeSimpleContactRowsAndColumnsReport()
{
$report = new Report();
$report->setDescription('A test contact report');
$report->setModuleClassName('ContactsModule');
$report->setName('A rows and columns report');
$report->setType(Report::TYPE_ROWS_AND_COLUMNS);
$report->setOwner(Yii::app()->user->userModel);
$report->setCurrencyConversionType(Report::CURRENCY_CONVERSION_TYPE_BASE);
$report->setFiltersStructure('');
$displayAttribute = new DisplayAttributeForReportForm('ContactsModule', 'Contact', $report->getType());
$displayAttribute->attributeIndexOrDerivedType = 'lastName';
$report->addDisplayAttribute($displayAttribute);
$savedReport = new SavedReport();
SavedReportToReportAdapter::resolveReportToSavedReport($report, $savedReport);
$saved = $savedReport->save();
if (!$saved) {
throw new FailedToSaveModelException();
}
return $savedReport;
}