本文整理汇总了PHP中Report::addDisplayAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP Report::addDisplayAttribute方法的具体用法?PHP Report::addDisplayAttribute怎么用?PHP Report::addDisplayAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Report
的用法示例。
在下文中一共展示了Report::addDisplayAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testExportRelationAttributes
public function testExportRelationAttributes()
{
$report = new Report();
$report->setType(Report::TYPE_ROWS_AND_COLUMNS);
$report->setModuleClassName('EmailMessagesModule');
$report->setFiltersStructure('');
$emailMessage = new EmailMessage();
$emailMessage->owner = Yii::app()->user->userModel;
$emailMessage->subject = 'A test email';
$emailContent = new EmailMessageContent();
$emailContent->textContent = 'A test text message from Zurmo.';
$emailContent->htmlContent = 'A test text message from Zurmo.';
$emailMessage->content = $emailContent;
$sender = new EmailMessageSender();
$sender->fromAddress = 'super@zurmo.com';
$sender->fromName = 'super';
$sender->personsOrAccounts->add(Yii::app()->user->userModel);
$emailMessage->sender = $sender;
$recipient = new EmailMessageRecipient();
$recipient->toAddress = 'billy@joe.com';
$recipient->toName = 'Test Recipient';
$recipient->type = EmailMessageRecipient::TYPE_TO;
$emailMessage->recipients->add($recipient);
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_SENT);
$this->assertTrue($emailMessage->save());
$displayAttribute1 = new DisplayAttributeForReportForm('EmailMessagesModule', 'EmailMessage', Report::TYPE_ROWS_AND_COLUMNS);
$displayAttribute1->setModelAliasUsingTableAliasName('relatedModel');
$displayAttribute1->attributeIndexOrDerivedType = 'sender___User__personsOrAccounts__Inferred___firstName';
$report->addDisplayAttribute($displayAttribute1);
$displayAttribute2 = new DisplayAttributeForReportForm('EmailMessagesModule', 'EmailMessage', Report::TYPE_ROWS_AND_COLUMNS);
$displayAttribute2->setModelAliasUsingTableAliasName('relatedModel');
$displayAttribute2->attributeIndexOrDerivedType = 'sender___Contact__personsOrAccounts__Inferred___firstName';
$report->addDisplayAttribute($displayAttribute2);
$dataProvider = new RowsAndColumnsReportDataProvider($report);
$adapter = ReportToExportAdapterFactory::createReportToExportAdapter($report, $dataProvider);
$compareHeaderData = array('Sender >> Users >> First Name', 'Sender >> Contacts >> First Name');
$compareRowData = array(array('Clark', ''));
$this->assertEquals($compareHeaderData, $adapter->getHeaderData());
$this->assertEquals($compareRowData, $adapter->getData());
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:41,代码来源:EmailMessagesRowsAndColumnsReportToExportAdapterTest.php
示例2: testRunQueryAndGrandTotalsData
public function testRunQueryAndGrandTotalsData()
{
ContactTestHelper::createContactByNameForOwner('testContact', $this->super);
$report = new Report();
$report->setType(Report::TYPE_SUMMATION);
$report->setModuleClassName('ContactsModule');
$report->setFiltersStructure('');
$groupBy = new GroupByForReportForm('ContactsModule', 'Contact', Report::TYPE_SUMMATION);
$groupBy->attributeIndexOrDerivedType = 'createdDateTime__Day';
$report->addGroupBy($groupBy);
$displayAttribute = new DisplayAttributeForReportForm('ContactsModule', 'Contact', Report::TYPE_SUMMATION);
$displayAttribute->attributeIndexOrDerivedType = 'createdDateTime__Day';
$report->addDisplayAttribute($displayAttribute);
$dataProvider = new SummationReportDataProvider($report);
$this->assertEmpty($dataProvider->runQueryAndGrandTotalsData());
}
示例3: testSqlQueryWithLinkTypeSpecificOnRelatedModels
public function testSqlQueryWithLinkTypeSpecificOnRelatedModels()
{
$quote = DatabaseCompatibilityUtil::getQuote();
Yii::app()->user->userModel = User::getByUsername('super');
$reportModelTestItem2 = new ReportModelTestItem2();
$reportModelTestItem2->name = 'name';
$this->assertTrue($reportModelTestItem2->save());
$reportModelTestItem = new ReportModelTestItem();
$reportModelTestItem->lastName = 'lastName';
$reportModelTestItem->string = 'string';
$reportModelTestItem->hasOne = $reportModelTestItem2;
$this->assertTrue($reportModelTestItem->save());
$report = new Report();
$report->setType(Report::TYPE_ROWS_AND_COLUMNS);
$report->setModuleClassName('ReportsTest2Module');
$report->setFiltersStructure('');
$displayAttribute1 = new DisplayAttributeForReportForm('ReportsTest2Module', 'ReportModelTestItem2', Report::TYPE_ROWS_AND_COLUMNS);
$displayAttribute1->setModelAliasUsingTableAliasName('relatedModel');
$displayAttribute1->attributeIndexOrDerivedType = 'hasMany2___FullName';
$report->addDisplayAttribute($displayAttribute1);
$dataProvider = new RowsAndColumnsReportDataProvider($report);
$content = $dataProvider->makeSqlQueryForDisplay();
$compareContent = "select {$quote}reportmodeltestitem{$quote}.{$quote}id{$quote} reportmodeltestitemid " . "from {$quote}reportmodeltestitem2{$quote} " . "left join {$quote}reportmodeltestitem{$quote} on " . "{$quote}reportmodeltestitem{$quote}.{$quote}hasone_reportmodeltestitem2_id{$quote} " . "= {$quote}reportmodeltestitem2{$quote}.{$quote}id{$quote} limit 10 offset 0";
$this->assertEquals($compareContent, $content);
}
示例4: testExportReportWithMultiplePagesOfData
/**
* @depends testExportByModelIds
*/
public function testExportReportWithMultiplePagesOfData()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$numberOfUserNotifications = Notification::getCountByTypeAndUser('ExportProcessCompleted', Yii::app()->user->userModel);
$report = new Report();
$report->setType(Report::TYPE_ROWS_AND_COLUMNS);
$report->setModuleClassName('AccountsModule');
$report->setFiltersStructure('');
$displayAttribute = new DisplayAttributeForReportForm('AccountsModule', 'Account', Report::TYPE_ROWS_AND_COLUMNS);
$displayAttribute->setModelAliasUsingTableAliasName('model1');
$displayAttribute->attributeIndexOrDerivedType = 'name';
$report->addDisplayAttribute($displayAttribute);
$dataProvider = new RowsAndColumnsReportDataProvider($report);
$exportItem = new ExportItem();
$exportItem->isCompleted = 0;
$exportItem->exportFileType = 'csv';
$exportItem->exportFileName = 'rowAndColumnsTest2';
$exportItem->modelClassName = 'SavedReport';
$exportItem->serializedData = ExportUtil::getSerializedDataForExport($dataProvider);
$this->assertTrue($exportItem->save());
$id = $exportItem->id;
$exportItem->forget();
unset($exportItem);
//Delete queued jobs from test exportItems created above
Yii::app()->jobQueue->deleteAll();
ExportModule::$asynchronousPageSize = 2;
$job = new ExportJob();
$this->assertEquals(0, count(Yii::app()->jobQueue->getAll()));
$this->assertTrue($job->run());
$this->assertEquals(0, count(Yii::app()->jobQueue->getAll()));
$exportItem = ExportItem::getById($id);
$fileModel = $exportItem->exportFileModel;
$this->assertEquals(1, $exportItem->isCompleted);
$this->assertEquals(0, $exportItem->processOffset);
$this->assertEquals('csv', $exportItem->exportFileType);
$this->assertEquals('rowAndColumnsTest2', $exportItem->exportFileName);
$this->assertTrue($fileModel instanceof ExportFileModel);
$accounts = Account::getAll();
$headerData = array('Name');
$data = array();
foreach ($accounts as $account) {
$data[] = array($account->name);
}
$output = ExportItemToCsvFileUtil::export($data, $headerData, 'rowAndColumnsTest2.csv', false);
$this->assertEquals($output, $fileModel->fileContent->content);
// Check if user got notification message, and if its type is ExportProcessCompleted
$this->assertEquals($numberOfUserNotifications + 1, Notification::getCountByTypeAndUser('ExportProcessCompleted', Yii::app()->user->userModel));
//Matrix report should not paginate
$report = new Report();
$report->setType(Report::TYPE_MATRIX);
$report->setModuleClassName('AccountsModule');
$report->setFiltersStructure('');
$displayAttribute = new DisplayAttributeForReportForm('AccountsModule', 'Account', Report::TYPE_MATRIX);
$displayAttribute->setModelAliasUsingTableAliasName('model1');
$displayAttribute->attributeIndexOrDerivedType = 'Count';
$report->addDisplayAttribute($displayAttribute);
$groupBy = new GroupByForReportForm('AccountsModule', 'Account', Report::TYPE_MATRIX);
$groupBy->attributeIndexOrDerivedType = 'name';
$groupBy->axis = 'y';
$report->addGroupBy($groupBy);
$groupBy = new GroupByForReportForm('AccountsModule', 'Account', Report::TYPE_MATRIX);
$groupBy->attributeIndexOrDerivedType = 'officePhone';
$report->addGroupBy($groupBy);
$dataProvider = new MatrixReportDataProvider($report);
$exportItem = new ExportItem();
$exportItem->isCompleted = 0;
$exportItem->exportFileType = 'csv';
$exportItem->exportFileName = 'matrixTest1';
$exportItem->modelClassName = 'SavedReport';
$exportItem->serializedData = ExportUtil::getSerializedDataForExport($dataProvider);
$this->assertTrue($exportItem->save());
$id = $exportItem->id;
$exportItem->forget();
unset($exportItem);
//Delete queued jobs from test exportItems created above
Yii::app()->jobQueue->deleteAll();
ExportModule::$asynchronousPageSize = 2;
$job = new ExportJob();
$this->assertTrue($job->run());
$exportItem = ExportItem::getById($id);
$fileModel = $exportItem->exportFileModel;
$this->assertEquals(1, $exportItem->isCompleted);
$this->assertEquals(0, $exportItem->processOffset);
$this->assertEquals('csv', $exportItem->exportFileType);
$this->assertEquals('matrixTest1', $exportItem->exportFileName);
$this->assertTrue($fileModel instanceof ExportFileModel);
$fileContent = $fileModel->fileContent->content;
$this->assertContains('Test Account', $fileContent);
$this->assertContains('Test Account 2', $fileContent);
$this->assertContains('Test Account 3', $fileContent);
$this->assertContains('Test Account 4', $fileContent);
// Check if user got notification message, and if its type is ExportProcessCompleted
$this->assertEquals($numberOfUserNotifications + 2, Notification::getCountByTypeAndUser('ExportProcessCompleted', Yii::app()->user->userModel));
}
示例5: testViaSelectAndViaModelTogether
public function testViaSelectAndViaModelTogether()
{
$reportModelTestItem = new ReportModelTestItem();
$reportModelTestItem->string = 'string';
$reportModelTestItem->lastName = 'lastName';
$reportModelTestItem->integer = 9000;
$reportModelTestItem->boolean = true;
$this->assertTrue($reportModelTestItem->save());
$report = new Report();
$report->setType(Report::TYPE_SUMMATION);
$report->setModuleClassName('ReportsTestModule');
$report->setFiltersStructure('');
//viaSelect attribute
$displayAttribute1 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
$displayAttribute1->attributeIndexOrDerivedType = 'integer__Minimum';
$displayAttribute1->madeViaSelectInsteadOfViaModel = true;
$this->assertTrue($displayAttribute1->columnAliasName == 'col0');
$report->addDisplayAttribute($displayAttribute1);
//viaModel attribute
$reportModelTestItem->boolean = true;
$displayAttribute2 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
$displayAttribute2->setModelAliasUsingTableAliasName('model1');
$displayAttribute2->attributeIndexOrDerivedType = 'boolean';
$report->addDisplayAttribute($displayAttribute2);
$dataProvider = new SummationReportDataProvider($report);
$adapter = ReportToExportAdapterFactory::createReportToExportAdapter($report, $dataProvider);
$compareHeaderData = array('Integer -(Min)', 'Boolean');
$compareRowData = array(array(9000, true), array('Total'));
$this->assertEquals($compareHeaderData, $adapter->getHeaderData());
$this->assertEquals($compareRowData, $adapter->getData());
$reportModelTestItem->delete();
}
示例6: 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');
}
示例7: testGetAvailableAttributesForSummationOrderBysThatAreDisplayCalculations
/**
* @depends testGetAvailableAttributesForSummationOrderBys
*/
public function testGetAvailableAttributesForSummationOrderBysThatAreDisplayCalculations()
{
//You can only order what is grouped on or a display calculation attribute
$model = new ReportModelTestItem();
$rules = new ReportsTestReportRules();
$report = new Report();
$report->setType(Report::TYPE_SUMMATION);
$report->setModuleClassName('ReportsTestModule');
$adapter = new ModelRelationsAndAttributesToSummationReportAdapter($model, $rules, $report->getType());
$attributes = $adapter->getAttributesForOrderBys($report->getGroupBys(), $report->getDisplayAttributes());
$this->assertEquals(0, count($attributes));
$displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
$this->assertNull($displayAttribute->label);
$displayAttribute->attributeIndexOrDerivedType = 'createdDateTime__Minimum';
$report->addDisplayAttribute($displayAttribute);
$adapter = new ModelRelationsAndAttributesToSummationReportAdapter($model, $rules, $report->getType());
$attributes = $adapter->getAttributesForOrderBys($report->getGroupBys(), $report->getDisplayAttributes());
$this->assertEquals(1, count($attributes));
$this->assertTrue(isset($attributes['createdDateTime__Minimum']));
$compareData = array('label' => 'Created Date Time -(Min)');
$this->assertEquals($compareData, $attributes['createdDateTime__Minimum']);
$displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
$this->assertNull($displayAttribute->label);
$displayAttribute->attributeIndexOrDerivedType = 'integer__Minimum';
$report->addDisplayAttribute($displayAttribute);
$adapter = new ModelRelationsAndAttributesToSummationReportAdapter($model, $rules, $report->getType());
$attributes = $adapter->getAttributesForOrderBys($report->getGroupBys(), $report->getDisplayAttributes());
$this->assertEquals(2, count($attributes));
$this->assertTrue(isset($attributes['integer__Minimum']));
$compareData = array('label' => 'Integer -(Min)');
$this->assertEquals($compareData, $attributes['integer__Minimum']);
//This should not add because we are at the wrong point in the chain
$displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
$this->assertNull($displayAttribute->label);
$displayAttribute->attributeIndexOrDerivedType = 'hasOne___createdDateTime__Minimum';
$report->addDisplayAttribute($displayAttribute);
$adapter = new ModelRelationsAndAttributesToSummationReportAdapter($model, $rules, $report->getType());
$attributes = $adapter->getAttributesForOrderBys($report->getGroupBys(), $report->getDisplayAttributes());
$this->assertEquals(2, count($attributes));
$this->assertFalse(isset($attributes['hasOne___createdDateTime__Minimum']));
}
示例8: 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;
}
示例9: testCalculateTotalGroupingsCount
public function testCalculateTotalGroupingsCount()
{
Yii::app()->user->userModel = User::getByUsername('super');
$report = new Report();
$report->setType(Report::TYPE_MATRIX);
$report->setModuleClassName('ReportsTestModule');
$report->setFiltersStructure('');
$displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_MATRIX);
$displayAttribute->attributeIndexOrDerivedType = 'integer__Maximum';
$report->addDisplayAttribute($displayAttribute);
$reportDataProvider = new MatrixReportDataProvider($report);
$count = $reportDataProvider->calculateTotalGroupingsCount();
$this->assertEquals(0, $count);
}
示例10: 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);
}
示例11: testGetLeadingHeadersDataFromMatrixReportDataProviderWithALinkableAttribute
public function testGetLeadingHeadersDataFromMatrixReportDataProviderWithALinkableAttribute()
{
$reportModelTestItem2 = new ReportModelTestItem2();
$reportModelTestItem2->name = 'report name';
$reportModelTestItem2->phone = '123456789';
$this->assertTrue($reportModelTestItem2->save());
$reportModelTestItem2 = new ReportModelTestItem2();
$reportModelTestItem2->name = 'report name';
$reportModelTestItem2->phone = '987654321';
$this->assertTrue($reportModelTestItem2->save());
$report = new Report();
$report->setType(Report::TYPE_MATRIX);
$report->setModuleClassName('ReportsTest2Module');
$report->setFiltersStructure('');
$displayAttribute = new DisplayAttributeForReportForm('ReportsTest2Module', 'ReportModelTestItem2', Report::TYPE_MATRIX);
$displayAttribute->attributeIndexOrDerivedType = 'Count';
$report->addDisplayAttribute($displayAttribute);
$groupBy = new GroupByForReportForm('ReportsTest2Module', 'ReportModelTestItem2', Report::TYPE_MATRIX);
$groupBy->attributeIndexOrDerivedType = 'phone';
$report->addGroupBy($groupBy);
$groupBy = new GroupByForReportForm('ReportsTest2Module', 'ReportModelTestItem2', Report::TYPE_MATRIX);
$groupBy->attributeIndexOrDerivedType = 'name';
$groupBy->axis = 'y';
$report->addGroupBy($groupBy);
$dataProvider = new MatrixReportDataProvider($report);
$adapter = ReportToExportAdapterFactory::createReportToExportAdapter($report, $dataProvider);
$compareRowData = array(array(null, '123456789', '987654321', 'Total'), array('Name', 'Count', 'Count', 'Count'), array('report name', 1, 1, 2), array('Total', 1, 1));
$this->assertEmpty($adapter->getHeaderData());
$this->assertEquals($compareRowData, $adapter->getData());
$report = new Report();
$report->setType(Report::TYPE_MATRIX);
$report->setModuleClassName('ReportsTest2Module');
$report->setFiltersStructure('');
$displayAttribute = new DisplayAttributeForReportForm('ReportsTest2Module', 'ReportModelTestItem2', Report::TYPE_MATRIX);
$displayAttribute->attributeIndexOrDerivedType = 'Count';
$report->addDisplayAttribute($displayAttribute);
$groupBy = new GroupByForReportForm('ReportsTest2Module', 'ReportModelTestItem2', Report::TYPE_MATRIX);
$groupBy->attributeIndexOrDerivedType = 'name';
$report->addGroupBy($groupBy);
$groupBy = new GroupByForReportForm('ReportsTest2Module', 'ReportModelTestItem2', 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, 'report name', 'Total'), array('Phone', 'Count', 'Count'), array('123456789', 1, 1), array('987654321', 1, 1), array('Total', 2));
$this->assertEmpty($adapter->getHeaderData());
$this->assertEquals($compareRowData, $adapter->getData());
}
示例12: testGetAttributesForChartRange
/**
* @depends testGetAttributesForChartSeries
*/
public function testGetAttributesForChartRange()
{
$model = new ReportModelTestItem();
$rules = new ReportsTestReportRules();
$report = new Report();
$report->setType(Report::TYPE_SUMMATION);
$report->setModuleClassName('ReportsTestModule');
$adapter = new ModelRelationsAndAttributesToSummationReportAdapter($model, $rules, $report->getType());
$attributes = $adapter->getAttributesForChartRange($report->getDisplayAttributes());
$this->assertEquals(0, count($attributes));
//Add a display attribute that cannot be a range
$displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
$displayAttribute->attributeIndexOrDerivedType = 'dropDown';
$report->setModuleClassName('ReportsTestModule');
$report->addDisplayAttribute($displayAttribute);
$attributes = $adapter->getAttributesForChartRange($report->getDisplayAttributes());
$this->assertEquals(0, count($attributes));
//Add a display attribute that can be a range
$displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
$displayAttribute->attributeIndexOrDerivedType = 'float__Summation';
$report->setModuleClassName('ReportsTestModule');
$report->addDisplayAttribute($displayAttribute);
$attributes = $adapter->getAttributesForChartRange($report->getDisplayAttributes());
$this->assertEquals(1, count($attributes));
$compareData = array('label' => 'Float -(Sum)');
$this->assertEquals($compareData, $attributes['float__Summation']);
//Add a second display attribute that can be a range
$displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
$displayAttribute->attributeIndexOrDerivedType = 'float__Average';
$report->setModuleClassName('ReportsTestModule');
$report->addDisplayAttribute($displayAttribute);
$attributes = $adapter->getAttributesForChartRange($report->getDisplayAttributes());
$this->assertEquals(2, count($attributes));
$compareData = array('label' => 'Float -(Sum)');
$this->assertEquals($compareData, $attributes['float__Summation']);
$compareData = array('label' => 'Float -(Avg)');
$this->assertEquals($compareData, $attributes['float__Average']);
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:41,代码来源:ModelRelationsAndAttributesToSummationReportAdapterTest.php
示例13: testFiltersWorksOnAccountsAndNoteReport
/**
* Running a report centered on notes, with a display attribute from notes and accounts. With a created
* by dateTime filter should produce proper query filter notes.
* This test just makes sure the sql is structured properly
*/
public function testFiltersWorksOnAccountsAndNoteReport()
{
$report = new Report();
$report->setType(Report::TYPE_ROWS_AND_COLUMNS);
$filter = new FilterForReportForm('NotesModule', 'Note', $report->getType());
$filter->attributeIndexOrDerivedType = 'createdDateTime';
$filter->valueType = MixedDateTypesSearchFormAttributeMappingRules::TYPE_BETWEEN;
$filter->value = '1991-05-05';
$filter->secondValue = '1991-06-05';
$filter->availableAtRunTime = true;
$report->addFilter($filter);
$report->setFiltersStructure('1');
$report->setModuleClassName('NotesModule');
$displayAttribute = new DisplayAttributeForReportForm('NotesModule', 'Note', $report->getType());
$displayAttribute->attributeIndexOrDerivedType = 'description';
$report->addDisplayAttribute($displayAttribute);
$displayAttribute2 = new DisplayAttributeForReportForm('NotesModule', 'Note', $report->getType());
$displayAttribute2->attributeIndexOrDerivedType = 'Account__activityItems__Inferred___name';
$report->addDisplayAttribute($displayAttribute2);
$reportDataProvider = new RowsAndColumnsReportDataProvider($report);
$sql = $reportDataProvider->makeSqlQueryForDisplay();
$q = DatabaseCompatibilityUtil::getQuote();
$compareSql = "select {$q}note{$q}.{$q}id{$q} noteid, {$q}account{$q}.{$q}id{$q} accountid " . "from ({$q}note{$q}, {$q}activity{$q}, {$q}ownedsecurableitem{$q} ownedsecurableitem1, {$q}securableitem{$q} securableitem1, {$q}item{$q} item1) " . "left join {$q}activity_item{$q} on {$q}activity_item{$q}.{$q}activity_id{$q} = {$q}activity{$q}.{$q}id{$q} " . "left join {$q}item{$q} on {$q}item{$q}.{$q}id{$q} = {$q}activity_item{$q}.{$q}item_id{$q} " . "left join {$q}securableitem{$q} on {$q}securableitem{$q}.{$q}item_id{$q} = {$q}item{$q}.{$q}id{$q} " . "left join {$q}ownedsecurableitem{$q} on {$q}ownedsecurableitem{$q}.{$q}securableitem_id{$q} = {$q}securableitem{$q}.{$q}id{$q} " . "left join {$q}account{$q} on {$q}account{$q}.{$q}ownedsecurableitem_id{$q} = {$q}ownedsecurableitem{$q}.{$q}id{$q} " . "where ((({$q}item1{$q}.{$q}createddatetime{$q} >= '1991-05-05 00:00:00') " . "and ({$q}item1{$q}.{$q}createddatetime{$q} <= '1991-06-05 23:59:59'))) " . "and {$q}activity{$q}.{$q}id{$q} = {$q}note{$q}.{$q}activity_id{$q} " . "and {$q}ownedsecurableitem1{$q}.{$q}id{$q} = {$q}activity{$q}.{$q}ownedsecurableitem_id{$q} " . "and {$q}securableitem1{$q}.{$q}id{$q} = {$q}ownedsecurableitem1{$q}.{$q}securableitem_id{$q} " . "and {$q}item1{$q}.{$q}id{$q} = {$q}securableitem1{$q}.{$q}item_id{$q} limit 10 offset 0";
$this->assertEquals($compareSql, $sql);
}
示例14: testGetDataStacked
public function testGetDataStacked()
{
Yii::app()->user->userModel = User::getByUsername('super');
$data = array(1 => array(ReportDataProviderToAmChartMakerAdapter::FIRST_SERIES_VALUE . 0 => 500.42134), 2 => array(ReportDataProviderToAmChartMakerAdapter::SECOND_SERIES_VALUE . 0 => 32));
$secondSeriesValueData = array(0);
$secondSeriesDisplayLabels = array();
$secondSeriesValueCount = 5;
$chart = new ChartForReportForm();
$chart->type = 'StackedBar3D';
$chart->firstSeries = 'dropDown';
$chart->firstRange = 'float__Summation';
$chart->secondSeries = 'radioDropDown';
$chart->secondRange = 'integer__Summation';
$report = new Report();
$report->setChart($chart);
$displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
$displayAttribute->attributeIndexOrDerivedType = 'float__Summation';
$report->addDisplayAttribute($displayAttribute);
$displayAttribute2 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
$displayAttribute2->attributeIndexOrDerivedType = 'integer__Summation';
$report->addDisplayAttribute($displayAttribute2);
$adapter = new ReportDataProviderToAmChartMakerAdapter($report, $data, $secondSeriesValueData, $secondSeriesDisplayLabels, $secondSeriesValueCount);
$compareData = array(1 => array('FirstSeriesValue0' => 500.42134, 'FirstSeriesFormattedValue0' => 500.421), 2 => array('SecondSeriesValue0' => 32, 'SecondSeriesFormattedValue0' => 32));
$this->assertEquals($compareData, $adapter->getData());
//todo: more coverage needed. date, dateTime, string, and currency
}
示例15: testGetDataWithNoRelationsSet
public function testGetDataWithNoRelationsSet()
{
$values = array('Test1', 'Test2', 'Test3', 'Sample', 'Demo');
$customFieldData = CustomFieldData::getByName('ReportTestDropDown');
$customFieldData->serializedData = serialize($values);
$saved = $customFieldData->save();
$this->assertTrue($saved);
//for fullname attribute (derived attribute)
$reportModelTestItem1 = new ReportModelTestItem();
$reportModelTestItem1->firstName = 'xFirst';
$reportModelTestItem1->lastName = 'xLast';
$reportModelTestItem1->boolean = true;
$reportModelTestItem1->date = '2013-02-12';
$reportModelTestItem1->dateTime = '2013-02-12 10:15:00';
$reportModelTestItem1->float = 10.5;
$reportModelTestItem1->integer = 10;
$reportModelTestItem1->phone = '7842151012';
$reportModelTestItem1->string = 'xString';
$reportModelTestItem1->textArea = 'xtextAreatest';
$reportModelTestItem1->url = 'http://www.test.com';
$reportModelTestItem1->dropDown->value = $values[1];
$currencies = Currency::getAll();
$currencyValue = new CurrencyValue();
$currencyValue->value = 100;
$currencyValue->currency = $currencies[0];
$this->assertEquals('USD', $currencyValue->currency->code);
$reportModelTestItem1->currencyValue = $currencyValue;
$reportModelTestItem1->primaryAddress->street1 = 'someString';
$reportModelTestItem1->primaryEmail->emailAddress = "test@someString.com";
$customFieldValue = new CustomFieldValue();
$customFieldValue->value = 'Multi 1';
$reportModelTestItem1->multiDropDown->values->add($customFieldValue);
$customFieldValue = new CustomFieldValue();
$customFieldValue->value = 'Multi 2';
$reportModelTestItem1->multiDropDown->values->add($customFieldValue);
$customFieldValue = new CustomFieldValue();
$customFieldValue->value = 'Cloud 2';
$reportModelTestItem1->tagCloud->values->add($customFieldValue);
$customFieldValue = new CustomFieldValue();
$customFieldValue->value = 'Cloud 3';
$reportModelTestItem1->tagCloud->values->add($customFieldValue);
$reportModelTestItem1->radioDropDown->value = $values[1];
$reportModelTestItem7 = new ReportModelTestItem7();
$reportModelTestItem7->name = 'someName';
$reportModelTestItem1->likeContactState = $reportModelTestItem7;
$reportModelTestItem1->owner = Yii::app()->user->userModel;
$saved = $reportModelTestItem1->save();
$this->assertTrue($saved);
$reportModelTestItem2 = new ReportModelTestItem();
$reportModelTestItem2->firstName = 'xFirst';
$reportModelTestItem2->lastName = 'xLast';
$reportModelTestItem2->boolean = true;
$reportModelTestItem2->date = '2013-02-14';
$reportModelTestItem2->dateTime = '2013-02-14 23:15:00';
$reportModelTestItem2->float = 200.5;
$reportModelTestItem2->integer = 1010;
$reportModelTestItem2->phone = '7842151012';
$reportModelTestItem2->string = 'xString';
$reportModelTestItem2->textArea = 'xtextAreatest';
$reportModelTestItem2->url = 'http://www.test.com';
$reportModelTestItem2->dropDown->value = $values[1];
$reportModelTestItem2->currencyValue = $currencyValue;
$reportModelTestItem2->primaryAddress->street1 = 'someString';
$reportModelTestItem2->primaryEmail->emailAddress = "test@someString.com";
$reportModelTestItem2->multiDropDown->values->add($customFieldValue);
$reportModelTestItem2->tagCloud->values->add($customFieldValue);
$reportModelTestItem2->radioDropDown->value = $values[1];
$reportModelTestItem2->likeContactState = $reportModelTestItem7;
$reportModelTestItem2->owner = Yii::app()->user->userModel;
$saved = $reportModelTestItem2->save();
$this->assertTrue($saved);
$report = new Report();
$report->setType(Report::TYPE_SUMMATION);
$report->setModuleClassName('ReportsTestModule');
$report->setFiltersStructure('');
//for date summation
$displayAttribute1 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
$displayAttribute1->attributeIndexOrDerivedType = 'date__Maximum';
$displayAttribute1->madeViaSelectInsteadOfViaModel = true;
$this->assertTrue($displayAttribute1->columnAliasName == 'col0');
$report->addDisplayAttribute($displayAttribute1);
$displayAttribute2 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
$displayAttribute2->attributeIndexOrDerivedType = 'date__Minimum';
$displayAttribute2->madeViaSelectInsteadOfViaModel = true;
$this->assertTrue($displayAttribute2->columnAliasName == 'col1');
$report->addDisplayAttribute($displayAttribute2);
//for dateTime summation
$displayAttribute3 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
$displayAttribute3->attributeIndexOrDerivedType = 'dateTime__Maximum';
$displayAttribute3->madeViaSelectInsteadOfViaModel = true;
$this->assertTrue($displayAttribute3->columnAliasName == 'col2');
$report->addDisplayAttribute($displayAttribute3);
$displayAttribute4 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
$displayAttribute4->attributeIndexOrDerivedType = 'dateTime__Minimum';
$displayAttribute4->madeViaSelectInsteadOfViaModel = true;
$this->assertTrue($displayAttribute4->columnAliasName == 'col3');
$report->addDisplayAttribute($displayAttribute4);
//for createdDateTime summation
$displayAttribute5 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
$displayAttribute5->attributeIndexOrDerivedType = 'createdDateTime__Maximum';
//.........这里部分代码省略.........