/** * save the post's account (*3) */ public function saveAccount() { $this->invest_ids = []; $pcs = Terminvest::find()->where(['ID' => $this->INVES_ID])->all(); if (is_array($this->invest_ids)) { foreach ($pcs as $key => $value) { $pc = new Termdetail(); $pc->CUST_KD_PARENT = $this->cus_kd; $pc->TERM_ID = $this->term_id; $pc->INVES_ID = $value->ID; $pc->save(); } } }
public function searchbudgetdetailinves($params, $id) { $query = Termdetail::find()->JoinWith('termhead', true, 'LEFT JOIN')->where(['t0000detail.TERM_ID' => $id])->andwhere(['like', 't0001header.KD_RIB', 'RI'])->andwhere(['like', 't0001header.KD_RIB', 'RID']); $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', 'CUST_KD_PARENT', $this->CUST_KD_PARENT])->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; }
public function getTerm() { return $this->hasOne(Termdetail::className(), ['TERM_ID' => 'TERM_ID']); }
public function actionDeleteHeaderAcc($id, $id_invest, $cus_kd) { $model = Termdetail::find()->where(['TERM_ID' => $id, 'INVES_ID' => $id_invest])->one(); $model->delete(); return $this->redirect(['review', 'id' => $id, 'cus_kd' => $cus_kd]); }
public function actionAddNewInvest($kd, $term_id, $cust_kd) { # code... $model = new Rtdetail(); if ($model->load(Yii::$app->request->post())) { $model->TERM_ID = $term_id; $model->KD_RIB = $kd; $model->ID_INVEST = $model->INVESTASI_TYPE; if ($model->save()) { $cari_account = Termdetail::find()->where(['TERM_ID' => $model->TERM_ID, 'INVES_ID' => $model->ID_INVEST])->andwhere(['<>', 'STATUS', 2])->one(); if (!$cari_account) { $termdetail = new Termdetail(); $termdetail->CUST_KD_PARENT = $cust_kd; $termdetail->INVES_ID = $model->INVESTASI_TYPE; $termdetail->INVES_TYPE = $termdetail->INVES_ID; $termdetail->TERM_ID = $model->TERM_ID; $termdetail->CORP_ID = Yii::$app->getUserOpt->Profile_user()->emp->EMP_CORP_ID; $termdetail->STATUS = 2; $termdetail->CREATE_BY = Yii::$app->user->identity->username; $termdetail->CREATE_AT = date('Y-m-d'); $termdetail->save(); } } return $this->redirect(['/purchasing/request-term/edit?kd=' . $model->KD_RIB]); } else { return $this->renderAjax('_new_invest', ['model' => $model]); } }
public function getTermdet() { return $this->hasOne(Termdetail::className(), ['INVES_ID' => 'INVESTASI_TYPE']); }
/** * Prosess Edit RO | Change Colomn Row | Tambah Row * @param string $id * @author ptrnov <*****@*****.**> * @since 1.1 */ public function actionEdit($kd) { /*inbox tab ||index*/ $searchModel1 = new DetailListSearch(); $dataProviderList = $searchModel1->search(Yii::$app->request->queryParams, $kd); /* * Init Models * @author ptrnov <*****@*****.**> * @since 1.1 **/ $roHeader = Requesttermheader::find()->where(['KD_RIB' => $kd])->one(); if (count($roHeader['KD_RIB']) != 0) { $detro = $roHeader->detro; // print_r($detro); // die(); $employ = $roHeader->employe; $dept = $roHeader->dept; /* * Convert $roHeader->detro to ArrayDataProvider | Identity 'key' => 'ID', * @author ptrnov <*****@*****.**> * @since 1.1 **/ $detroProvider = new ArrayDataProvider(['key' => 'ID', 'allModels' => $detro, 'pagination' => ['pageSize' => 10]]); /* * Process Editable Row [Columm SQTY] * @author ptrnov <*****@*****.**> * @since 1.1 **/ if (Yii::$app->request->post('hasEditable')) { $id = Yii::$app->request->post('editableKey'); $model = Rtdetail::findOne($id); $termdetail = Termdetail::find()->where(['TERM_ID' => $model->TERM_ID, 'INVES_ID' => $model->ID_INVEST, 'STATUS' => 2])->one(); $out = Json::encode(['output' => '', 'message' => '']); $post = []; $posted = current($_POST['Rtdetail']); $post['Rtdetail'] = $posted; if ($model->load($post)) { $model->save(); $output = ''; if (isset($posted['RQTY'])) { $output = $model->RQTY; } if (isset($posted['SQTY'])) { $output = $model->SQTY; } if (isset($posted['HARGA'])) { $output = Yii::$app->formatter->asDecimal($model->HARGA, 2); } if (isset($posted['INVESTASI_PROGRAM'])) { // $output = Yii::$app->formatter->asDecimal($model->EMP_NM, 2); $output = $model->INVESTASI_PROGRAM; } if (isset($posted['NOMER_INVOCE'])) { $output = $model->NOMER_INVOCE; } if (isset($posted['NOMER_FAKTURPAJAK'])) { $output = $model->NOMER_FAKTURPAJAK; } if (isset($posted['PERIODE_START'])) { $output = $model->PERIODE_START; } if (isset($posted['PERIODE_END'])) { $output = $model->PERIODE_START; } if (isset($posted['PPN'])) { $output = $model->PPN; $termdetail->PPN = $model->PPN; $termdetail->save(); } if (isset($posted['PPH23'])) { $output = $model->PPH23; $termdetail->PPH23 = $model->PPH23; $termdetail->save(); } $out = Json::encode(['output' => $output, 'message' => '']); } // return ajax json encoded response and exit echo $out; return; } /* * Render Approved View * @author ptrnov <*****@*****.**> * @since 1.1 **/ return $this->render('edit', ['roHeader' => $roHeader, 'detro' => $detro, 'employ' => $employ, 'dept' => $dept, 'dataProvider' => $detroProvider, 'dataProviderList' => $dataProviderList]); } else { return $this->redirect('index'); } }