db->select('users.*, employees.*'); $this->db->from('users'); $this->db->join('employees', 'employees.user_id = users.id'); $this->db->where('users.business_id', $business_id); $this->db->where('users.is_active', 1); $this->db->where('employees.is_active', 1); $this->db->order_by('users.id', 'desc'); $query = $this->db->get(); if ($query->num_rows() > 0) { return $query->result(); } else { return; } } public function get_emp_by_md5_id($id,$business_id) { $this->db->select('users.*, employees.*'); $this->db->from('users'); $this->db->join('employees', 'users.id = employees.user_id'); $this->db->where('users.is_active', 1); $this->db->where('employees.is_active', 1); $this->db->where('users.business_id', $business_id); $this->db->where('md5(employees.user_id)', $id); $query = $this->db->get(); if ($query->num_rows() > 0) { return $query->row(); } else { return false; } } public function delete_emp_by_md5_id($id,$business_id) { $this->db->where('id', $id); $this->db->where('business_id', $business_id); $this->db->set('is_active',0); $this->db->update('users'); $this->db->where('user_id', $id); $this->db->where('business_id', $business_id); $this->db->set('is_active',0); $this->db->update('employees'); return; } public function get_data($business_id , $id , $table) { $this->db->select('*'); $this->db->from($table); $this->db->where('md5(emp_id)', $id); $this->db->where('business_id', $business_id); $this->db->where('is_active', 1); $query = $this->db->get(); $query = $query->result(); return $query; } public function get_manager_name($manager_id) { $this->db->select('*'); $this->db->from('users'); $this->db->where('id', $manager_id); $query = $this->db->get(); return $query->result(); } public function get_user_data_by_insert_id($insert_id) { $this->db->select('*'); $this->db->from('users'); $this->db->join('employees', 'users.id = employees.user_id'); $this->db->where('users.id', $insert_id); $query = $this->db->get(); $result = $query->result(); } public function get_leave_type($business_id) { $this->db->select('*'); $this->db->from('leave_master'); $this->db->where('business_id', $business_id); $query = $this->db->get(); return $query->result(); } public function get_modules($business_id) { $this->db->select('permit_modules.*,modules.modules'); $this->db->from('permit_modules'); $this->db->join('modules', 'permit_modules.module_id = modules.id and modules.is_active = 1', 'left'); $this->db->where('uid', $business_id); $this->db->where('permit_modules.is_active', 1); $query = $this->db->get(); return $query->result(); } public function get_group_list($business_id) { $this->db->select('*'); $this->db->from('groups'); $this->db->where('business_id', $business_id); $query = $this->db->get(); return $query->result(); } public function get_members_details($user_id, $business_id) { $this->db->select('group_id'); $this->db->from('group_membership'); $this->db->where('emp_id', $user_id); $this->db->where('business_id', $business_id); $query = $this->db->get(); return $query->result(); } public function get_members_list($id, $business_id) { $this->db->select('group_membership.*,groups.group_name'); $this->db->from('group_membership'); $this->db->join('groups', 'group_membership.group_id = groups.id and groups.is_active = 1', 'left'); $this->db->where('md5(emp_id)', $id); $this->db->where('group_membership.business_id', $business_id); $this->db->where('group_membership.is_active', 1); $query = $this->db->get(); return $query->result(); } public function get_group_module_data_by_id($id , $group_id = null) { $this->db->select('group_id'); $this->db->from('group_membership'); $this->db->where('emp_id', $id); if($group_id != null){ $this->db->where('group_id', $group_id); } $this->db->where('is_active', 1); $query = $this->db->get(); return $query->result(); } public function delete_group_module_data_by_id($user_id , $group_id ) { $this->db->where('group_id', $group_id); $this->db->where('emp_id', $user_id); $this->db->delete('group_membership'); return; } }