load->model('rawmaterialdetails_model'); $this->load->library('pagination'); $this->load->library('form_validation'); $this->isLoggedIn(); } /** * This function used to load the first screen of the user */ public function index() { $this->global['pageTitle'] = 'Siddharth : RawMaterialDetails'; $this->loadViews("rawmaterialListing", $this->global, NULL , NULL); } /** * This function is used to load the RawMaterialDetails list */ function rawmaterialListing() { $this->load->model('rawmaterialdetails_model'); $searchText = $this->input->post('searchText'); $data['searchText'] = $searchText; $count = $this->rawmaterialdetails_model->rawmaterialListingCount($searchText); $returns = $this->paginationCompress ( "rawmaterialListing/", $count, 10 ); $data['userRecords'] = $this->rawmaterialdetails_model->rawmaterialListing($searchText, $returns["page"], $returns["segment"]); $this->global['pageTitle'] = 'Siddharth : RawMaterial Listing'; $this->loadViews("rawmaterialListing", $this->global, $data, NULL); } /** * This function is used to load the add new cost */ function addRawMaterial() { $this->load->model('rawmaterialdetails_model'); $data['material'] = $this->rawmaterialdetails_model->getmaterialType(); $data['UOM'] = $this->rawmaterialdetails_model->getUOM(); $this->global['pageTitle'] = 'siddharth : AddNew RawMaterial'; $this->loadViews("addRawMaterial", $this->global, $data, NULL); } /* Validation for Material Type Dropdown */ function MaterialType_validate($selectValue) { //echo 'select_validate method called'; // 'none' is the first option and the text says something like "-Choose one-" if($selectValue == '-1') { $this->form_validation->set_message('MaterialType_validate', 'Please Select Material Type.'); return false; } else // user picked something { return true; } } /* Validation for Material Type Dropdown */ function UOM_validate($selectValue) { //echo 'select_validate method called'; // 'none' is the first option and the text says something like "-Choose one-" if($selectValue == '-1') { $this->form_validation->set_message('UOM_validate', 'Please Select UOM.'); return false; } else // user picked something { return true; } } /* This function is used to add new Cost to the system */ function addNewRawMaterial() { $this->form_validation->set_rules('MaterialName','Material Name','trim|required|'); $this->form_validation->set_rules('MaterialType','MaterialType','trim|callback_MaterialType_validate'); $this->form_validation->set_rules('UOM','UOM','trim|callback_UOM_validate'); if($this->form_validation->run() == FALSE) { $this->addRawMaterial(); } else { $MaterialName = $this->input->post('MaterialName'); $MaterialType = $this->input->post('MaterialType'); $UOM = $this->input->post('UOM'); $CreatedBy = $this->session->userdata('userId'); $chked = $this->input->post('isactive'); if( $chked != '') { $IsActive = '1'; } else { $IsActive = '0'; } $RawMaterial = array('MaterialName'=>$MaterialName, 'MaterialType'=>$MaterialType, 'UOM'=>$UOM,'CreatedBy'=>$CreatedBy,'IsActive' => $IsActive); $result = $this->rawmaterialdetails_model->addNewRawMaterial($RawMaterial); if($result > 0) { redirect('rawmaterialListing','refresh'); echo ""; } else { redirect('rawmaterialListing','refresh'); echo ""; } } } function viewRawmaterial($RID= '') { $MaterialType = ''; $UOM = ''; if($RID == '') { $RawMaterialID = $_GET['RID']; $MaterialType = $_GET['MType']; $UOM = $_GET['UOM']; } else { $RawMaterialID = $RID; } $data['materialDetails'] = $this->rawmaterialdetails_model->getMaterialDetails($RawMaterialID); $data['materialType'] = $this->rawmaterialdetails_model->getmaterialType($MaterialType ); $data['UOMList'] = $this->rawmaterialdetails_model->getUOM($UOM); $this->global['pageTitle'] = 'Siddharth : Edit Material Master'; $this->loadViews("editOldRawmaterial", $this->global,$data, NULL); } /** * This function is used to edit the user information */ function editRawmaterial() { if($this->isAdmin() == TRUE) { $this->loadThis(); } else { $RawmaterialID = $this->input->post('MaterialCode'); $this->form_validation->set_rules('MaterialName','Material Name','trim|required|'); $this->form_validation->set_rules('MaterialType','MaterialType','trim'); $this->form_validation->set_rules('UOM','UOM','trim'); if($this->form_validation->run() == FALSE) { $this->viewRawmaterial($RawmaterialID); } else { $MaterialCode = $this->input->post('MaterialCode'); $MaterialName = $this->input->post('MaterialName'); $MaterialType = $this->input->post('MaterialType'); $UOM = $this->input->post('UOM'); $UpdatedBy = $this->session->userdata ('userId'); $chked = $this->input->post('isactive'); if( $chked != '') { $IsActive = '1'; } else { $IsActive = '0'; } $RawMaterial = array(); $RawMaterial = array('MaterialName'=>$MaterialName,'MaterialType'=>$MaterialType,'UpdatedBy'=>$UpdatedBy, 'UOM'=>$UOM,'IsActive' => $IsActive); $result = $this->rawmaterialdetails_model->editRawmaterial($RawMaterial, $MaterialCode); if($result == true) { redirect('rawmaterialListing','refresh'); echo ""; } else { redirect('rawmaterialListing','refresh'); echo ""; } } } } function pageNotFound() { $this->global['pageTitle'] = 'Siddharth : 404 - Page Not Found'; $this->loadViews("404", $this->global, NULL, NULL); } } ?>