/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = WagonStatus::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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(['status_id' => $this->status_id]);
     $query->andFilterWhere(['like', 'name_of_status', $this->name_of_status]);
     return $dataProvider;
 }
예제 #2
0
$this->title = 'Wagons';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wagon-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::button('Thêm toa', ['value' => Url::to('wagon/create'), 'class' => 'btn btn-success', 'id' => 'modalButton']);
?>
    </p>

    <?php 
Modal::begin(['header' => '<h4>THÊM TOA XE</h4>', 'id' => 'modal', 'size' => 'modal-lg']);
echo "<div id='modalContent'></div>";
Modal::end();
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'wagon_number', 'created_year', ['attribute' => 'start_date', 'value' => 'start_date', 'filter' => DatePicker::widget(['model' => $searchModel, 'attribute' => 'start_date', 'clientOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']])], ['attribute' => 'wagon_status_id_status', 'value' => 'wagonStatusIdStatus.name_of_status', 'filter' => Html::activeDropDownList($searchModel, 'wagon_status_id_status', ArrayHelper::map(WagonStatus::find()->all(), 'status_id', 'name_of_status'), ['class' => 'form-control', 'prompt' => 'Please select...'])], ['attribute' => 'station_station_id', 'value' => 'stationStation.station_name', 'filter' => Html::activeDropDownList($searchModel, 'station_station_id', ArrayHelper::map(\app\models\Station::find()->all(), 'station_id', 'station_name'), ['class' => 'form-control', 'prompt' => 'Please select...'])], ['attribute' => 'kind_of_wagon_kind_id', 'value' => 'kindOfWagonKind.kind_name', 'filter' => Html::activeDropDownList($searchModel, 'kind_of_wagon_kind_id', ArrayHelper::map(\app\models\KindOfWagon::find()->all(), 'kind_id', 'kind_name'), ['class' => 'form-control', 'prompt' => 'Please select...'])], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
예제 #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getWagonStatusIdStatus()
 {
     return $this->hasOne(WagonStatus::className(), ['status_id' => 'wagon_status_id_status']);
 }
예제 #4
0
?>

    <?php 
echo $form->field($model, 'wagon_number')->textInput();
?>

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

    <?php 
echo $form->field($model, 'start_date')->widget(DatePicker::className(), ['inline' => false, 'clientOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']]);
?>

    <?php 
echo $form->field($model, 'wagon_status_id_status')->dropDownList(ArrayHelper::map(WagonStatus::find()->all(), 'status_id', 'name_of_status'), ['prompt' => 'Trạng thái toa...']);
?>



    <?php 
echo $form->field($model, 'station_station_id')->dropDownList(ArrayHelper::map(Station::find()->all(), 'station_id', 'station_name'), ['prompt' => 'Chọn ga...']);
?>
    <?php 
echo $form->field($model, 'kind_of_wagon_kind_id')->dropDownList(ArrayHelper::map(KindOfWagon::find()->all(), 'kind_id', 'kind_name'), ['prompt' => 'Chọn loại toa...']);
?>



    <div class="form-group">
        <?php 
 /**
  * Finds the WagonStatus model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return WagonStatus the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = WagonStatus::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }