/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Affiliated::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, 'create_date' => $this->create_date]); $query->andFilterWhere(['like', 'company_id', $this->company_id])->andFilterWhere(['like', 'company', $this->company])->andFilterWhere(['like', 'tax_number', $this->tax_number])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'tel', $this->tel]); return $dataProvider; }
/** * Finds the Affiliated model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Affiliated the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Affiliated::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<div class="box box-info"> <div class="box-header with-border">ผู้ว่าจ้าง</div> <div class="box-body"> <?php echo $form->field($model, 'order_id')->textInput(['value' => $order_id, 'readonly' => 'readonly']); ?> <?php echo $form->field($model, 'employer')->dropdownList(ArrayHelper::map(Customer::find()->all(), 'cus_id', 'company'), ['id' => 'cus_id', 'required' => 'required', 'prompt' => 'เลือกบริษัทผู้ว่าจ้าง']); ?> </div> </div> <div class="box box-info"> <div class="box-header with-border">บริษัทรถร่วม</div> <div class="box-body"> <?php echo $form->field($model, 'company_id')->dropdownList(ArrayHelper::map(Affiliated::find()->all(), 'company_id', 'company'), ['id' => 'company_id', 'required' => 'required', 'prompt' => 'เลือกบริษัทรถร่วม']); ?> <?php echo $form->field($model, 'truck1')->widget(DepDrop::classname(), ['data' => ArrayHelper::map(\app\models\AffiliatedTruck::find()->where(['company_id' => $model->company_id])->all(), 'id', 'license_plate'), 'type' => DepDrop::TYPE_SELECT2, 'options' => ['id' => 'truck1'], 'pluginOptions' => ['required' => 'required', 'depends' => ['company_id'], 'placeholder' => 'เลือกรถ...', 'url' => Url::to(['orders-transport-affiliated/get_truck'])]]); ?> <?php echo $form->field($model, 'truck2')->widget(DepDrop::classname(), ['data' => ArrayHelper::map(\app\models\AffiliatedTruck::find()->where(['company_id' => $model->company_id])->all(), 'id', 'license_plate'), 'type' => DepDrop::TYPE_SELECT2, 'options' => ['id' => 'truck2'], 'pluginOptions' => ['depends' => ['company_id'], 'placeholder' => 'เลือกรถ...', 'url' => Url::to(['orders-transport-affiliated/get_truck2'])]]); ?> <?php echo $form->field($model, 'order_date_start')->widget(\kartik\widgets\DatePicker::classname(), ['language' => 'th', 'removeButton' => false, 'options' => ['value' => date("Y-m-d"), 'readonly' => true], 'pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd', 'todayHighlight' => true]]); ?> <?php
/* @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>
/** * @return \yii\db\ActiveQuery */ public function getCompany() { return $this->hasOne(Affiliated::className(), ['company_id' => 'company_id']); }