From 65987607c518df2ab9c59a914912a20513b31f94 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 29 May 2024 11:46:55 +0530 Subject: [PATCH 1/4] FEAT_COPY_PASTE_EXCEL_TO_RACK_RATE_DATA_COMPLETE : RV --- app/Controllers/ClientController.php | 35 +- app/Views/policy_grid.php | 129 ++++-- app/Views/policy_grid_excel.php | 599 +++++++++++++++++---------- 3 files changed, 501 insertions(+), 262 deletions(-) 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/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 @@ + + - -
-
+
+ + Copy from excel
-
+
+
+ +
@@ -158,6 +173,26 @@ $('#btnGridSubmit').hide(); $('.close').click(function() { + $('#grid_content_input').show(); + $('#grid_content_from_excel').hide(); + + if ($('#copyfromexcel').text() == "Manual entry") { + $('#copyfromexcel').text("Copy from excel") + } else { + $('#copyfromexcel').text("Copy from excel"); + } + + + $('#additional_grid_content_input').show(); + $('#additional_grid_content_from_excel').hide(); + + if ($('#copyfromexcelforadditional').text() == "Manual entry") { + $('#copyfromexcelforadditional').text("Copy from excel") + } else { + $('#copyfromexcelforadditional').text("Copy from excel"); + } + + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); $('#add_grid_' + i).remove(); @@ -166,6 +201,7 @@ $('.close').click(function() { }); $('#copyfromexcel').click(function() { + // alert('called'); // $('#copyfromexcel').toggle(); // $("#copied_excel_data").val(result.exampleMessage); @@ -182,6 +218,22 @@ $('#copyfromexcel').click(function() { +}); + +$('#copyfromexcelforadditional').click(function() { + + if ($(this).text() == "Copy from excel") { + $(this).text("Manual entry") + + } else { + $(this).text("Copy from excel"); + } + + $('#additional_grid_content_input').toggle(); + $('#additional_grid_content_from_excel').toggle(); + + + }); function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = false, rr_type = false) { @@ -807,8 +859,7 @@ $("#GridForm").submit(function(event) { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - var message = (policy_PrimaryKey === '') ? 'Policy Premium Added successfully' : - 'Policy Premium Added Successfully'; + var message = (policy_PrimaryKey === '') ? 'Policy Premium Added successfully' :'Policy Premium Added Successfully'; toastr.success(message, 'Success'); // $('.close').click(); @@ -829,7 +880,6 @@ $("#GridForm").submit(function(event) { $("#AdditionalGridForm").submit(function(event) { var check = checkDuplicate(1); - event.preventDefault(); if ($('#grid_emp_count').val() == 'false') { @@ -966,18 +1016,21 @@ $('body').on('click', '.btnPolicyModel', function() { res.premiumData = JSON.parse(res.premiumData); console.log('policy grid responce', res.premiumData); - console.log('policy grid responce', res.policy_name); + console.log('policy name', res.policy_name); - $('#nameOfThePolicy').html(' - ' + res.policy_name); + $('#nameOfThePolicy').text(' - ' + res.policy_name); $('#grid_emp_count').val(res.count); if (res.count > 0) { $("#hide_smbt_btn").hide(); + $("#secondary_rack_rate_btn_grp").hide(); } else { $("#hide_smbt_btn").show(); + $("#secondary_rack_rate_btn_grp").show(); } + if (res.status === false) { toastr.error(res.status); @@ -1037,8 +1090,6 @@ $('body').on('click', '.btnPolicyModel', function() { console.log('policy_grid_id_value', policy_grid_id_value); console.log('secondary_policy_grid_id_value', secondary_policy_grid_id_value); - - $('#grid_content_input').empty(); var policeGridOptionHTML = ''; policeGridOptionHTML += ` `; @@ -1050,7 +1101,7 @@ $('body').on('click', '.btnPolicyModel', function() { }); - + $('#additional_grid_content_input').empty(); var policeGridOptionHTMLforSecondary = ''; policeGridOptionHTMLforSecondary += ` `; @@ -1129,7 +1180,12 @@ $('body').on('click', '.btnPolicyModel', function() { $(this).trigger('keyup'); }); - var id_for_trigger = temp_for_premiumData[0].policy_grid_id; + var id_for_trigger = []; + if (temp_for_premiumData.length > 0 && temp_for_premiumData[0] !== undefined) { + id_for_trigger = temp_for_premiumData[0].policy_grid_id; + } + + $(`input[name="${id_for_trigger}_si[]"]`).each(function() { // console.log($(this)); $(this).trigger('keyup'); @@ -1167,6 +1223,8 @@ $('body').on('click', '.btnPolicyModel', function() { $('#grid').change(function() { + $('.excel_textarea').val(''); + var grid_id = $(this)[0].value; var client_policy_id = $('#client_policy_id')[0].value; @@ -1239,7 +1297,6 @@ $('#grid').change(function() { si_or_bp_value = res.premiumData[0].si_or_bp; $('#si_or_bp').val(si_or_bp_value); - } @@ -1277,6 +1334,8 @@ $('#grid').change(function() { $('#additional_grid').change(function() { + $('.excel_textarea').val(''); + var grid_id = $(this)[0].value; var client_policy_id = $('#client_policy_id')[0].value; @@ -1302,9 +1361,9 @@ $('#additional_grid').change(function() { if (res.count > 0) { // console.log(' hide submit btn count ', res.count); - $("#hide_smbt_btn").hide(); + $("#secondary_rack_rate_btn_grp").hide(); } else { - $("#hide_smbt_btn").show(); + $("#secondary_rack_rate_btn_grp").show(); // console.log('show submit btn count ', res.count); } @@ -1315,9 +1374,9 @@ $('#additional_grid').change(function() { if (res.count > 0) { // console.log(' hide submit btn count ', res.count); - $("#hide_smbt_btn").hide(); + $("#secondary_rack_rate_btn_grp").hide(); } else { - $("#hide_smbt_btn").show(); + $("#secondary_rack_rate_btn_grp").show(); // console.log('show submit btn count ', res.count); } @@ -1332,7 +1391,7 @@ $('#additional_grid').change(function() { policy_grid_id_value = res.premiumData[0].policy_grid_id; } - $('#grid_content_input').empty(); + $('#additional_grid_content_input').empty(); var policeGridOptionHTML = ''; policeGridOptionHTML += ` `; $.each(res.data, function(index, item) { @@ -1341,7 +1400,9 @@ $('#additional_grid').change(function() { 'selected="selected"' : '') + '>' + item.policy_grid_type + ''; }); + // $('#grid').html(policeGridOptionHTML); + var si_or_bp_value = ''; if (res.premiumData && res.premiumData.length > 0) { @@ -2530,12 +2591,16 @@ function getCurrentTime() { function createCheckboxes(obj, additional_relationship) { - console.log('createCheckboxes function called'); - console.log(additional_relationship) - additional_relationship = JSON.parse(additional_relationship); - console.log(additional_relationship) + console.log(additional_relationship); + try { + additional_relationship = JSON.parse(additional_relationship); + console.log(additional_relationship); + } catch (error) { + console.error("Error parsing additional_relationship:", error); + return; + } $('#relationship').empty(); const $relationshipElement = $('#relationship'); @@ -2545,24 +2610,24 @@ function createCheckboxes(obj, additional_relationship) { const multiplier = 7; // Adjust this value as needed $.each(obj, function(key, value) { - if (value > 0 && key != 'either-parents-pil') { - + const isChecked = additional_relationship && typeof additional_relationship === 'object' && additional_relationship[key] == 1 ? 'checked' : ''; key = formatString(key); - const isChecked = additional_relationship && additional_relationship[key] === 1 ? 'checked' : ''; + console.log('isChecked', isChecked); html += `
- +
`; + // console.log(html); } }); $relationshipElement.append(html); - } + function formatString(str) { return str.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' '); } diff --git a/app/Views/policy_grid_excel.php b/app/Views/policy_grid_excel.php index 50487a0a..009c6bb6 100644 --- a/app/Views/policy_grid_excel.php +++ b/app/Views/policy_grid_excel.php @@ -1,241 +1,412 @@ +table { + border-collapse: collapse; + width: 100%; +} -
- - -

Paste excel data here: Copy Excel Headers

-
- - -
-
- -
-
- -

-

JSON output:

-
-
+td, +th { + padding: 0.2rem; +} - -
+ $(`input[name="${formatType}_premium[]"]`).each(function() { + // console.log($(this)); + $(this).trigger('keyup'); + }); + + + + } + + \ No newline at end of file From 127a12d2351d19b88d015ea6ef879979960dd121 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Wed, 29 May 2024 12:19:10 +0530 Subject: [PATCH 2/4] CHANGE _ adding branch_id : GWM --- app/Controllers/EmployeeRestController.php | 129 +++++------------- .../RestAuthenticationController.php | 2 +- 2 files changed, 36 insertions(+), 95 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index daf246d7..67306e3c 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 { @@ -404,7 +407,7 @@ class EmployeeRestController extends AdminController 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,client_branch_id:$this->request->getGet('client_branch_id')); if ($empData) { return $this->respond(['status' => 'success', 'code' => 200, 'data' => $empData], 200); @@ -934,7 +937,8 @@ public function getEmployeePolicy() $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 +946,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 +1098,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 +1130,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 +1174,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 @@ -1320,7 +1329,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 +1345,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 = []; @@ -1970,83 +1985,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 +1993,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 +2002,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'], From d16c0799bb76285996491b0d3f09699387e772c5 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Wed, 29 May 2024 12:26:10 +0530 Subject: [PATCH 3/4] CHANGE _ adding branch_id : GWM --- app/Controllers/EmployeeRestController.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 67306e3c..81529bc7 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -407,7 +407,7 @@ class EmployeeRestController extends AdminController 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,client_branch_id:$this->request->getGet('client_branch_id')); + $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); @@ -426,7 +426,8 @@ 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)) { @@ -1783,6 +1784,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') @@ -1812,7 +1814,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)) From 0d17c1692b04f73c8f557fb19d2054e87390a92c Mon Sep 17 00:00:00 2001 From: bitbucket Date: Wed, 29 May 2024 13:27:34 +0530 Subject: [PATCH 4/4] CHANGE_ adding branch_id : GWM --- app/Controllers/EmployeeRestController.php | 142 +++++++++++---------- 1 file changed, 74 insertions(+), 68 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 81529bc7..09dff202 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -403,6 +403,73 @@ 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() { @@ -422,7 +489,6 @@ class EmployeeRestController extends AdminController } - public function exportDataByClientPolicyId() { try { @@ -500,6 +566,7 @@ class EmployeeRestController extends AdminController } + //not in use public function getClientPolicy() { try { @@ -538,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() @@ -618,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(); @@ -636,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(); @@ -670,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'; @@ -932,6 +935,7 @@ public function getAgeRange($terms,$familyFloatesValue) } + public function getEmployeePolicy() { try { @@ -1266,6 +1270,7 @@ public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id,$cl } } + public function FloterConvertion($array){ $result = []; @@ -1806,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();