/** * Utilized for summation with drill down rows. For a given group, the grouped value needs to be used * as a filter for the drilled down row. This method will add that groupBy as a filter and update the * filterStructure accordingly. * @param array $getData */ public function resolveGroupBysAsFilters(array $getData) { $newStartingStructurePosition = count($this->filters) + 1; $structure = null; foreach ($this->getGroupBys() as $groupBy) { $index = ReportResultsRowData::resolveDataParamKeyForDrillDown($groupBy->attributeIndexOrDerivedType); if (isset($getData[$index])) { $value = $getData[$index]; } else { $value = null; } $filter = new FilterForReportForm($groupBy->getModuleClassName(), $groupBy->getModelClassName(), $this->type); $filter->attributeIndexOrDerivedType = $groupBy->attributeIndexOrDerivedType; self::resolveGroupByAsFilterValue($value, $filter); $this->addFilter($filter); if ($structure != null) { $structure .= ' AND '; } $structure .= $newStartingStructurePosition; $newStartingStructurePosition++; } $structure = '(' . $structure . ')'; if ($this->filtersStructure != null) { $this->filtersStructure = '(' . $this->filtersStructure . ')'; $this->filtersStructure .= ' AND '; } $this->filtersStructure .= $structure; }
public function testResolveDataParamKeyForDrillDown() { $this->assertEquals(ReportResultsRowData::DRILL_DOWN_GROUP_BY_VALUE_PREFIX . 'abc', ReportResultsRowData::resolveDataParamKeyForDrillDown('abc')); }