コード例 #1
0
 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']);
     }
 }
コード例 #2
0
ファイル: IssuemdSearch.php プロジェクト: adem-team/advanced
 /**
  * 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;
 }
コード例 #3
0
 /** author wawan
  * close Berita model.
  * If close is successful, delete bt0001notify and return true.
  * @return mixed
  */
 public function actionCloseBerita()
 {
     if (Yii::$app->request->isAjax) {
         $request = Yii::$app->request;
         $id = $request->post('id');
         $kd_ref = $request->post('kd_ref');
         $connection = Yii::$app->db_widget;
         $transaction = $connection->beginTransaction();
         try {
             $connection->createCommand()->update('bt0001', ['STATUS' => 0], 'KD_BERITA="' . $id . '"')->execute();
             if (count($kd_ref) != 0) {
                 $issue = Issuemd::findOne(['ID_ISSUE_REF' => $kd_ref]);
                 $issue->STATUS = 3;
                 $issue->save();
             }
             $close = $connection->createCommand('DELETE FROM bt0001notify WHERE KD_BERITA=:kd_berita');
             $close->bindParam(':kd_berita', $kd_berita);
             $kd_berita = $id;
             $close->execute();
             $transaction->commit();
         } catch (\Exception $e) {
             $transaction->rollBack();
             throw $e;
         }
         return true;
     }
 }
コード例 #4
0
 /**
  * Finds the Issuemd model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Issuemd the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Issuemd::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }