/**
  * @param string $nodeId
  * @return array
  */
 public function getData($nodeId)
 {
     assert('is_string($nodeId)');
     $nodeId = $this->resolveNodeIdByRemovingTreeType($nodeId);
     $moduleClassName = $this->report->getModuleClassName();
     $modelToReportAdapter = $this->makeModelRelationsAndAttributesToReportAdapter($moduleClassName, $moduleClassName::getPrimaryModelName());
     $nodeIdPrefix = self::resolveNodeIdPrefixByNodeId($nodeId);
     $precedingModel = null;
     $precedingRelation = null;
     if ($nodeId != 'source') {
         self::resolvePrecedingModelRelationAndAdapterByNodeId($nodeId, $modelToReportAdapter, $precedingModel, $precedingRelation);
     } else {
         $nodeIdPrefix = null;
     }
     if ($nodeIdPrefix == null) {
         $data = array();
         $data[0] = array('expanded' => true, 'text' => $moduleClassName::getModuleLabelByTypeAndLanguage('Singular'));
     }
     $childrenNodeData = $this->getChildrenNodeData($modelToReportAdapter, $precedingModel, $precedingRelation, $nodeIdPrefix);
     if (!empty($childrenNodeData) && $nodeIdPrefix == null) {
         $data[0]['children'] = $childrenNodeData;
     } else {
         $data = $childrenNodeData;
     }
     return $data;
 }
 /**
  * @param ReportWizardForm $formModel
  */
 protected function setCommonAttributes(ReportWizardForm $formModel)
 {
     $formModel->id = $this->report->getId();
     $formModel->description = $this->report->getDescription();
     $formModel->moduleClassName = $this->report->getModuleClassName();
     if ($this->report->getOwner()->id > 0) {
         $formModel->ownerId = (int) $this->report->getOwner()->id;
         $formModel->ownerName = strval($this->report->getOwner());
     }
     $formModel->name = $this->report->getName();
     $formModel->type = $this->report->getType();
     $formModel->filtersStructure = $this->report->getFiltersStructure();
     $formModel->currencyConversionType = $this->report->getCurrencyConversionType();
     $formModel->spotConversionCurrencyCode = $this->report->getSpotConversionCurrencyCode();
     if ($this->report->isNew()) {
         $formModel->setIsNew();
     }
     $formModel->setExplicitReadWriteModelPermissions($this->report->getExplicitReadWriteModelPermissions());
     $formModel->filters = $this->report->getFilters();
     $formModel->orderBys = $this->report->getOrderBys();
     $formModel->groupBys = $this->report->getGroupBys();
     $formModel->displayAttributes = $this->report->getDisplayAttributes();
     $formModel->drillDownDisplayAttributes = $this->report->getDrillDownDisplayAttributes();
     $formModel->chart = $this->report->getChart();
 }
 /**
  * @param array $filters
  * @return array
  */
 protected function makeVariableStatesAttributeIndexes(array $filters)
 {
     $moduleClassName = $this->report->getModuleClassName();
     $attributeIndexes = array();
     VariableStatesForReportUtil::resolveAttributeIndexes($moduleClassName::getPrimaryModelName(), $attributeIndexes);
     VariableStatesForReportUtil::resolveAttributeIndexesByComponents($attributeIndexes, $this->resolveDisplayAttributes());
     VariableStatesForReportUtil::resolveAttributeIndexesByComponents($attributeIndexes, $filters);
     VariableStatesForReportUtil::resolveAttributeIndexesByComponents($attributeIndexes, $this->report->getOrderBys());
     VariableStatesForReportUtil::resolveAttributeIndexesByComponents($attributeIndexes, $this->resolveGroupBys());
     return $attributeIndexes;
 }
 /**
  * @param array $data
  * @param Report $report
  */
 protected static function resolveChart($data, Report $report)
 {
     if ($report->getType() != Report::TYPE_SUMMATION) {
         return;
     }
     $moduleClassName = $report->getModuleClassName();
     if ($moduleClassName != null) {
         $modelClassName = $moduleClassName::getPrimaryModelName();
         $adapter = ModelRelationsAndAttributesToSummationReportAdapter::make($moduleClassName, $modelClassName, $report->getType());
         $seriesDataAndLabels = ReportUtil::makeDataAndLabelsForSeriesOrRange($adapter->getAttributesForChartSeries($report->getGroupBys(), $report->getDisplayAttributes()));
         $rangeDataAndLabels = ReportUtil::makeDataAndLabelsForSeriesOrRange($adapter->getAttributesForChartRange($report->getDisplayAttributes()));
     } else {
         $seriesDataAndLabels = array();
         $rangeDataAndLabels = array();
     }
     $chart = new ChartForReportForm($seriesDataAndLabels, $rangeDataAndLabels);
     if (null != ($chartData = ArrayUtil::getArrayValue($data, 'ChartForReportForm'))) {
         $chart->setAttributes($chartData);
     }
     $report->setChart($chart);
 }
Ejemplo n.º 5
0
 /**
  * Process attribute addition from tree and than renders it.
  *
  * @param string $nodeId
  * @param string $treeType
  * @param Report $report
  * @param int $rowNumber
  * @param bool $trackableStructurePosition
  */
 public static function processAttributeAdditionFromTree($nodeId, $treeType, Report $report, $rowNumber, $trackableStructurePosition)
 {
     $nodeIdWithoutTreeType = ReportRelationsAndAttributesToTreeAdapter::removeTreeTypeFromNodeId($nodeId, $treeType);
     $moduleClassName = $report->getModuleClassName();
     $modelClassName = $moduleClassName::getPrimaryModelName();
     $form = new WizardActiveForm();
     $form->id = 'edit-form';
     $form->enableAjaxValidation = true;
     //ensures error validation populates correctly
     $wizardFormClassName = ReportToWizardFormAdapter::getFormClassNameByType($report->getType());
     $model = ComponentForReportFormFactory::makeByComponentType($moduleClassName, $modelClassName, $report->getType(), $treeType);
     $form->modelClassNameForError = $wizardFormClassName;
     $attribute = ReportRelationsAndAttributesToTreeAdapter::resolveAttributeByNodeId($nodeIdWithoutTreeType);
     $model->attributeIndexOrDerivedType = ReportRelationsAndAttributesToTreeAdapter::resolveAttributeByNodeId($nodeIdWithoutTreeType);
     $inputPrefixData = ReportRelationsAndAttributesToTreeAdapter::resolveInputPrefixData($wizardFormClassName, $treeType, (int) $rowNumber);
     $adapter = new ReportAttributeToElementAdapter($inputPrefixData, $model, $form, $treeType);
     $view = new AttributeRowForReportComponentView($adapter, (int) $rowNumber, $inputPrefixData, $attribute, (bool) $trackableStructurePosition, true, $treeType);
     $content = $view->render();
     $form->renderAddAttributeErrorSettingsScript($view::getFormId());
     Yii::app()->getClientScript()->setToAjaxMode();
     Yii::app()->getClientScript()->render($content);
     echo $content;
 }
 /**
  * @param array $componentFormsData
  * @param Report $report
  * @param null|string $componentPrefix
  */
 protected static function makeComponentFormAndPopulateReportFromData($componentFormsData, Report $report, $componentPrefix)
 {
     $moduleClassName = $report->getModuleClassName();
     $addMethodName = 'add' . $componentPrefix;
     $componentClassName = $componentPrefix . 'ForReportForm';
     $rowKey = 0;
     foreach ($componentFormsData as $componentFormData) {
         $component = new $componentClassName($moduleClassName, $moduleClassName::getPrimaryModelName(), $report->getType(), $rowKey);
         $component->setAttributes($componentFormData);
         $report->{$addMethodName}($component);
         $rowKey++;
     }
 }
Ejemplo n.º 7
0
 /**
  * Save calendar with serialized data.
  * @param Report $report
  * @param SavedCalendar $savedCalendar
  * @param array $wizardFormPostData
  * @throws FailedToSaveModelException
  */
 public static function saveCalendarWithSerializedData(Report $report, SavedCalendar $savedCalendar, $wizardFormPostData)
 {
     $filtersData = ArrayUtil::getArrayValue($wizardFormPostData, ComponentForReportForm::TYPE_FILTERS);
     if ($filtersData != null) {
         $sanitizedFiltersData = DataToReportUtil::sanitizeFiltersData($report->getModuleClassName(), $report->getType(), $filtersData);
         $unserializedData = array(ComponentForReportForm::TYPE_FILTERS => $sanitizedFiltersData, 'filtersStructure' => $report->getFiltersStructure());
         $savedCalendar->serializedData = serialize($unserializedData);
     }
     if (!$savedCalendar->save()) {
         throw new FailedToSaveModelException();
     }
 }