load->model('costcenter_model'); $this->isLoggedIn(); } /** * This function used to load the first screen of the user */ public function index() { $this->global['pageTitle'] = 'Siddharth : Cost'; $this->loadViews("costListing", $this->global, NULL , NULL); } /** * This function is used to load the Cost list */ function CostListing() { $this->load->model('costcenter_model'); $searchText = $this->input->post('searchText'); $data['searchText'] = $searchText; $this->load->library('pagination'); $count = $this->costcenter_model->costListingCount($searchText); $returns = $this->paginationCompress ( "costListing/", $count, 5 ); $data['userRecords'] = $this->costcenter_model->costListing($searchText, $returns["page"], $returns["segment"]); $this->global['pageTitle'] = 'Siddharth : Cost List'; $this->loadViews("costListing", $this->global, $data, NULL); } /** * This function is used to load the add new cost */ function addcost() { $this->load->model('costcenter_model'); //$data['costName'] = $this->purchaseorder_model->getcostName(); //$data['users'] = $this->purchaseorder_model->getusers(); $this->global['pageTitle'] = 'siddharth : Add Cost'; $this->loadViews("addcost", $this->global, NULL); } /** * This function is used to load the add new cost Center */ function addCostCenter() { $this->load->model('costcenter_model'); //$data['costName'] = $this->purchaseorder_model->getcostName(); //$data['users'] = $this->purchaseorder_model->getusers(); $this->global['pageTitle'] = 'siddharth : Add Cost Center'; $this->loadViews("addCostCenter", $this->global, NULL); } /** * This function is used to add new Cost to the system */ function addNewcost() { $this->load->library('form_validation'); $this->form_validation->set_rules('CostName','Address','trim|required|'); $this->form_validation->set_rules('Description','Contact Number','trim'); if($this->form_validation->run() == FALSE) { $this->addcost(); } else { $CostName = ($this->input->post('CostName')); $Description = $this->input->post('Description'); $Cost = array('CostName'=>$CostName, 'Description'=>$Description,'createdDate'=>date('Y-m-d H:i:sa')); $this->load->model('costcenter_model'); $result = $this->costcenter_model->addNewcost($Cost); if($result > 0) { $this->session->set_flashdata('success', 'New Cost created successfully'); } else { $this->session->set_flashdata('error', 'Cost creation failed'); } echo $result; redirect('addcost'); } } /** * This function is used load user edit information * @param number $userId : Optional : This is user id */ function editOldcost($CostCenterID = NULL) { if($CostCenterID == null) { redirect('costListing'); } $data['Cost'] = $this->costcenter_model->getuserinfo($CostCenterID); //$data['users'] = $this->purchaseorder_model->getusers(); $this->global['pageTitle'] = 'Siddharth : Edit Cost'; $this->loadViews("editOldcost", $this->global, $data,NULL); } function ech() { echo $this->input->post('CostCentreID'); echo $this->input->post('CostName'); echo $this->input->post('Description'); } /** * This function is used to edit the user information */ function editcost() { $this->load->library('form_validation'); $CostCenterID = $this->input->post('CostCentreID'); $this->form_validation->set_rules('CostName','Cost Name','trim|required|'); $this->form_validation->set_rules('Description','Description','trim|required|'); if($this->form_validation->run() == FALSE) { $this->editcost($CostCenterID); } else { $CostCenterID = $this->input->post('CostCentreID'); $CostName = ucwords(strtolower($this->input->post('CostName'))); $Description = $this->input->post('Description'); //$this->costcenter_model->editcost($Cost); $cost = array(); $Cost = array('CostCentreID'=>$CostCenterID,'CostName'=>$CostName, 'Description'=>$Description,'createdDate'=>date('Y-m-d H:i:sa')); $result = $this->costcenter_model->editcost($Cost, $CostCenterID); if($result == true) { $this->session->set_flashdata('success', 'Cost updated successfully'); } else { $this->session->set_flashdata('error', 'Cost updation failed'); } redirect('costListing'); } } function viewcost($CostCenterID = NULL) { if($CostCenterID == null) { redirect('costListing'); } $data['Cost'] = $this->costcenter_model->getuserinfo($CostCenterID); //$data['users'] = $this->purchaseorder_model->getusers(); $this->global['pageTitle'] = 'Siddharth : View Cost'; $this->loadViews("viewcost", $this->global, $data,NULL); } /** * This function is used to delete the user using userId * @return boolean $result : TRUE / FALSE */ function deletecost() { if($this->isAdmin() == TRUE) { echo(json_encode(array('status'=>'access'))); } else { $CostCenterID = $this->input->Costst('CostCentreID'); $cost = array('CreateDate'=>date('Y-m-d H:i:sa')); $result = $this->costcenter_model->deletecost($Cost, $CostCenterID); if ($result > 0) { echo(json_encode(array('status'=>TRUE))); } else { echo(json_encode(array('status'=>FALSE))); } } } function pageNotFound() { $this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found'; $this->loadViews("404", $this->global, NULL, NULL); } } ?>