コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = BrandRepair::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(['brand_repair_id' => $this->brand_repair_id, 'telephone' => $this->telephone]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'address', $this->address]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBrandRepairBrandRepair()
 {
     return $this->hasOne(BrandRepair::className(), ['brand_repair_id' => 'brand_repair_brand_repair_id']);
 }
コード例 #3
0
 /**
  * Finds the BrandRepair model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return BrandRepair the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = BrandRepair::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #4
0
ファイル: index.php プロジェクト: linhtt15/Capstone-Project
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Create Date Repair', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'begin_day', 'value' => 'begin_day', 'contentOptions' => ['style' => 'width:10%'], 'filter' => DatePicker::widget(['model' => $searchModel, 'attribute' => 'begin_day', 'clientOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']])], ['attribute' => 'repair_day', 'contentOptions' => ['style' => 'width:10%'], 'value' => function ($data) {
    $date = date("d-m-Y", strtotime($data["repair_day"]));
    $date2 = new DateTime($date);
    $date2->add(new DateInterval('P20M'));
    return $date2->format("Y-m-d");
}, 'filter' => DatePicker::widget(['model' => $searchModel, 'attribute' => 'repair_day', 'clientOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']])], ['attribute' => 'repair_complete_day', 'contentOptions' => ['style' => 'width:10%'], 'value' => function ($data) {
    $date = date("d-m-Y", strtotime($data["repair_day"]));
    $date2 = new DateTime($date);
    $date2->add(new DateInterval('P20M'));
    $date2 = $date2->add(new DateInterval('P10D'));
    return $date2->format("Y-m-d");
}, 'filter' => DatePicker::widget(['model' => $searchModel, 'attribute' => 'repair_complete_day', 'clientOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']])], ['attribute' => 'wagon_wagon_id', 'value' => 'wagonWagon.wagon_number', 'filter' => Html::activeDropDownList($searchModel, 'wagon_wagon_id', ArrayHelper::map(Wagon::find()->all(), 'wagon_id', 'wagon_number'), ['class' => 'form-control', 'prompt' => 'Please select...'])], ['attribute' => 'brand_repair_brand_repair_id', 'value' => 'brandRepairBrandRepair.name', 'filter' => Html::activeDropDownList($searchModel, 'brand_repair_brand_repair_id', ArrayHelper::map(\app\models\BrandRepair::find()->all(), 'brand_repair_id', 'name'), ['class' => 'form-control', 'prompt' => 'Please select...'])], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
コード例 #5
0
ファイル: _form.php プロジェクト: linhtt15/Capstone-Project

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


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

    <?php 
echo $form->field($model, 'wagon_wagon_id')->dropDownList(ArrayHelper::map(Wagon::find()->all(), 'wagon_id', 'wagon_number'), ['prompt' => 'Số hiệu toa...']);
?>

    <?php 
echo $form->field($model, 'brand_repair_brand_repair_id')->dropDownList(ArrayHelper::map(BrandRepair::find()->all(), 'brand_repair_id', 'name'), ['prompt' => 'Hãng sửa chữa...']);
?>

    <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>