public function addProgramChargeAction()
 {
     if ($this->getRequest()->isPost()) {
         try {
             $_data = $this->getRequest()->getPost();
             $_model = new Accounting_Model_DbTable_DbProgramCharge();
             //print_r($_data);exit();
             $rs = $_model->addServiceCharge($_data);
             if (!empty($rs)) {
                 Application_Form_FrmMessage::Sucessfull("INSERT_SUCCESS", "/accounting/ProgramCharge/add-program-charge");
             } else {
                 Application_Form_FrmMessage::Sucessfull("INSERT_FAIL", "/accounting/ProgramCharge/add-program-charge");
             }
         } catch (Exception $e) {
             Application_Form_FrmMessage::message("INSERT_FAIL");
             Application_Model_DbTable_DbUserLog::writeMessageError($e->getMessage());
         }
     }
     $frm = new Accounting_Form_FrmServicePrice();
     $frm_set_price = $frm->frmAddProgramCharge();
     Application_Model_Decorator::removeAllDecorator($frm_set_price);
     $this->view->frm_set_charge = $frm_set_price;
     $_model = new Application_Model_GlobalClass();
     $this->view->service_options = $_model->getAllServiceItemOption(2);
     $model = new Application_Model_DbTable_DbGlobal();
     $this->view->payment_term = $model->getAllGEPPrgramPayment();
     $frm = new Application_Form_FrmPopupGlobal();
     $frm_service = $frm->addProgramName(null, 2);
     Application_Model_Decorator::removeAllDecorator($frm_service);
     $this->view->frm_service_name = $frm_service;
     $frm_ser_category = $frm->addProServiceCategory();
     Application_Model_Decorator::removeAllDecorator($frm_ser_category);
     $this->view->frm_ser_category = $frm_ser_category;
     $this->view->rate = $model->getRate();
 }
 public function editServiceChargeAction()
 {
     if ($this->getRequest()->isPost()) {
         try {
             $_data = $this->getRequest()->getPost();
             $_model = new Accounting_Model_DbTable_DbServiceCharge();
             $rs = $_model->upDateServiceCharge($_data);
             if (!empty($rs)) {
                 Application_Form_FrmMessage::Sucessfull("EDIT_SUCCESS", "/accounting/ServiceCharge/index");
             }
         } catch (Exception $e) {
             Application_Form_FrmMessage::message("INSERT_FAIL");
             Application_Model_DbTable_DbUserLog::writeMessageError($e->getMessage());
         }
     }
     $id = $this->getRequest()->getParam('id');
     $_model = new Accounting_Model_DbTable_DbServiceCharge();
     $_rs = $_model->getServiceChargeById($id);
     $db = new Accounting_Model_DbTable_DbServiceCharge();
     $model = new Application_Model_DbTable_DbGlobal();
     $row = 0;
     $key = 0;
     if (!empty($_rs)) {
         foreach ($_rs as $id => $rs) {
             $rows = $db->getServiceFeebyId($rs['service_id']);
             $fee_row = 1;
             if (!empty($rows)) {
                 foreach ($rows as $payment_tran) {
                     if ($payment_tran['pay_type'] == 1) {
                         $rs_rows[$key] = $this->headAddRecordService($rs, $key);
                         $rs_rows[$key]['remark'] = $payment_tran['remark'];
                         $term = $model->getAllServicePayment($fee_row);
                         $rs_rows[$key]['price_' . $payment_tran['pay_type']] = $payment_tran['price'];
                         $key_old = $key;
                         $key++;
                     } elseif ($payment_tran['pay_type'] == 2) {
                         $term = $model->getAllServicePayment($payment_tran['pay_type']);
                         $rs_rows[$key_old]['price_' . $payment_tran['pay_type']] = $payment_tran['price'];
                     } elseif ($payment_tran['pay_type'] == 3) {
                         $term = $model->getAllServicePayment($payment_tran['pay_type']);
                         $rs_rows[$key_old]['price_' . $payment_tran['pay_type']] = $payment_tran['price'];
                     } else {
                         $term = $model->getAllServicePayment($payment_tran['pay_type']);
                         $rs_rows[$key_old]['price_4'] = $payment_tran['price'];
                     }
                 }
             }
         }
     }
     $this->view->service_exist = $rs_rows;
     $frm = new Accounting_Form_FrmServicePrice();
     $frm_set_price = $frm->frmAddServiceCharge($_rs);
     Application_Model_Decorator::removeAllDecorator($frm_set_price);
     $this->view->frm_set_charge = $frm_set_price;
     $_model = new Application_Model_GlobalClass();
     $this->view->service_options = $_model->getAllServiceItemOption();
     $model = new Application_Model_DbTable_DbGlobal();
     $this->view->payment_term = $model->getAllServicePayment();
     $frm = new Application_Form_FrmPopupGlobal();
     $frm_service = $frm->addProgramName();
     Application_Model_Decorator::removeAllDecorator($frm_service);
     $this->view->frm_service_name = $frm_service;
     $frm_ser_category = $frm->addProServiceCategory();
     Application_Model_Decorator::removeAllDecorator($frm_ser_category);
     $this->view->frm_ser_category = $frm_ser_category;
     $this->view->rate = $model->getRate();
 }