/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Discipline::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $query->joinWith('cathedra'); $query->joinWith('disciplineName'); $query->joinWith('lessonsType'); $this->load($params); $dataProvider->setSort(['attributes' => ['id_discipline' => ['asc' => ['discipline_name' => SORT_ASC], 'desc' => ['discipline_name' => SORT_DESC]], 'id_cathedra' => ['asc' => ['cathedra.cathedra_name' => SORT_ASC], 'desc' => ['cathedra.cathedra_name' => SORT_DESC]], 'id_lessons_type' => ['asc' => ['lesson_type_name' => SORT_ASC], 'desc' => ['lesson_type_name' => SORT_DESC]], 'course' => ['asc' => ['course' => SORT_ASC], 'desc' => ['course' => SORT_DESC]], 'hours' => ['asc' => ['hours' => SORT_ASC], 'desc' => ['hours' => SORT_DESC]], 'semestr_hours' => ['asc' => ['semestr_hours' => SORT_ASC], 'desc' => ['semestr_hours' => SORT_DESC]]]]); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['discipline_distribution_id' => $this->discipline_distribution_id, 'id_edbo' => $this->id_edbo, 'id_deanery' => $this->id_deanery, 'id_group' => $this->id_group, 'course' => $this->course, 'hours' => $this->hours, 'semestr_hours' => $this->semestr_hours, 'id_classroom' => $this->id_classroom]); $query->andFilterWhere(['like', 'cathedra.cathedra_name', $this->id_cathedra])->andFilterWhere(['like', 'discipline_name', $this->id_discipline])->andFilterWhere(['like', 'lesson_type_name', $this->id_lessons_type]); return $dataProvider; }
$classes = ClassRooms::find()->Where('seats>' . $sig)->orderBy('classrooms_number ASC')->all(); foreach ($classes as $cl) { $housing = Housing::findOne(['housing_id' => $cl['id_housing']]); $classroomsArray[$cl['classrooms_id']] = $cl['classrooms_number'] . ' - ' . $housing['name']; } $d = Discipline::findAll(['id_group' => $id_group]); if (empty($d)) { $d = Discipline::findAll(['id_group' => $students_in_group[0]['parent_group']]); } if (empty($d)) { echo '<div class="alert alert-danger" role="alert">Для даної групи немає дисциплін!</div>'; exit; } foreach ($d as $dd) { //$disciplines = Discipline::findAll(['discipline_distribution_id' => $dd['id_discipline']]); $disciplines = Discipline::findAll(['id_discipline' => $dd['id_discipline']]); foreach ($disciplines as $disc) { $disc_name = DisciplineList::findOne(['discipline_id' => $disc['id_discipline']]); $disc_type = LessonsType::findOne(['id' => $disc['id_lessons_type']]); $da[$disc['discipline_distribution_id']] = $disc_name['discipline_name'] . " - " . $disc_type['lesson_type_name']; } } asort($da); foreach ($da as $x => $x_value) { $discipline_array[$x] = $x_value; } ?> <div class="lessons-form"> <?php
public function actionTeacher_by_cathedra($id) { $cathedra_id = Discipline::findOne(['discipline_distribution_id' => $id]); $countPosts = Teachers::find()->where(['id_cathedra' => $cathedra_id['id_cathedra']])->count(); $posts = Teachers::find()->where(['id_cathedra' => $cathedra_id['id_cathedra']])->orderBy('teacher_name ASC')->all(); if ($countPosts > 0) { echo "<option>Оберіть викладача</option>"; foreach ($posts as $post) { echo "<option value='" . $post->teacher_id . "'>" . $post->teacher_name . "</option>"; } } else { echo "<option>-</option>"; } }
/** * @return \yii\db\ActiveQuery */ public function getDisciplines() { return $this->hasMany(Discipline::className(), ['id_discipline' => 'discipline_id']); }
/** * @return \yii\db\ActiveQuery */ public function getIdDiscipline() { return $this->hasOne(Discipline::className(), ['discipline_id' => 'id_discipline']); }
/** * Finds the Discipline model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Discipline the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Discipline::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
function getDisciplineType($id_discipline) { $disc_info = Discipline::findOne(['discipline_distribution_id' => $id_discipline]); $discipline_type = LessonsType::findOne(['id' => $disc_info['id_lessons_type']]); return $discipline_type['lesson_type_name']; }