/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ClassRooms::find()->joinWith(['classTypes', 'classTypes.specClass']); //$query->joinWith('specClass'); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->setSort(['attributes' => ['options' => ['asc' => ['spec_class_name' => SORT_ASC], 'desc' => ['spec_class_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 = ClassRooms::find()->joinWith('housing'); $query->joinWith('housing'); $query->andFilterWhere(['classrooms_id' => $this->classrooms_id, 'seats' => $this->seats, 'comp_number' => $this->comp_number]); $query->andFilterWhere(['like', 'classrooms_number', $this->classrooms_number])->andFilterWhere(['like', 'options', $this->options])->andFilterWhere(['like', 'spec_class_name', $this->class_type_name])->andFilterWhere(['like', 'name', $this->id_housing]); $query->andFilterWhere(['like', 'housing.name', $this->housing_name]); return new ActiveDataProvider(['query' => $query]); }
/** * Finds the ClassRooms model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return ClassRooms the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = ClassRooms::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
function classHous($val) { $classes = ClassRooms::findOne(['classrooms_id' => $val]); $housing = Housing::findOne(['housing_id' => $classes['id_housing']]); return $classes['classrooms_number'] . ' - ' . $housing['name']; }
use app\module\handbook\models\DisciplineGroups; /* @var $this yii\web\View */ /* @var $model app\module\timetable\models\Lessons */ /* @var $form yii\widgets\ActiveForm */ $lesson_number = $_GET['lesson_number']; $day = $_GET['day']; $id_faculty = $_GET['id_faculty']; $id_speciality = $_GET['id_speciality']; $course = $_GET['course']; $semester = $_GET['semester']; $is_numerator = $_GET['is_numerator']; $id_group = $_GET['id_group']; $id_okr = $_GET['id_okr']; $students_in_group = Groups::find()->where(['group_id' => $id_group])->all(); $sig = $students_in_group[0]['number_of_students'] + 5; $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']]);
/* @var $searchModel app\module\handbook\models\ClassroomsBusySearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Забронювати аудиторію'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="classrooms-busy-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Забронювати аудиторію', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['label' => 'Аудиторія', 'attribute' => 'id_classroom', 'value' => function ($data) { $classes = ClassRooms::findOne(['classrooms_id' => $data->id_classroom]); $housing = Housing::findOne(['housing_id' => $classes['id_housing']]); return $classes['classrooms_number'] . ' - ' . $housing['name']; }], ['attribute' => 'lesson', 'value' => 'lesson0.lesson_time_name'], ['attribute' => 'day', 'value' => 'day', 'filter' => DatePicker::Widget(['model' => $searchModel, 'attribute' => 'day', 'inline' => false, 'language' => 'ua', 'clientOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd', 'class' => 'ijjijj']])], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
/** * @return \yii\db\ActiveQuery */ public function getClassroom() { return $this->hasOne(ClassRooms::className(), ['classrooms_id' => 'id_classroom']); }
public function actionClass_list($id, $seats) { if ($id == true) { $posts = ClassRooms::find()->orderBy('classrooms_number ASC')->all(); foreach ($posts as $cl) { $housing = Housing::findOne(['housing_id' => $cl['id_housing']]); echo "<option value='" . $cl['classrooms_id'] . "'>" . $cl['classrooms_number'] . ' - ' . $housing['name'] . "</option>"; } } else { $classes = ClassRooms::find()->Where('seats>' . $seats)->orderBy('classrooms_number ASC')->all(); foreach ($classes as $cl) { $housing = Housing::findOne(['housing_id' => $cl['id_housing']]); echo "<option value='" . $cl['classrooms_id'] . "'>" . $cl['classrooms_number'] . ' - ' . $housing['name'] . "</option>"; } } }
use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use kartik\select2\Select2; use app\module\handbook\models\DisciplineList; use app\module\handbook\models\Cathedra; use app\module\handbook\models\LessonsType; use app\module\handbook\models\Groups; use app\module\handbook\models\ClassRooms; use app\module\handbook\models\Housing; use app\module\handbook\models\Faculty; /* @var $this yii\web\View */ /* @var $model app\module\handbook\models\Discipline */ /* @var $form yii\widgets\ActiveForm */ $classes = ClassRooms::find()->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']; } $all_faculty = Faculty::find()->orderBy('faculty_name ASC')->all(); foreach ($all_faculty as $af) { $tmp_cathedra = Cathedra::find()->where(['id_faculty' => $af['faculty_id']])->orderBy('cathedra_name ASC')->all(); foreach ($tmp_cathedra as $tc) { $all_cathedra[$tc['cathedra_id']] = $tc['cathedra_name'] . " / " . $af['faculty_name']; } } ?> <div class="discipline-form">
/** * @return \yii\db\ActiveQuery */ public function getClassRooms() { return $this->hasMany(ClassRooms::className(), ['id_housing' => 'housing_id']); }
function getClassromNumber($id_classroom) { $classroom_array = ClassRooms::findOne(['classrooms_id' => $id_classroom]); return 'Аудиторія № ' . $classroom_array['classrooms_number']; }