public function actionUpdateVoucher($id) { $model = MyFormat::loadModelByClass($id, 'FiPaymentVoucher'); $cmsFormater = new CmsFormatter(); if ($model) { if (!FiPaymentVoucher::CanUpdate($model)) { $this->redirect(array('index')); } $model->scenario = 'update_voucher'; $dataTmp = ''; if (isset($_POST['FiPaymentVoucher'])) { $model->attributes = $_POST['FiPaymentVoucher']; if ($model->validate()) { $statusTmp = MyFormat::loadModelByClass($id, 'FiPaymentVoucher'); if ($statusTmp->status != STATUS_ACTIVE && $model->status == STATUS_ACTIVE && empty($model->date_paid)) { $model->date_paid = date('Y-m-d'); } if ($model->save()) { //save detail FiPaymentVoucherDetail::saveDetailWithVoucherID($model->id, $_POST['FiPaymentVoucherDetail']); } $this->redirect(Yii::app()->createAbsoluteUrl('admin/fiInvoice/viewvoucher', array('id' => $id))); } } else { $model->created_date = date('d-m-Y', strtotime($model->created_date)); // $model->date_paid = ($model->date_paid !='' && $model->date_paid !='0000-00-00') ? date('d-m-Y',strtotime($model->date_paid)) : date('d-m-Y'); $model->date_paid = $cmsFormater->formatDatePickerInput($model->date_paid); $dataTmp = FiPaymentVoucherDetail::getDataWithWithVoucherID($id); } } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } $this->render('payment_voucher', array('actions' => $this->listActionsCanAccess, 'model' => $model, 'dataTmp' => $dataTmp)); }