/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Helpdesk::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'section' => $this->section, 'date' => $this->date, 'datetime' => $this->datetime, 'status' => $this->status, 'sentDealer' => $this->sentDealer, 'sentDate' => $this->sentDate, 'mod' => $this->mod]); $query->andFilterWhere(['like', 'error_type', $this->error_type])->andFilterWhere(['like', 'error_text', $this->error_text])->andFilterWhere(['like', 'helpdesk_no', $this->helpdesk_no])->andFilterWhere(['like', 'images', $this->images])->andFilterWhere(['like', 'req_name', $this->req_name]); return $dataProvider; }
</div> </div> </div> </div> <!-- /.box-header --> <div class="box-body table-responsive no-padding"> <table class="table table-hover"> <tr> <th>#ID</th> <th>วันที่</th> <th>สถานะ</th> <th>ชื่ออุปกรณ์</th> <th>ใช้งานที่</th> </tr> <?php $models = \app\models\Helpdesk::find()->limit(20)->orderBy('id desc')->all(); foreach ($models as $model) { if ($model->status == 1) { $statusLable = "<span class='label label-success'>กำลังใช้งาน</span>"; } elseif ($model->status == 2) { $statusLable = "<span class='label label-info'>พร้อมใช้งาน</span>"; } elseif ($model->status == 3) { $statusLable = "<span class='label label-warning'>อยู่ระหว่างซ่อม</span>"; } elseif ($model->status == 4) { $statusLable = "<span class='label label-primary'>ส่งซ่อม</span>"; } elseif ($model->status == 5) { $statusLable = "<span class='label label-danger'>ส่งซ่อม</span>"; } elseif ($model->status == 6) { $statusLable = "<span class='label label-default'>ส่งซ่อม</span>"; } else { $statusLable = "<span class='label'>ไม่อยู่ในเงื่อนไข</span>";
/** * Finds the Helpdesk model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Helpdesk the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Helpdesk::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }