public function actionDelete($id)
 {
     if (!Yii::app()->request->isAjaxRequest) {
         return;
     }
     if (isset($_POST) && !empty($_POST)) {
         $id = $_POST['id'];
         $memo_ = $_POST['memo_'];
         $status = false;
         $msg = 'Transaksi berhasil divoid.';
         $user = Yii::app()->user->getId();
         //require_once(Yii::app()->basePath . '/vendors/frontaccounting/ui.inc');
         app()->db->autoCommit = false;
         $transaction = app()->db->beginTransaction();
         try {
             $aktivitas = PeAktivitasGrupTrans::model()->findByPk($id);
             $date = $aktivitas->trans_date;
             $docref = $aktivitas->doc_ref;
             //                $bank_account = $kas_masuk->pe_bank_accounts_id;
             $void = new PeVoided();
             $void->type = T_AKTIVITASGRUP;
             $void->id = $id;
             $void->date_ = $date;
             $void->memo_ = $memo_;
             if (!$void->save()) {
                 throw new Exception("Gagal menyimpan void.");
             }
             $bank = PeBankAccounts::model()->findByPk($aktivitas->pe_bank_accounts_id);
             $act_sub = $aktivitas->peSubAktivitas->account_code;
             //void gl
             //beban kredit , kas debet karena pengeluaran
             Pe::add_gl(VOID, $void->id_voided, $date, $docref, $bank->account_code, "VOID Aktivitas Grup {$docref}", $aktivitas->amount, $user);
             Pe::add_gl(VOID, $void->id_voided, $date, $docref, $act_sub, "VOID Aktivitas Grup {$docref}", -$aktivitas->amount, $user);
             $transaction->commit();
             $status = true;
         } catch (Exception $ex) {
             $transaction->rollback();
             $status = false;
             $msg = $ex;
         }
     }
     echo CJSON::encode(array('success' => $status, 'msg' => $msg));
     Yii::app()->end();
 }
 public function actionDelete()
 {
     if (!Yii::app()->request->isAjaxRequest) {
         return;
     }
     if (isset($_POST) && !empty($_POST)) {
         $id = $_POST['id'];
         $memo_ = $_POST['memo_'];
         $status = false;
         $msg = 'Kas keluar berhasil divoid.';
         $user = Yii::app()->user->getId();
         //require_once(Yii::app()->basePath . '/vendors/frontaccounting/ui.inc');
         app()->db->autoCommit = false;
         $transaction = app()->db->beginTransaction();
         try {
             $kas_keluar = PeKasKeluar::model()->findByPk($id);
             $date = $kas_keluar->trans_date;
             $docref = $kas_keluar->doc_ref;
             //                $bank_account = $kas_masuk->pe_bank_accounts_id;
             $void = new PeVoided();
             $void->type = KAS_KELUAR;
             $void->id = $id;
             $void->date_ = $date;
             $void->memo_ = $memo_;
             if (!$void->save()) {
                 throw new Exception("Gagal menyimpan void.");
             }
             $bank = PeBankAccounts::model()->findByPk($kas_keluar->pe_bank_accounts_id);
             //void gl
             Pe::add_gl(VOID, $void->id_voided, $date, $docref, $bank->account_code, "VOID Kas Keluar {$docref}", $kas_keluar->amount, $user);
             Pe::add_gl(VOID, $void->id_voided, $date, $docref, $kas_keluar->pe_account_code, "VOID Kas Keluar {$docref}", -$kas_keluar->amount, $user);
             $transaction->commit();
             $status = true;
         } catch (Exception $ex) {
             $transaction->rollback();
             $status = false;
             $msg = $ex;
         }
     }
     echo CJSON::encode(array('success' => $status, 'msg' => $msg));
     Yii::app()->end();
     //        if (Yii::app()->request->isPostRequest) {
     //            $this->loadModel($id, 'PeKasKeluar')->delete();
     //
     //            if (!Yii::app()->request->isAjaxRequest)
     //                $this->redirect(array('admin'));
     //        } else
     //            throw new CHttpException(400,
     //                Yii::t('app', 'Invalid request. Please do not repeat this request again.'));
 }