From ec5ae2349764eb56040e2365f07b7a0460bee8f5 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 13 Jun 2024 17:41:23 +0530 Subject: [PATCH 1/6] FEAT_OTHER_POLICY_TERMS : RV --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 24 ++ app/Views/client_policy.php | 33 +- app/Views/other_policy_terms.php | 593 +++++++++++++++++++++++++++ app/Views/policy_gmc_terms.php | 60 +-- app/Views/policy_gpa_terms.php | 2 +- 6 files changed, 667 insertions(+), 46 deletions(-) create mode 100644 app/Views/other_policy_terms.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 34426123..f8e0756c 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -114,6 +114,7 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) { $routes->group("terms", ["filter" => "authMVC"], function ($routes) { $routes->post("gpa_create", "ClientController::policyGPATerms"); $routes->post("edit", "ClientController::editClientPolicyPremium"); + $routes->post("other_terms", "ClientController::otherPolicyTermsFormSubmit"); }); }); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 2dbe4d60..d6b271f7 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2157,4 +2157,28 @@ class ClientController extends AdminController } + public function otherPolicyTermsFormSubmit() + { + + $client_policy_id = $this->request->getPost("client_policy_id"); + $policy_terms = $this->request->getPost("policy_terms"); + + $record = $this->clientPolicyModel->where('id', $client_policy_id)->first(); + + if ($record) { + + $update = $this->clientPolicyModel->where('id', $client_policy_id)->set('policy_terms', $policy_terms)->update(); + + if ($update) { + return $this->respond(['status' => true, 'code' => 200, 'message' => 'Data updated successfully', 'client_policy_id' => $client_policy_id], 200); + } else { + return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to update data', 'formdata' => $this->request->getPost()], 200); + } + } else { + + return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to store data. The client policy does not exist', 'formdata' => $this->request->getPost()], 200); + } + } + + } \ No newline at end of file diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index 00cb1960..9ccb3996 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -157,6 +157,7 @@ + + + + \ No newline at end of file diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index 2b710321..3893ee7f 100644 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -615,7 +615,7 @@ // $('input[name="family_floater"]').change(function() { - // console.log($(this).val()); + // //console.log($(this).val()); // if ($(this).val() == '1') { // var element = $(this).parent().next()[0]; // $(element).css("display", "block"); @@ -631,7 +631,7 @@ $('input[name="ayudhtreatmentcover"]').change(function() { - console.log($(this).val()); + ////console.log($(this).val()); if ($(this).val() == '1') { var element = $(this).parent().parent().next()[0]; @@ -645,7 +645,7 @@ $('input[name="cataract"]').change(function() { - console.log($(this).val()); + //console.log($(this).val()); if ($(this).val() == '1') { var element = $(this).parent().parent().next()[0]; @@ -715,7 +715,7 @@ } if (!isValid) { - console.log('Form is Empty', 'Warning'); + //console.log('Form is Empty', 'Warning'); return; } @@ -751,7 +751,7 @@ setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - console.log('Something Wrong!', 'warning'); + //console.log('Something Wrong!', 'warning'); }, 1000); } }); @@ -773,14 +773,14 @@ $('body').on('click', '.btnPolicyMaster', function() { var client_policy_id = $(this).data('id'); - console.log('gmc_client_policy_id :', client_policy_id); + //console.log('gmc_client_policy_id :', client_policy_id); $('#gmc_client_policy_id').val(client_policy_id) $('.removeDom').remove(); var gmc_policy_type_id = $(this).attr('id'); - // console.log(gmc_policy_type_id) + // //console.log(gmc_policy_type_id) if (gmc_policy_type_id == 'GMC') { @@ -798,10 +798,10 @@ client_policy_id: client_policy_id }, success: function(response) { - console.log('response', response); + //console.log('response', response); - // console.log('count', response.count); + // //console.log('count', response.count); setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); @@ -809,18 +809,18 @@ $('#nameOfThePolicyInGMC').html(' - ' + response.policy_name.name); $('gmc_emp_count').val(response.count); - // console.log('count--1', response.count); + // //console.log('count--1', response.count); // $('emp_count').val(response.count) // if (response && response.hasOwnProperty('count')) { // if (response.count === false) { - // console.log('count -- 2', response.count); - // console.log(document.getElementById('btnGridSubmit1')) + // //console.log('count -- 2', response.count); + // //console.log(document.getElementById('btnGridSubmit1')) // $("#btnGridSubmit1").hide(); // $("#myButtonSpecialCondition").hide(); // } else { // $("#btnGridSubmit1").show(); // $("#myButtonSpecialCondition").show(); - // console.log('count -- ', response.count); + // //console.log('count -- ', response.count); // } // } else { // console.error('Response object does not have a "count" property or is invalid.'); @@ -849,13 +849,13 @@ } } - console.log('key', key) + //console.log('key', key) let elements = document.getElementsByName(`${key}[]`); - console.log(elements) + //console.log(elements) if (elements) { elements.forEach((element, index) => { - console.log() + //console.log() if(jsonObject[key][index] == undefined){ element.value = " "; }else{ @@ -869,8 +869,8 @@ let checkboxes = document.querySelectorAll(`input[name="${key}[]"]`); if (jsonObject[key]) { - console.log(jsonObject[key]); - // console.log(jsonObject[key]); + //console.log(jsonObject[key]); + // //console.log(jsonObject[key]); if (jsonObject[key].childrens) { $('#children').val(jsonObject[key].childrens); } @@ -998,7 +998,7 @@ pTag.innerHTML = jsonObject[key]; // Add your new content inside the

tag } } - // console.log(jsonObject[key]); + // //console.log(jsonObject[key]); } else { if(jsonObject[key] == undefined){ @@ -1047,8 +1047,8 @@ $('.spouse-age').css('display','none'); } - console.log("child "); - console.log($('#children').val()); + //console.log("child "); + //console.log($('#children').val()); if($('#children').val() != 0){ $('.child-age').css('display',''); @@ -1087,7 +1087,7 @@ setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - console.log('Something Wrong!', 'warning'); + //console.log('Something Wrong!', 'warning'); }, 1000); } }); @@ -1109,8 +1109,8 @@ $('.spouse-age').css('display','none'); } - console.log("child "); - console.log($('#children').val()); + //console.log("child "); + //console.log($('#children').val()); if($('#children').val() != 0){ $('.child-age').css('display',''); @@ -1179,7 +1179,7 @@ \ No newline at end of file diff --git a/app/Views/policy_gpa_terms.php b/app/Views/policy_gpa_terms.php index 4d0b9882..3cc25545 100644 --- a/app/Views/policy_gpa_terms.php +++ b/app/Views/policy_gpa_terms.php @@ -90,16 +90,21 @@

-
+
-
+
+
+
+
+
+
@@ -132,13 +137,13 @@
Min Age: - +
Max Age: - +
@@ -569,6 +574,12 @@ }); } } + + if (key.includes("multiple_sum_insured")) { + gpaJsonObjectForSpecialCondition[key].forEach((value, index) => { + appendGPASIAddMore(value); + }); + } }); let jsonObject = JSON.parse(res.data); @@ -634,6 +645,7 @@ } $("#sumInsured2").trigger("keyup"); + $('.multiple_sum_insured').trigger("keyup"); $("#totalSumInsured").trigger("keyup"); @@ -723,6 +735,16 @@ } }); + $(".multiple_sum_insured").on("keyup", function() { + var inputNumber = $(this).val(); + if (inputNumber) { + var result = convertCommaNumberToWords(inputNumber); + $(".numberToWordSumInsured").text(result); + } else { + $(".numberToWordSumInsured").text(""); + } + }); + $("#totalSumInsured").on("keyup", function() { var inputNumber = $(this).val(); @@ -735,16 +757,27 @@ }); + function appendGPASIAddMore(data = null){ + console.log('function called') - // function formatNumber(input) { - // Remove non-numeric characters - // let value = input.value.replace(/\D/g, ''); + var html = ` +
+
+ +
+
+ +
+
+ + +
+
+
+
+
`; - // Add commas - // value = Number(value).toLocaleString('en-IN'); - - // Update the input value - // input.value = value; - // } + $('#gpa_si_add_more').append(html); + } \ No newline at end of file diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index f69a7648..6f3a858a 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -6,7 +6,7 @@ @@ -391,13 +391,13 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
- +
@@ -808,6 +808,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa if (dataIdValue == '1') { $('#gpa_sum_si').trigger('keyup'); $('#gpa_sum_si2').trigger('keyup'); + $('#gpa_basic_si_first').trigger('keyup'); // $('input[name="gpa_sum_si[]"]').each(function() { // //console.log($(this)); // $(this).trigger('keyup'); @@ -1216,8 +1217,8 @@ $('body').on('click', '.btnPolicyModel', function() { $('input[name="gpa_sum_si2[]"]').each(function() { $(this).trigger('keyup'); - }); - + }); + $('input[name="gpa_sum_premium[]"]').each(function() { $(this).trigger('keyup'); }); @@ -1226,6 +1227,18 @@ $('body').on('click', '.btnPolicyModel', function() { $(this).trigger('keyup'); }); + $('input[name="gpa_basic_si[]"]').each(function() { + $(this).trigger('keyup'); + }); + + $('input[name="gpa_basic_premium[]"]').each(function() { + $(this).trigger('keyup'); + }); + + $('input[name="basic_pay[]"]').each(function() { + $(this).trigger('keyup'); + }); + 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; @@ -1596,12 +1609,12 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
- +
@@ -2411,6 +2424,8 @@ function checkDuplicate(val) { function basicPayMultiple(input) { + console.log('basicPayMultiple function called') + var inputId = input.id; var inputValue = input.value.replace(/,/g, ''); var count = inputId.split('_')[2]; // Extract the count from the id @@ -2419,6 +2434,7 @@ function basicPayMultiple(input) { console.log('input class ', input.className); if (input.className.includes('basic_pay')) { + // Sum insured var basicMultiplier = $('#basic_multiplier').val().replace(/,/g, ''); var multi = basicMultiplier * inputValue; @@ -2431,45 +2447,57 @@ function basicPayMultiple(input) { var multi_2 = gpaBasicSiValue * premiumMultiplier / 1000; console.log('multi_2', multi_2); $('#gpa_basic_premium_' + count).val(multi_2).trigger('keyup'); + } else if (input.className.includes('basic_multiplier')) { + var multi = inputValue * $('#basic_pay_' + count).val().replace(/,/g, ''); $('#gpa_basic_si_' + count).val(multi).trigger('keyup'); var multi_2 = multi * $('#premium_multiplier').val().replace(/,/g, '') / 1000; $('#gpa_basic_premium_' + count).val(multi_2).trigger('keyup'); + } else if (input.className.includes('premium_multiplier')) { - var multi = inputValue / 1000 * $('#gpa_basic_si_' + count).val().replace(/,/g, ''); - $('#gpa_basic_premium_' + count).val(multi).trigger('keyup'); - } else if (input.className.includes('gpa_basic_si')) { + + // Sum insured + var basicMultiplier = $('#basic_multiplier').val().replace(/,/g, ''); + var multi = basicMultiplier * inputValue; + console.log('multi', multi); + $('#gpa_basic_si_' + count).val(multi).trigger('keyup'); + + // Premium + var gpaBasicSiValue = multi; // We just calculated this value + var premiumMultiplier = $('#premium_multiplier').val().replace(/,/g, ''); + var multi_2 = gpaBasicSiValue * premiumMultiplier / 1000; + console.log('multi_2', multi_2); } else if (input.className.includes('gpa_basic_si')) { var multi = inputValue * $('#premium_multiplier').val().replace(/,/g, ''); $('#gpa_basic_premium_' + count).val(multi).trigger('keyup'); + } } function basicPayMultipleforfirstone(input){ + var inputId = input.id; + var inputValue = input.value.replace(/,/g, ''); + + console.log('basicPayMultipleforfirstone') console.log('input', input); console.log('input id ', input.id); console.log('input class ', input.className); + console.log('inputValue', inputValue); - var basicMultiplier = $('#basic_multiplier').val().replace(/,/g, ''); - var inputValue = input.value.replace(/,/g, ''); - var multi = basicMultiplier * inputValue; + // Sum insured + var basicMultiplier = $('#basic_multiplier').val().replace(/,/g, ''); + var multi = basicMultiplier * inputValue; + console.log('multi', multi); + $('#gpa_basic_si_first').val(multi).trigger('keyup'); - console.log('multi', multi); - - // Find the input element with the class 'gpa_basic_si' within the same form-row and set its value - $(input).closest('.form-group').find('.form-row input.gpa_basic_si').val(multi).trigger('keyup'); - - // Premium calculation - var gpaBasicSiValue = $(input).closest('.form-group').find('.form-row input.gpa_basic_si').val().replace(/,/g, ''); - var premiumMultiplier = $('#premium_multiplier').val().replace(/,/g, ''); - var multi_2 = gpaBasicSiValue * premiumMultiplier / 1000; - - console.log('multi_2', multi_2); - - // Find the input element with the class 'gpa_basic_premium' within the same form-row and set its value - $(input).closest('.form-group').find('.form-row input.gpa_basic_premium').val(multi_2).trigger('keyup'); + // Premium + var gpaBasicSiValue = multi; // We just calculated this value + var premiumMultiplier = $('#premium_multiplier').val().replace(/,/g, ''); + var multi_2 = gpaBasicSiValue * premiumMultiplier / 1000; + console.log('multi_2', multi_2); + $('#gpa_basic_premium_first').val(multi_2).trigger('keyup'); } From 9024cc72bf3f9be16c0f4e95b360d1db1ef0276e Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 17 Jun 2024 12:07:58 +0530 Subject: [PATCH 4/6] FIX_TERMS_SI_IS_EQUAL_TO_RACK_RATE_SI_CHECK : RV --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 17 +++++ app/Views/policy_grid.php | 97 ++++++++++++++++++++-------- app/Views/policy_grid_excel.php | 5 ++ 4 files changed, 93 insertions(+), 27 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 38c81300..2c6946d5 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -246,6 +246,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("check_cd_ac_no/(:any)", "MasterController::checkUniqueCDAccountNumber/$1"); $routes->get("get_cd_ac/(:any)", "ClientController::get_cd_ac/$1"); $routes->get("check_policy_type/(:any)", "ClientController::checkPolicyType/$1"); + $routes->get("getPolicyTerms/(:any)", "ClientController::getPolicyTerms/$1"); }); $routes->cli('cli/processjob', 'JobWorker::processJob'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index b7b114be..8d69abfb 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2214,4 +2214,21 @@ class ClientController extends AdminController } + public function getPolicyTerms($client_policy_id){ + + $policy_terms = $this->clientPolicyModel->where('id', $client_policy_id)->first(); + + if(isset($policy_terms['policy_terms']) && $policy_terms['policy_terms'] != null){ + + $JSON = json_decode($policy_terms['policy_terms']); + $si = $JSON->sum_insured ?? $JSON->sumInsured2; + $multi_si = $JSON->multiple_sum_insured; + $multi_si[] = $si; + }else{ + $$multi_si = []; + } + + return $this->respond(['status' => true, 'data'=>$multi_si], 200); + } + } \ No newline at end of file diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index 3f37c87b..0cd0acda 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -319,7 +319,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -348,7 +348,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -391,7 +391,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -421,7 +421,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -442,7 +442,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -466,7 +466,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -501,7 +501,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -534,7 +534,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -569,7 +569,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -604,7 +604,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -633,7 +633,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -654,7 +654,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -687,7 +687,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -721,7 +721,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -759,7 +759,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -1552,7 +1552,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) { html = `
- +
@@ -1580,7 +1580,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1609,7 +1609,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1634,7 +1634,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1680,7 +1680,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1731,7 +1731,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1759,7 +1759,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1783,7 +1783,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1807,7 +1807,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1835,7 +1835,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1863,7 +1863,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1895,7 +1895,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -2875,4 +2875,47 @@ function checkCheckboxes() { return true; } + +function checkTermsSISameAsRackRateSI(input) { + + console.log('checkTermsSISameAsRackRateSI testing..........'); + console.log(input); + + var client_policy_id = $('#client_policy_id').val(); + console.log('client_policy_id', client_policy_id) + + var inputValue = input.value.replace(/,/g, ''); + inputValue = parseFloat(inputValue); + console.log(inputValue); + + var url = '' + client_policy_id; + + $.get(url, function(response) { + console.log(response); + console.log(response.data); + + var policyTerms = response.data; + var valueExists = false; + + for (var i = 0; i < policyTerms.length; i++) { + if (parseFloat(policyTerms[i]) === inputValue) { + valueExists = true; + break; + } + } + + if (!valueExists) { + input.value = ""; + toastr.warning(`Value does not exist in the Policy Terms.`); + } + + }).fail(function(xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + toastr.error(`Failed to retrieve Policy Terms. Error: ${error}`); + }); +} + + + \ No newline at end of file diff --git a/app/Views/policy_grid_excel.php b/app/Views/policy_grid_excel.php index ba977aad..b5cf2531 100644 --- a/app/Views/policy_grid_excel.php +++ b/app/Views/policy_grid_excel.php @@ -537,26 +537,31 @@ function submitData(rack_rate_type) { $(`input[name="${formatType}_si[]"]`).each(function() { // //console.log($(this)); $(this).trigger('keyup'); + $(this).trigger('change').keyup(); }); $(`input[name="${formatType}_premium[]"]`).each(function() { // //console.log($(this)); $(this).trigger('keyup'); + $(this).trigger('change').keyup(); }); $(`input[name="basic_pay[]"]`).each(function() { // //console.log($(this)); $(this).trigger('keyup'); + $(this).trigger('change').keyup(); }); $(`input[name="gpa_basic_si[]"]`).each(function() { // //console.log($(this)); $(this).trigger('keyup'); + $(this).trigger('change').keyup(); }); $(`input[name="gpa_basic_premium[]"]`).each(function() { // //console.log($(this)); $(this).trigger('keyup'); + $(this).trigger('change').keyup(); }); From 8bd9f9d25450574ba1574f30667c6afe2807486c Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 17 Jun 2024 16:52:24 +0530 Subject: [PATCH 5/6] FIX_RACK_RATE_CHECK_SUM_INSURED : RV --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 18 +- app/Views/policy_grid.php | 264 ++++++++++++++++++++------- 3 files changed, 218 insertions(+), 65 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 2c6946d5..041caaa3 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -247,6 +247,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("get_cd_ac/(:any)", "ClientController::get_cd_ac/$1"); $routes->get("check_policy_type/(:any)", "ClientController::checkPolicyType/$1"); $routes->get("getPolicyTerms/(:any)", "ClientController::getPolicyTerms/$1"); + $routes->get("getPolicyTermsFormJson/(:any)", "ClientController::getPolicyTermsFormJson/$1"); }); $routes->cli('cli/processjob', 'JobWorker::processJob'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 8d69abfb..13be8344 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -32,6 +32,8 @@ use App\Models\EmployeeModel; use App\Models\EmployeePolicyModel; use App\Models\NotificationModel; use App\Models\CDMasterModel; +use App\Models\PolicyTypeModel; + @@ -65,13 +67,14 @@ class ClientController extends AdminController protected $employeePolicyModel; protected $notificationModel; protected $CDMasterModel; + protected $policyTypeModel; public function __construct() { set_session_context('Client'); $this->myLogger = \Config\Services::mylogger(); - + $this->clientModel = new ClientModel(); $this->userModel = new UserModel(); $this->clientBranchModel = new ClientBranchModel(); @@ -93,8 +96,10 @@ class ClientController extends AdminController $this->policyPremium2Model = new PolicyPremium2Model(); $this->employeeModel = new EmployeeModel(); $this->employeePolicyModel = new EmployeePolicyModel(); - $this->notificationModel = new NotificationModel(); - $this->CDMasterModel = new CDMasterModel(); + $this->notificationModel = new NotificationModel(); + $this->CDMasterModel = new CDMasterModel(); + $this->policyTypeModel = new PolicyTypeModel(); + @@ -2231,4 +2236,11 @@ class ClientController extends AdminController return $this->respond(['status' => true, 'data'=>$multi_si], 200); } + + public function getPolicyTermsFormJson($policy_type_id){ + + $JSON = $this->policyTypeModel->where('id', $policy_type_id)->first(); + return $this->respond(['status' => true, 'data' => $JSON], 200); + } + } \ No newline at end of file diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index 0cd0acda..927895d0 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -319,7 +319,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -348,7 +348,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -391,7 +391,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -421,7 +421,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -442,7 +442,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -466,7 +466,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -501,7 +501,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -534,7 +534,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -569,7 +569,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -604,7 +604,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -633,7 +633,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -654,7 +654,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -687,7 +687,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -721,7 +721,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -759,7 +759,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
@@ -827,11 +827,11 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa }; -$("#GridForm").submit(function(event) { +$("#GridForm").submit(async function(event) { var check = checkDuplicate(0); - - + console.log(check) + event.preventDefault(); if ($('#grid_emp_count').val() == 'false') { @@ -845,6 +845,7 @@ $("#GridForm").submit(function(event) { return; } + $('.loader').fadeIn(); $('.loader-mask').fadeIn(); @@ -852,45 +853,63 @@ $("#GridForm").submit(function(event) { var policy_form_action = ''; - if (check) { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - } else { - $.ajax({ - data: formData, - url: policy_form_action, - type: "POST", - dataType: 'json', - processData: false, - contentType: false, - success: function(res) { - - //console.log("Response", res); - - if (res.status === false) { - toastr.error('Policy Dose Not Create', 'Error'); - return; - } + checkPolicyTermsSI(function(result) { + if (!result) { + if (check) { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - var message = (policy_PrimaryKey === '') ? 'Policy Premium Added successfully' :'Policy Premium Added Successfully'; - toastr.success(message, 'Success'); + } else { + + $.ajax({ + data: formData, + url: policy_form_action, + type: "POST", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { - if($('#grid').val() == 1 || $('#grid').val() == 2){ - $('.close').click(); - } + //console.log("Response", res); - }, - error: function(xhr, status, error) { + if (res.status === false) { + toastr.error('Policy Dose Not Create', 'Error'); + return; + } - console.error(xhr.responseText); - console.error(status, error); - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + var message = (policy_PrimaryKey === '') ? 'Policy Premium Added successfully' :'Policy Premium Added Successfully'; + toastr.success(message, 'Success'); + + if($('#grid').val() == 1 || $('#grid').val() == 2){ + $('.close').click(); + } + + }, + error: function(xhr, status, error) { + + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + } + }); } - }); - } + + }else{ + + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + toastr.warning(`Value does not exist in the Policy Terms.`); + + } + +}).catch(function(error) { + console.error('Error checking policy terms:', error); + // Handle error if necessary + toastr.error(`Error checking policy terms: ${error}`); + }); }); @@ -1552,7 +1571,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) { html = `
- +
@@ -1580,7 +1599,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1609,7 +1628,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1634,7 +1653,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1680,7 +1699,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1731,7 +1750,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1759,7 +1778,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1783,7 +1802,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1807,7 +1826,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1835,7 +1854,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1863,7 +1882,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -1895,7 +1914,7 @@ function appendGridtHtml(ui_type = false, secondary = 0, data = false) {
- +
@@ -2917,5 +2936,126 @@ function checkTermsSISameAsRackRateSI(input) { } + function checkPolicyTermsSI(callback) { + + + console.log('r function called'); + + var id = $('#additional_grid')[0]; + var container = $('#additional_grid_content_input'); + + var val = 0; + + if (val == 0) { + id = $('#grid')[0]; + container = $('#grid_content_input'); + } + + + console.log(id); + console.log(container); + + var siInputs = 0; + + if (id.value === '2') { + siInputs = container.find('input[name="gpa_si"]'); + } else if (id.value === '3') { + siInputs = container.find('input[name="3_si[]"]'); + } else if (id.value === '4') { + siInputs = container.find('input[name="4_si[]"]'); + } else if (id.value === '5') { + siInputs = container.find('input[name="5_si[]"]'); + } else if (id.value === '6') { + siInputs = container.find('input[name="6_si[]"]'); + } else if (id.value === '7') { + siInputs = container.find('input[name="7_si[]"]'); + } else if (id.value === '8') { + siInputs = container.find('input[name="8_si[]"]'); + } else if (id.value === '9') { + siInputs = container.find('input[name="9_si[]"]'); + } else if (id.value === '10') { + siInputs = container.find('input[name="10_si[]"]'); + } else if (id.value === '11') { + siInputs = container.find('input[name="11_si[]"]'); + } else if (id.value === '1') { + var selectedValue = $('#si_or_bp').val(); + + if (selectedValue == 1) { + siInputs = container.find('input[name="gpa_sum_si[]"]'); + } else if (selectedValue == 3) { + siInputs = container.find('input[name="gpa_sum_si2[]"]'); + } + } + + var client_policy_id = $('#client_policy_id').val(); + console.log('client_policy_id', client_policy_id) + + var url = '' + client_policy_id; + + var arrayLength = 0; + + $.ajax({ + url: url, + type: 'GET', + dataType: 'json', + success: function(response) { + console.log(response); + console.log(response.data); + + var array1 = response.data; + var array2 = []; + + siInputs.each(function() { + var input = $(this).val(); + array2.push(input.replace(/,/g, '')); + }); + + console.log('array1', array1) + console.log('array2', array2) + + + function intersection(arr1, arr2) { + return arr1.filter(value => arr2.includes(value)); + } + + var commonElements = intersection(array1, array2); + + function removeCommonElements(arr, common) { + return arr.filter(value => !common.includes(value)); + } + + array1 = removeCommonElements(array1, commonElements); + array2 = removeCommonElements(array2, commonElements); + + console.log('array1', array1) + console.log('array2', array2) + + + // var result = array1.concat(array2); + var result = array1; + + console.log('result', result) + + arrayLength = result.length; + + console.log('arrayLength', arrayLength) + + if (arrayLength > 0) { + callback(true); + } else { + callback(false); + } + + }, + error: function(xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + toastr.error(`Failed to retrieve Policy Terms. Error: ${error}`); + callback(false); + } + }); + + +} \ No newline at end of file From 767830e626e908207f5424bc4b4d238bd1cec303 Mon Sep 17 00:00:00 2001 From: velz Date: Tue, 18 Jun 2024 08:52:17 +0530 Subject: [PATCH 6/6] FIX_UAT_ISSUES_PRE_CALC_PRE_DAYS --- app/Controllers/EmployeeServiceController.php | 4 +- app/Helpers/excel_util_helper.php | 39 +++++++++++++++++-- app/Models/EmployeePolicyModel.php | 2 +- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index ed6bf76e..3be910e8 100644 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -36,7 +36,7 @@ class EmployeeServiceController extends AdminController protected $empEndorsementModel; protected $messageModel; protected $general_relationships = ['self' => ['name' => 'Self', 'gender' => 'M','age_min' => 18,'age_max' => null], 'spouse' => ['name' => 'Spouse', 'gender' => 'F','age_min' => 18,'age_max' => null], 'son' => ['name' => 'Son', 'gender' => 'M','age_min' => null,'age_max' => 25], 'daughter' => ['name' => 'Daughter', 'gender' => 'F','age_min' => null,'age_max' => 25], 'father' => ['name' => 'Father', 'gender' => 'M','age_min' => 18,'age_max' => null], 'mother' => ['name' => 'Mother', 'gender' => 'F','age_min' => 18,'age_max' => null], 'father-in-law' => ['name' => 'Father in Law', 'gender' => 'M','age_min' => 18,'age_max' => null], 'mother-in-law' => ['name' => 'Mother in Law', 'gender' => 'F','age_min' => 18,'age_max' => null]]; - protected $inception_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'dob'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'DOB','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_dob_diff','params'=>['row','relationship','default_age_ratio']],'gender'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Gender','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['M','F']],'relationship'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'RELATIONSHIP','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_relationship','params'=>['row','relationship','policy_terms']],'basic_cover_si'=>['col_idx'=>6,'col_cell_name'=>'G','col_name'=>'BASIC COVER SI','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_si','params' => ['row','policy_terms','slab_details']],'doc'=>['col_idx'=>7,'col_cell_name'=>'H','col_name'=>'Date of Coverage','is_mandatory'=>['A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'params'=>['row']],'doj'=>['col_idx'=>8,'col_cell_name'=>'I','col_name'=>'DOJ','is_mandatory'=>false,'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_doj','params'=>['row']],'basic_pay'=>['col_idx'=>9,'col_cell_name'=>'J','col_name'=>'Basic Pay','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_basic_pay','params'=>['row','policy_terms','slab_details']],'band_grade'=>['col_idx'=>10,'col_cell_name'=>'K','col_name'=>'Band/Grade','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_employee_band','params'=>['row','policy_terms','slab_details']],'designation'=>['col_idx'=>11,'col_cell_name'=>'L','col_name'=>'Designation','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'phone'=>['col_idx'=>12,'col_cell_name'=>'M','col_name'=>'Phone','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_dup_mobileno','params' => ['row','existing_mobilenos']],'email'=>['col_idx'=>13,'col_cell_name'=>'N','col_name'=>'Email','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'pre_existing_ailments'=>['col_idx'=>14,'col_cell_name'=>'O','col_name'=>'PRE EXISTING AILMENTS','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['0','1']],'change_event'=>['col_idx'=>15,'col_cell_name'=>'P','col_name'=>'Change event','is_mandatory'=>['A','DA','D'],'data_type'=>'str','format'=>null,'allowed_values'=>null],'date_of_exit'=>['col_idx'=>16,'col_cell_name'=>'Q','col_name'=>'Date of exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null],'reason_for_exit'=>['col_idx'=>17,'col_cell_name'=>'R','col_name'=>'Reason for exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null]]; + protected $inception_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'dob'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'DOB','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_dob_diff','params'=>['row','relationship','default_age_ratio']],'gender'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Gender','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['M','F']],'relationship'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'RELATIONSHIP','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_relationship','params'=>['row','relationship','policy_terms']],'basic_cover_si'=>['col_idx'=>6,'col_cell_name'=>'G','col_name'=>'BASIC COVER SI','is_mandatory'=>null,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_si','params' => ['row','policy_terms','slab_details']],'doc'=>['col_idx'=>7,'col_cell_name'=>'H','col_name'=>'Date of Coverage','is_mandatory'=>['A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom' => 'check_doc','params' => ['row','policy_details']],'doj'=>['col_idx'=>8,'col_cell_name'=>'I','col_name'=>'DOJ','is_mandatory'=>false,'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_doj','params'=>['row']],'basic_pay'=>['col_idx'=>9,'col_cell_name'=>'J','col_name'=>'Basic Pay','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_basic_pay','params'=>['row','policy_terms','slab_details']],'band_grade'=>['col_idx'=>10,'col_cell_name'=>'K','col_name'=>'Band/Grade','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_employee_band','params'=>['row','policy_terms','slab_details']],'designation'=>['col_idx'=>11,'col_cell_name'=>'L','col_name'=>'Designation','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'phone'=>['col_idx'=>12,'col_cell_name'=>'M','col_name'=>'Phone','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_dup_mobileno','params' => ['row','existing_mobilenos']],'email'=>['col_idx'=>13,'col_cell_name'=>'N','col_name'=>'Email','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'pre_existing_ailments'=>['col_idx'=>14,'col_cell_name'=>'O','col_name'=>'PRE EXISTING AILMENTS','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['0','1']],'change_event'=>['col_idx'=>15,'col_cell_name'=>'P','col_name'=>'Change event','is_mandatory'=>['A','DA','D'],'data_type'=>'str','format'=>null,'allowed_values'=>null],'date_of_exit'=>['col_idx'=>16,'col_cell_name'=>'Q','col_name'=>'Date of exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null],'reason_for_exit'=>['col_idx'=>17,'col_cell_name'=>'R','col_name'=>'Reason for exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null]]; protected $deletion_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'change_event'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'Change event','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null],'date_of_exit'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Date of exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null],'reason_for_exit'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'Reason for exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null]]; @@ -350,7 +350,7 @@ class EmployeeServiceController extends AdminController $relationship = $this->general_relationships; - if(in_array($file['action'],['inception','addition','dependent_addition']))// the below funcitons are only for I,DA,A + if(in_array($file['action'],['inception','addition','dependent_addition','deletion','correction','si_enhancement']))// the below funcitons are only for I,DA,A { $employee_data_group_by_family = data_group_by_family($excel_data); diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index ca88b7f1..5dc29d0d 100644 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -143,6 +143,28 @@ if(!function_exists('check_doj')) } } +if(!function_exists('check_doc')) +{ + + function check_doc($row,$policy_details) + { + if($row['current_action'] != null && $row[7] != null && $row[7] != '' && in_array(strtoupper($row['current_action']), ['A','DA']))// check rule only of action column data available + { + // dd($policy_details); + $date = new DateTime($row[7]); + $startDate = new DateTime($policy_details[0]->policy_start_date); + $endDate = new DateTime($policy_details[0]->policy_end_date); + + if ($date >= $startDate && $date <= $endDate) { + return array('status' => true); + } else { + return array('status' => false,'error' => 'the given date of coverage is not between policy start/end date'); + } + } + else { return array('status' => true); } // in else condition no need to check rule, just return true + } +} + if(!function_exists('check_employee_band')) { @@ -206,7 +228,7 @@ if(!function_exists('check_si')) } // check age slab - if(in_array(strtoupper($row['current_action']), ['I','A','DA'])) + if(in_array(strtoupper($row['current_action']), ['I','A','DA']) && strtolower($row['5']) == 'self') { if($row[3] != null && DateTime::createFromFormat('d-M-Y', $row[3]) !== false)// dob { @@ -236,6 +258,7 @@ if(!function_exists('check_si')) else { $is_age_slab_found = true;// send true if age conditin is not applicable + $is_si_found = true; }//end of check age slab }// end of for loop @@ -252,6 +275,12 @@ if(!function_exists('check_si')) $return_array['error'] = !empty($return_array['error']) ? ($return_array['error'].', '.'Sum insured not configured for this age slab') : 'Sum insured not configured for this age slab'; } + if(empty($received_si)) + { + $return_array['status'] = false; + $return_array['error'] = "Sum insured value mandantory"; + } + return $return_array; } } @@ -417,6 +446,7 @@ if (!function_exists('name_and_empid_check_in_db')) $result = ['del' => [],'i' => []]; $client_id = $actionArr['client_id']; $policy_id = $actionArr['policy_id']; + $client_branch_id = $actionArr['client_branch_id']; $current_action = $actionArr['action']; foreach ($family_data as $rkey => $row) @@ -428,6 +458,7 @@ if (!function_exists('name_and_empid_check_in_db')) ->join('employee_polices ep',"cp.id = ep.client_policy_id AND employees.id = ep.employee_id") ->where("cp.id",$policy_id) ->where("employees.client_id",$client_id) + ->where("employees.client_branch_id",$client_branch_id) ->where("employees.is_active",1) ->where("employees.emp_status",'active') ->where("ep.is_active",1) @@ -956,7 +987,7 @@ if (!function_exists('premium_calculation_manager')) $employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si; foreach ($temp_slab_rates as $skey => $slab_value) { - if($slab_value['si'] == $employee_received_si) + if($slab_value['si'] == $employee_received_si && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['additional_rack_rate_acting_self']) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) )) { $emp_data['policy_details']['basic_cover_si'] = $slab_value['si']; $emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']); @@ -979,7 +1010,7 @@ if (!function_exists('premium_calculation_manager')) foreach ($temp_slab_rates as $skey => $slab_value) { $age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y; - if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age)) + if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['additional_rack_rate_acting_self']) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) )) { // dd($slab_value); $emp_data['policy_details']['basic_cover_si'] = $slab_value['si']; @@ -1000,7 +1031,7 @@ if (!function_exists('premium_calculation_manager')) foreach ($temp_slab_rates as $skey => $slab_value) { $age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y; - if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age)) + if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['additional_rack_rate_acting_self']) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) )) { $emp_data['policy_details']['basic_cover_si'] = $slab_value['si']; $emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']); diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 4f9652d9..c21b8f5d 100644 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -76,7 +76,7 @@ class EmployeePolicyModel extends Model } // ----------------------------------------------------------------------------------------------------- - public function getEmployeePolicy($client_id,$policy_id,$status, $branch_id) + public function getEmployeePolicy($client_id,$policy_id,$status,$branch_id) { $result = $this->select(['employee_polices.*','pm.name as policy_name','im.short_name as insurer_short_name','ib.branch_name as insurer_branch_name','ib.branch_code as insurer_branch_code','tpam.name as tpa_name','tpam.short_name as tpa_short_name','tpab.branch_code as tpa_branch_code','cm.client_name','cm.short_name as client_short_name','emp.relationship','emp.relationship_code','emp.change_event','emp.emp_code','emp.name','emp.email_corporate','emp.dob','emp.gender','emp.emp_status','emp.is_active as emp_is_active','emp.mobile as mobile']) ->join('employees emp', 'employee_polices.employee_id = emp.id')