Esempio n. 1
0
 public function add_gl_trans($type, $trans_id, $date_, $account, $memo_, $amount, $person_id)
 {
     $gl_trans = new PahGlTrans();
     $gl_trans->type = $type;
     $gl_trans->type_no = $trans_id;
     $gl_trans->tran_date = $date_;
     $gl_trans->account = $account;
     $gl_trans->memo_ = $memo_;
     $gl_trans->users_id = $person_id;
     $gl_trans->amount = $amount;
     if (!$gl_trans->save()) {
         throw new Exception("Gagal menyimpan transaksi jurnal.");
     }
     return $amount;
 }
 public function actionCreate()
 {
     $model = new PahGlTrans();
     if (isset($_POST) && !empty($_POST)) {
         foreach ($_POST as $k => $v) {
             $_POST['PahGlTrans'][$k] = $v;
         }
         $model->attributes = $_POST['PahGlTrans'];
         if ($model->save()) {
             $status = true;
             $msg = "Data berhasil di simpan ";
         } else {
             $msg = CHtml::errorSummary($model);
             $status = false;
         }
         if (Yii::app()->request->isAjaxRequest) {
             echo CJSON::encode(array('success' => $status, 'msg' => $msg, 'id' => $model->counter));
             Yii::app()->end();
         } else {
             $this->redirect(array('view', 'id' => $model->counter));
         }
     }
     $this->render('create', array('model' => $model));
 }