/**
  * Validates that at least one groupBy has been selected, since this is required for a summation report
  * @return bool
  */
 public function validateGroupBys()
 {
     $validated = parent::validateGroupBys();
     if (count($this->groupBys) == 0) {
         $this->addError('groupBys', Zurmo::t('ReportsModule', 'At least one grouping must be selected'));
         $validated = false;
     }
     return $validated;
 }
 /**
  * Validates report wizard form against the post data
  * @param type $postData
  * @param ReportWizardForm $model
  * @throws NotSupportedException
  */
 public static function validateReportWizardForm($postData, ReportWizardForm $model)
 {
     if (isset($postData['validationScenario']) && $postData['validationScenario'] != null) {
         $model->setScenario($postData['validationScenario']);
     } else {
         throw new NotSupportedException();
     }
     $model->validate();
     $errorData = array();
     foreach ($model->getErrors() as $attribute => $errors) {
         $errorData[ZurmoHtml::activeId($model, $attribute)] = $errors;
     }
     return $errorData;
 }
 /**
  * Validates that at least one x and y axis groupBy has been selected.
  * @return bool
  */
 public function validateGroupBys()
 {
     $validated = parent::validateGroupBys();
     $xAxisFound = false;
     $yAxisFound = false;
     foreach ($this->groupBys as $groupBy) {
         if ($groupBy->axis == 'x') {
             $xAxisFound = true;
         }
         if ($groupBy->axis == 'y') {
             $yAxisFound = true;
         }
     }
     if (!$xAxisFound || !$yAxisFound) {
         $this->addError('groupBys', Zurmo::t('ReportsModule', 'At least one x-axis and one y-axis grouping must be selected'));
         $validated = false;
     }
     return $validated;
 }
 /**
  * @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();
 }
 protected function actionValidate($postData, ReportWizardForm $model)
 {
     if (isset($postData['validationScenario']) && $postData['validationScenario'] != null) {
         $model->setScenario($postData['validationScenario']);
     } else {
         throw new NotSupportedException();
     }
     $model->validate();
     $errorData = array();
     foreach ($model->getErrors() as $attribute => $errors) {
         $errorData[ZurmoHtml::activeId($model, $attribute)] = $errors;
     }
     echo CJSON::encode($errorData);
     Yii::app()->end(0, false);
 }