/**
  * @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;
 }
 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());
 }
 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 = '*****@*****.**';
     $sender->fromName = 'super';
     $sender->personsOrAccounts->add(Yii::app()->user->userModel);
     $emailMessage->sender = $sender;
     $recipient = new EmailMessageRecipient();
     $recipient->toAddress = '*****@*****.**';
     $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());
 }
 /**
  * @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;
 }
Exemplo n.º 5
0
 /**
  * Log a message
  * @param bool $success
  * @param string $msg A message to you ho... :)
  */
 public function report($success, $msg)
 {
     $report = new Report();
     $report->setType($this->_type)->setSuccess($success)->setMsg($msg);
     $this->_reports[] = $report;
 }
 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;
 }
 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');
 }
Exemplo n.º 8
0
 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]);
 }
 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);
 }
 protected function resolveSavedReportAndReportByPostData(array $postData, &$savedReport, &$report, $type, $id = null, $isBeingCopied = false)
 {
     if ($id == null) {
         $this->resolveCanCurrentUserAccessReports();
         $savedReport = new SavedReport();
         $report = new Report();
         $report->setType($type);
     } elseif ($isBeingCopied) {
         $savedReport = new SavedReport();
         $oldReport = SavedReport::getById(intval($id));
         ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($oldReport);
         SavedReportCopyModelUtil::copy($oldReport, $savedReport);
         $report = SavedReportToReportAdapter::makeReportBySavedReport($savedReport);
     } else {
         $savedReport = SavedReport::getById(intval($id));
         ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($savedReport);
         $report = SavedReportToReportAdapter::makeReportBySavedReport($savedReport);
     }
     DataToReportUtil::resolveReportByWizardPostData($report, $postData, ReportToWizardFormAdapter::getFormClassNameByType($type));
 }
 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);
 }
 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);
 }
Exemplo n.º 13
0
 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');
 }
 /**
  * @depends testResolveRealAttributeName
  */
 public function testGetCalculationOrModifierType()
 {
     $model = new ReportModelTestItem();
     $rules = new ReportsTestReportRules();
     //ReportsTestModule rules
     $report = new Report();
     $report->setType(Report::TYPE_SUMMATION);
     $report->setModuleClassName('ReportsTestModule');
     $adapter = new ModelRelationsAndAttributesToSummationReportAdapter($model, $rules, $report->getType());
     $this->assertEquals('Maximum', $adapter->getCalculationOrModifierType('integer__Maximum'));
     $this->assertEquals('something', $adapter->getCalculationOrModifierType('something'));
 }
 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());
 }
 /**
  * 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);
 }
 public function testDateTimeConvertsValueTypeToNullWhenNeeded()
 {
     $filter = new FilterForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_ROWS_AND_COLUMNS);
     $filter->attributeIndexOrDerivedType = 'dateTime';
     $filter->value = '2011-05-05';
     $filter->valueType = MixedDateTypesSearchFormAttributeMappingRules::TYPE_ON;
     $report = new Report();
     $report->setType(Report::TYPE_ROWS_AND_COLUMNS);
     $report->setModuleClassName('ReportsTestModule');
     $report->addFilter($filter);
     $stickyData = array();
     $stickyData[ComponentForReportForm::TYPE_FILTERS][] = array('valueType' => MixedDateTypesSearchFormAttributeMappingRules::TYPE_TODAY, 'value' => '');
     StickyReportUtil::resolveStickyDataToReport($report, $stickyData);
     $filters = $report->getFilters();
     $this->assertCount(1, $filters);
     $this->assertEquals(MixedDateTypesSearchFormAttributeMappingRules::TYPE_TODAY, $filters[0]->valueType);
     $this->assertNull(null, $filters[0]->value);
 }
Exemplo n.º 18
0
 /**
  * Resolve report by saved calendar post data.
  * @param string $type
  * @param int $id
  * @param array $postData
  * @return Report
  */
 public static function resolveReportBySavedCalendarPostData($type, $id = null, $postData)
 {
     assert('is_string($type)');
     assert('is_array($postData)');
     if ($id == null) {
         $report = new Report();
         $report->setType($type);
     } else {
         $savedCalendar = SavedCalendar::getById(intval($id));
         ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($savedCalendar);
         $report = SavedCalendarToReportAdapter::makeReportBySavedCalendar($savedCalendar);
     }
     if (isset($postData['SavedCalendar']) && isset($postData['SavedCalendar']['moduleClassName'])) {
         $report->setModuleClassName($postData['SavedCalendar']['moduleClassName']);
     } else {
         throw new NotSupportedException();
     }
     DataToReportUtil::resolveReportByWizardPostData($report, $postData, ReportToWizardFormAdapter::getFormClassNameByType($type));
     return $report;
 }
 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();
 }
 public function testGetData()
 {
     $moduleClassName = Contact::getModuleClassName();
     $type = Report::TYPE_ROWS_AND_COLUMNS;
     $treeType = ComponentForReportForm::TYPE_FILTERS;
     $report = new Report();
     $report->setModuleClassName($moduleClassName);
     $report->setType($type);
     $reportToTreeAdapter = new MergeTagsReportRelationsAndAttributesToTreeAdapter($report, $treeType, 'EmailTemplate');
     $emailTemplate = new EmailTemplate();
     $emailTemplate->type = EmailTemplate::TYPE_CONTACT;
     $emailTemplate->subject = 'Another Test subject';
     $emailTemplate->name = 'Another Test Email Template';
     $emailTemplate->textContent = 'Text Content ';
     $emailTemplate->htmlContent = 'Html Content ';
     $emailTemplate->builtType = EmailTemplate::BUILT_TYPE_PASTED_HTML;
     $emailTemplate->modelClassName = 'Contact';
     // By testing the getData method we're actually testing that all Merge Tags are valid
     // and that we can save the EmailTemplate with each Merge Tag without having the error 'Invalid Merge Tag'.
     $data = $reportToTreeAdapter->getData('source');
     foreach ($data[1]['children'] as $child) {
         if (isset($child['dataValue']) && $child['dataValue']) {
             $emailTemplate->textContent .= ' ' . $child['dataValue'];
             $emailTemplate->htmlContent .= ' ' . $child['dataValue'];
         }
     }
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertTrue($validated);
     $this->assertEmpty($emailTemplate->getErrors());
     $this->assertTrue($emailTemplate->save());
     $data = $reportToTreeAdapter->getData('EmailTemplate_createdByUser');
     $emailTemplate->textContent = '';
     $emailTemplate->htmlContent = '';
     foreach ($data as $child) {
         if (isset($child['dataValue']) && $child['dataValue']) {
             $emailTemplate->textContent .= ' ' . $child['dataValue'];
             $emailTemplate->htmlContent .= ' ' . $child['dataValue'];
         }
     }
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertTrue($validated);
     $this->assertEmpty($emailTemplate->getErrors());
     $this->assertTrue($emailTemplate->save());
     $data = $reportToTreeAdapter->getData('EmailTemplate_owner');
     $emailTemplate->textContent = '';
     $emailTemplate->htmlContent = '';
     foreach ($data as $child) {
         if (isset($child['dataValue']) && $child['dataValue']) {
             $emailTemplate->textContent .= ' ' . $child['dataValue'];
             $emailTemplate->htmlContent .= ' ' . $child['dataValue'];
         }
     }
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertTrue($validated);
     $this->assertEmpty($emailTemplate->getErrors());
     $this->assertTrue($emailTemplate->save());
     $data = $reportToTreeAdapter->getData('EmailTemplate_owner___primaryEmail');
     $emailTemplate->textContent = '';
     $emailTemplate->htmlContent = '';
     foreach ($data as $child) {
         if (isset($child['dataValue']) && $child['dataValue']) {
             $emailTemplate->textContent .= ' ' . $child['dataValue'];
             $emailTemplate->htmlContent .= ' ' . $child['dataValue'];
         }
     }
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertTrue($validated);
     $this->assertEmpty($emailTemplate->getErrors());
     $this->assertTrue($emailTemplate->save());
     $data = $reportToTreeAdapter->getData('EmailTemplate_primaryAddress');
     $emailTemplate->textContent = '';
     $emailTemplate->htmlContent = '';
     foreach ($data as $child) {
         if (isset($child['dataValue']) && $child['dataValue']) {
             $emailTemplate->textContent .= ' ' . $child['dataValue'];
             $emailTemplate->htmlContent .= ' ' . $child['dataValue'];
         }
     }
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertTrue($validated);
     $this->assertEmpty($emailTemplate->getErrors());
     $this->assertTrue($emailTemplate->save());
     // Test against invalid Merge Tags
     $emailTemplate->textContent = 'Text Content [[TEXT__INVALID^MERGE^TAG]]';
     $emailTemplate->htmlContent = 'Html Content [[HTMLINVALIDMERGETAG]]';
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertFalse($validated);
     $errorMessages = $emailTemplate->getErrors();
     $this->assertEquals(2, count($errorMessages));
     $this->assertTrue(array_key_exists('textContent', $errorMessages));
     $this->assertTrue(array_key_exists('htmlContent', $errorMessages));
     $this->assertEquals(1, count($errorMessages['textContent']));
     $this->assertEquals(1, count($errorMessages['htmlContent']));
     $this->assertContains('TEXT__INVALID^MERGE^TAG', $errorMessages['textContent'][0]);
     $this->assertContains('HTMLINVALIDMERGETAG', $errorMessages['htmlContent'][0]);
 }
 /**
  * @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']);
 }
 /**
  * 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']);
 }
Exemplo n.º 23
0
 /**
  * @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));
 }
Exemplo n.º 24
0
 /**
  * Saves a report
  * @param <type> $reportName
  * @param <type> $reportGroupId
  * @param <type> $useFilterField
  * @param <type> $type
  * @return Report
  */
 public function saveReport($reportName, $reportGroupId, $useFilterField, $type)
 {
     try {
         $report = new Report();
         $report->setName($reportName);
         $report->setReportGroupId($reportGroupId);
         $report->setUseFilterField($useFilterField);
         $report->setType($type);
         $report->save();
         return $report;
     } catch (Exception $ex) {
         throw new DaoException($ex->getMessage());
     }
 }
Exemplo n.º 25
0
 /**
  * @param null $uniqueId
  * @param null $nodeId
  * @param string $modelClassName
  */
 public function actionRelationsAndAttributesTreeForMergeTags($uniqueId = null, $nodeId = null, $modelClassName = 'Contact')
 {
     if ($modelClassName == null) {
         $modelClassName = 'Contact';
     }
     $moduleClassName = $modelClassName::getModuleClassName();
     $type = Report::TYPE_ROWS_AND_COLUMNS;
     $treeType = ComponentForReportForm::TYPE_FILTERS;
     $report = new Report();
     $report->setModuleClassName($moduleClassName);
     $report->setType($type);
     if ($nodeId != null) {
         $reportToTreeAdapter = new MergeTagsReportRelationsAndAttributesToTreeAdapter($report, $treeType, $uniqueId);
         echo ZurmoTreeView::saveDataAsJson($reportToTreeAdapter->getData($nodeId));
         Yii::app()->end(0, false);
     }
     $view = new ReportRelationsAndAttributesForMergeTagsTreeView($type, $treeType, 'edit-form', $uniqueId);
     $content = $view->render();
     Yii::app()->getClientScript()->setToAjaxMode();
     Yii::app()->getClientScript()->render($content);
     echo $content;
 }
Exemplo n.º 26
0
 public function testResolveFiltersForVariableStatesWithOneDisplayAttributeAndOneFilterForANonSuperUserWhoCanSeeAnotherState()
 {
     Yii::app()->user->userModel = User::getByUsername('sarah');
     $report = new Report();
     $report->setType(Report::TYPE_ROWS_AND_COLUMNS);
     $report->setModuleClassName('AccountsModule');
     $displayAttribute = new DisplayAttributeForReportForm('AccountsModule', 'Account', Report::TYPE_ROWS_AND_COLUMNS);
     $displayAttribute->attributeIndexOrDerivedType = 'contacts___officePhone';
     $report->addDisplayAttribute($displayAttribute);
     $reportDataProvider = new RowsAndColumnsReportDataProvider($report);
     $filtersStructure = '1';
     $filter = new FilterForReportForm('AccountsModule', 'Account', Report::TYPE_ROWS_AND_COLUMNS);
     $filter->attributeIndexOrDerivedType = 'opportunities___contacts___website';
     $filter->operator = OperatorRules::TYPE_EQUALS;
     $filter->value = 'Zurmo';
     $filters = array($filter);
     $filters = $reportDataProvider->resolveFiltersForVariableStates($filters, $filtersStructure);
     $stateAdapter = new LeadsStateMetadataAdapter(array('clauses' => array(), 'structure' => ''));
     $this->assertTrue(count($stateAdapter->getStateIds()) > 0);
     $this->assertEquals(3, count($filters));
     $this->assertEquals('contacts___state', $filters[1]->attributeIndexOrDerivedType);
     $this->assertEquals(OperatorRules::TYPE_ONE_OF, $filters[1]->operator);
     $this->assertEquals($stateAdapter->getStateIds(), $filters[1]->value);
     $this->assertEquals('opportunities___contacts___state', $filters[2]->attributeIndexOrDerivedType);
     $this->assertEquals(OperatorRules::TYPE_ONE_OF, $filters[2]->operator);
     $this->assertEquals($stateAdapter->getStateIds(), $filters[2]->value);
     $this->assertEquals('1 and (2 and 3)', $filtersStructure);
 }
 public function testResolveFiltersAndDateConvertsProperlyToDbFormat()
 {
     $report = new Report();
     $report->setType(Report::TYPE_ROWS_AND_COLUMNS);
     $report->setModuleClassName('ReportsTestModule');
     $data = array();
     $data[ComponentForReportForm::TYPE_FILTERS][] = array('attributeIndexOrDerivedType' => 'date', 'valueType' => 'Between', 'value' => '2/24/2012', 'secondValue' => '2/28/2012');
     $data[ComponentForReportForm::TYPE_FILTERS][] = array('attributeIndexOrDerivedType' => 'dateTime', 'value' => '2/25/2012', 'availableAtRunTime' => true);
     DataToReportUtil::resolveFilters($data, $report);
     $filters = $report->getFilters();
     $this->assertCount(2, $filters);
     $this->assertEquals('Between', $filters[0]->valueType);
     $this->assertEquals('2012-02-24', $filters[0]->value);
     $this->assertEquals('2012-02-28', $filters[0]->secondValue);
     $this->assertEquals('2012-02-25', $filters[1]->value);
     //Should remove only the runtime filter
     $data = array();
     $data[ComponentForReportForm::TYPE_FILTERS][] = array('attributeIndexOrDerivedType' => 'dateTime', 'value' => '2/25/2012', 'availableAtRunTime' => true);
     DataToReportUtil::resolveFilters($data, $report, true);
     $filters = $report->getFilters();
     $this->assertCount(2, $filters);
     $this->assertEquals('Between', $filters[0]->valueType);
     $this->assertEquals('2012-02-24', $filters[0]->value);
     $this->assertEquals('2012-02-28', $filters[0]->secondValue);
     $this->assertEquals('2012-02-25', $filters[1]->value);
 }
 /**
  * @depends testIsRelation
  */
 public function testIsRelationASingularRelation()
 {
     $model = new ReportModelTestItem();
     $rules = new ReportsTestReportRules();
     $report = new Report();
     $report->setType(Report::TYPE_ROWS_AND_COLUMNS);
     $report->setModuleClassName('ReportsTestModule');
     $adapter = new ModelRelationsAndAttributesToRowsAndColumnsReportAdapter($model, $rules, $report->getType());
     $this->assertTrue($adapter->isRelationASingularRelation('hasOne'));
     $this->assertFalse($adapter->isRelationASingularRelation('hasMany'));
     $model = new ReportModelTestItem5();
     $rules = new ReportsTestReportRules();
     $report = new Report();
     $report->setType(Report::TYPE_ROWS_AND_COLUMNS);
     $report->setModuleClassName('ReportsTestModule');
     $adapter = new ModelRelationsAndAttributesToRowsAndColumnsReportAdapter($model, $rules, $report->getType());
     $this->assertFalse($adapter->isRelationASingularRelation('ReportModelTestItem2__reportItems__Inferred'));
     $this->assertFalse($adapter->isRelationASingularRelation('ReportModelTestItem__reportItems__Inferred'));
 }
 /**
  * Running a report centered on notes, with a display attribute from notes and accounts.  Ordered by
  * created date time in notes.  Should produce proper query to order by notes.  This test just makes sure
  * the sql is structured properly
  */
 public function testOrderByWorksOnAccountsAndNoteReport()
 {
     $report = new Report();
     $report->setFiltersStructure('');
     $report->setType(Report::TYPE_ROWS_AND_COLUMNS);
     $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);
     $orderBy = new OrderByForReportForm('NotesModule', 'Note', Report::TYPE_SUMMATION);
     $orderBy->attributeIndexOrDerivedType = 'createdDateTime';
     $report->addOrderBy($orderBy);
     $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}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} order by {$q}item1{$q}.{$q}createddatetime{$q} asc limit 10 offset 0";
     $this->assertEquals($compareSql, $sql);
 }
 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 = "*****@*****.**";
     $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 = "*****@*****.**";
     $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';
     $displayAttribute5->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute5->columnAliasName == 'col4');
     $report->addDisplayAttribute($displayAttribute5);
     $displayAttribute6 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute6->attributeIndexOrDerivedType = 'createdDateTime__Minimum';
     $displayAttribute6->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute6->columnAliasName == 'col5');
     $report->addDisplayAttribute($displayAttribute6);
     //for modifiedDateTime summation
     $displayAttribute7 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute7->attributeIndexOrDerivedType = 'modifiedDateTime__Maximum';
     $displayAttribute7->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute7->columnAliasName == 'col6');
     $report->addDisplayAttribute($displayAttribute7);
     $displayAttribute8 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute8->attributeIndexOrDerivedType = 'modifiedDateTime__Minimum';
     $displayAttribute8->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute8->columnAliasName == 'col7');
     $report->addDisplayAttribute($displayAttribute8);
     //for float summation
     $displayAttribute9 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute9->attributeIndexOrDerivedType = 'float__Minimum';
     $displayAttribute9->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute9->columnAliasName == 'col8');
     $report->addDisplayAttribute($displayAttribute9);
     $displayAttribute10 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute10->attributeIndexOrDerivedType = 'float__Maximum';
     $displayAttribute10->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute10->columnAliasName == 'col9');
     $report->addDisplayAttribute($displayAttribute10);
     $displayAttribute11 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute11->attributeIndexOrDerivedType = 'float__Summation';
     $displayAttribute11->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute11->columnAliasName == 'col10');
     $report->addDisplayAttribute($displayAttribute11);
     $displayAttribute12 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute12->attributeIndexOrDerivedType = 'float__Average';
     $displayAttribute12->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute12->columnAliasName == 'col11');
     $report->addDisplayAttribute($displayAttribute12);
     //for integer summation
     $displayAttribute13 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute13->attributeIndexOrDerivedType = 'integer__Minimum';
     $displayAttribute13->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute13->columnAliasName == 'col12');
     $report->addDisplayAttribute($displayAttribute13);
     $displayAttribute14 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute14->attributeIndexOrDerivedType = 'integer__Maximum';
     $displayAttribute14->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute14->columnAliasName == 'col13');
     $report->addDisplayAttribute($displayAttribute14);
     $displayAttribute15 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute15->attributeIndexOrDerivedType = 'integer__Summation';
     $displayAttribute15->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute15->columnAliasName == 'col14');
     $report->addDisplayAttribute($displayAttribute15);
     $displayAttribute16 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute16->attributeIndexOrDerivedType = 'integer__Average';
     $displayAttribute16->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute16->columnAliasName == 'col15');
     $report->addDisplayAttribute($displayAttribute16);
     //for currency summation
     $displayAttribute17 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute17->attributeIndexOrDerivedType = 'currencyValue__Minimum';
     $displayAttribute17->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute17->columnAliasName == 'col16');
     $report->addDisplayAttribute($displayAttribute17);
     $displayAttribute18 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute18->attributeIndexOrDerivedType = 'currencyValue__Maximum';
     $displayAttribute18->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute18->columnAliasName == 'col17');
     $report->addDisplayAttribute($displayAttribute18);
     $displayAttribute19 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute19->attributeIndexOrDerivedType = 'currencyValue__Summation';
     $displayAttribute19->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute19->columnAliasName == 'col18');
     $report->addDisplayAttribute($displayAttribute19);
     $displayAttribute20 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute20->attributeIndexOrDerivedType = 'currencyValue__Average';
     $displayAttribute20->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute20->columnAliasName == 'col19');
     $report->addDisplayAttribute($displayAttribute20);
     $dataProvider = new SummationReportDataProvider($report);
     $adapter = ReportToExportAdapterFactory::createReportToExportAdapter($report, $dataProvider);
     $compareHeaderData = array('Date -(Max)', 'Date -(Min)', 'Date Time -(Max)', 'Date Time -(Min)', 'Created Date Time -(Max)', 'Created Date Time -(Min)', 'Modified Date Time -(Max)', 'Modified Date Time -(Min)', 'Float -(Min)', 'Float -(Max)', 'Float -(Sum)', 'Float -(Avg)', 'Integer -(Min)', 'Integer -(Max)', 'Integer -(Sum)', 'Integer -(Avg)', 'Currency Value -(Min)', 'Currency Value -(Min) Currency', 'Currency Value -(Max)', 'Currency Value -(Max) Currency', 'Currency Value -(Sum)', 'Currency Value -(Sum) Currency', 'Currency Value -(Avg)', 'Currency Value -(Avg) Currency');
     $compareRowData = array(array('2013-02-14', '2013-02-12', '2013-02-14 23:15:00', '2013-02-12 10:15:00', $reportModelTestItem2->createdDateTime, $reportModelTestItem1->createdDateTime, $reportModelTestItem2->modifiedDateTime, $reportModelTestItem1->modifiedDateTime, 10.5, 200.5, 211, 105.5, 10, 1010, 1020, 510, 100, 'Mixed Currency', 100, 'Mixed Currency', 200, 'Mixed Currency', 100, 'Mixed Currency'), array('Total', '2013-02-12', '2013-02-14 23:15:00', '2013-02-12 10:15:00', $reportModelTestItem2->createdDateTime, $reportModelTestItem1->createdDateTime, $reportModelTestItem2->modifiedDateTime, $reportModelTestItem1->modifiedDateTime, 10.5, 200.5, 211, 105.5, 10, 1010, 1020, 510, 100, '', 100, '', 200, '', 100, ''));
     $this->assertEquals($compareHeaderData, $adapter->getHeaderData());
     $this->assertEquals($compareRowData, $adapter->getData());
     //With drill down
     $groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $groupBy->attributeIndexOrDerivedType = 'firstName';
     $report->addGroupBy($groupBy);
     $drillDownDisplayAttribute1 = new DrillDownDisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $drillDownDisplayAttribute1->attributeIndexOrDerivedType = 'float';
     $report->addDrillDownDisplayAttribute($drillDownDisplayAttribute1);
     $drillDownDisplayAttribute2 = new DrillDownDisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $drillDownDisplayAttribute2->attributeIndexOrDerivedType = 'integer';
     $report->addDrillDownDisplayAttribute($drillDownDisplayAttribute2);
     $dataProvider = new SummationReportDataProvider($report);
     $adapter = ReportToExportAdapterFactory::createReportToExportAdapter($report, $dataProvider);
     $compareHeaderData = array('Date -(Max)', 'Date -(Min)', 'Date Time -(Max)', 'Date Time -(Min)', 'Created Date Time -(Max)', 'Created Date Time -(Min)', 'Modified Date Time -(Max)', 'Modified Date Time -(Min)', 'Float -(Min)', 'Float -(Max)', 'Float -(Sum)', 'Float -(Avg)', 'Integer -(Min)', 'Integer -(Max)', 'Integer -(Sum)', 'Integer -(Avg)', 'Currency Value -(Min)', 'Currency Value -(Min) Currency', 'Currency Value -(Max)', 'Currency Value -(Max) Currency', 'Currency Value -(Sum)', 'Currency Value -(Sum) Currency', 'Currency Value -(Avg)', 'Currency Value -(Avg) Currency', 'First Name');
     $compareRowData = array(array('2013-02-14', '2013-02-12', '2013-02-14 23:15:00', '2013-02-12 10:15:00', $reportModelTestItem2->createdDateTime, $reportModelTestItem1->createdDateTime, $reportModelTestItem2->modifiedDateTime, $reportModelTestItem1->modifiedDateTime, 10.5, 200.5, 211, 105.5, 10, 1010, 1020, 510, 100, 'Mixed Currency', 100, 'Mixed Currency', 200, 'Mixed Currency', 100, 'Mixed Currency', 'xFirst'), array(null, 'Float', 'Integer'), array(null, '10.5', '10'), array(null, '200.5', '1010'), array('Total', '2013-02-12', '2013-02-14 23:15:00', '2013-02-12 10:15:00', $reportModelTestItem2->createdDateTime, $reportModelTestItem1->createdDateTime, $reportModelTestItem2->modifiedDateTime, $reportModelTestItem1->modifiedDateTime, 10.5, 200.5, 211, 105.5, 10, 1010, 1020, 510, 100, '', 100, '', 200, '', 100, ''));
     $this->assertEquals($compareHeaderData, $adapter->getHeaderData());
     $this->assertEquals($compareRowData, $adapter->getData());
 }