department_model = new Department_model(); $this->session = session(); helper('form'); //$this->load->library('form_validation'); // $this->load->library('pagination'); // $this->load->library('Excel'); $this->isLoggedIn(); } /** * This function used to load the first screen of the user */ public function index() { // if($this->isAdmin() == TRUE) // { // $this->loadThis(); // } // else // { $this->department_model = new department_model(); //$searchText = $this->request->getPost('searchText'); //$data['searchText'] = $searchText; //$count = $this->department_model->departmentListing($searchText); //$returns = $this->paginationCompress ( "departmentListing/", $count, 20 ); $data['userRecords'] = $this->department_model->departmentListing(); //$searchText, $returns["page"], $returns["segment"]); $this->global['pageTitle'] = 'Department Listing'; $this->loadViews("departmentListing", $this->global, $data, NULL); //} } /** * This function is used to load the add new supplier */ function adddepartment() { //$data['payment'] = $this->department_model->getpayment(); //$data['depcode'] = $this->department_model->getdepcode(); $data['depcode'] = $this->department_model->getdepcode(); $this->global['pageTitle'] = 'AddNew Department'; $this->loadViews("adddepartment", $this->global, $data, NULL); } function savedepartment() { $DepartmentName = $this->request->getPost('DepartmentName'); $DEPCode = $this->request->getPost('DEPCode'); $HeadDept = $this->request->getPost('HeadDept'); $Createdby = $this->session->get('userId'); $chked = $this->request->getPost('IsActive'); if ($chked != '') { $IsActive = '1'; } else { $IsActive = '0'; } $department = array('DepartmentName' => $DepartmentName, 'DEPCode' => $DEPCode, 'HeadDept' => $HeadDept, 'Createdby' => $Createdby, 'IsActive' => $IsActive); $result = $this->department_model->savedepartment($department); if ($result > 0) { $this->session->setFlashdata('success', 'Department Created successfully!'); }else{ $this->session->setFlashdata('error', 'Department Record Not Created!'); } return redirect()->route('departmentListing'); } /** * This function is used to edit the department information */ function editdepartment() { $DepartmentName = $this->request->getPost('DepartmentName'); $DEPCode = $this->request->getPost('DEPCode'); $HeadDept = $this->request->getPost('HeadDept'); $Createdby = $this->session->get('userId'); $chked = $this->request->getPost('IsActive'); if ($chked != '') { $IsActive = '1'; } else { $IsActive = '0'; } $department = array('DepartmentName' => $DepartmentName, 'DEPCode' => $DEPCode, 'HeadDept' => $HeadDept, 'IsActive' => $IsActive); $result = $this->department_model->Updatedepartment($department, $DEPCode); if ($result == True) { $this->session->setFlashdata('success', 'Department Record Successfully Updated!'); }else{ $this->session->setFlashdata('error', 'Department Record Not Updated!'); } return redirect()->route('departmentListing'); } function viewdepartment($SID = '') { //print_r('hello');die(); if ($SID == '') { $DepartmentID = $_GET['SID']; } else { $DepartmentID = $SID; } $data['department'] = $this->department_model->getDeptInfo($DepartmentID); $data['depcode'] = $this->department_model->getdepcode(); $this->global['pageTitle'] = 'Edit Department'; $this->loadViews("editdepartment", $this->global, $data, NULL); } }