コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = KindOfWagon::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(['kind_id' => $this->kind_id]);
     $query->andFilterWhere(['like', 'kind_name', $this->kind_name]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: index.php プロジェクト: linhtt15/Capstone-Project
$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
ファイル: _form.php プロジェクト: linhtt15/Capstone-Project
    <?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 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
コード例 #4
0
ファイル: Wagon.php プロジェクト: linhtt15/Capstone-Project
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getKindOfWagonKind()
 {
     return $this->hasOne(KindOfWagon::className(), ['kind_id' => 'kind_of_wagon_kind_id']);
 }
コード例 #5
0
 /**
  * Finds the KindOfWagon model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return KindOfWagon the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = KindOfWagon::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }