public function cekdata($budget) { $id = $this->ID_TERM; $inves = $this->INVES_TYPE; $data = Termbudget::find()->where(['ID_TERM' => $id, 'INVES_TYPE' => $inves])->asArray()->one(); if ($inves === $data['INVES_TYPE']) { $this->addError($budget, 'Maaf Duplikat data'); } }
public function searchbudget($params, $id) { // Customers::find()->joinWith('cus',true,'JOIN') // ->where('c0001.STATUS <> 3'); $query = Termbudget::find()->joinWith('budget', true, 'JOIN')->where(['c0003.ID_TERM' => $id]); $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' => $this->ID, 'BUDGET_PLAN' => $this->BUDGET_PLAN, 'BUDGET_ACTUAL' => $this->BUDGET_ACTUAL, 'PERIODE_END' => $this->PERIODE_END, 'STATUS' => $this->STATUS, 'CREATE_AT' => $this->CREATE_AT, 'UPDATE_AT' => $this->UPDATE_AT]); $query->andFilterWhere(['like', 'ID_TERM', $this->ID_TERM])->andFilterWhere(['like', 'INVES_TYPE', $this->INVES_TYPE])->andFilterWhere(['like', 'BUDGET_SOURCE', $this->BUDGET_SOURCE])->andFilterWhere(['like', 'CREATE_BY', $this->CREATE_BY])->andFilterWhere(['like', 'UPDATE_BY', $this->UPDATE_BY]); return $dataProvider; }
/** * Finds the Termcustomers model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Termcustomers the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModelbudget($id) { if (($Model = Termbudget::find()->where(['ID_TERM' => $id])->one()) !== null) { return $Model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
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; }