/** * 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; }
public function actionConfirmdir($kdpo) { $hsl = Purchaseorder::find()->where(['KD_PO' => $kdpo])->one(); if ($hsl->APPROVE_DIR == '') { $hsl->APPROVE_DIR = Yii::$app->user->identity->EMP_ID; $hsl->TGL_APPROVE = date('Y-m-d H:i:s'); $hsl->STATUS = 1; $hsl->save(); return $this->redirect(['view', 'kd' => $kdpo]); } else { return $this->redirect(['view', 'kd' => $kdpo]); } }