public function auth3_saved() { $conn = Yii::$app->db_esm; if ($this->validate()) { $transaction = $conn->beginTransaction(); try { $rtHeader_3 = Requesttermheader::find()->where(['KD_RIB' => $this->kdrib])->one(); $rtSignStt_3 = Requesttermstatus::find()->where(['KD_RIB' => $this->kdrib, 'ID_USER' => $this->getProfile()->EMP_ID])->one(); $profile = Yii::$app->getUserOpt->Profile_user(); $rtHeader_3->STATUS = $this->status; if ($rtHeader_3->STATUS == 4) { $rtHeader_3->SIG3_SVGBASE64 = ""; $rtHeader_3->SIG3_SVGBASE30 = ""; } else { $rtHeader_3->SIG3_SVGBASE64 = $profile->emp->SIGSVGBASE64; $rtHeader_3->SIG3_SVGBASE30 = $profile->emp->SIGSVGBASE30; } $rtHeader_3->SIG3_NM = $profile->emp->EMP_NM . ' ' . $profile->emp->EMP_NM_BLK; $rtHeader_3->SIG3_TGL = date('Y-m-d'); $rtHeader_3->save(); if (!$rtSignStt_3) { $rtHeaderStt_3 = new Requesttermstatus(); $rtHeaderStt_3->KD_RIB = $this->kdrib; $rtHeaderStt_3->ID_USER = $this->getProfile()->EMP_ID; if ($rtHeader_3->STATUS == 4) { $rtHeaderStt_3->STATUS = 4; } else { $rtHeaderStt_3->STATUS = 102; } $rtHeaderStt_3->UPDATED_AT = date('Y-m-d H:m:s'); } if ($this->status == 102) { $conn->createCommand()->update('t0001detail', ['STATUS' => 102], ['TERM_ID' => $this->trm_id])->execute(); $conn->createCommand()->update('t0000detail', ['STATUS' => 0], ['TERM_ID' => $this->trm_id])->execute(); } else { $conn->createCommand()->update('t0001detail', ['STATUS' => 4], ['TERM_ID' => $this->trm_id])->execute(); $conn->createCommand()->delete('t0000detail', ['STATUS' => 2, 'TERM_ID' => $this->trm_id])->execute(); } $transaction->commit(); } catch (\Exception $e) { $transaction->rollBack(); throw $e; } return $rtHeader_3; } }
public function auth2_saved() { if ($this->validate()) { $rtHeader_2 = Requesttermheader::find()->where(['KD_RIB' => $this->kdrib])->one(); #header $rtdetail = Rtdetail::find()->where(['KD_RIB' => $this->kdrib])->one(); #detail $poSignStt = Requesttermstatus::find()->where(['KD_RIB' => $this->kdrib, 'ID_USER' => $this->getProfile()->EMP_ID])->one(); $profile = Yii::$app->getUserOpt->Profile_user(); $rtHeader_2->STATUS = $this->status; $rtHeader_2->SIG2_SVGBASE64 = $profile->emp->SIGSVGBASE64; $rtHeader_2->SIG2_SVGBASE30 = $profile->emp->SIGSVGBASE30; $rtHeader_2->SIG2_NM = $profile->emp->EMP_NM . ' ' . $profile->emp->EMP_NM_BLK; $rtHeader_2->SIG2_TGL = date('Y-m-d'); if ($rtHeader_2->save()) { $rtdetail->STATUS = 101; $rtdetail->save(); if (!$poSignStt) { $rtHeader_2Stt = new Requesttermstatus(); $rtHeader_2Stt->KD_RIB = $this->kdrib; $rtHeader_2Stt->ID_USER = $this->getProfile()->EMP_ID; //$rtHeader_2Stt->TYPE $rtHeader_2Stt->STATUS = 101; $rtHeader_2Stt->UPDATED_AT = date('Y-m-d H:m:s'); if ($rtHeader_2Stt->save()) { // Notification::notify(Notification::KEY_NEW_MESSAGE, 23,Yii::$app->user->identity->id,$this->kdrib); // // $msgNotify = new MessageNotify; // $msgNotify->USER_CREATE=Yii::$app->user->identity->id; //integer // $msgNotify->USER_FROM_ID= $this->getProfile()->EMP_ID; // $msgNotify->USER_FROM= $this->getProfile()->EMP_NM; //varchar 50 // $msgNotify->USER_TO='Stephen'; //varchar 50 // $msgNotify->SUBJECT='PO'; //varchar 10 // $msgNotify->CREATE_AT=date('Y-m-d H:m:s'); //varchar 10 // $msgNotify->IMG=''; //TEXT // $msgNotify->REF = $this->kdrib; //TEXT // $msgNotify->save(); } } return $rtHeader_2; } return $rtHeader_2; } return null; }
public function auth1_saved() { if ($this->validate()) { $rtheader = Requesttermheader::find()->where(['KD_RIB' => $this->kdrib])->one(); #header $rtdetail = Rtdetail::find()->where(['KD_RIB' => $this->kdrib])->one(); #detail $rtSignStt = Requesttermstatus::find()->where(['KD_RIB' => $this->kdrib, 'ID_USER' => $this->getProfile()->EMP_ID])->one(); $rtheader->STATUS = $this->status; $rtheader->SIG1_SVGBASE64 = $this->getProfile()->SIGSVGBASE64; $rtheader->SIG1_SVGBASE30 = $this->getProfile()->SIGSVGBASE30; $rtheader->SIG1_NM = $this->getProfile()->EMP_NM . ' ' . $this->getProfile()->EMP_NM_BLK; $rtheader->SIG1_TGL = date('Y-m-d'); if ($rtheader->save()) { $rtdetail->STATUS = 100; $rtdetail->save(); if (!$rtSignStt) { $rtheaderStt = new Requesttermstatus(); $rtheaderStt->KD_RIB = $this->kdrib; $rtheaderStt->ID_USER = $this->getProfile()->EMP_ID; //$rtheaderStt->TYPE $rtheaderStt->STATUS = 100; $rtheaderStt->UPDATED_AT = date('Y-m-d H:m:s'); if ($rtheaderStt->save()) { //Notification::notify(Notification::KEY_NEW_MESSAGE, $id_Pengirim, $id_penerima(user_login),$ref_kode); // Notification::notify(Notification::KEY_NEW_MESSAGE, 25,Yii::$app->user->identity->id,$this->kdrib); // $msgNotify = new MessageNotify; // $msgNotify->USER_CREATE=Yii::$app->user->identity->id; //integer // $msgNotify->USER_FROM_ID= $this->getProfile()->EMP_ID; // $msgNotify->USER_FROM= $this->getProfile()->EMP_NM; //varchar 50 // $msgNotify->USER_TO='Melissa'; //varchar 50 // $msgNotify->SUBJECT='PO'; //varchar 10 // $msgNotify->CREATE_AT=date('Y-m-d H:m:s'); //varchar 10 // $msgNotify->IMG=''; //TEXT // $msgNotify->REF = $this->kdrib; //TEXT // $msgNotify->save(); } } return $rtheader; } return $rtheader; } return null; }
public function cari($params) { $empId = Yii::$app->user->identity->EMP_ID; $dt = Employe::find()->where(['EMP_ID' => $empId])->all(); $crp = $dt[0]['EMP_CORP_ID']; if ($dt[0]['JAB_ID'] == 'MGR') { $query = Requesttermheader::find()->where("t0001header.STATUS <> 3 and t0001header.STATUS <> 0 and t0001header.KD_CORP = '{$crp}' "); } else { $query = Requesttermheader::find()->where("t0001header.STATUS <> 3 and t0001header.STATUS <> 0 and t0001header.KD_CORP = '{$crp}' and t0001header.ID_USER = '******' "); } $query->joinWith(['employe' => function ($q) { $q->where('a0001.EMP_NM LIKE "%' . $this->nmemp . '%"'); }]); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->setSort(['attributes' => ['KD_RIB', 'KD_CORP', 'nmemp' => ['asc' => ['a0001.EMP_NM' => SORT_ASC], 'desc' => ['a0001.EMP_NM' => SORT_DESC], 'label' => 'Pembuat']]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['like', 'a0001.EMP_NM', $this->EMP_NM])->andFilterWhere(['like', 'KD_RIB', $this->KD_RIB])->andFilterWhere(['like', 'KD_CORP', $this->KD_CORP]); return $dataProvider; }
/** * Finds the Requesttermheader model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Requestorder the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Requesttermheader::findOne($id)) !== 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; }