public function actionProsesBerita($id) { $berita_save = Issuemd::find()->where(['ID' => $id])->one(); $profile = $berita_save->userprofile; $con = Yii::$app->db_esm; $connection = Yii::$app->db_widget; $post = Yii::$app->request->post(); $status = $post['DynamicModel']['status']; if ($status == 1) { $transaction = $connection->beginTransaction(); try { $generate_code = \Yii::$app->ambilkonci->getBeritaCode(); $code = \Yii::$app->ambilkonci->getkdIssue(); $connection->createCommand()->insert('bt0001', ['KD_BERITA' => $generate_code, 'JUDUL' => $berita_save->NM_CUSTOMER . ' - ' . $profile->NM_FIRST, 'ISI' => $berita_save->NM_CUSTOMER, 'KD_CORP' => Yii::$app->getUserOpt->Profile_user()->emp->EMP_CORP_ID, 'KD_DEP' => Yii::$app->getUserOpt->Profile_user()->emp->DEP_ID, 'CREATED_BY' => Yii::$app->getUserOpt->Profile_user()->EMP_ID, 'CREATED_ATCREATED_BY' => date('y-m-d h:i:s'), 'KD_REF' => $code, 'DATA_ALL' => $berita_save->ISI_MESSAGES])->execute(); $con->createCommand()->update('c0014', ['STATUS' => 2, 'ID_ISSUE_REF' => $code], ['ID' => $id])->execute(); //.... other SQL executions $transaction->commit(); } catch (\Exception $e) { $transaction->rollBack(); throw $e; } return $this->redirect(['/widget/berita/detail-berita', 'KD_BERITA' => $generate_code]); } else { $con->createCommand()->update('c0014', ['STATUS' => 3], ['ID' => $id])->execute(); return $this->redirect(['index']); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Issuemd::find(); // add conditions that should always apply here $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; } // grid filtering conditions $query->andFilterWhere(['ID' => $this->ID, 'ID_DETAIL' => $this->ID_DETAIL, 'ID_USER' => $this->ID_USER, 'TGL' => $this->TGL, 'STATUS' => $this->STATUS, 'CREATE_BY' => $this->CREATE_BY, 'CREATE_AT' => $this->CREATE_AT, 'UPDATE_BY' => $this->UPDATE_BY, 'UPDATE_AT' => $this->UPDATE_AT]); $query->andFilterWhere(['like', 'KD_CUSTOMER', $this->KD_CUSTOMER])->andFilterWhere(['like', 'NM_CUSTOMER', $this->NM_CUSTOMER])->andFilterWhere(['like', 'NM_USER', $this->NM_USER])->andFilterWhere(['like', 'ISI_MESSAGES', $this->ISI_MESSAGES]); return $dataProvider; }