public function safeUp()
 {
     $recordsData = array(array('title' => 'Подготовка проекта', 'type' => 'MethodOfCollectionData', 'price' => 3500, 'duration' => 2, 'comments' => 'Разработка и согласование анкеты, обучение интервьюеров.', 'sortOrder' => 0, 'readOnly' => true, "selectable" => false, "defaultCount" => 1), array('title' => 'Личный опрос', 'type' => 'MethodOfCollectionDataByQuestions', 'price' => 10, 'duration' => 0, 'comments' => '', 'sortOrder' => 1, 'readOnly' => false, "selectable" => true, "defaultCount" => 385), array('title' => 'Телефонный опрос', 'type' => 'MethodOfCollectionDataByQuestions', 'price' => 7, 'duration' => 0, 'comments' => '', 'sortOrder' => 2, 'readOnly' => false, "selectable" => true, "defaultCount" => 385), array('title' => 'Онлайн-опрос', 'type' => 'MethodOfCollectionDataByQuestions', 'price' => 7, 'duration' => 0, 'comments' => '', 'sortOrder' => 3, 'readOnly' => false, "selectable" => true, "defaultCount" => 385), array('title' => 'Холл-тест', 'type' => 'MethodOfCollectionData', 'price' => 450, 'duration' => 0, 'comments' => '', 'sortOrder' => 4, 'readOnly' => false, "selectable" => true, "defaultCount" => 200), array('title' => 'Экспертные интервью', 'type' => 'MethodOfCollectionData', 'price' => 1500, 'duration' => 0, 'comments' => '', 'sortOrder' => 5, 'readOnly' => false, "selectable" => true, "defaultCount" => 10), array('title' => 'Глубинные интервью', 'type' => 'MethodOfCollectionData', 'price' => 2300, 'duration' => 0, 'comments' => '', 'sortOrder' => 6, 'readOnly' => false, "selectable" => true, "defaultCount" => 20), array('title' => 'Фокус-группа', 'type' => 'MethodOfCollectionData', 'price' => 37500, 'duration' => 0, 'comments' => '', 'sortOrder' => 7, 'readOnly' => false, "selectable" => true, "defaultCount" => 2), array('title' => 'Кабинетное исследование', 'type' => 'MethodOfCollectionDataByRegions', 'price' => 16500, 'duration' => 0, 'comments' => '', 'sortOrder' => 8, 'readOnly' => false, "selectable" => true, "defaultCount" => 1), array('title' => 'Онлайн-опрос с приглашением через e-mail по моей базе (средняя отвечаемость до 1%)', 'type' => 'MethodOfCollectionDataByQuestions', 'price' => 4, 'duration' => 0, 'comments' => '', 'sortOrder' => 9, 'readOnly' => false, "selectable" => true, "defaultCount" => 385), array('title' => 'Онлайн-опрос с приглашением через смс по моей базе (средняя отвечаемость до 3%)', 'type' => 'MethodOfCollectionDataByQuestions', 'price' => 5, 'duration' => 0, 'comments' => '', 'sortOrder' => 10, 'readOnly' => false, "selectable" => true, "defaultCount" => 385), array('title' => 'Онлайн-опрос, распространением ссылки я займусь самостоятельно', 'type' => 'MethodOfCollectionData', 'price' => 0, 'duration' => 0, 'comments' => '', 'sortOrder' => 11, 'readOnly' => false, "selectable" => true, "defaultCount" => 0), array('title' => 'Итоговая отчетность', 'type' => 'MethodOfCollectionDataByRegions', 'price' => 16500, 'duration' => 0, 'comments' => '', 'sortOrder' => 12, 'readOnly' => true, "selectable" => false, "defaultCount" => 0), array('title' => 'Сравнение с показателями отрасли', 'type' => 'MethodOfCollectionDataComparingWithOrganizations', 'price' => 2000, 'duration' => 0, 'comments' => '', 'sortOrder' => 13, 'readOnly' => true, "selectable" => false, "defaultCount" => 0));
     foreach ($recordsData as $recordData) {
         $method = new MethodOfCollectionData();
         $method->setAttributes($recordData);
         $method->save();
     }
 }
Ejemplo n.º 2
0
 protected function getParamsToRender()
 {
     return array_merge(parent::getParamsToRender(), array('methods' => MethodOfCollectionData::model()->findAll()));
 }
 /**
  * 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;
 }
Ejemplo n.º 4
0
 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();
     }
 }