public function search($params) { $profile = Yii::$app->getUserOpt->Profile_user(); // if($profile->emp->DEP_ID == 'GM'|| $profile->emp->DEP_ID == 'DRC') // { // $query = Termheader::find(); // } // elseif($profile->emp->DEP_ID == 'ACT') // { // $query = Termheader::find(); // }else{ // // $query = Termheader::find()->where(['CREATED_BY'=>$profile->username]); // $query = Termheader::find(); // } $query = Termheader::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(['PERIOD_START' => $this->PERIOD_START, 'PERIOD_END' => $this->PERIOD_END, 'TARGET_VALUE' => $this->TARGET_VALUE, 'GROWTH' => $this->GROWTH, 'STATUS' => $this->STATUS, 'CREATED_AT' => $this->CREATED_AT, 'UPDATE_AT' => $this->UPDATE_AT]); $query->andFilterWhere(['like', 'CUST_KD_PARENT', $this->NmCustomer])->andFilterWhere(['like', 'PRINCIPAL_KD', $this->Nmprincipel])->andFilterWhere(['like', 'DIST_KD', $this->NmDis])->andFilterWhere(['like', 'TARGET_TEXT', $this->TARGET_TEXT])->andFilterWhere(['like', 'RABATE_CNDT', $this->RABATE_CNDT])->andFilterWhere(['like', 'TOP', $this->TOP])->andFilterWhere(['like', 'CREATED_BY', $this->CREATED_BY])->andFilterWhere(['like', 'UPDATE_BY', $this->UPDATE_BY]); $query->orderby(['CREATED_AT' => SORT_DESC]); //SORT PENTING UNTUK RECURSIVE BIAR TREE BISA URUTAN, save => (IF (PATENT =0) {SORT=ID}, ELSE { return $dataProvider; }
public function cekExistTermrunning($model) { $data = Termheader::find()->where(['CUST_KD_PARENT' => $this->CUST_KD_PARENT, 'STATUS' => 1])->one(); if ($data) { $this->addError($model, 'sorry Customer already been there'); } }
public function actionActualReviewAdd($id) { /* $model = new Termcustomers(); if ($model->load(Yii::$app->request->post())) { $model->ID_TERM = Yii::$app->ambilkonci->getkdTerm(); if($model->validate()) { $model->CREATED_AT = date("Y-m-d H:i:s"); $model->CREATED_BY = Yii::$app->user->identity->username; $model->save(); } return $this->redirect(['review-act','id'=>$model->ID_TERM]); } else { return $this->renderAjax('create', [ 'model' => $model, ]); } */ $termHeader = Termheader::find()->where(['TERM_ID' => $id])->one(); /*Model Scnario*/ $actualModel = new ActualModel(); return $this->renderAjax('actual_form', ['term_id' => $id, 'termHeader' => $termHeader, 'actualModel' => $actualModel]); }