/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Specclasses::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(['spec_class_id' => $this->spec_class_id]); $query->andFilterWhere(['like', 'spec_class_name', $this->spec_class_name]); return $dataProvider; }
/** * Finds the Specclasses model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Specclasses the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Specclasses::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php use yii\helpers\Html; use yii\widgets\DetailView; use app\module\handbook\models\ClassType; use app\module\handbook\models\Specclasses; /* @var $this yii\web\View */ /* @var $model app\module\handbook\models\ClassRooms */ $this->title = 'Аудиторія №' . $model->classrooms_number; $this->params['breadcrumbs'][] = ['label' => 'Аудиторії', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; $optionsId = ClassType::findAll(['classroom_id' => $model->classrooms_id]); for ($i = 0; $i < count($optionsId); $i++) { $optionName[] = Specclasses::findAll(['spec_class_id' => $optionsId[$i]['spec_class_id']]); $optionsArray[] = $optionName[$i][0]['spec_class_name'] . " "; } $optionsString = implode($optionsArray); function translater($val) { if ($val == 0) { return "Ні"; } else { return "Так"; } } ?> <div class="classrooms-view"> <h1><?php echo Html::encode($this->title); ?>
<?php echo $form->field($model, 'id_housing')->dropDownList(ArrayHelper::map(Housing::find()->all(), 'housing_id', 'name')); ?> <?php echo $form->field($model, 'seats')->textInput(); ?> <?php echo $form->field($model, 'comp_number')->textInput(); ?> <?php echo Html::label("Тип аудиторії"); echo Select2::widget(['model' => $model, 'attribute' => 'options', 'language' => 'ru', 'data' => ArrayHelper::map(Specclasses::find()->all(), 'spec_class_id', 'spec_class_name'), 'options' => ['multiple' => true]]); ?> <br/> <?php echo Html::label('Інші дисципліни'); echo $form->field($model, 'is_public')->widget(SwitchInput::classname(), ['type' => SwitchInput::CHECKBOX])->label(false); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Створити' : 'Оновити', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?>