protected function getDataProvider(Report $report, $stickyKey, $runReport)
 {
     assert('is_string($stickyKey) || is_int($stickyKey)');
     assert('is_bool($runReport)');
     $getData = GetUtil::getData();
     if (isset($getData['clearRuntimeFilters']) && $getData['clearRuntimeFilters']) {
         StickyReportUtil::clearDataByKey($stickyKey);
     }
     if (null != ($stickyData = StickyReportUtil::getDataByKey($stickyKey))) {
         StickyReportUtil::resolveStickyDataToReport($report, $stickyData);
     }
     $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('reportResultsListPageSize', get_class($this->getModule()));
     $dataProvider = ReportDataProviderFactory::makeByReport($report, $pageSize);
     if ($runReport) {
         $dataProvider->setRunReport($runReport);
     }
     return $dataProvider;
 }
 /**
  * @param integer $rowCount
  * @param WizardActiveForm $form
  * @return array
  */
 protected function renderItems(&$rowCount, WizardActiveForm $form)
 {
     assert('is_int($rowCount)');
     $items = array();
     $wizardFormClassName = $this->getWizardFormClassName();
     $treeType = ComponentForReportForm::TYPE_FILTERS;
     $trackableStructurePosition = false;
     //can we set this to false without jacking things up?
     $report = $this->params["relationModel"];
     if (null != ($stickyData = StickyReportUtil::getDataByKey($report->id))) {
         StickyReportUtil::resolveStickyDataToReport($report, $stickyData);
     }
     foreach ($report->getFilters() as $filterForReportForm) {
         if ($filterForReportForm->availableAtRunTime) {
             $nodeIdWithoutTreeType = $filterForReportForm->attributeIndexOrDerivedType;
             $inputPrefixData = ReportRelationsAndAttributesToTreeAdapter::resolveInputPrefixData($wizardFormClassName, $treeType, $rowCount);
             $adapter = new RuntimeReportAttributeToElementAdapter($inputPrefixData, $filterForReportForm, $form, $treeType);
             $view = new AttributeRowForReportComponentView($adapter, $rowCount, $inputPrefixData, ReportRelationsAndAttributesToTreeAdapter::resolveAttributeByNodeId($nodeIdWithoutTreeType), (bool) $trackableStructurePosition, false, null);
             $view->addWrapper = false;
             $items[] = array('content' => $view->render());
         }
         $rowCount++;
     }
     return $items;
 }
 protected function getDataProviderForExport(Report $report, $stickyKey, $runReport)
 {
     assert('is_string($stickyKey) || is_int($stickyKey)');
     assert('is_bool($runReport)');
     if (null != ($stickyData = StickyReportUtil::getDataByKey($stickyKey))) {
         StickyReportUtil::resolveStickyDataToReport($report, $stickyData);
     }
     $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('reportResultsListPageSize', get_class($this->getModule()));
     $dataProvider = ReportDataProviderFactory::makeByReport($report, $pageSize);
     if (!$dataProvider instanceof MatrixReportDataProvider) {
         $totalItems = intval($dataProvider->calculateTotalItemCount());
         $dataProvider->getPagination()->setPageSize($totalItems);
     }
     if ($runReport) {
         $dataProvider->setRunReport($runReport);
     }
     return $dataProvider;
 }
 /**
  * @depends testSuperUserAllDefaultControllerActions
  */
 public function testSuperUserListSearchAction()
 {
     StickyReportUtil::clearDataByKey('MarketingListsSearchForm');
     $this->setGetArray(array('MarketingListsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => 'xyz')));
     $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/list');
     $this->assertContains('No results found', $content);
     StickyReportUtil::clearDataByKey('MarketingListsSearchForm');
     $this->setGetArray(array('MarketingListsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => 'Marketing')));
     $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/list');
     $this->assertContains('2 result(s)', $content);
     $this->assertEquals(2, substr_count($content, 'MarketingListName'));
     $this->assertContains('Clark Kent', $content);
     StickyReportUtil::clearDataByKey('MarketingListsSearchForm');
     $this->setGetArray(array('MarketingListsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => 'Marketing', 'selectedListAttributes' => array('name', 'createdByUser', 'fromAddress', 'fromName'))));
     $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/list');
     $this->assertContains('2 result(s)', $content);
     $this->assertEquals(2, substr_count($content, 'MarketingListName'));
     $this->assertContains('Clark Kent', $content);
     $this->assertEquals(3, substr_count($content, 'Clark Kent'));
     $this->assertContains('@zurmo.com', $content);
     $this->assertEquals(4, substr_count($content, '@zurmo.com'));
     $this->assertEquals(2, substr_count($content, '*****@*****.**'));
     $this->assertEquals(2, substr_count($content, '*****@*****.**'));
     StickyReportUtil::clearDataByKey('MarketingListsSearchForm');
     $this->setGetArray(array('clearingSearch' => 1, 'MarketingListsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => '', 'selectedListAttributes' => array('name', 'createdByUser', 'fromAddress', 'fromName'), 'dynamicClauses' => array(array('attributeIndexOrDerivedType' => 'fromAddress', 'structurePosition' => 1, 'fromAddress' => '*****@*****.**')), 'dynamicStructure' => '1')));
     $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/list');
     $this->assertContains('1 result(s)', $content);
     $this->assertEquals(1, substr_count($content, 'MarketingListName2'));
     $this->assertContains('Clark Kent', $content);
     $this->assertEquals(2, substr_count($content, 'Clark Kent'));
     $this->assertContains('@zurmo.com', $content);
     $this->assertEquals(2, substr_count($content, '@zurmo.com'));
     $this->assertEquals(2, substr_count($content, '*****@*****.**'));
     StickyReportUtil::clearDataByKey('MarketingListsSearchForm');
     $this->setGetArray(array('clearingSearch' => 1, 'MarketingListsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => '', 'selectedListAttributes' => array('name', 'createdByUser', 'fromAddress', 'fromName'), 'dynamicClauses' => array(array('attributeIndexOrDerivedType' => 'fromName', 'structurePosition' => 1, 'fromName' => 'first')), 'dynamicStructure' => '1')));
     $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/list');
     $this->assertContains('1 result(s)', $content);
     $this->assertEquals(1, substr_count($content, 'MarketingListName'));
     $this->assertContains('Clark Kent', $content);
     $this->assertEquals(2, substr_count($content, 'Clark Kent'));
     $this->assertContains('@zurmo.com', $content);
     $this->assertEquals(2, substr_count($content, '@zurmo.com'));
     $this->assertEquals(2, substr_count($content, '*****@*****.**'));
 }
 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);
 }
 /**
  * @depends testSuperUserAllDefaultControllerActions
  */
 public function testSuperUserListSearchAction()
 {
     StickyReportUtil::clearDataByKey('CampaignsSearchForm');
     $this->setGetArray(array('CampaignsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => 'xyz')));
     $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list');
     $this->assertContains('No results found', $content);
     StickyReportUtil::clearDataByKey('CampaignsSearchForm');
     $this->setGetArray(array('CampaignsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => 'camp')));
     $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list');
     $this->assertContains('2 result(s)', $content);
     $this->assertContains('<th id="list-view_c2">Status</th>', $content);
     $this->assertEquals(1, substr_count($content, 'campaign01'));
     $this->assertEquals(1, substr_count($content, 'campaign02'));
     $this->assertEquals(2, substr_count($content, 'Active'));
     StickyReportUtil::clearDataByKey('CampaignsSearchForm');
     $this->setGetArray(array('CampaignsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => 'campaign', 'selectedListAttributes' => array('name', 'status', 'createdByUser', 'fromAddress', 'fromName'))));
     $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list');
     $this->assertContains('2 result(s)', $content);
     $this->assertContains('<th id="list-view_c2">Status</th>', $content);
     $this->assertEquals(1, substr_count($content, 'campaign01'));
     $this->assertEquals(1, substr_count($content, 'campaign02'));
     $this->assertEquals(2, substr_count($content, 'Active'));
     $this->assertEquals(3, substr_count($content, 'Clark Kent'));
     $this->assertEquals(4, substr_count($content, '@zurmo.com'));
     $this->assertEquals(6, substr_count($content, 'fromCampaign'));
     $this->assertEquals(3, substr_count($content, 'fromCampaign2'));
     $this->assertEquals(2, substr_count($content, '*****@*****.**'));
     $this->assertEquals(2, substr_count($content, '*****@*****.**'));
     StickyReportUtil::clearDataByKey('CampaignsSearchForm');
     $this->setGetArray(array('clearingSearch' => 1, 'CampaignsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => '', 'selectedListAttributes' => array('name', 'status', 'createdByUser', 'fromAddress', 'fromName'), 'dynamicClauses' => array(array('attributeIndexOrDerivedType' => 'fromAddress', 'structurePosition' => 1, 'fromAddress' => '*****@*****.**')), 'dynamicStructure' => '1')));
     $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list');
     $this->assertContains('1 result(s)', $content);
     $this->assertContains('<th id="list-view_c2">Status</th>', $content);
     $this->assertEquals(1, substr_count($content, 'campaign02'));
     $this->assertEquals(1, substr_count($content, 'Active'));
     $this->assertEquals(2, substr_count($content, 'Clark Kent'));
     $this->assertEquals(2, substr_count($content, '@zurmo.com'));
     $this->assertEquals(7, substr_count($content, 'fromCampaign2'));
     $this->assertEquals(2, substr_count($content, '*****@*****.**'));
     StickyReportUtil::clearDataByKey('CampaignsSearchForm');
     $this->setGetArray(array('clearingSearch' => 1, 'CampaignsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'anyMixedAttributes' => '', 'selectedListAttributes' => array('name', 'status', 'createdByUser', 'fromAddress', 'fromName'), 'dynamicClauses' => array(array('attributeIndexOrDerivedType' => 'fromName', 'structurePosition' => 1, 'fromName' => 'fromCampaign2')), 'dynamicStructure' => '1')));
     $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list');
     $this->assertContains('1 result(s)', $content);
     $this->assertContains('<th id="list-view_c2">Status</th>', $content);
     $this->assertEquals(1, substr_count($content, 'campaign02'));
     $this->assertEquals(1, substr_count($content, 'Active'));
     $this->assertEquals(2, substr_count($content, 'Clark Kent'));
     $this->assertEquals(2, substr_count($content, '@zurmo.com'));
     $this->assertEquals(7, substr_count($content, 'fromCampaign2'));
     $this->assertEquals(2, substr_count($content, '*****@*****.**'));
 }