/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Typecar::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(['id' => $this->id]); $query->andFilterWhere(['like', 'type_name', $this->type_name])->andFilterWhere(['like', 'detail', $this->detail]); return $dataProvider; }
function Get_type() { $type = Typecar::find()->all(); return $type; }
?> <p class="pull-right"> <?php echo Html::a('<i class="fa fa-pencil"></i> แก้ไข', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a('<i class="fa fa-trash"></i> ลบ', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]); ?> <?php } ?> </p> </div> <div class="box-body"> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['license_plate', 'brand', 'model', 'color', ['attribute' => 'date_buy', 'format' => 'raw', 'value' => $config->thaidate($model->date_buy), 'displayOnly' => true], ['attribute' => 'price', 'format' => 'integer'], ['attribute' => 'down', 'format' => 'integer'], ['attribute' => 'period_price', 'format' => 'integer'], 'period', 'date_supply', ['attribute' => 'type_id', 'format' => 'raw', 'value' => \app\models\Typecar::find()->where(['id' => $model->type_id])->one()['type_name'], 'displayOnly' => true]], 'mode' => 'view', 'striped' => true, 'condensed' => true, 'responsive' => true, 'hAlign' => 'left', 'vAlign' => 'center']); ?> </div> </div> </div> <!-- ประวัติการวิ่งรถ --> <div class="tab-pane" id="history"> <div id="load_history"></div> </div> <div class="tab-pane" id="repair"> <div class="row"> <div class="col-xs-12 col-sm-12 col-md-5 col-lg-5"> <div class="form-group"> <div class="input-group"> <div class="input-group-addon">ปี</div>
/* @var $model app\models\Truck */ /* @var $form yii\widgets\ActiveForm */ if ($flag == '1') { $readonly = true; } else { $readonly = false; } ?> <div class="truck-form"> <?php $form = ActiveForm::begin(['type' => ActiveForm::TYPE_HORIZONTAL, 'formConfig' => ['labelSpan' => 2, 'deviceSize' => ActiveForm::SIZE_SMALL]]); ?> <?php echo $form->field($model, 'type_id')->dropDownList(ArrayHelper::map(\app\models\Typecar::find()->all(), 'id', 'type_name'), ['id' => 'id', 'required' => 'required', 'prompt' => 'เลือกประเภทรถ']); ?> <?php echo $form->field($model, 'license_plate')->textInput(['maxlength' => true, 'readonly' => $readonly]); ?> <?php echo $form->field($model, 'brand')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'model')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'color')->textInput(['maxlength' => true]);
<?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('<i class="fa fa-plus"></i> เพิ่มรถบรรทุก', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php $columns = [['class' => 'yii\\grid\\SerialColumn'], 'license_plate', 'brand', 'model', 'color', ['attribute' => 'price', 'format' => 'raw', 'header' => 'ราคา', 'hAlign' => 'right', 'mergeHeader' => true, 'value' => function ($model) { return number_format($model->price); }], ['attribute' => 'type_id', 'width' => '200px', 'value' => function ($model) { return \app\models\Typecar::find()->where(['id' => $model->type_id])->one()['type_name']; }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(\app\models\Typecar::find()->orderBy('type_name')->asArray()->all(), 'id', 'type_name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'ประเภทรถ']], ['attribute' => 'status', 'hAlign' => 'center', 'format' => 'raw', 'label' => 'สถานะ', 'mergeHeader' => true, 'value' => function ($model) { if ($model->status == '1') { $status = "<font style='color:red'><i class='fa fa-remove'></i> ถูกจำหน่าย</font>"; } else { $status = "<font style='color:green'><i class='fa fa-check'></i> ใช้งานได้</font>"; } return $status; }], ['class' => 'kartik\\grid\\ActionColumn', 'header' => 'ตัวเลือก', 'template' => '{view} {update} {delete} ', 'buttons' => ['view' => function ($url, $model) { return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url); }, 'update' => function ($url, $model) { //$sql = "SELECT COUNT(*) AS TOTAL FROM map_truck WHERE (truck_1 = '$model->license_plate' OR truck_2 = '$model->license_plate' )"; //$check = Yii::$app->db->createCommand($sql)->queryOne(); if ($model->status == '1') { $url = "javascript:alert('ไม่สามารถแก้ไขข้อมูลนี้ได้ ... !')"; } return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url);
/* @var $this yii\web\View */ /* @var $model app\models\AffiliatedTruck */ $company = Affiliated::find()->where(['company_id' => $company_id])->one()['company']; $this->title = $model->license_plate; $this->params['breadcrumbs'][] = ['label' => $company, 'url' => ['affiliated/view', 'id' => $id]]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="box box-primary"> <div class="box-header with-border"> <i class="fa fa-truck"></i><i class="fa fa-pencil"></i> <?php echo Html::encode($this->title); ?> <div class="pull-right"> <?php echo Html::a('<i class="fa fa-pencil"></i> แก้ไข', ['update', 'company_id' => $company_id, '_id' => $id, 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a('<i class="fa fa-trash"></i> ลบ', ['delete', '_id' => $id, 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]); ?> </div> </div> <div class="box-body"> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['id', ['attribute' => 'company_id', 'format' => 'raw', 'value' => Affiliated::find()->where(['company_id' => $model->company_id])->one()['company']], 'license_plate', 'brand', 'model', 'color', ['attribute' => 'type_id', 'format' => 'raw', 'value' => Typecar::find()->where(['id' => $model->type_id])->one()['type_name']]]]); ?> </div> </div>