Exemplo n.º 1
0
 public function actionEdit()
 {
     //var_dump($_POST);
     $user = \Yii::$app->user;
     if ($user->isGuest) {
         return $this->redirect('/polzovatel/vhod');
     }
     $fiz_lico_id = ApiGlobals::getFizLicoPolzovatelyaId();
     $id = $_GET['id'];
     if (!$this->canEdit($fiz_lico_id, $id)) {
         return $this->redirect('/polzovatel/vhod');
     }
     $kursModel = KursRecord::find($id)->with('kategoriyaSlushatelyas')->where(['id' => $id])->one();
     if ($kursModel->load(Yii::$app->request->post()) && $kursModel->validate()) {
         KursGlobals::set_kurs_status($kursModel->id, 'redaktiruetsya');
         $kursModel->save();
         $kursModel = KursRecord::find($id)->with('kategoriyaSlushatelyas')->where(['id' => $id])->one();
     }
     if (!$kursModel->status_programmy) {
         $kursModel->status_programmy = StatusProgrammyKursa::REDAKTIRUETSYA;
     }
     $podrazdels = KursGlobals::get_podrazdel_and_themes($id);
     $attestaciya = KursGlobals::get_attestatciya($id);
     $vidy_rabot = KursGlobals::get_vidy_rabot();
     $sotrudniki = KursGlobals::get_sotrudniki();
     $sotrudniki[-1] = 'Вакансия';
     $kf_temi = KursGlobals::get_kontrolnie_formi_temi();
     if ($kursModel['tip'] != 'pk') {
         $kf_temi[-1] = 'без формы контроля';
     }
     $fiak = KursGlobals::get_formi_itogovoi_attestacii();
     $kug = KursGlobals::get_kug($id);
     $kims = KursGlobals::get_kims($id);
     $razdels = KursGlobals::get_razdels();
     $razdels[-1] = 'Другое';
     $max_week_num = KursGlobals::get_max_week_of_kurs($id);
     $razdel_types = ['baz' => 'Базовая часть', 'prof' => 'Профильная часть'];
     $weeks = [];
     for ($i = 1; $i <= 40; $i++) {
         $weeks[$i] = $i;
     }
     return $this->render('edit', ['kursModel' => $kursModel, 'podrazdels' => $podrazdels, 'vidy_rabot' => $vidy_rabot, 'sotrudniki' => $sotrudniki, 'kug' => $kug, 'kf_temi' => $kf_temi, 'fiak' => $fiak, 'attestaciya' => $attestaciya, 'kims' => $kims, 'razdels' => $razdels, 'max_week_num' => $max_week_num, 'weeks' => $weeks, 'razdel_types' => $razdel_types]);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getKurs()
 {
     return $this->hasMany(KursRecord::className(), ['id' => 'kurs'])->viaTable('kategoriya_slushatelya_kursa', ['kategoriya_slushatelya' => 'id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getKurs0()
 {
     return $this->hasOne(KursRecord::className(), ['id' => 'kurs']);
 }