Beispiel #1
0
 /**
  * Finds the Kurs model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Kurs the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Kurs::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Kurs::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['kurs_id' => $this->kurs_id, 'user_id' => $this->user_id]);
     $query->andFilterWhere(['like', 'kurs_name', $this->kurs_name])->andFilterWhere(['like', 'kurs_url', $this->kurs_url])->andFilterWhere(['like', 'kurs_brief', $this->kurs_brief])->andFilterWhere(['like', 'kurs_subscribe', $this->kurs_subscribe])->andFilterWhere(['like', 'kurs_anons', $this->kurs_anons])->andFilterWhere(['like', 'kurs_tizer', $this->kurs_tizer])->andFilterWhere(['like', 'kursStatusName', $this->kursStatusName->kurs_status_name])->andFilterWhere(['like', 'kurs_whom', $this->kurs_whom]);
     return $dataProvider;
 }
Beispiel #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Kurs::find()->where(['przedmiot_id' => $params]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     return $dataProvider;
 }
 /**
  * Updates an existing Przedmiot model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @param integer $kierunekStudiow_id
  * @param integer $user_id
  * @return mixed
  */
 public function actionUpdate($step, $id = null)
 {
     $forModal = null;
     switch ($step) {
         case '1':
             if (!($model = Przedmiot::find()->where(['id' => $id])->one())) {
                 $model = new Przedmiot();
             }
             break;
         case '2':
             $forModal = new Kurs();
             $searchModel = new KursSearch();
             $model = $searchModel->search(['przedmiot_id' => $id]);
             break;
         case '3':
             // wymagania
             if (!($model = Przedmiot::find()->where(['id' => $id])->one())) {
                 $model = new Przedmiot();
             }
             break;
         case '4':
             // celKP
             $forModal = new CelKP();
             $searchModel = new CelKPSearch();
             $model = $searchModel->search(['przedmiot_id' => $id]);
             break;
         case '5':
             // pek
             $forModal = new Pek();
             $searchModel = new PekSearch();
             $model = $searchModel->search(['przedmiot_id' => $id]);
             break;
         case '6':
             // tresci programowe
             $forModal = new TresciProgramowe();
             $searchModel = new TresciProgramoweSearch();
             $model = $searchModel->search(['przedmiot_id' => $id]);
             break;
         case '7':
             // narzedziaDydaktyczne
             $forModal = new NarzedziaDydaktyczne();
             $searchModel = new NarzedziaDydaktyczneSearch();
             $model = $searchModel->search(['przedmiot_id' => $id]);
             break;
         case '8':
             // ocena osiagniecie pek
             $forModal = new Ocena();
             $searchModel = new OcenaSearch();
             $model = $searchModel->search(['przedmiot_id' => $id]);
             break;
         case '9':
             // literatura
             if (!($model = Przedmiot::find()->where(['id' => $id])->one())) {
                 $model = new Przedmiot();
             }
             break;
         case '10':
             // opiekun
             if (!($model = Przedmiot::find()->where(['id' => $id])->one())) {
                 $model = new Przedmiot();
             }
             break;
     }
     if (Yii::$app->user->identity->groupId != 'admin' && Przedmiot::idAutora($id) != Yii::$app->user->identity->id) {
         Yii::trace(Yii::$app->user->identity->groupId);
         Yii::trace(Yii::$app->user->identity->id);
         throw new \yii\base\ErrorException("Nie masz odpowiednich uprawnień do edycji tej karty przedmiotu.");
     } else {
         if ($step != 2 && $step != 4 && $step != 5 && $step != 6 && $step != 7 && $step != 8 && $model->load(Yii::$app->request->post()) && $model->save()) {
             if ($step != 11) {
                 return $this->redirect(['update', 'id' => $id, 'step' => $step]);
                 $step++;
             } else {
                 return $this->redirect(['index']);
             }
         } else {
             if ($step == 4 && $forModal->load(Yii::$app->request->post()) && $forModal->save()) {
                 $forModal = new CelKP();
             } elseif ($step == 2 && $forModal->load(Yii::$app->request->post()) && $forModal->save()) {
                 $forModal = new Kurs();
             } elseif ($step == 5 && $forModal->load(Yii::$app->request->post()) && $forModal->save()) {
                 $forModal = new Pek();
             } elseif ($step == 6 && $forModal->load(Yii::$app->request->post()) && $forModal->save()) {
                 $forModal = new TresciProgramowe();
             } elseif ($step == 7 && $forModal->load(Yii::$app->request->post()) && $forModal->save()) {
                 $forModal = new NarzedziaDydaktyczne();
             } elseif ($step == 8 && $forModal->load(Yii::$app->request->post())) {
                 $forModal->przedmiot_id = $id;
                 $forModal->save();
                 if ($wybranePek = Yii::$app->request->post()['wybranePek']) {
                     foreach ($wybranePek as $pek) {
                         $ocenapek = new OcenaOsiagnieciaPekpek();
                         $ocenapek->pek_id = $pek;
                         $ocenapek->ocenaOsiagnieciaPek_id = $forModal->id;
                         $ocenapek->save();
                     }
                 }
                 $forModal = new Ocena();
             }
         }
         return $this->render('update', ['model' => $model, 'id' => $id, 'step' => $step, 'forModal' => $forModal]);
     }
 }
Beispiel #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getKurs()
 {
     return $this->hasMany(Kurs::className(), ['przedmiot_id' => 'id']);
 }
Beispiel #6
0
 public function getKurs()
 {
     return $this->hasOne(Kurs::className(), ['kurs_status_id' => 'kurs_status_id']);
 }