Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Rooms::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pagesize' => 50]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'branch_id' => $this->branch_id]);
     $query->andFilterWhere(['like', 'room_title', $this->room_title]);
     return $dataProvider;
 }
Пример #2
0
 /**
  * Finds the Rooms model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Rooms the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Rooms::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRoom()
 {
     return $this->hasOne(Rooms::className(), ['id' => 'room_id']);
 }
Пример #4
0
    <?php 
$form = ActiveForm::begin();
?>
    <?php 
if ($mode !== 'update' && $id_wp == 0) {
    ?>
    <?php 
    echo $form->field($model, 'branch_id')->dropDownList(ArrayHelper::map(Branches::find()->all(), 'id', 'branch_title'), ['prompt' => 'Выберите подраздление...', 'onchange' => '$.post("/admin/rooms/list?id=' . '"+$(this).val(), function(data) {
            var devRoom = $("select#devices-room_id");
            devRoom.html(data);
            var devWork = $("select#devices-workplace_id");
            devWork.html(\'<option value="0"> - </option>\');
        });']);
    ?>
    <?php 
    echo $form->field($model, 'room_id')->dropDownList(ArrayHelper::map(Rooms::find()->orderBy('room_title')->all(), 'id', 'room_title'), ['prompt' => 'Выберите отдел/кабинет...', 'onchange' => '$.post("/admin/workplaces/list?id=' . '"+$(this).val(), function(data) {
            $("select#devices-workplace_id").html(data);
        });']);
    ?>
    <?php 
}
if ($id_wp > 0) {
    $model->workplace_id = $id_wp;
}
?>
    <?php 
echo $form->field($model, 'workplace_id')->dropDownList(ArrayHelper::map(Workplaces::find()->all(), 'id', function ($model_wp) {
    $snp = '';
    if ($model_wp->owner) {
        $snp = $model_wp->owner[0]['snp'];
    }
Пример #5
0
<div class="workplaces-form">

    <?php 
$form = ActiveForm::begin();
?>
    <?php 
if (Yii::$app->user->can('admin')) {
    ?>
    <?php 
    echo $form->field($model, 'branch_id')->dropDownList(ArrayHelper::map(Branches::find()->all(), 'id', 'branch_title'), ['prompt' => 'Выберите подраздление...', 'onchange' => '$.post("/admin/rooms/list?id=' . '"+$(this).val(), function(data) {
            $("select#workplaces-room_id").html(data);
        });']);
    ?>

    <?php 
    echo $form->field($model, 'room_id')->dropDownList(ArrayHelper::map(Rooms::find()->all(), 'id', 'room_title'), ['prompt' => 'Выберите отдел/кабинет...']);
    ?>
    <?php 
} else {
    echo '<p><b>' . $model->branch->branch_title . '</b></p>';
    echo '<p><b>' . $model->room->room_title . '</b></p>';
}
?>


    <?php 
echo $form->field($model, 'workplaces_title')->textInput(['maxlength' => true]);
?>
    <?php 
echo $form->field($model, 'mu')->checkbox();
?>