/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return MethodOfCollectionData the loaded model * @throws CHttpException */ public function loadModel($id) { $model = MethodOfCollectionData::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
protected function getParamsToRender() { return array_merge(parent::getParamsToRender(), array('methods' => MethodOfCollectionData::model()->findAll())); }
public function next() { if (count($this->steps) <= $this->curStep + 1) { return null; } else { $this->curStep++; // Если нужно загрузить анкету (в финале), то пропускаем щаг с анкетой if ($this->needFileWithClientData() && $this->steps[$this->curStep] instanceof SurveyRequestStep5) { $this->next(); } // Если перед нами представитель малого бизнеса, то пролистываем после Исследуемого рынка до Калькуляции if ($this->isSmallBusiness() && ($this->steps[$this->curStep] instanceof SurveyRequestStep3 || $this->steps[$this->curStep] instanceof SurveyRequestStep4 || $this->steps[$this->curStep] instanceof SurveyRequestStep5)) { $this->next(); } if ($this->steps[$this->curStep] instanceof SurveyRequestStep5) { $purposesIds = $this->steps[0]->purposes; if (!empty($purposesIds)) { $purposes = SurveyPurpose::model()->findAllByPk($purposesIds); $questionsIds = array(); $blocksIds = array(); foreach ($purposes as $purpose) { $blocks = $purpose->questionsBlocks; if (!empty($blocks)) { $blocksIds = array_merge(array_map(function ($block) { return $block->id; }, $blocks), $blocksIds); } } if (!empty($blocksIds)) { $criteria = new CDbCriteria(); $criteria->with = 'questionBlockQuestions'; $criteria->addInCondition('questionBlockQuestions.questionBlockId', $blocksIds); $criteria->select = 't.id'; $questions = SurveyPurposeQuestion::model()->findAll($criteria); $questionsIds = array_map(function ($question) { return $question->id; }, $questions); } $this->steps[$this->curStep]->questions = $questionsIds; } } $smallBusinessServices = array(); $commonServices = array(); if ($this->steps[$this->curStep] instanceof SurveyRequestStep6) { $this->steps[$this->curStep]->init(); $this->steps[$this->curStep]->selectedSurveySteps = array(); if (count($this->steps[0]->purposes) > 0) { $criteria = new CDbCriteria(); $purposesTable = SurveyPurpose::model()->tableName(); $criteria->join = "INNER JOIN {$purposesTable} purpose ON t.id = purpose.serviceId"; $criteria->addInCondition('purpose.id', $this->steps[0]->purposes); $services = Service::model()->findAll($criteria); foreach ($services as $service) { if ($service->type == ServiceHelper::TYPE_SMALL_BUSINESS) { $smallBusinessServices[] = $service->id; } else { $commonServices[] = $service->id; } } } if (count($this->steps[3]->methodsOfCollectionData) > 0) { $criteria = new CDbCriteria(); $methodsTable = MethodOfCollectionData::model()->tableName(); $criteria->join = "INNER JOIN {$methodsTable} method ON t.id = method.serviceId"; $methodIds = array_keys($this->steps[3]->methodsOfCollectionData); $criteria->addInCondition('method.id', $methodIds); $services = Service::model()->findAll($criteria); foreach ($services as $service) { if ($service->type == ServiceHelper::TYPE_SMALL_BUSINESS) { $smallBusinessServices[] = $service->id; } else { $commonServices[] = $service->id; } } } if (count($commonServices) == 0) { $commonServices[] = SurveyRequestWizard::DEFAULT_SERVICE; } $criteria = new CDbCriteria(); $criteria->addCondition("isStatic"); $services = Service::model()->findAll($criteria); foreach ($services as $service) { $commonServices[] = $service->id; } if (count($smallBusinessServices) > 0) { $this->steps[$this->curStep]->selectedSurveySteps = $smallBusinessServices; } else { $this->steps[$this->curStep]->selectedSurveySteps = $commonServices; } } return $this->current(); } }