/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Speciality::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $query->joinWith('faculty'); $query->joinWith('cathedra'); $dataProvider->setSort(['attributes' => ['speciality_name' => ['asc' => ['speciality_name' => SORT_ASC], 'desc' => ['speciality_name' => SORT_DESC]], 'id_cathedra' => ['asc' => ['cathedra.cathedra_name' => SORT_ASC], 'desc' => ['cathedra.cathedra_name' => SORT_DESC]], 'id_faculty' => ['asc' => ['faculty.faculty_name' => SORT_ASC], 'desc' => ['faculty.faculty_name' => SORT_DESC]]]]); $this->load($params); 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(['speciality_id' => $this->speciality_id, 'id_edebo' => $this->id_edebo]); $query->andFilterWhere(['like', 'speciality_name', $this->speciality_name])->andFilterWhere(['like', 'faculty.faculty_name', $this->id_faculty])->andFilterWhere(['like', 'cathedra.cathedra_name', $this->id_cathedra]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getSpeciality() { return $this->hasOne(Speciality::className(), ['speciality_id' => 'id_speciality']); }
?> <?php echo $form->field($model, 'course_get')->dropDownList($course)->label("Курс"); ?> <?php echo $form->field($model, 'id_faculty')->dropDownList(ArrayHelper::map(Faculty::find()->all(), 'faculty_id', 'faculty_name'), ['prompt' => 'Оберіть факультет', 'onchange' => ' $.post("index.php?r=timetable/lessons/speciality_list&id=' . '"+$(this).val(), function( data ) { $( "select#lessons-id_speciality" ).html( data ); }); '])->label("Факультет"); ?> <?php echo $form->field($model, 'id_speciality')->dropDownList(ArrayHelper::map(Speciality::find()->all(), 'speciality_id', 'speciality_name'), ['prompt' => 'Оберіть спеціальність', 'onchange' => ' $.post("index.php?r=timetable/lessons/groups_list&id=' . '"+$(this).val()+"&course=' . '"+$("#lessons-course_get").val(), function( data ) { $( "select#lessons-id_group" ).html( data ); }); '])->label("Спеціальність"); ?> <?php echo $form->field($model, 'id_group')->dropDownList(ArrayHelper::map(Groups::findAll(['is_subgroup' => 0]), 'group_id', 'main_group_name'), ['prompt' => 'Оберіть групу'])->label("Група"); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Обрати' : 'Оновити', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>
public function actionSpeciality_list($id) { $countPosts = Speciality::find()->where(['id_faculty' => $id])->count(); $posts = Speciality::find()->where(['id_faculty' => $id])->orderBy('id_faculty DESC')->all(); if ($countPosts > 0) { echo "<option>Оберіть спеціальність</option>"; foreach ($posts as $post) { echo "<option value='" . $post->speciality_id . "'>" . $post->speciality_name . "</option>"; } } else { echo "<option>-</option>"; } }
<?php ActiveForm::end(); ?> <?php } else { $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'main_group_name')->textInput(['maxlength' => 50]); ?> <?php echo $form->field($model, 'id_speciality')->widget(Select2::classname(), ['data' => ArrayHelper::map(Speciality::find()->all(), 'speciality_id', 'speciality_name'), 'language' => 'uk', 'disabled' => true, 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model, 'inflow_year')->textInput(['disabled' => true]); ?> <?php echo $form->field($model, 'number_of_students')->textInput(); ?> <?php echo $form->field($model, 'id_edebo')->textInput(); ?>
/** * Finds the Speciality model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Speciality the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Speciality::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
use app\module\handbook\models\Teachers; use app\module\handbook\models\Discipline; use app\module\handbook\models\LessonsType; use app\module\handbook\models\Housing; use app\module\handbook\models\ClassRooms; use yii\bootstrap\Modal; use yii\helpers\Url; /* @var $this yii\web\View */ /* @var $model app\module\timetable\models\Lessons */ $semester_for_editor = $_GET['semester_for_editor']; $course_get = $_GET['course_get']; $faculty = $_GET['faculty_id']; $speciality = $_GET['speciality_id']; $group_id = $_GET['group_id']; $inflow_year = date('Y') - $course_get; $spec_name = Speciality::findOne(["speciality_id" => $speciality]); $faculty_name = Faculty::findOne(["faculty_id" => $faculty]); $week = ["", "Понеділок", "Вівторок", "Середа", "Четвер", "П'ятниця", "Субота"]; $groups_list = Groups::findAll(["id_speciality" => $speciality, "inflow_year" => $inflow_year, "group_id" => $group_id]); $less_time = LessonTime::find()->all(); $gl = Groups::findAll(["parent_group" => $group_id]); if (count($gl) > 0) { //Определяем есть ли у группы подгруппы $group_has_subgroup = true; $groups_list = $gl; $parent = $gl[0]['parent_group']; } else { $group_has_subgroup = false; $parent = 0; } $this->title = 'Редагувати розклад:';