/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { if (!in_array($params, ['1', '2', '3', '4', '5', '6', '7'])) { $query = Adashboard::find()->where(['jobstatus' => 1]); } else { $query = Adashboard::find()->where(['jobstatus' => 1, 'jobtype' => $params]); } $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([ // 'recid' => $this->recid, // 'jobtype' => $this->jobtype, // 'jobaction' => $this->jobaction, // 'jobdate' => $this->jobdate, // 'aproveddate' => $this->aproveddate, // 'requestby' => $this->requestby, // 'approvedby' => $this->approvedby, // 'jobstatus' => $this->jobstatus, // 'startdate' => $this->startdate, // 'enddate' => $this->enddate, // 'operateby' => $this->operateby, // ]); $query->orFilterWhere(['like', 'jobtitle', $this->globalSearch])->orFilterWhere(['like', 'comment', $this->globalSearch])->orFilterWhere(['like', 'usdef1', $this->usdef1]); return $dataProvider; }
public function actionShowjob($type) { $session = new Session(); $session->open(); if ($type == 1) { $session->setFlash('msg', "แจ้งปัญหาข้อมูลและโปรแกรมคอมพิวเตอร์"); } if ($type == 2) { $session->setFlash('msg', "ร้องขอผู้ใช้งาน"); } if ($type == 3) { $session->setFlash('msg', "ร้องขอรายงาน"); } if ($type == 4) { $session->setFlash('msg', "ร้องขออุปกรณ์คอมพิวเตอร์"); } if ($type == 5) { $session->setFlash('msg', "แจ้งปัญหากล้องวงจรปิด"); } if ($type == 6) { $session->setFlash('msg', "แจ้งปัญหาโทรศัพท์"); } if ($type == 7) { $session->setFlash('msg', "ร้องขอกู้ข้อมูล"); } $searchModel = new AdashboardSearch(); $dataProvider = $searchModel->search($type); $dataProvider->pagination->pageSize = 10; // // return $this->render('index', [ // 'searchModel' => $searchModel, // 'dataProvider' => $dataProvider, // ]); $session = new Session(); $session->open(); $countJob = Adashboard::find()->count(); $countProgramActive = Adashboard::find()->where(['jobstatus' => 1, 'jobtype' => 1])->count(); $countUserActive = Adashboard::find()->where(['jobstatus' => 1, 'jobtype' => 2])->count(); $countReportActive = Adashboard::find()->where(['jobstatus' => 1, 'jobtype' => 3])->count(); $countDeviceActive = Adashboard::find()->where(['jobstatus' => 1, 'jobtype' => 4])->count(); $countCameraActive = Adashboard::find()->where(['jobstatus' => 1, 'jobtype' => 5])->count(); $countPhoneActive = Adashboard::find()->where(['jobstatus' => 1, 'jobtype' => 6])->count(); $countRestoreActive = Adashboard::find()->where(['jobstatus' => 1, 'jobtype' => 7])->count(); $totalCount = Adashboard::find()->count(); $pages = new Pagination(['totalCount' => $totalCount, 'pageSize' => 10]); $model = Adashboard::find()->offset($pages->offset)->limit($pages->limit)->all(); return $this->render('index', ['model' => $model, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'programactive' => $countProgramActive, 'useractive' => $countUserActive, 'reportactive' => $countReportActive, 'deviceactive' => $countDeviceActive, 'cameraactive' => $countCameraActive, 'phoneactive' => $countPhoneActive, 'restoreactive' => $countRestoreActive, 'alljob' => $countJob, 'pages' => $pages]); }