public function actionCreate() { $model = new MtGlTrans(); if (isset($_POST) && !empty($_POST)) { foreach ($_POST as $k => $v) { $_POST['MtGlTrans'][$k] = $v; } $model->attributes = $_POST['MtGlTrans']; if ($model->save()) { $status = true; } else { $status = false; } if (Yii::app()->request->isAjaxRequest) { echo CJSON::encode(array('success' => $status, 'id' => $model->counter)); Yii::app()->end(); } else { $this->redirect(array('view', 'id' => $model->counter)); } } $this->render('create', array('model' => $model)); }
static function add_gl_trans($type, $trans_id, $date_, $account, $memo_, $amount, $person_id, $id_mobil) { $gl_trans = new MtGlTrans(); $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; $gl_trans->id_mobil = $id_mobil; $gl_trans->save(); return $amount; }