/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Faculty::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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(['faculty_id' => $this->faculty_id, 'id_edbo' => $this->id_edbo, 'id_deanery' => $this->id_deanery]); $query->andFilterWhere(['like', 'faculty_name', $this->faculty_name]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getFaculty() { return $this->hasOne(Faculty::className(), ['faculty_id' => 'id_faculty']); }
<div class="lessons-create"> <div class="col-md-7"> <h2>Створити новий розклад</h2> <?php echo $this->render('_beginForm', ['model' => $model]); ?> </div> <div class="col-md-5"> <h2>Вже існуючі розклади</h2> <div class="panel-group" role="tablist"> <?php $all_faculty = Faculty::find()->orderBy('faculty_name ASC')->all(); $count = 0; foreach ($all_faculty as $af) { unset($groups_array); $all_gr = Lessons::find()->where(['id_faculty' => $af['faculty_id']])->select('id_group')->distinct()->all(); foreach ($all_gr as $ag) { $gr = Groups::find()->where(['group_id' => $ag['id_group']])->all(); if ($gr[0]['parent_group'] == 0) { $groups_array[] = $gr[0]['group_id']; } else { $groups_array[] = $gr[0]['parent_group']; } } $groups_list = array_unique($groups_array); ?> <div class="panel panel-default">
<div class="lessons-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'semester_for_editor')->dropDownList($semestr)->label("Семестр"); ?> <?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
$form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'speciality_name')->textInput(['maxlength' => 100]); ?> <?php echo $form->field($model, 'id_edebo')->textInput(); ?> <?php echo $form->field($model, 'id_cathedra')->widget(Select2::classname(), ['data' => $all_cathedra, 'language' => 'uk', 'pluginOptions' => ['allowClear' => true]])->label('Кафедра'); ?> <?php echo $form->field($model, 'id_faculty')->dropDownList(ArrayHelper::map(Faculty::find()->orderBy('faculty_name ASC')->all(), 'faculty_id', 'faculty_name')); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Додати' : 'Оновити', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
/** * Finds the Faculty model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Faculty the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Faculty::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
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 = 'Редагувати розклад:'; $this->params['breadcrumbs'][] = ['label' => 'Редактор розкладу', 'url' => ['index']];