diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 4e22dbbd..7a9e9263 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -1165,21 +1165,24 @@ class ClientController extends AdminController $self = $policy_terms_data->family_floaters; } - $emp_count = $this->employeeModel->join('client_policy cp', "employees.client_id = cp.client_id") - ->join('employee_polices ep', "cp.id = ep.client_policy_id AND employees.id = ep.employee_id") - ->where("employees.client_id", $record['client_id']) - ->where("employees.emp_status", 'active') - ->where("ep.status", 'active') - ->where("employees.is_active", 1) - ->where("ep.is_active", 1) + // $emp_count = $this->employeeModel + // ->join('client_policy cp', "employees.client_id = cp.client_id") + // ->join('employee_polices ep', "cp.id = ep.client_policy_id AND employees.id = ep.employee_id") + // ->where("employees.client_id", $record['client_id']) + // ->where("employees.emp_status", 'active') + // ->where("ep.status", 'active') + // ->where("employees.is_active", 1) + // ->where("ep.is_active", 1) + // ->countAllResults(); + + + $emp_count = $this->employeePolicyModel + ->join('client_policy cp', "cp.id = employee_polices.client_policy_id") + ->where("employee_polices.client_policy_id", $client_policy_id) + ->where("employee_polices.status", 'active') + ->where("employee_polices.is_active", 1) ->countAllResults(); - - // $data = $this->employeePolicyModel->select('employee_polices.id') - // ->where('employee_polices.is_active', 1) - // ->where('employee_polices.client_policy_id', $client_policy_id) - // ->findAll(); - // $emp_count = count($data); // if($emp_count == 0){ @@ -1289,14 +1292,14 @@ class ClientController extends AdminController // print_r($premium1); // print_r($premium2); die; - return $this->respond(['status' => true, 'code' => 200, 'data' => $resultss, 'premiumData' => json_encode($premiumDataa), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self], 200); + return $this->respond(['status' => true, 'code' => 200, 'data' => $resultss, 'premiumData' => json_encode($premiumDataa), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self, 'client_policy_id' => $client_policy_id], 200); } else if ($search_term === 'GPA') { - return $this->respond(['status' => true, 'code' => 200, 'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self], 200); + return $this->respond(['status' => true, 'code' => 200, 'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self, 'client_policy_id' => $client_policy_id], 200); } else { - return $this->respond(['status' => false, 'code' => 200, 'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self], 200); + return $this->respond(['status' => false, 'code' => 200, 'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self, 'client_policy_id' => $client_policy_id], 200); } } diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index daf246d7..09dff202 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -84,10 +84,12 @@ class EmployeeRestController extends AdminController try { $emp_code = $this->request->getGet('emp_code'); $client_id = $this->request->getGet('client_id'); + $client_branch_id = $this->request->getGet('client_branch_id'); if ($emp_code) { $relationship = 'self'; $employee = $this->employeeModel->where('emp_code', $emp_code) ->where('client_id', $client_id) + ->where('client_branch_id', $client_branch_id) ->where('is_active', 1 ) ->where('relationship', $relationship) ->first(); @@ -102,7 +104,7 @@ class EmployeeRestController extends AdminController } } - + //not in use public function editEmployeeProfile() { try { @@ -125,7 +127,7 @@ class EmployeeRestController extends AdminController } - + //not in use public function getEmployeeAndDependence() { try { @@ -152,7 +154,7 @@ class EmployeeRestController extends AdminController } - + //not in use public function editEmployeeAndDependence() { try { @@ -372,6 +374,7 @@ class EmployeeRestController extends AdminController return null; } } + public function deleteDependence() { try { @@ -400,11 +403,78 @@ class EmployeeRestController extends AdminController } + // Get the RelationShip list + public function createOrUpdateEmployeePolicySiAmount() + { + + try { + $requestData = $this->request->getJSON(); + + foreach ($requestData as $key => $value) { + + + $checkIfExist = $this->employeePolicyModel->where('employee_id', $value->employee_id) + ->where('client_policy_id', $value->client_policy_id) + ->where('is_active', 1 ) + ->findAll(); + + + // dd($checkIfExist); + if ($checkIfExist) { + + $empPolicy = $this->employeePolicyModel->updateSiAndPremium($value->client_policy_id, $value->employee_id, $value->basic_cover_si); + + }else{ + + $data['employee_id']= $value->employee_id; + $data['client_policy_id']= $value->client_policy_id; + $data['basic_cover_si']= $value->basic_cover_si; + $data['status'] = 'draft'; + + $this->employeePolicyModel->insert($data); + } + } + + $this->updatePremiumAmount($requestData[0]->client_policy_id , $requestData[0]->emp_code); + + return $this->respond(['status' => 'success','code' => 200,'data' => []], 200); + + } catch (\Exception $e) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); + } + } + + public function findPremiumAmount($slabArray,$siAmount) + { + foreach ($slabArray as $key => $value) { + if($value['si'] == $siAmount){ + return $value['premium']; + break; + } + } + } + + public function relationshipList() + { + try { + + $relation_ships= $this->relationshipModel->findAll(); + + if(count($relation_ships) > 0){ + return $this->respond(['status' => 'success','code' => 200,'data' => $relation_ships], 200); + }else{ + return $this->respond(['status' => 'success','code' => 200,'data' => "No Data..!"], 200); + } + + } catch (\Exception $e) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); + } + } public function getEmployeeAndDependenceByClientId() { try { - $empData = $this->employeePolicyModel->getEmployeePolicy( client_id:$this->request->getGet('client_id'),policy_id: $this->request->getGet('client_policy_id'),status:0); + $empData = $this->employeePolicyModel->getEmployeePolicy( client_id:$this->request->getGet('client_id'),policy_id: $this->request->getGet('client_policy_id'),status:0,branch_id:$this->request->getGet('client_branch_id')); if ($empData) { return $this->respond(['status' => 'success', 'code' => 200, 'data' => $empData], 200); @@ -419,11 +489,11 @@ class EmployeeRestController extends AdminController } - public function exportDataByClientPolicyId() { try { - $empData = $this->employeePolicyModel->getEmployeePolicy( client_id:$this->request->getGet('client_id'),policy_id: $this->request->getGet('client_policy_id'),status:0); + + $empData = $this->employeePolicyModel->getEmployeePolicy( client_id:$this->request->getGet('client_id'),policy_id: $this->request->getGet('client_policy_id'),status:0,branch_id:$this->request->getGet('client_branch_id')); if(count($empData)) { @@ -496,6 +566,7 @@ class EmployeeRestController extends AdminController } + //not in use public function getClientPolicy() { try { @@ -534,73 +605,7 @@ class EmployeeRestController extends AdminController - // Get the RelationShip list - public function createOrUpdateEmployeePolicySiAmount() - { - - try { - $requestData = $this->request->getJSON(); - - foreach ($requestData as $key => $value) { - - - $checkIfExist = $this->employeePolicyModel->where('employee_id', $value->employee_id) - ->where('client_policy_id', $value->client_policy_id) - ->where('is_active', 1 ) - ->findAll(); - - - // dd($checkIfExist); - if ($checkIfExist) { - - $empPolicy = $this->employeePolicyModel->updateSiAndPremium($value->client_policy_id, $value->employee_id, $value->basic_cover_si); - - }else{ - - $data['employee_id']= $value->employee_id; - $data['client_policy_id']= $value->client_policy_id; - $data['basic_cover_si']= $value->basic_cover_si; - $data['status'] = 'draft'; - - $this->employeePolicyModel->insert($data); - } - } - - $this->updatePremiumAmount($requestData[0]->client_policy_id , $requestData[0]->emp_code); - - return $this->respond(['status' => 'success','code' => 200,'data' => []], 200); - - } catch (\Exception $e) { - return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); - } - } - - public function findPremiumAmount($slabArray,$siAmount) - { - foreach ($slabArray as $key => $value) { - if($value['si'] == $siAmount){ - return $value['premium']; - break; - } - } - } - public function relationshipList() - { - try { - - $relation_ships= $this->relationshipModel->findAll(); - - if(count($relation_ships) > 0){ - return $this->respond(['status' => 'success','code' => 200,'data' => $relation_ships], 200); - }else{ - return $this->respond(['status' => 'success','code' => 200,'data' => "No Data..!"], 200); - } - - } catch (\Exception $e) { - return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); - } - } // Upload the Employee Detail in DB by Sheet Data public function employeeUpload() @@ -614,6 +619,7 @@ class EmployeeRestController extends AdminController // die; $file = $this->request->getFile('file'); $client_id = $this->request->getPost('client_id'); + $client_branch_id = $this->request->getPost('client_branch_id'); $policy_id = $this->request->getPost('policy_id'); $client_data = $this->clientModel->where('id', $client_id)->first(); @@ -632,7 +638,7 @@ class EmployeeRestController extends AdminController - $client_policy = $this->clientPolicyModel->where('id', $policy_id)->where('client_id', $client_id)->first(); + $client_policy = $this->clientPolicyModel->where('id', $policy_id)->where('client_id', $client_id)->where('client_branch_id', $client_branch_id)->first(); if ($client_policy) { $policy = $this->policesModel->where('id', $client_policy['policy_id'])->first(); $policy_permium_1 = $this->policyPremium1Model->where(['client_id' => $client_id , 'client_policy_id' => $policy_id,'is_active' =>1])-> first(); @@ -666,6 +672,7 @@ class EmployeeRestController extends AdminController $extractData['file_name']= $filename; $extractData['client_id']= $client_id; + $extractData['client_branch_id']= $client_branch_id; $extractData['status']= 'success'; $extractData['policy_id']= $policy_id; $extractData['action']= 'enrollment'; @@ -928,13 +935,15 @@ public function getAgeRange($terms,$familyFloatesValue) } + public function getEmployeePolicy() { try { $id = $this->request->getGet('id'); $emp_code = $this->request->getGet('emp_code'); - $client_id = $this->request->getGet('client_id'); + $client_id = $this->request->getGet('client_id'); + $client_branch_id = $this->request->getGet('client_branch_id'); // This is an array containing keys to be removed from the terms and conditions array $keysToRemove = ["removable_keys"]; @@ -942,8 +951,11 @@ public function getEmployeePolicy() $empPolicy = $this->employeeModel->getEmployeePolicy($id); // Retrieve employee and dependents data by passing the employee code - $employeeData = $this->employeeModel->where('emp_code',$emp_code)->where('client_id',$client_id) - ->where('is_active', 1 )->where('is_addon_value',0)->findAll(); + $employeeData = $this->employeeModel->where('emp_code',$emp_code) + ->where('client_id',$client_id) + ->where('client_branch_id',$client_branch_id) + ->where('is_active', 1 ) + ->where('is_addon_value',0)->findAll(); if ($empPolicy) { @@ -1091,12 +1103,13 @@ public function getEmployeePolicy() ->where('client_policy.policy_type_id', 3 ) ->where('client_policy.is_addon', 1 ) ->where('client_policy.client_id', $this->request->getGet('client_id') ) + ->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') ) ->where('client_policy.is_active', 1 ) ->get() ->getResult(); if($checkGmcParentsPolicyExist) { - $GmcParrentsData = $this->getGmcParrentsPolicy($checkGmcParentsPolicyExist,$emp_code,$client_id); + $GmcParrentsData = $this->getGmcParrentsPolicy($checkGmcParentsPolicyExist,$emp_code,$client_id,$client_branch_id); return $this->respond(['status' => 'success','code' => 200,'data' => [$array,$GmcParrentsData]], 200); } @@ -1122,11 +1135,14 @@ public function getEmployeePolicy() } -public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id) +public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id,$client_branch_id) { - $employeeData = $this->employeeModel->where('emp_code',$emp_code)->where('client_id',$client_id) - ->where('is_active', 1 )->where('is_addon_value',0)->findAll(); + $employeeData = $this->employeeModel->where('emp_code',$emp_code) + ->where('client_id',$client_id) + ->where('client_branch_id',$client_branch_id) + ->where('is_active', 1 ) + ->where('is_addon_value',0)->findAll(); foreach ($GmcParrentsPolicy as $key => $array) { @@ -1163,9 +1179,7 @@ public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id) $array->eCardDownload = null; } - // if($array->tpa_id != null){ - // $array->eCardDownload = base_url('download-e-card/') . $array->rand_string; - // }else{ $array->eCardDownload = null; } + $array->eCardDownload = null; // Map family floaters that already exist in the employee table @@ -1256,6 +1270,7 @@ public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id) } } + public function FloterConvertion($array){ $result = []; @@ -1320,7 +1335,8 @@ public function getClientDetails() $client = $this->clientModel->where('id',$this->request->getGet('client_id'))->first(); if($client) { $client['client_logo'] = base_url().'public/uploads/logo/'.$client['client_logo']; - $clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id'))->findAll(); + $clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id')) + ->where('client_branch_id',$this->request->getGet('client_branch_id'))->findAll(); return $this->respond(['status' => 'success','code' => 200,'data' => ['client'=>$client,'client_policy'=>$clientPolicy]], 200); }else{ @@ -1335,17 +1351,22 @@ public function getAddOnPolicy() { try { - $addOnEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('is_addon_value',1)->findAll(); + $addOnEmployeeData = $this->employeeModel->where('is_active', 1 ) + ->where('emp_code',$this->request->getGet('emp_code')) + ->where('client_id',$this->request->getGet('client_id')) + ->where('client_branch_id',$this->request->getGet('client_branch_id')) + ->where('is_addon_value',1)->findAll(); $clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id')) + ->where('client_branch_id',$this->request->getGet('client_branch_id')) ->where('policy_status', 1) ->findAll(); if(count($clientPolicy)) { - $band = $addOnEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('family_floater_key','self')->get()->getRow()->band; + $band = $addOnEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('client_branch_id',$this->request->getGet('client_branch_id'))->where('family_floater_key','self')->get()->getRow()->band; $PolicyData = []; foreach ($clientPolicy as $key => $array) { $responce = []; @@ -1768,6 +1789,7 @@ public function getCashDepositData() $ClientPolicyData = $this->clientPolicyModel->select('client_policy.client_id as clientId , client_policy.insurer_id as insurerId,insurers.name as insurer_name') ->join('insurers', 'client_policy.insurer_id = insurers.id', 'left') ->where('client_policy.client_id', $this->request->getGet('client_id') ) + ->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') ) ->where('client_policy.is_active', 1 ) ->where('client_policy.policy_status', 1) ->groupBy('client_policy.insurer_id') @@ -1789,6 +1811,7 @@ public function getCashDepositData() ->join('policies', 'client_policy.policy_id = policies.id', 'left') ->where('client_policy.insurer_id', $value['insurerId'] ) ->where('client_policy.client_id', $this->request->getGet('client_id') ) + ->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') ) ->where('client_policy.is_active', 1 ) ->where('client_policy.policy_status', 1) ->findAll(); @@ -1797,7 +1820,7 @@ public function getCashDepositData() { $value['type'] = $this->policyTypeModel->where('id',$value['policy_type_id'])->get()->getRow()->policy_type; - $employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0); + $employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0,branch_id:$this->request->getGet('client_branch_id')); $enrolledCount = 0; $draftCount = 0; if(count($employeeDetails)) @@ -1970,83 +1993,6 @@ public function removeEmpAndEmpPolicyData() } - - -function getEmployeeOldPolicy() -{ - $ClientPolicyData = $this->clientPolicyModel->select('client_policy.* , policies.name as policy_name , policy_type.policy_type as policy_type') - ->join('policies', 'client_policy.policy_id = policies.id', 'left') - ->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left') - ->where('client_policy.client_id', $this->request->getGet('client_id') ) - ->where('client_policy.is_active', 1 ) - ->where('client_policy.policy_status', 0) - ->orderby('client_policy.id' , 'ASC') - ->findAll(); - - // Retrieve employee and dependents data by passing the employee code - $employeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code')) - ->where('client_id',$this->request->getGet('client_id')) - ->where('is_active', 1 )->findAll(); - $whereArrayForId = []; - foreach ( $employeeData as $key => $value) { array_push($whereArrayForId, $value['id']); } - - if(count($ClientPolicyData) > 0 && count($employeeData) > 0) - { - $result = []; - foreach ($ClientPolicyData as $key => $ClientPolicyValue) { - - $terms = json_decode($ClientPolicyValue['policy_terms']); - // dd($terms); - $data['client_id'] = $ClientPolicyValue['client_id']; - $data['client_policy_id'] = $ClientPolicyValue['id']; - $data['policy_name'] = $ClientPolicyValue['policy_name']; - $data['policy_type'] = $ClientPolicyValue['policy_type']; - $data['policy_type'] = $ClientPolicyValue['policy_type']; - $data['policy_start_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_start_date']); - $data['policy_end_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_end_date']); - - if($ClientPolicyValue['policy_type_id'] == 1){ $data['heading'] = 'Group Personal Accident Coverage'; }else - if($ClientPolicyValue['policy_type_id'] == 2){ $data['heading'] = 'Group Medical Coverage'; }else - if($ClientPolicyValue['policy_type_id'] == 3){ $data['heading'] = 'Group Medical Coverage - Parents'; }else - if($ClientPolicyValue['policy_type_id'] == 4){ $data['heading'] = 'Group Medical Coverage - Top Up'; }else - if($ClientPolicyValue['policy_type_id'] == 5){ $data['heading'] = 'Group Medical Coverage - Parents (Top Up)'; } - - if($ClientPolicyValue['policy_type_id'] == 1){ $data['floter_text_heading'] = 'Sum Insured'; } - else - { - if($terms->family_floater == 1){ $data['floter_text_heading'] = 'Floter Sum Insured'; }else{ $data['floter_text_heading'] = 'Sum Insured'; } - } - - $employee_policy = $this->employeePolicyModel->select('employees.*,employee_polices.employee_id , employee_polices.basic_cover_si , employee_polices.premium , employee_polices.gst , employee_polices.tpa_id , employee_polices.rand_string') - ->join('employees', 'employee_polices.employee_id = employees.id', 'left') - ->whereIn('employee_polices.employee_id',$whereArrayForId) - ->where('employee_polices.client_policy_id',$ClientPolicyValue['id']) - ->where('employee_polices.is_active', 1 )->findAll(); - $si_value = 0; - $si_premium_value = 0; - $si_gst_value = 0; - foreach ($employee_policy as $key => $value) { - if(isset($value['basic_cover_si'])){ $si_value = $value['basic_cover_si']; } - if(isset($value['premium'])){ $si_premium_value = $si_premium_value + $value['premium'];} - if(isset($value['gst'])){ $si_gst_value = $si_gst_value + $value['gst'];} - } - - $data['si_value'] = $si_value; - $data['si_premium_value'] = ($ClientPolicyValue['policy_type_id'] == 1 || $ClientPolicyValue['policy_type_id'] == 2) ? 0 : $si_premium_value; - $data['si_gst_value'] = ($ClientPolicyValue['policy_type_id'] == 1 || $ClientPolicyValue['policy_type_id'] == 2) ? 0 : $si_gst_value; - - $data['EmployeePolicy'] = $employee_policy; - array_push($result, $data); - } - - return $this->respond(['status' => 'success','code' => 200,'data' => $result ], 200); - - }else{ - return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 200); - } - -} - function getEmployeeActiveOrInactivePolicy() { @@ -2055,6 +2001,7 @@ function getEmployeeActiveOrInactivePolicy() ->join('policies', 'client_policy.policy_id = policies.id', 'left') ->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left') ->where('client_policy.client_id', $this->request->getGet('client_id') ) + ->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') ) ->where('client_policy.is_active', 1 ) ->where('client_policy.policy_status', $policy_status) ->orderby('client_policy.id' , 'ASC') @@ -2063,9 +2010,11 @@ function getEmployeeActiveOrInactivePolicy() // Retrieve employee and dependents data by passing the employee code $employeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code')) ->where('client_id',$this->request->getGet('client_id')) + ->where('client_branch_id',$this->request->getGet('client_branch_id')) ->where('is_active', 1 )->findAll(); $employeeName = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code')) ->where('client_id',$this->request->getGet('client_id')) + ->where('client_branch_id',$this->request->getGet('client_branch_id')) ->where('family_floater_key','self')->where('is_active', 1 ) ->get()->getRow()->name; $whereArrayForId = []; diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 3af70fc4..72e7b8c7 100644 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -101,7 +101,7 @@ class RestAuthenticationController extends AdminController $auth = HttpRequestHelper::getRequestInfo(); if ($auth) { $data = [ - 'user_id' => $employeeData['id'], + 'user_id' => $employeeData['id'], 'user_type' => 'employee', 'ip' => $auth['ip'], 'platform' => $auth['platform'], diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index e3c8ff95..c96b1c69 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -1,3 +1,5 @@ + +
- -Paste excel data here: Copy Excel Headers
-JSON output:
- -