public function add_data() { if (!$this->securitypolicy->validateAccessRight(1, 'add')) { $this->load->view('access_denied'); } $this->load->library('form_validation'); $this->load->helper('form'); $this->form_validation->set_rules('hotel', "Hotel", 'required'); $this->form_validation->set_rules('category', "Category", 'required'); $this->form_validation->set_rules('amount', "Amount", 'required|numeric|greater_than[0]'); $this->form_validation->set_rules('date', "Date", 'required'); $this->_viewdata['showmsg'] = true; $revenueData = new Revenuedata(); $hotels = new HotelColl(); $hotels->setAll(); $this->_viewdata['hotels'] = $hotels; if ($this->form_validation->run() == false) { $this->_viewdata['acctCat']['dropdown'] = $revenueData->getCatAsDropdown(); $this->_viewdata['acctCat']['default'] = $this->input->post('category'); $this->_viewdata['status'] = 'error'; $this->_getLatestActivity(); $this->load->view("add_financial_info", $this->_viewdata); } else { $nameFilter = new HtlNameFiltr(); $nameFilter->setFilter($this->input->post('hotel')); $hotel = new Hotel(); $hotel->addFilter($nameFilter); $hotel->set(); $revenueData = new Revenuedata(); $revenueData->initByInput(); $revenueData->setHotelId($hotel->getId()); $revenueData->save(); if (!empty($revenueData->errors)) { $this->_viewdata['msg'] = $revenueData->errors; $this->_viewdata['acctCat']['dropdown'] = $revenueData->getCatAsDropdown(); $this->_viewdata['acctCat']['default'] = $this->input->post('category'); $this->_viewdata['status'] = 'error'; $this->_getLatestActivity(); $this->load->view("add_financial_info_csverr", $this->_viewdata); } else { $this->session->set_userdata(array("status" => "success")); redirect(site_url('Admin/add_revenue_data')); } } }