当前位置: 首页>>代码示例>>PHP>>正文


PHP Report::addOrderBy方法代码示例

本文整理汇总了PHP中Report::addOrderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Report::addOrderBy方法的具体用法?PHP Report::addOrderBy怎么用?PHP Report::addOrderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Report的用法示例。


在下文中一共展示了Report::addOrderBy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCanCurrentUserProperlyRenderResults

 public function testCanCurrentUserProperlyRenderResults()
 {
     $billy = User::getByUsername('billy');
     $billy->setRight('AccountsModule', AccountsModule::RIGHT_ACCESS_ACCOUNTS);
     $billy->setRight('OpportunitiesModule', OpportunitiesModule::RIGHT_ACCESS_OPPORTUNITIES);
     $saved = $billy->save();
     $this->assertTrue($saved);
     $report = new Report();
     $report->setModuleClassName('ContactsModule');
     $report->setType(Report::TYPE_ROWS_AND_COLUMNS);
     $this->assertTrue($report->canCurrentUserProperlyRenderResults());
     //Now set to Billy
     Yii::app()->user->userModel = $billy;
     //Billy can't see the contacts module.
     $this->assertFalse($report->canCurrentUserProperlyRenderResults());
     //Billy can see accounts
     $report->setModuleClassName('AccountsModule');
     $this->assertTrue($report->canCurrentUserProperlyRenderResults());
     //A filter on accounts is ok for Billy to see
     $filter = new FilterForReportForm('AccountsModule', 'Account', $report->getType());
     $filter->attributeIndexOrDerivedType = 'officePhone';
     $filter->value = 'aValue';
     $filter->operator = 'equals';
     $report->addFilter($filter);
     $this->assertTrue($report->canCurrentUserProperlyRenderResults());
     //A filter on contacts is not ok for Billy to see
     $filter2 = new FilterForReportForm('AccountsModule', 'Account', $report->getType());
     $filter2->attributeIndexOrDerivedType = 'contacts___lastName';
     $filter2->value = 'aValue';
     $filter2->operator = 'equals';
     $report->addFilter($filter2);
     $this->assertFalse($report->canCurrentUserProperlyRenderResults());
     //A related filter on opportunities would be ok for Billy to see
     $report->removeAllFilters();
     $filter = new FilterForReportForm('AccountsModule', 'Account', $report->getType());
     $filter->attributeIndexOrDerivedType = 'opportunities___name';
     $filter->value = 'aValue';
     $filter->operator = 'equals';
     $report->addFilter($filter);
     $this->assertTrue($report->canCurrentUserProperlyRenderResults());
     $report->removeAllFilters();
     //Billy can see a groupBy on Accounts
     $groupBy = new GroupByForReportForm('AccountsModule', 'Account', $report->getType());
     $groupBy->attributeIndexOrDerivedType = 'name';
     $groupBy->axis = 'y';
     $report->addGroupBy($groupBy);
     $this->assertTrue($report->canCurrentUserProperlyRenderResults());
     //Billy cannot see a related groupBy on Contacts
     $groupBy = new GroupByForReportForm('AccountsModule', 'Account', $report->getType());
     $groupBy->attributeIndexOrDerivedType = 'contacts___lastName';
     $groupBy->axis = 'y';
     $report->addGroupBy($groupBy);
     $this->assertFalse($report->canCurrentUserProperlyRenderResults());
     //Billy can see a related groupBy on Opportunities
     $report->removeAllGroupBys();
     $groupBy = new GroupByForReportForm('AccountsModule', 'Account', $report->getType());
     $groupBy->attributeIndexOrDerivedType = 'opportunities___name';
     $groupBy->axis = 'y';
     $report->addGroupBy($groupBy);
     $this->assertTrue($report->canCurrentUserProperlyRenderResults());
     $report->removeAllGroupBys();
     //Billy can see an orderBy on Accounts
     $orderBy = new OrderByForReportForm('AccountsModule', 'Account', $report->getType());
     $orderBy->attributeIndexOrDerivedType = 'name';
     $orderBy->order = 'desc';
     $report->addOrderBy($orderBy);
     $this->assertTrue($report->canCurrentUserProperlyRenderResults());
     //Billy cannot see a related orderBy on Contacts
     $orderBy = new OrderByForReportForm('AccountsModule', 'Account', $report->getType());
     $orderBy->attributeIndexOrDerivedType = 'contacts___lastName';
     $orderBy->order = 'desc';
     $report->addOrderBy($orderBy);
     $this->assertFalse($report->canCurrentUserProperlyRenderResults());
     //Billy can see a related orderBy on Opportunities
     $report->removeAllOrderBys();
     $orderBy = new OrderByForReportForm('AccountsModule', 'Account', $report->getType());
     $orderBy->attributeIndexOrDerivedType = 'opportunities___name';
     $orderBy->order = 'desc';
     $report->addOrderBy($orderBy);
     $this->assertTrue($report->canCurrentUserProperlyRenderResults());
     $report->removeAllOrderBys();
     //Billy can see a displayAttribute on Accounts
     $displayAttribute = new DisplayAttributeForReportForm('AccountsModule', 'Account', $report->getType());
     $displayAttribute->attributeIndexOrDerivedType = 'name';
     $displayAttribute->label = 'someNewLabel';
     $report->addDisplayAttribute($displayAttribute);
     $this->assertTrue($report->canCurrentUserProperlyRenderResults());
     //Billy cannot see a related displayAttribute on Contacts
     $displayAttribute = new DisplayAttributeForReportForm('AccountsModule', 'Account', $report->getType());
     $displayAttribute->attributeIndexOrDerivedType = 'contacts___firstName';
     $displayAttribute->label = 'someNewLabel';
     $report->addDisplayAttribute($displayAttribute);
     $this->assertFalse($report->canCurrentUserProperlyRenderResults());
     //Billy can see a related displayAttribute on Opportunities
     $report->removeAllDisplayAttributes();
     $displayAttribute = new DisplayAttributeForReportForm('AccountsModule', 'Account', $report->getType());
     $displayAttribute->attributeIndexOrDerivedType = 'opportunities___name';
     $displayAttribute->label = 'someNewLabel';
     $report->addDisplayAttribute($displayAttribute);
     $this->assertTrue($report->canCurrentUserProperlyRenderResults());
//.........这里部分代码省略.........
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:101,代码来源:ReportTest.php

示例2: testResolveReportToSavedReport

 public function testResolveReportToSavedReport()
 {
     $billy = User::getByUsername('billy');
     $report = new Report();
     $report->setDescription('aDescription');
     $report->setModuleClassName('ReportsTestModule');
     $report->setName('myFirstReport');
     $report->setType(Report::TYPE_ROWS_AND_COLUMNS);
     $report->setOwner($billy);
     $report->setFiltersStructure('1 and 2 or 3');
     $report->setCurrencyConversionType(Report::CURRENCY_CONVERSION_TYPE_SPOT);
     $report->setSpotConversionCurrencyCode('CAD');
     $filter = new FilterForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
     $filter->attributeIndexOrDerivedType = 'string';
     $filter->value = 'aValue';
     $filter->operator = 'equals';
     $filter->availableAtRunTime = true;
     $report->addFilter($filter);
     $filter = new FilterForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
     $filter->attributeIndexOrDerivedType = 'currencyValue';
     $filter->value = 'aValue';
     $filter->secondValue = 'bValue';
     $filter->operator = 'between';
     $filter->currencyIdForValue = '4';
     $filter->availableAtRunTime = true;
     $report->addFilter($filter);
     $filter = new FilterForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
     $filter->attributeIndexOrDerivedType = 'owner__User';
     $filter->value = 'aValue';
     $filter->stringifiedModelForValue = 'someName';
     $filter->availableAtRunTime = false;
     $report->addFilter($filter);
     $filter = new FilterForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
     $filter->attributeIndexOrDerivedType = 'createdDateTime';
     $filter->value = 'aValue';
     $filter->secondValue = 'bValue';
     $filter->operator = null;
     $filter->currencyIdForValue = null;
     $filter->availableAtRunTime = true;
     $filter->valueType = 'Between';
     $report->addFilter($filter);
     $groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
     $groupBy->attributeIndexOrDerivedType = 'lastName';
     $groupBy->axis = 'y';
     $report->addGroupBy($groupBy);
     $orderBy = new OrderByForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
     $orderBy->attributeIndexOrDerivedType = 'url';
     $orderBy->order = 'desc';
     $report->addOrderBy($orderBy);
     $displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
     $displayAttribute->attributeIndexOrDerivedType = 'phone';
     $displayAttribute->label = 'someNewLabel';
     $report->addDisplayAttribute($displayAttribute);
     $drillDownDisplayAttribute = new DrillDownDisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
     $drillDownDisplayAttribute->attributeIndexOrDerivedType = 'firstName';
     $drillDownDisplayAttribute->label = 'someNewLabel';
     $report->addDrillDownDisplayAttribute($drillDownDisplayAttribute);
     $savedReport = new SavedReport();
     $this->assertNull($savedReport->serializedData);
     SavedReportToReportAdapter::resolveReportToSavedReport($report, $savedReport);
     $this->assertEquals('ReportsTestModule', $savedReport->moduleClassName);
     $this->assertEquals('myFirstReport', $savedReport->name);
     $this->assertEquals('aDescription', $savedReport->description);
     $this->assertEquals(Report::TYPE_ROWS_AND_COLUMNS, $savedReport->type);
     $this->assertEquals('1 and 2 or 3', $report->getFiltersStructure());
     $this->assertTrue($savedReport->owner->isSame($billy));
     $compareData = array('Filters' => array(array('availableAtRunTime' => true, 'currencyIdForValue' => null, 'value' => 'aValue', 'secondValue' => null, 'stringifiedModelForValue' => null, 'valueType' => null, 'attributeIndexOrDerivedType' => 'string', 'operator' => 'equals'), array('availableAtRunTime' => true, 'currencyIdForValue' => '4', 'value' => 'aValue', 'secondValue' => 'bValue', 'stringifiedModelForValue' => null, 'valueType' => null, 'attributeIndexOrDerivedType' => 'currencyValue', 'operator' => 'between'), array('availableAtRunTime' => false, 'currencyIdForValue' => null, 'value' => 'aValue', 'secondValue' => null, 'stringifiedModelForValue' => 'someName', 'valueType' => null, 'attributeIndexOrDerivedType' => 'owner__User', 'operator' => null), array('availableAtRunTime' => true, 'value' => 'aValue', 'secondValue' => 'bValue', 'stringifiedModelForValue' => null, 'valueType' => 'Between', 'attributeIndexOrDerivedType' => 'createdDateTime', 'operator' => null, 'currencyIdForValue' => null)), 'OrderBys' => array(array('order' => 'desc', 'attributeIndexOrDerivedType' => 'url')), 'GroupBys' => array(array('axis' => 'y', 'attributeIndexOrDerivedType' => 'lastName')), 'DisplayAttributes' => array(array('label' => 'someNewLabel', 'attributeIndexOrDerivedType' => 'phone', 'columnAliasName' => 'col0', 'queryOnly' => false, 'valueUsedAsDrillDownFilter' => false, 'madeViaSelectInsteadOfViaModel' => false)), 'DrillDownDisplayAttributes' => array(array('label' => 'someNewLabel', 'attributeIndexOrDerivedType' => 'firstName', 'columnAliasName' => 'col0', 'queryOnly' => false, 'valueUsedAsDrillDownFilter' => false, 'madeViaSelectInsteadOfViaModel' => false)));
     $unserializedData = unserialize($savedReport->serializedData);
     $this->assertEquals($compareData['Filters'], $unserializedData['Filters']);
     $this->assertEquals($compareData['OrderBys'], $unserializedData['OrderBys']);
     $this->assertEquals($compareData['GroupBys'], $unserializedData['GroupBys']);
     $this->assertEquals($compareData['DisplayAttributes'], $unserializedData['DisplayAttributes']);
     $this->assertEquals($compareData['DrillDownDisplayAttributes'], $unserializedData['DrillDownDisplayAttributes']);
     $this->assertEquals('1 and 2 or 3', $unserializedData['filtersStructure']);
     $this->assertEquals(Report::CURRENCY_CONVERSION_TYPE_SPOT, $unserializedData['currencyConversionType']);
     $this->assertEquals('CAD', $unserializedData['spotConversionCurrencyCode']);
     $saved = $savedReport->save();
     $this->assertTrue($saved);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:79,代码来源:SavedReportToReportAdapterTest.php

示例3: resolveOrderBys

 /**
  * @param array $data
  * @param Report $report
  */
 protected static function resolveOrderBys($data, Report $report)
 {
     $report->removeAllOrderBys();
     $moduleClassName = $report->getModuleClassName();
     if (count($orderBysData = ArrayUtil::getArrayValue($data, ComponentForReportForm::TYPE_ORDER_BYS)) > 0) {
         foreach ($orderBysData as $key => $orderByData) {
             $orderBy = new OrderByForReportForm($moduleClassName, $moduleClassName::getPrimaryModelName(), $report->getType(), $key);
             $orderBy->setAttributes($orderByData);
             $report->addOrderBy($orderBy);
         }
     } else {
         $report->removeAllOrderBys();
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:18,代码来源:DataToReportUtil.php

示例4: testOrderByWorksOnAccountsAndNoteReport

 /**
  * 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);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:26,代码来源:QueryBuilderDocumentationTest.php


注:本文中的Report::addOrderBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。