/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Purchaseorder::find(); $query->joinWith(['employe' => function ($q) { $q->where('a0001.EMP_NM LIKE "%' . $this->pembuat . '%"'); }]); $query->joinWith(['employe' => function ($q) { $q->where('a0001.EMP_NM LIKE "%' . $this->disetujui . '%"'); }]); $query->joinWith(['employe' => function ($q) { $q->where('a0001.EMP_NM LIKE "%' . $this->approved . '%"'); }]); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->setSort(['attributes' => ['KD_PO', 'KD_SUPPLIER', 'pembuat' => ['asc' => ['a0001.EMP_NM' => SORT_ASC], 'desc' => ['a0001.EMP_NM' => SORT_DESC], 'label' => 'Pembuat'], 'disetujui' => ['asc' => ['a0001.EMP_NM' => SORT_ASC], 'desc' => ['a0001.EMP_NM' => SORT_DESC], 'label' => 'Pembuat'], 'approved' => ['asc' => ['a0001.EMP_NM' => SORT_ASC], 'desc' => ['a0001.EMP_NM' => SORT_DESC], 'label' => 'Pembuat']]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['ID' => $this->ID, 'CREATE_AT' => $this->CREATE_AT, 'APPROVE_AT' => $this->APPROVE_AT, 'STATUS' => $this->STATUS]); $query->andFilterWhere(['like', 'KD_PO', $this->KD_PO])->andFilterWhere(['like', 'KD_SUPPLIER', $this->KD_SUPPLIER])->andFilterWhere(['like', 'CREATE_BY', $this->CREATE_BY])->andFilterWhere(['like', 'APPROVE_BY', $this->APPROVE_BY])->andFilterWhere(['like', 'NOTE', $this->NOTE]); return $dataProvider; }
/** * Finds the Purchaseorder model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Purchaseorder the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Purchaseorder::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }