From 55e3e3f4afeff0c71656ffde4d9ca51d8a53216c Mon Sep 17 00:00:00 2001 From: gandhimathi Bharathirajan Date: Wed, 12 Apr 2017 14:56:07 +0530 Subject: [PATCH] Supplier details added --- application/models/employeedetails_model.php | 192 +++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 application/models/employeedetails_model.php diff --git a/application/models/employeedetails_model.php b/application/models/employeedetails_model.php new file mode 100644 index 00000000..a9f06577 --- /dev/null +++ b/application/models/employeedetails_model.php @@ -0,0 +1,192 @@ +db->select('count(*) as Count'); + $this->db->from('T_Employee_Details Emp'); + //$likeCriteria = ''; + $this->db->join('T_DepartmentDetails Dep', 'Emp.Departmentcode = Dep.DEPCode','left'); + if(!empty($searchText)) { + $likeCriteria = "(Emp.EmpID LIKE '%".$searchText."%' + OR Emp.FirstName LIKE '%".$searchText."%' + OR Emp.LastName LIKE '%".$searchText."%' + OR Emp.ContactNumber LIKE '%".$searchText."%' + OR Emp.EmailId LIKE '%".$searchText."%' + OR Emp.Designation LIKE '%".$searchText."%' + OR Dep.DepartmentName LIKE '%".$searchText."%' + + )"; + + $this->db->where($likeCriteria); + } + + + // print_r( $this->db->last_query()); + + $query = $this->db->get(); + // print_r( $this->db->last_query()); + return $query->result_array(); + } + + + /** + * This function is used to get the user listing count + * @param string $searchText : This is optional search text + * @param number $page : This is pagination offset + * @param number $segment : This is pagination limit + * @return array $result : This is result + */ + function employeeListing($searchText = '', $page, $segment) + { + $this->db->select(' Emp.*,Dep.DepartmentName as DepartmentName'); + $this->db->from('T_Employee_Details Emp'); + + $this->db->join('T_DepartmentDetails Dep', 'Emp.Departmentcode = Dep.DEPCode','left'); + if(!empty($searchText)) { + $likeCriteria = "(Emp.EmpID LIKE '%".$searchText."%' + OR Emp.FirstName LIKE '%".$searchText."%' + OR Emp.LastName LIKE '%".$searchText."%' + OR Emp.ContactNumber LIKE '%".$searchText."%' + OR Emp.EmailId LIKE '%".$searchText."%' + OR Emp.Designation LIKE '%".$searchText."%' + OR Dep.DepartmentName LIKE '%".$searchText."%' + )"; + $this->db->where($likeCriteria); + } + + + $this->db->order_by("Emp.EmpID", "asc"); + $this->db->limit($page, $segment); + $query = $this->db->get(); + //print_r( $this->db->last_query()); + $result = $query->result(); + return $result; + } + + + function getUserRoles() + { + $this->db->select('roleId, role'); + $this->db->from('tbl_roles'); + $this->db->where('roleId !=', 1); + $query = $this->db->get(); + + return $query->result(); + } + + /** + * This function is used to get the Config value from configuration table + * @return array $result : This is result of the query + */ + function getConfigValue($ConfigID ) + { + + $this->db->select('ConfigValue'); + $this->db->from('T_ConfigDetails'); + $this->db->where('Config_id ',$ConfigID ); + $query = $this->db->get(); + + return $query->result(); + } + + /* *//** + * This function is used to get the Department details from T_DepartmentDetails + * @return array $result : This is result of the query + */ + function getDepartment() + { + $this->db->select('DEPCode, DepartmentName'); + $this->db->from('T_DepartmentDetails'); + $this->db->where('IsActive =', 1); + $query = $this->db->get(); + + return $query->result(); + } + /** + * This function used to get user information by id + * @param number $userId : This is user id + * @return array $result : This is user information + */ + +function addNewemployee($Employee) + { + + $this->db->insert('T_Employee_Details', $Employee); + + $EmpID = $this->db->affected_rows(); + + return $EmpID; + } + + + function UpdateEmployee($Emp, $EmpID) + { + //echo $EmpID; + $this->db->where('EmpID', $EmpID); + $this->db->update('T_Employee_Details', $Emp); + //print_r($this->db->last_query()); + return TRUE; + } + + + function viewemployee( $EmpID) + { + $this->db->select('Emp.*,Dep.DepartmentName as DepartmentName'); + $this->db->from('T_Employee_Details AS Emp'); + $this->db->join('T_DepartmentDetails Dep', 'Emp.Departmentcode = Dep.DEPCode','left'); + $this->db->where('Emp.EmpID', $EmpID); + $query = $this->db->get(); + + $result = $query->result(); + + // print_r($this->db->last_query()); + return $result; + } + + /* This function to get the Employee department on respective Employee */ + function GetEmployeeDepartment($EmployeeID) + { + $this->db->select('DepartmentName'); + $this->db->from('T_EmployeeDetails'); + $this->db->where($EmployeeID); + $query = $this->db->get(); + return $query->result_array(); + } + + function checkMailExists($email='',$Empid='') + { + $this->db->select('EmailId'); + $this->db->from('T_Employee_Details'); + $this->db->where('EmailId',$email); + if ($Empid != '') + { + $this->db->where('EmpID !=',$Empid); + } + $query = $this->db->get(); + //print_r($this->db->last_query()); + if ($query->num_rows > 0) { + return $query->result_array(); + } + } + + function checkPhotoExists($Pic) + { + $this->db->select('ProfilePic'); + $this->db->from('T_Employee_Details'); + $this->db->where($Pic); + + $query = $this->db->get(); + // print_r($this->db->last_query()); + if ($query->num_rows > 0) { + return $query->result_array(); + } + } +} +?> \ No newline at end of file