本文整理汇总了PHP中Report::setFiltersStructure方法的典型用法代码示例。如果您正苦于以下问题:PHP Report::setFiltersStructure方法的具体用法?PHP Report::setFiltersStructure怎么用?PHP Report::setFiltersStructure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Report
的用法示例。
在下文中一共展示了Report::setFiltersStructure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeReportBySavedCalendar
/**
* @param $savedCalendar
* @return Report
*/
public static function makeReportBySavedCalendar(SavedCalendar $savedCalendar)
{
$report = new Report();
if ($savedCalendar->id > 0) {
$report->setId((int) $savedCalendar->id);
}
$report->setDescription($savedCalendar->description);
if ($savedCalendar->moduleClassName != null) {
$report->setModuleClassName($savedCalendar->moduleClassName);
}
if ($savedCalendar->name != null) {
$report->setName($savedCalendar->name);
}
$report->setOwner($savedCalendar->owner);
$report->setType(Report::TYPE_ROWS_AND_COLUMNS);
$explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($savedCalendar);
$report->setExplicitReadWriteModelPermissions($explicitReadWriteModelPermissions);
if ($savedCalendar->serializedData != null) {
$unserializedData = unserialize($savedCalendar->serializedData);
if (isset($unserializedData['filtersStructure'])) {
$report->setFiltersStructure($unserializedData['filtersStructure']);
}
CalendarUtil::makeComponentFormAndPopulateReportFromData($unserializedData[ComponentForReportForm::TYPE_FILTERS], $report, 'Filter');
}
return $report;
}
示例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: 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
示例4: 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;
}
示例5: 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);
}
示例6: resolveFiltersStructure
/**
* Resolve filters structure
* @param array $data
* @param Report $report
*/
public static function resolveFiltersStructure($data, Report $report)
{
if (isset($data['filtersStructure'])) {
$report->setFiltersStructure($data['filtersStructure']);
}
}
示例7: 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);
}
示例8: 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));
}
示例9: 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();
}
示例10: 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');
}
示例11: 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;
}
示例12: 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);
}
示例13: 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());
}
示例14: 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);
}
示例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';
//.........这里部分代码省略.........