public function actionCreate() { $model = new PeGlTrans(); if (!Yii::app()->request->isAjaxRequest) { return; } if (isset($_POST) && !empty($_POST)) { foreach ($_POST as $k => $v) { $_POST['PeGlTrans'][$k] = $v; } $model->attributes = $_POST['PeGlTrans']; $msg = "Data gagal disimpan"; if ($model->save()) { $status = true; $msg = "Data berhasil di simpan dengan id " . $model->counter; } else { $msg .= " " . CHtml::errorSummary($model); $status = false; } echo CJSON::encode(array('success' => $status, 'msg' => $msg)); Yii::app()->end(); } }
static function add_gl_trans($type, $trans_id, $date_, $account, $memo_, $amount, $person_id) { $gl_trans = new PeGlTrans(); $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 gl trans."); } return $amount; }