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(); 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->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(string $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; } /** * This function used to get user information by id * @param number $userId : This is user id * @return array $result : This is user information */ function getuserInfo($EmpID) { $this->db->select('EmpID,FirstName,LastName,DateofBirth,ContactNumber,EmailId,DateofJoining,Role,Address1,Address2, Place,City,State,Pin,DepartmentName,User_Comments,Created_date'); $this->db->from('T_EmpDetails'); //$this->db->where('isDeleted', 0); //$this->db->where('roleId !=', 1); $this->db->where('EmpID', $EmpID); $query = $this->db->get(); return $query->result(); } function editemployee($Emp, $EmpID) { echo $EmpID; $this->db->where('EmpID', $EmpID); $this->db->update('T_EmpDetails', $Emp); return TRUE; } function viewemployee($Emp, $EmpID) { echo $EmpID; $this->db->where('EmpID', $EmpID); $this->db->update('T_EmpDetails', $Emp); return TRUE; } /* 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('EmpID', $EmployeeID); $query = $this->db->get(); return $query->result_array(); } public function insert($data = array()){ $this->tableName = 'uploadphoto'; $this->primaryKey = 'id'; if(!array_key_exists("created",$data)){ $data['created'] = date("Y-m-d H:i:s"); } if(!array_key_exists("modified",$data)){ $data['modified'] = date("Y-m-d H:i:s"); } $insert = $this->db->insert($this->tableName,$data); if($insert){ return $this->db->insert_id(); }else{ return false; } } } ?>