public function auth1_saved() { if ($this->validate()) { $model = Termcustomers::find()->where(['ID_TERM' => $this->id])->one(); $termSignStt = Statusterm::find()->where(['ID_TERM' => $this->id, 'ID_USER' => $this->getProfile()->EMP_ID])->one(); $model->STATUS = $this->status; $model->SIG1_SVGBASE64 = $this->getProfile()->SIGSVGBASE64; $model->SIG1_SVGBASE30 = $this->getProfile()->SIGSVGBASE30; $model->SIG1_NM = $this->getProfile()->EMP_NM . ' ' . $this->getProfile()->EMP_NM_BLK; $model->SIG1_TGL = date('Y-m-d'); if ($model->save()) { if (!$termSignStt) { $statusterm = new Statusterm(); $statusterm->STATUS = $this->status; //required $statusterm->ID_TERM = $this->id; //required $statusterm->ID_USER = $this->getProfile()->EMP_ID; //required $statusterm->UPDATE_AT = date('Y-m-d H:m:s'); $statusterm->save(); } } return $model; } return null; }
public function search($params) { $profile = Yii::$app->getUserOpt->Profile_user(); if ($profile->emp->DEP_ID == 'GM' || $profile->emp->DEP_ID == 'DRC') { $query = Termcustomers::find()->where('STATUS <> 3 AND STATUS = 101 OR STATUS = 102'); } elseif ($profile->emp->DEP_ID == 'ACT') { $query = Termcustomers::find()->where('STATUS<>3'); } else { $query = Termcustomers::find()->where(['CREATED_BY' => $profile->username])->andwhere('STATUS<>3'); } $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(['ID_TERM' => $this->ID_TERM, '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', 'NM_TERM', $this->NM_TERM])->andFilterWhere(['like', 'CUST_KD', $this->CUST_KD])->andFilterWhere(['like', 'CUST_NM', $this->CUST_NM])->andFilterWhere(['like', 'CUST_KD', $this->getAttribute('cus.CUST_NM')])->andFilterWhere(['like', 'DIST_KD', $this->getAttribute('dis.NM_DISTRIBUTOR')])->andFilterWhere(['like', 'PRINCIPAL_KD', $this->getAttribute('corp.CORP_NM')])->andFilterWhere(['like', 'CUST_SIGN', $this->CUST_SIGN])->andFilterWhere(['like', 'PRINCIPAL_KD', $this->PRINCIPAL_KD])->andFilterWhere(['like', 'PRINCIPAL_NM', $this->PRINCIPAL_NM])->andFilterWhere(['like', 'PRINCIPAL_SIGN', $this->PRINCIPAL_SIGN])->andFilterWhere(['like', 'DIST_KD', $this->DIST_KD])->andFilterWhere(['like', 'DIST_NM', $this->DIST_NM])->andFilterWhere(['like', 'DIST_SIGN', $this->DIST_SIGN])->andFilterWhere(['like', 'DCRP_SIGNARURE', $this->DCRP_SIGNARURE])->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; }
protected function findModel($id) { if (($model = Termcustomers::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getBudget() { return $this->hasOne(Termcustomers::className(), ['ID_TERM' => 'ID_TERM']); }
public function auth3_saved() { if ($this->validate()) { $model = Termcustomers::find()->where(['ID_TERM' => $this->id])->one(); $termSignStt = Statusterm::find()->where(['ID_TERM' => $this->id, 'ID_USER' => $this->getProfile()->EMP_ID])->one(); $model->STATUS = $this->status; $model->SIG3_SVGBASE64 = $this->getProfile()->SIGSVGBASE64; $model->SIG3_SVGBASE30 = $this->getProfile()->SIGSVGBASE30; $model->SIG3_NM = $this->getProfile()->EMP_NM . ' ' . $this->getProfile()->EMP_NM_BLK; $model->SIG3_TGL = date('Y-m-d'); if ($model->save()) { if (!$termSignStt) { $statusterm = new Statusterm(); $statusterm->STATUS = $this->status; //required $statusterm->ID_TERM = $this->id; //required $statusterm->ID_USER = $this->getProfile()->EMP_ID; //required $statusterm->UPDATE_AT = date('Y-m-d H:m:s'); $statusterm->save(); //header t0000header $copy_term = new Termheader(); $copy_term->TERM_ID = Yii::$app->ambilkonci->getkdTermData(); $copy_term->TERM_REF = $model->ID_TERM; $copy_term->STATUS = 0; $copy_term->CUST_KD_PARENT = $model->CUST_KD; $copy_term->PRINCIPAL_KD = $model->PRINCIPAL_KD; $copy_term->DIST_KD = $model->DIST_KD; $copy_term->PERIOD_START = $model->PERIOD_START; $copy_term->PERIOD_END = $model->PERIOD_END; $copy_term->SIG1_ID = $model->SIG1_ID; $copy_term->SIG1_NM = $model->SIG1_NM; $copy_term->SIG1_TGL = $model->SIG1_TGL; $copy_term->SIG1_SVGBASE64 = $model->SIG1_SVGBASE64; $copy_term->SIG2_ID = $model->SIG2_ID; $copy_term->SIG2_NM = $model->SIG2_NM; $copy_term->SIG2_TGL = $model->SIG2_TGL; $copy_term->SIG2_SVGBASE64 = $model->SIG2_SVGBASE64; $copy_term->SIG3_ID = $model->SIG3_ID; $copy_term->SIG3_NM = $model->SIG3_NM; $copy_term->SIG3_TGL = $model->SIG3_TGL; $copy_term->SIG3_SVGBASE64 = $model->SIG3_SVGBASE64; $copy_term->CREATED_BY = $model->CREATED_BY; $copy_term->CREATED_AT = date('Y-m-d H:m:s'); $copy_term->BUDGET_AWAL = $model->BUDGET_AWAL; $copy_term->save(); // t0001header $copy_budget = new Requesttermheader(); $copy_budget->TERM_ID = $copy_term->TERM_ID; $copy_budget->KD_RIB = Yii::$app->ambilkonci->getRaCode($this->getProfile()->EMP_CORP_ID); $copy_budget->ID_USER = $this->getProfile()->EMP_ID; $copy_budget->CUST_ID_PARENT = $model->CUST_KD; $copy_budget->STATUS = 102; $copy_budget->save(); // detail $budget_detail = Termbudget::find()->where(['ID_TERM' => $model->ID_TERM])->all(); foreach ($budget_detail as $key => $value) { # code... //t0000detail $connection = Yii::$app->db_esm; $connection->createCommand()->batchInsert('t0000detail', ['TERM_ID', 'CUST_KD_PARENT', 'INVES_ID', 'BUDGET_SOURCE', 'BUDGET_PLAN', 'BUDGET_ACTUAL', 'PERIODE_START', 'PERIODE_END', 'PPH23', 'PPN', 'PROGRAM'], [[$copy_term->TERM_ID, $copy_term->CUST_KD_PARENT, $value->INVES_TYPE, $value->BUDGET_SOURCE, $value->BUDGET_PLAN, $value->BUDGET_ACTUAL, $value->PERIODE_START, $value->PERIODE_END, $value->PPH23, $value->PPN, $value->PROGRAM]])->execute(); //t0001detail $connection->createCommand()->batchInsert('t0001detail', ['KD_RIB', 'TERM_ID', 'ID_INVEST', 'HARGA', 'STATUS', 'PPH23', 'PPN', 'PERIODE_START', 'PERIODE_END'], [[$copy_budget->KD_RIB, $copy_budget->TERM_ID, $value->INVES_TYPE, $value->BUDGET_PLAN, 102, $value->PPH23, $value->PPN, $value->PERIODE_START, $value->PERIODE_END]])->execute(); } } } return $model; } return null; }
public function imagedisplay($id) { # code... $data = Termcustomers::find()->where(['ID_TERM' => $id])->one(); return $data; }