本文整理汇总了PHP中Report::setModuleClassName方法的典型用法代码示例。如果您正苦于以下问题:PHP Report::setModuleClassName方法的具体用法?PHP Report::setModuleClassName怎么用?PHP Report::setModuleClassName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Report
的用法示例。
在下文中一共展示了Report::setModuleClassName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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']);
}
self::resolveFiltersStructure($data, $report);
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);
}
示例2: 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;
}
示例3: 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());
}
示例4: 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
示例5: 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;
}
示例6: 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);
}
示例7: testWhereNestedGroupBysAndGettingDataForOrderBy
/**
* @depends testNextedGroupBys
*/
public function testWhereNestedGroupBysAndGettingDataForOrderBy()
{
$report = new Report();
$report->setType(Report::TYPE_SUMMATION);
$groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
$groupBy->attributeIndexOrDerivedType = 'hasOne___name';
$groupBy->axis = 'x';
$report->addGroupBy($groupBy);
$report->setModuleClassName('ReportsTestModule');
$adapter = new ReportRelationsAndAttributesToTreeAdapter($report, ComponentForReportForm::TYPE_ORDER_BYS);
$data = $adapter->getData(ComponentForReportForm::TYPE_ORDER_BYS . '_hasOne');
$this->assertEquals('OrderBys_hasOne___name', $data[0]['id']);
$this->assertEquals('OrderBys_hasOne___createdByUser', $data[1]['id']);
$this->assertEquals('OrderBys_hasOne___hasMany3', $data[2]['id']);
$this->assertEquals('OrderBys_hasOne___modifiedByUser', $data[3]['id']);
$this->assertEquals('OrderBys_hasOne___owner', $data[4]['id']);
}
示例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: 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);
}
示例10: 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();
}
示例11: testRemoveRuntimeFilters
public function testRemoveRuntimeFilters()
{
$report = new Report();
$report->setModuleClassName('ContactsModule');
$report->setType(Report::TYPE_ROWS_AND_COLUMNS);
//A filter available at runtime
$filter = new FilterForReportForm('AccountsModule', 'Account', $report->getType());
$filter->availableAtRunTime = true;
$filter->attributeIndexOrDerivedType = 'officePhone';
$filter->value = 'aValue';
$filter->operator = 'equals';
$report->addFilter($filter);
//A filter not available at runtime
$filter2 = new FilterForReportForm('AccountsModule', 'Account', $report->getType());
$filter2->availableAtRunTime = false;
$filter2->attributeIndexOrDerivedType = 'contacts___lastName';
$filter2->value = 'aValue';
$filter2->operator = 'equals';
$report->addFilter($filter2);
$report->removeRuntimeFilters();
$filters = $report->getFilters();
$this->assertCount(1, $filters);
$this->assertEquals($filter2, $filters[0]);
}
示例12: 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);
}
示例13: testGetAllReportableRelationsAsANonElevatedUser
/**
* Sally cannot access notes, tasks, or contacts. User is always accessible regardless of right to access
*/
public function testGetAllReportableRelationsAsANonElevatedUser()
{
Yii::app()->user->userModel = User::getByUsername('sally');
$model = new Account();
$rules = new AccountsReportRules();
$report = new Report();
$report->setType(Report::TYPE_ROWS_AND_COLUMNS);
$report->setModuleClassName('AccountsModule');
$adapter = new ModelRelationsAndAttributesToReportAdapter($model, $rules, $report->getType());
$relations = $adapter->getSelectableRelationsData();
$relations = $adapter->getSelectableRelationsDataResolvedForUserAccess(Yii::app()->user->userModel, $relations);
$this->assertEquals(9, count($relations));
$compareData = array('label' => 'Billing Address');
$this->assertEquals($compareData, $relations['billingAddress']);
$compareData = array('label' => 'Created By User');
$this->assertEquals($compareData, $relations['createdByUser']);
$compareData = array('label' => 'Meetings');
$this->assertEquals($compareData, $relations['meetings']);
$compareData = array('label' => 'Modified By User');
$this->assertEquals($compareData, $relations['modifiedByUser']);
$compareData = array('label' => 'Opportunities');
$this->assertEquals($compareData, $relations['opportunities']);
$compareData = array('label' => 'Owner');
$this->assertEquals($compareData, $relations['owner']);
$compareData = array('label' => 'Primary Email');
$this->assertEquals($compareData, $relations['primaryEmail']);
$compareData = array('label' => 'Shipping Address');
$this->assertEquals($compareData, $relations['shippingAddress']);
$compareData = array('label' => 'Secondary Email');
$this->assertEquals($compareData, $relations['secondaryEmail']);
}
示例14: 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;
}
示例15: 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');
}