diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index f0265973..f5b918c4 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -660,7 +660,7 @@ class RestAuthenticationController extends AdminController if(isset($this->request->getJSON()->mobile_no)){ - $getAllhrData = $this->hrModel->select('level_contacts.mobile , level_contacts.email , clients.id as client_id, clients.client_name, clients.short_name , client_branch.id as client_branch_id,client_branch.branch_name') + $getAllhrData = $this->hrModel->select('level_contacts.id ,level_contacts.mobile , level_contacts.email , clients.id as client_id, clients.client_name, clients.short_name , client_branch.id as client_branch_id,client_branch.branch_name, client_branch.pre_branch_id') ->join('client_branch', 'level_contacts.ref_id = client_branch.id', 'left') ->join('clients', 'client_branch.client_id = clients.id', 'left') ->where('level_contacts.mobile', $mobile_number ) @@ -671,7 +671,7 @@ class RestAuthenticationController extends AdminController $this->hrModel->where('email', $email)->where('otp', $otp)->where('contact_type', 'client')->set(['otp'=>null])->update(); - $getAllhrData = $this->hrModel->select('level_contacts.mobile , level_contacts.email , clients.id as client_id, clients.client_name, clients.short_name , client_branch.id as client_branch_id,client_branch.branch_name') + $getAllhrData = $this->hrModel->select('level_contacts.id ,level_contacts.mobile , level_contacts.email , clients.id as client_id, clients.client_name, clients.short_name , client_branch.id as client_branch_id,client_branch.branch_name, client_branch.pre_branch_id') ->join('client_branch', 'level_contacts.ref_id = client_branch.id', 'left') ->join('clients', 'client_branch.client_id = clients.id', 'left') ->where('level_contacts.email', $email ) @@ -679,16 +679,46 @@ class RestAuthenticationController extends AdminController ->findAll(); } - print_rr($getAllhrData); die; - $HRAccessData = $this->getHRAccessData( $hrData['0']['id'] , 'post_enrollment'); + if(count($getAllhrData)) + { + + foreach ($getAllhrData as $key => $value) { - if(isset($HRAccessData['allowed_modules'])){ $hrData['0']['allowed_modules'] = json_decode($HRAccessData['allowed_modules'],true)['post']; }else{ $hrData['0']['allowed_modules'] = []; } + $HRAccessData = $this->hrAccessControlModel + ->where('post_client_id',$value['client_id']) + ->where('post_branch_id', $value['client_branch_id']) + ->where('post_hr_id', $value['id']) + ->get()->getRowArray(); - $hrData['0']['token_type'] = 'post'; - $result = JWTToken::encode($hrData['0']); + + if (!empty($HRAccessData) && isset($HRAccessData['allowed_modules'])) { + + $decoded = json_decode($HRAccessData['allowed_modules'], true); + $getAllhrData[$key]['allowed_modules'] = $decoded; + + $token = JWTToken::encode($HRAccessData); + $getAllhrData[$key]['token'] = $token; + + } else { + $getAllhrData[$key]['allowed_modules'] = []; + $getAllhrData[$key]['token'] = ""; + } + + } + } + + return $this->respond(['status' => 'success','code' => 200,'data' => $getAllhrData ],200); + + + // $HRAccessData = $this->getHRAccessData( $hrData['0']['id'] , 'post_enrollment'); + + // if(isset($HRAccessData['allowed_modules'])){ $hrData['0']['allowed_modules'] = json_decode($HRAccessData['allowed_modules'],true)['post']; }else{ $hrData['0']['allowed_modules'] = []; } + + // $hrData['0']['token_type'] = 'post'; + // $result = JWTToken::encode($hrData['0']); - return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200); + // return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200); } else {