From ec5ae2349764eb56040e2365f07b7a0460bee8f5 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 13 Jun 2024 17:41:23 +0530 Subject: [PATCH 01/14] 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 04/14] 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 05/14] 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 06/14] 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') From 2ab4cd65f280131d1f76e4e103ae6ac2d50b4773 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 18 Jun 2024 16:47:13 +0530 Subject: [PATCH 07/14] FIX_ELDERS_COUNT_IN_GMC_TERMS : RV --- app/Views/policy_gmc_terms.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index 69a89773..f64b7f4b 100644 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -189,7 +189,7 @@ - + From 8a692fa4f2e39f072c0a0fe0c2cb9cafc4fa3274 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 18 Jun 2024 17:00:08 +0530 Subject: [PATCH 08/14] FIX_ELDERS_COUNT_MISSING_CONTROLLER_FILE : RV --- app/Controllers/ClientController.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 13be8344..86556e52 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -1432,7 +1432,7 @@ class ClientController extends AdminController } } - $data['family_floaters']['elders_count'] =$this->request->getPost("member_count") ? $this->request->getPost("member_count") : 0; + $data['family_floaters']['elders_count'] =$this->request->getPost("elder_member_count") ? $this->request->getPost("elder_member_count") : 0; // print_r($data);die; @@ -1972,8 +1972,6 @@ class ClientController extends AdminController ]; - - foreach ($client_policy as $key => $value) { $policy_terms = json_decode($value['policy_terms'], true); @@ -2243,4 +2241,9 @@ class ClientController extends AdminController return $this->respond(['status' => true, 'data' => $JSON], 200); } + public function createPolicyTermsHtmlAsJSON(){ + + + } + } \ No newline at end of file From 5fc9d3a1f26571a1b2536eea5e422829da2c57df Mon Sep 17 00:00:00 2001 From: velz Date: Thu, 20 Jun 2024 11:28:08 +0530 Subject: [PATCH 09/14] FIX_SELF_CHECK&CROSS_PARENTS_HANDLED --- app/Controllers/EmployeeServiceController.php | 7 +++++-- app/Helpers/excel_util_helper.php | 6 ++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 3be910e8..25b4f08d 100644 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -359,7 +359,10 @@ class EmployeeServiceController extends AdminController { $temp = $policy_terms['family_floaters']; $temp = is_array($temp) ? $temp : (is_object($temp) ? (array)$temp : []); - $is_self_available_in_policy_terms = isset($temp['self']) ? true : false; + + $is_self_available_in_policy_terms = isset($temp['self']) && $temp['self'] == 1 ? true : false; + // Kint::dump($temp['self']); + // dd($is_self_available_in_policy_terms); } // dd($employee_data_group_by_family); foreach ($employee_data_group_by_family as $emp_id => $family) @@ -415,7 +418,7 @@ class EmployeeServiceController extends AdminController if(!count($self_details)) { array_push($result['error_summary'],14); // Self not found - $result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found in System"; + $result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found in Database"; } } diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index 5dc29d0d..90d74c3d 100644 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -603,10 +603,8 @@ if (!function_exists('check_dependent_conflict')) $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch } } - - // var_dump($allowed_adults == 0); - // dd($allowed_adults == 0 && (($allowed_parents_count < $received_parents_count) || ($allowed_parent_in_laws_count < $received_parent_in_laws_count))); - if($allowed_adults == 0 && (($allowed_parents_count < $received_parents_count) || ($allowed_parent_in_laws_count < $received_parent_in_laws_count) )) + //check for any cross parents but not more than two + if($allowed_adults == 0 && $allowed_parents_count == 1 && $allowed_parent_in_laws_count == 1 && (2 < ($received_parents_count + $received_parent_in_laws_count))) { // dd($allowed_adults); $result['status'] = false; From b9320f22daaab0b42a87405c2aae7a7fb4182c4d Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 21 Jun 2024 15:38:49 +0530 Subject: [PATCH 10/14] FIX_RACK_RATE_ISSUES_AND_OTHER : RV --- app/Controllers/ClientController.php | 54 ++++-- app/Views/client_info.php | 5 +- app/Views/other_policy_terms.php | 189 +++++++++++++------ app/Views/policy_gmc_terms.php | 20 +- app/Views/policy_gpa_terms.php | 12 +- app/Views/policy_grid.php | 262 +++++++++++++++------------ 6 files changed, 335 insertions(+), 207 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 86556e52..0503143e 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -1907,7 +1907,7 @@ class ClientController extends AdminController "sum_insured" => "Sum Insured", "family_floater" => "Family Floater", "family_floaters" => "Family Floaters", - "member_count" => "Elders Count:", + "elders_count" => "Elders Count:", "other_member_min_age" => "Min Age:", "other_member_max_age" => "Min Age:", "waiverofpreexistingdiseases" => "Waiver of Pre-existing Diseases", @@ -2067,19 +2067,27 @@ class ClientController extends AdminController } else if (array_key_exists($key, $mapping)) { $transformedData[$mapping[$key]] = $value; } else if ($key == 'special_condition_label') { - - foreach ($value as $key => $value) { - $transformedData[$value] = $data['special_condition_input'][$key]; + + if (is_array($value)) { + foreach ($value as $key => $value) { + $transformedData[$value] = $data['special_condition_input'][$key]; + } } - } else if ($key == 'gpa_special_condition_label') { - foreach ($value as $key => $value) { - $transformedData[$value] = $data['gpa_special_condition_input'][$key]; + } else if ($key == 'gpa_special_condition_label') { + if (is_array($value)) { + foreach ($value as $key => $value) { + $transformedData[$value] = $data['gpa_special_condition_input'][$key]; + } + } + } else if ($key == 'other_special_condition_label') { + if (is_array($value)) { + foreach ($value as $key => $value) { + $transformedData[$value] = $data['other_special_condition_label'][$key]; + } } } else if ($key == 'age_ratio') { - if (isset($data['sumInsured2'])) { - $transformedData['Self'] = "(Min: " . $data['age_ratio']['self']['min'] . ", Max: " . $data['age_ratio']['self']['max'] . ")"; } } else { @@ -2217,21 +2225,33 @@ class ClientController extends AdminController } - public function getPolicyTerms($client_policy_id){ + 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){ + 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 = []; + + $si = null; + if (isset($JSON->sum_insured) && !empty($JSON->sum_insured)) { + $si = $JSON->sum_insured; + } elseif (isset($JSON->sumInsured2) && !empty($JSON->sumInsured2)) { + $si = $JSON->sumInsured2; + } + + if ($si !== null) { + $multi_si = $JSON->multiple_sum_insured ?? []; + $multi_si[] = $si; + } else { + $multi_si = []; + } + } else { + $multi_si = []; } - return $this->respond(['status' => true, 'data'=>$multi_si], 200); + return $this->respond(['status' => true, 'data' => $multi_si], 200); } diff --git a/app/Views/client_info.php b/app/Views/client_info.php index f029a2b0..bcad4293 100644 --- a/app/Views/client_info.php +++ b/app/Views/client_info.php @@ -270,18 +270,20 @@ $(document).ready(function() { $(document).on('click', '.policy_terms', function() { var terms = $(this).data('id'); console.log(terms); + console.log(JSON.stringify(terms)); // terms = JSON.parse(terms); $('#modal_body').empty(); function createListItems(obj) { + const fragment = document.createDocumentFragment(); for (const key in obj) { if (obj.hasOwnProperty(key) && obj[key] !== null && obj[key] !== '' && key != 'family_floater' && key != 'gpa_special_condition_input' && key != 'gpa_special_condition_label' && key != 'special_condition_label' && key != - 'special_condition_input' && key != 'age_ratio') { + 'special_condition_input' && key != 'age_ratio' && key != "multiple_sum_insured" && key != "other_special_condition_label" && key != "other_special_condition_input") { const listItem = document.createElement('li'); @@ -326,6 +328,7 @@ $(document).on('click', '.policy_terms', function() { } $('#modal_body').append(createListItems(terms)); + }); \ No newline at end of file diff --git a/app/Views/other_policy_terms.php b/app/Views/other_policy_terms.php index 6e1160c2..d21d40c4 100644 --- a/app/Views/other_policy_terms.php +++ b/app/Views/other_policy_terms.php @@ -78,7 +78,8 @@ label { x -
+
@@ -87,7 +88,7 @@ label { -
+

@@ -108,12 +109,10 @@ label { @@ -395,13 +422,14 @@ $(document).on('click', '#otherPolicyTermsClose', function() { }); -$("#sumInsured2").on("keyup", function() { +$("#sum_insured_others").on("keyup", function() { var inputNumber = $(this).val(); + console.log('sum_insured_others keyup', inputNumber) if (inputNumber) { var result = convertCommaNumberToWords(inputNumber); - $("#numberToWordSumInsured").text(result); + $("#numberToWordOthers").text(result); } else { - $("#numberToWordSumInsured").text(""); + $("#numberToWordOthers").text(""); } }); @@ -417,6 +445,20 @@ $("#totalSumInsured").on("keyup", function() { }); +function si_keup_num_to_word2(input) { + + console.log('keyup sum insured'); + var inputNumber = $(input).val(); + console.log(inputNumber) + if (inputNumber) { + var result = convertCommaNumberToWords(inputNumber); + + $("#numberToWordOthers").text(result); + } else { + $("#numberToWordOthers").text(""); + } +}; + function appendPolicyTermsHTML(policy_type) { @@ -429,6 +471,25 @@ function appendPolicyTermsHTML(policy_type) {
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
@@ -523,11 +584,30 @@ function appendPolicyTermsHTML(policy_type) { ` } else if (policy_type == 6) { - + termsHTML = `
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
@@ -592,28 +672,31 @@ function appendPolicyTermsHTML(policy_type) { } -function appendOtherTermsSIAddMore(data = null){ +function appendOtherSIAddMore(data = null) { - console.log('function called') + const addMoreContainer = document.getElementById('sum_insured_add_more'); - var html = ` -
-
- -
-
- -
-
- - -
-
-
-
-
`; + console.log(addMoreContainer) - $('#other_si_add_more').append(html); + const html = ` +
+
+ +
+
+ +
+
+ + +
+
+
+
+
+
+
`; + + addMoreContainer.insertAdjacentHTML('beforeend', html); } - \ No newline at end of file diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index f64b7f4b..a28f44df 100644 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -111,9 +111,9 @@
- +
-
+
@@ -141,14 +141,14 @@
- - + + - - + + @@ -190,8 +190,8 @@ - - + +
Elders Count:
Elders Count:
Min Age:
Max Age:
Self:
Min Age:
Max Age:
Min Age:
Max Age:
Spouse:
Min Age:
Max Age:
Min Age:
Max Age:
Children:
Elders Count:
Min Age:
Max Age:
Min Age:
Max Age:
@@ -1418,9 +1418,9 @@
- +
-
+
diff --git a/app/Views/policy_gpa_terms.php b/app/Views/policy_gpa_terms.php index b19fd8a6..8754b519 100644 --- a/app/Views/policy_gpa_terms.php +++ b/app/Views/policy_gpa_terms.php @@ -91,9 +91,9 @@
- +
-
+
@@ -137,13 +137,13 @@
Min Age: - +
Max Age: - +
@@ -792,9 +792,9 @@
- +
-
+
diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index 927895d0..b1fa3667 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -827,12 +827,16 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa }; -$("#GridForm").submit(async function(event) { +$("#GridForm").submit(function(event) { + + event.preventDefault(); var check = checkDuplicate(0); console.log(check) + if(check){ + return; + } - event.preventDefault(); if ($('#grid_emp_count').val() == 'false') { toastr.warning('Client has active employees', 'Warning'); @@ -854,9 +858,16 @@ $("#GridForm").submit(async function(event) { checkPolicyTermsSI(function(result) { + + console.log('checkPolicyTermsSI callback') + console.log(result); + if (!result) { - if (check) { + console.log('after result'); + + + if (check = false) { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); } else { @@ -901,15 +912,14 @@ $("#GridForm").submit(async function(event) { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning(`Value does not exist in the Policy Terms.`); - + toastr.warning(`Sum Insured Amount 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}`); - }); + }).catch(function(error) { + console.error('Error checking policy terms:', error); + // Handle error if necessary + console.log(`Error checking policy terms: ${error}`); + }); }); @@ -941,46 +951,61 @@ $("#AdditionalGridForm").submit(function(event) { var formData = new FormData($('#AdditionalGridForm')[0]); var policy_form_action = ''; + checkPolicyTermsSI(function(result) { - 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; - } + if (!result) { + 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) { - var message = (policy_PrimaryKey === '') ? - 'Policy Additional Rack Rate Added successfully' : - 'Policy Additional Rack Rate Added Successfully'; - toastr.success(message, 'Success'); - $('.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 Additional Rack Rate Added successfully' : + 'Policy Additional Rack Rate Added Successfully'; + toastr.success(message, 'Success'); + $('.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(`Sum Insured Amount does not exist in the Policy Terms.`); + } + + }).catch(function(error) { + console.error('Error checking policy terms:', error); + // Handle error if necessary + console.log(`Error checking policy terms: ${error}`); + }); }); @@ -2936,126 +2961,123 @@ function checkTermsSISameAsRackRateSI(input) { } - function checkPolicyTermsSI(callback) { +function checkPolicyTermsSI(callback) { + console.log('checkPolicyTermsSI function called'); - console.log('r function called'); - - var id = $('#additional_grid')[0]; + var id = $('#additional_grid')[0]; var container = $('#additional_grid_content_input'); - var val = 0; + var val = 0; if (val == 0) { id = $('#grid')[0]; container = $('#grid_content_input'); } - console.log(id); console.log(container); - var siInputs = 0; + var siInputs = null; - 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[]"]'); - } + switch (id.value) { + case '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[]"]'); + } + break; + case '2': + siInputs = container.find('input[name="gpa_si"]'); + break; + case '3': + siInputs = container.find('input[name="3_si[]"]'); + break; + case '4': + siInputs = container.find('input[name="4_si[]"]'); + break; + case '5': + siInputs = container.find('input[name="5_si[]"]'); + break; + case '6': + siInputs = container.find('input[name="6_si[]"]'); + break; + case '7': + siInputs = container.find('input[name="7_si[]"]'); + break; + case '8': + siInputs = container.find('input[name="8_si[]"]'); + break; + case '9': + siInputs = container.find('input[name="9_si[]"]'); + break; + case '10': + siInputs = container.find('input[name="10_si[]"]'); + break; + case '11': + siInputs = container.find('input[name="11_si[]"]'); + break; + default: + siInputs = []; } + console.log('siInputs', siInputs); + var client_policy_id = $('#client_policy_id').val(); - console.log('client_policy_id', client_policy_id) + console.log('client_policy_id', client_policy_id); var url = '' + client_policy_id; - var arrayLength = 0; + console.log('url', url); $.ajax({ url: url, type: 'GET', dataType: 'json', success: function(response) { + console.log(response); console.log(response.data); - var array1 = response.data; - var array2 = []; + var policy_terms_si = response.data; + var rack_rate_si = []; siInputs.each(function() { var input = $(this).val(); - array2.push(input.replace(/,/g, '')); + rack_rate_si.push(input.replace(/,/g, '')); }); - console.log('array1', array1) - console.log('array2', array2) + console.log('policy_terms_si', policy_terms_si); + console.log('rack_rate_si', rack_rate_si); + let new_array = []; - function intersection(arr1, arr2) { - return arr1.filter(value => arr2.includes(value)); + rack_rate_si.forEach(element => { + if (!policy_terms_si.includes(element)) { + new_array.push(element); + } + }); + + console.log('filtered array', new_array); + + var arrayLength = new_array.length; + console.log('arrayLength', arrayLength); + + if (arrayLength > 0) { + callback(true); + } else { + callback(false); } - - 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}`); + console.log(xhr.responseText); + console.log(status, error); + console.log(`Failed to retrieve Policy Terms. Error: ${error}`); callback(false); } }); - - } \ No newline at end of file From 9ff46033eb61773250e07a2c41d53c048138c448 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 21 Jun 2024 17:20:29 +0530 Subject: [PATCH 11/14] FIX_RACK_RATE_TERMS_FIELD_NAME_CNG : RV --- app/Controllers/ClientController.php | 63 ++++++++++++++++++---------- app/Views/client_info.php | 18 ++++++-- app/Views/policy_gmc_terms.php | 23 +++++++--- app/Views/policy_gpa_terms.php | 14 +++++-- app/Views/policy_grid.php | 6 +-- 5 files changed, 83 insertions(+), 41 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 0503143e..ba3da3d8 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2227,33 +2227,50 @@ 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 = null; - if (isset($JSON->sum_insured) && !empty($JSON->sum_insured)) { - $si = $JSON->sum_insured; - } elseif (isset($JSON->sumInsured2) && !empty($JSON->sumInsured2)) { - $si = $JSON->sumInsured2; - } - - if ($si !== null) { - $multi_si = $JSON->multiple_sum_insured ?? []; - $multi_si[] = $si; - } else { - $multi_si = []; - } - } else { - $multi_si = []; + + if (!$policy_terms) { + return $this->respond(['status' => false, 'error' => 'Policy not found'], 404); } - + + if (is_array($policy_terms)) { + if (!isset($policy_terms['policy_terms'])) { + return $this->respond(['status' => false, 'error' => 'Policy terms not found in array'], 500); + } + $JSON = json_decode($policy_terms['policy_terms']); + } elseif (is_object($policy_terms)) { + if (!isset($policy_terms->policy_terms)) { + return $this->respond(['status' => false, 'error' => 'Policy terms not found in object'], 500); + } + $JSON = json_decode($policy_terms->policy_terms); + } else { + return $this->respond(['status' => false, 'error' => 'Unexpected data type for policy terms'], 500); + } + + if (!$JSON) { + return $this->respond(['status' => false, 'error' => 'Invalid JSON format in policy terms'], 500); + } + + $multi_si = []; + + if (isset($JSON->sum_insured) && !empty($JSON->sum_insured)) { + $multi_si[] = $JSON->sum_insured; + } elseif (isset($JSON->sumInsured2) && !empty($JSON->sumInsured2)) { + $multi_si[] = $JSON->sumInsured2; + } + + if (isset($JSON->multiple_sum_insured) && is_array($JSON->multiple_sum_insured)) { + foreach ($JSON->multiple_sum_insured as $msi) { + if (!empty($msi)) { + $multi_si[] = $msi; + } + } + } + return $this->respond(['status' => true, 'data' => $multi_si], 200); } - + + public function getPolicyTermsFormJson($policy_type_id){ diff --git a/app/Views/client_info.php b/app/Views/client_info.php index bcad4293..9eebe82d 100644 --- a/app/Views/client_info.php +++ b/app/Views/client_info.php @@ -280,10 +280,20 @@ $(document).on('click', '.policy_terms', function() { const fragment = document.createDocumentFragment(); for (const key in obj) { - if (obj.hasOwnProperty(key) && obj[key] !== null && obj[key] !== '' && key != - 'family_floater' && key != 'gpa_special_condition_input' && key != - 'gpa_special_condition_label' && key != 'special_condition_label' && key != - 'special_condition_input' && key != 'age_ratio' && key != "multiple_sum_insured" && key != "other_special_condition_label" && key != "other_special_condition_input") { + if ( + obj.hasOwnProperty(key) && + obj[key] !== null && + obj[key] !== '' && + key != 'family_floater' && + key != 'family_floater' && + key != 'gpa_special_condition_input' && + key != 'gpa_special_condition_label' && + key != 'special_condition_label' && + key != 'special_condition_input' && + key != 'age_ratio' && + key != "multiple_sum_insured" && + key != "other_special_condition_label" && + key != "other_special_condition_input") { const listItem = document.createElement('li'); diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index a28f44df..28ff4417 100644 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -507,7 +507,7 @@
From 644a525976141d55b5d8d950b448682b8fc644bd Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 21 Jun 2024 19:57:29 +0530 Subject: [PATCH 12/14] FIX_CLIENT_INFO_AND_RR_CHECK_SI : RV --- app/Views/client_info.php | 82 ++++++++++++++++++++++----------------- app/Views/policy_grid.php | 23 +++++++---- 2 files changed, 62 insertions(+), 43 deletions(-) diff --git a/app/Views/client_info.php b/app/Views/client_info.php index 9eebe82d..94bc56ee 100644 --- a/app/Views/client_info.php +++ b/app/Views/client_info.php @@ -16,7 +16,8 @@
- +
-
+
@@ -204,7 +205,7 @@
-
+
@@ -253,7 +254,7 @@ - @@ -270,62 +271,71 @@ $(document).ready(function() { $(document).on('click', '.policy_terms', function() { var terms = $(this).data('id'); console.log(terms); + console.log(terms.length); console.log(JSON.stringify(terms)); + + // terms = JSON.parse(terms); $('#modal_body').empty(); function createListItems(obj) { - + + if (obj.length == 0) { + const message = document.createElement('div'); + message.textContent = 'Policy Terms Not Available'; + message.style.display = 'flex'; + message.style.justifyContent = 'center'; + message.style.alignItems = 'center'; + message.style.height = '100%'; // Adjust as necessary to fit the context + message.style.textAlign = 'center'; + return message; + } + const fragment = document.createDocumentFragment(); for (const key in obj) { if ( - obj.hasOwnProperty(key) && - obj[key] !== null && - obj[key] !== '' && - key != 'family_floater' && - key != 'family_floater' && - key != 'gpa_special_condition_input' && - key != 'gpa_special_condition_label' && - key != 'special_condition_label' && - key != 'special_condition_input' && - key != 'age_ratio' && - key != "multiple_sum_insured" && - key != "other_special_condition_label" && - key != "other_special_condition_input") { - + obj.hasOwnProperty(key) && + obj[key] !== null && + obj[key] !== '' && + key !== 'family_floater' && + key !== 'gpa_special_condition_input' && + key !== 'gpa_special_condition_label' && + key !== 'special_condition_label' && + key !== 'special_condition_input' && + key !== 'age_ratio' && + key !== 'multiple_sum_insured' && + key !== 'other_special_condition_label' && + key !== 'other_special_condition_input' + ) { const listItem = document.createElement('li'); + let formattedKey = key.replace(/_/g, ' '); - var formattedKey = ''; - formattedKey = key.replace(/_/g, ' '); - obj[key] = obj[key].replace(/<\/?[^>]+>/gi, ''); + console.log('type', typeof obj[key]) + // Strip HTML tags from values + if (typeof obj[key] === 'string') { + console.log('before', obj[key]) + obj[key] = obj[key].replace(/<\/?[^>]+>/gi, ''); + console.log('after', obj[key]) + } + + // Convert 0 and 1 to 'No' and 'Yes' if (obj[key] == 0) { obj[key] = 'No'; } - if (obj[key] == 1) { obj[key] = 'Yes'; } - console.log(formattedKey) - - if (key == 'burnExpenses' && obj[key] == 'Yes') { - - listItem.innerHTML = - `${formattedKey.charAt(0).toUpperCase() + formattedKey.slice(1)}: ${obj['burnExpensesData']}`; - - } else if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) { - + // Handle nested objects + if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) { listItem.innerHTML = `${formattedKey.charAt(0).toUpperCase() + formattedKey.slice(1)}:`; const nestedList = document.createElement('ul'); - nestedList.appendChild(createListItems(obj[key])); - listItem.appendChild(nestedList); - } else { listItem.innerHTML = `${formattedKey.charAt(0).toUpperCase() + formattedKey.slice(1)}: ${Array.isArray(obj[key]) ? JSON.stringify(obj[key]) : obj[key]}`; @@ -337,8 +347,8 @@ $(document).on('click', '.policy_terms', function() { return fragment; } + $('#modal_body').append(createListItems(terms)); }); - \ No newline at end of file diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index d80a764c..a4f5a177 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -2597,6 +2597,8 @@ function si_orbp_change_function() { // $('.gpa_sum_insure_remove').remove(); var selectedValue = $('#si_or_bp').val(); + console.log('selectedValue', selectedValue) + if (selectedValue == 2) { $('.gpa_sum_insure_remove').hide(); @@ -2682,8 +2684,8 @@ function si_orbp_change_function() { $('#basic_multiplier').removeAttr('required', false); $('#premium_multiplier').removeAttr('required', false); $('#basic_pay').removeAttr('required', false); - $('#gpa_basic_si').removeAttr('required', false); - $('#gpa_basic_premium').removeAttr('required', false); + $('#gpa_basic_si_first').removeAttr('required', false); + $('#gpa_basic_premium_first').removeAttr('required', false); $('#gpa_sum_multiplier2').removeAttr('required', false); $('#gpa_sum_si2').removeAttr('required', false); @@ -2734,8 +2736,8 @@ function si_orbp_change_function() { $('#basic_multiplier').removeAttr('required', false); $('#premium_multiplier').removeAttr('required', false); $('#basic_pay').removeAttr('required', false); - $('#gpa_basic_si').removeAttr('required', false); - $('#gpa_basic_premium').removeAttr('required', false); + $('#gpa_basic_si_first').removeAttr('required', false); + $('#gpa_basic_premium_first').removeAttr('required', false); $('#gpa_sum_multiplier').attr('required', false); $('#gpa_sum_si').attr('required'); @@ -2994,13 +2996,13 @@ function checkPolicyTermsSI(callback) { siInputs = container.find('input[name="3_si[]"]'); break; case '4': - siInputs = container.find('input[name="4_si[]"]'); + siInputs = container.find('input[name="4_si"]'); break; case '5': siInputs = container.find('input[name="5_si[]"]'); break; case '6': - siInputs = container.find('input[name="6_si[]"]'); + siInputs = container.find('input[name="6_si"]'); break; case '7': siInputs = container.find('input[name="7_si[]"]'); @@ -3009,7 +3011,7 @@ function checkPolicyTermsSI(callback) { siInputs = container.find('input[name="8_si[]"]'); break; case '9': - siInputs = container.find('input[name="9_si[]"]'); + siInputs = container.find('input[name="gpa_si"]'); break; case '10': siInputs = container.find('input[name="10_si[]"]'); @@ -3017,6 +3019,12 @@ function checkPolicyTermsSI(callback) { case '11': siInputs = container.find('input[name="11_si[]"]'); break; + case '12': + siInputs = container.find('input[name="12_si[]"]'); + break; + case '13': + siInputs = container.find('input[name="13_si[]"]'); + break; default: siInputs = []; } @@ -3044,6 +3052,7 @@ function checkPolicyTermsSI(callback) { siInputs.each(function() { var input = $(this).val(); + console.log('input value', input); rack_rate_si.push(input.replace(/,/g, '')); }); From b32e9f80ac90c1660043ea54d3f0a9432be9784a Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 24 Jun 2024 17:26:46 +0530 Subject: [PATCH 13/14] CHANGE_EMP_FILTER_ADD_2_FIELDS_CHECK_HR_NO_DATATABLE_CSV : RV --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 12 ++++ app/Controllers/EmployeeController.php | 7 ++- app/Models/EmployeePolicyModel.php | 79 +++++++++++++++++++------- app/Views/client_branch.php | 31 +++++++++- app/Views/employee_list.php | 22 +++++-- app/Views/endorsement_list.php | 32 ++++++++--- app/Views/layout/footer.php | 1 + app/Views/policy_grid_excel.php | 16 ++++-- 9 files changed, 158 insertions(+), 43 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 041caaa3..73ce3697 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -248,6 +248,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("check_policy_type/(:any)", "ClientController::checkPolicyType/$1"); $routes->get("getPolicyTerms/(:any)", "ClientController::getPolicyTerms/$1"); $routes->get("getPolicyTermsFormJson/(:any)", "ClientController::getPolicyTermsFormJson/$1"); + $routes->get("checkHRNumber/(:any)", "ClientController::checkHRNumber/$1"); }); $routes->cli('cli/processjob', 'JobWorker::processJob'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index ba3da3d8..7b5c4e8d 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2283,4 +2283,16 @@ class ClientController extends AdminController } + public function checkHRNumber($mobileNumber) + { + try { + $mobileNumberCount = $this->levelContactModel->where('mobile', $mobileNumber)->countAllResults(); + return $this->respond(['status' => true, 'data' => $mobileNumberCount], 200); + } catch (\Exception $e) { + log_message('error', 'Error checking mobile number: ' . $e->getMessage()); + return $this->respond(['status' => false, 'data' => 0, 'message' => 'An error occurred while checking the mobile number. Please try again later.'], 500); + } + } + + } \ No newline at end of file diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 80571810..c2447397 100644 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -79,13 +79,16 @@ class EmployeeController extends AdminController $data['employees'] = $this->employeePolicyModel->getEmployeePolicy( client_id: $filterData['client_id'], policy_id: $filterData['policy_id'], - status: $filterData['status'], - branch_id: $filterData['branch_id'] + branch_id: $filterData['branch_id'], + emp_code : $filterData['emp_code'], + emp_name : $filterData['emp_name'], + status : $filterData['status'], ); $data['getData'] = $filterData; } + // dd($this->request->getGet()); $this->myLogger->logme('error', 'list called'); $this->loadLayout('employee_list', $data); } diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 2dcac592..15bf295d 100644 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -76,31 +76,68 @@ class EmployeePolicyModel extends Model } // ----------------------------------------------------------------------------------------------------- - public function getEmployeePolicy($client_id,$policy_id,$status,$branch_id) + public function getEmployeePolicy($client_id = 0, $policy_id=0, $status=0, $branch_id=0, $emp_code="", $emp_name="") { - $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') - ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy - ->join('policies pm', 'cp.policy_id = pm.id') //pm - policy master - ->join('insurers im', 'cp.insurer_id = im.id') //im - insurar master - ->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurar branch - ->join('tpa tpam', 'cp.tpa_id = tpam.id','left') //tpam - tpa master - ->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id','left') //tpab - tpa brach - ->join('clients cm', 'cp.client_id = cm.id') //cm - client master - ->where('emp.client_id',$client_id) - ->where('emp.client_branch_id',$branch_id) - ->where('employee_polices.is_active',1) - ->where('emp.is_active',1) - ->where('employee_polices.client_policy_id',$policy_id) - ->orderBy('emp.emp_code','ASC')->orderBy('employee_polices.employee_id','ASC'); - - - if($status != 0 && !empty($status)){ + + $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') + ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy + ->join('policies pm', 'cp.policy_id = pm.id') //pm - policy master + ->join('insurers im', 'cp.insurer_id = im.id') //im - insurer master + ->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurer branch + ->join('tpa tpam', 'cp.tpa_id = tpam.id', 'left') //tpam - tpa master + ->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id', 'left') //tpab - tpa branch + ->join('clients cm', 'cp.client_id = cm.id') //cm - client master + ->orderBy('emp.emp_code', 'ASC') + ->orderBy('employee_polices.employee_id', 'ASC'); + + // Conditionally add where clauses + if ($client_id !=0 && !empty($client_id)) { + $result->where('emp.client_id', $client_id); + } + if ($branch_id !=0 && !empty($branch_id)) { + $result->where('emp.client_branch_id', $branch_id); + } + if ($policy_id !=0 && !empty($policy_id)) { + $result->where('employee_polices.client_policy_id', $policy_id); + } + if ($status !=0 && !empty($status)) { $result->where('employee_polices.status', $status); } + if (!empty($emp_code)) { + $result->where('emp.emp_code', $emp_code); + } + if (!empty($emp_name)) { + $result->like('emp.name', $emp_name); + } - $result = $result->findAll(); - return ($result); + // Always check these conditions + $result->where('employee_polices.is_active', 1) + ->where('emp.is_active', 1); + + return $result->findAll(); } diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 93ea7137..213f47c2 100644 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -89,7 +89,7 @@
- +
@@ -423,7 +423,7 @@ $(document).ready(function () {
- +
@@ -563,6 +563,33 @@ $(document).ready(function () { + function checkMobileNumber(input){ + + console.log('function called') + console.log(input); + console.log('Input Value', input.value); + + var mobileNumber = input.value; + var url = '' + mobileNumber; + + $.get(url, function(response){ + + console.log(response) + console.log(response.data) + + if(response.data > 0){ + toastr.warning('The Mobile Number Already Exist.', 'Warning'); + input.value = ""; + return; + } + + }).fail(function(xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + }); + + } + \ No newline at end of file diff --git a/app/Views/employee_list.php b/app/Views/employee_list.php index 479260a6..65b8285b 100644 --- a/app/Views/employee_list.php +++ b/app/Views/employee_list.php @@ -59,6 +59,16 @@ table.dataTable tbody td {
+
+
+ +
+ +
+
+ +
+
@@ -318,18 +328,22 @@ function fetchEmpolyeeList(event) { var policy_id = $('#policies').val(); var status = $('#status2').val(); var branch_id = $('#branch_id').val(); + var emp_code = $('#emp_code').val(); + var emp_name = $('#emp_name').val(); // console.log(client_id + '-' + policy_id); - if (client_id == '0' || policy_id == '0') { - alert('Please select values in both dropdowns.'); - return; - } + // if (client_id == '0' || policy_id == '0') { + // alert('Please select values in both dropdowns.'); + // return; + // } var queryParams = { client_id: client_id, policy_id: policy_id, branch_id: branch_id, + emp_code : emp_code, + emp_name : emp_name, status : status, }; diff --git a/app/Views/endorsement_list.php b/app/Views/endorsement_list.php index 4fa12d55..45f7423b 100644 --- a/app/Views/endorsement_list.php +++ b/app/Views/endorsement_list.php @@ -587,16 +587,25 @@ dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" + "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>", - "buttons": [{ - "extend": 'csv', - "text": 'CSV', - "title": 'Endorsement-List', - "className": 'my_class', - "exportOptions": { - "columns": ':not(:last-child)' - }, + buttons: [{ + extend: 'csv', + text: 'CSV', + title: 'Endorsement-List', + className: 'my_class', + exportOptions: { + columns: ':not(:last-child)', + format: { + body: function (data, row, column, node) { + // Convert data to string to avoid scientific notation in CSV + if (!isNaN(data) && parseFloat(data) > 1e20) { + return `'${data}`; + } + return data.toString();// Ensures all data is treated as strings + } + } + } }], - "initComplete": function(settings, json) { + initComplete: function(settings, json) { $('.my_class').css({ "position": "relative", "left": "79px" @@ -608,7 +617,12 @@ }, paging: true, // pagingType: 'full_numbers' + columnDefs: [ + { type: 'scientific', targets: 0 } // Apply custom sorting type to the first column + ], }); + + }); \ No newline at end of file diff --git a/app/Views/layout/footer.php b/app/Views/layout/footer.php index 11e7405f..f43042ed 100644 --- a/app/Views/layout/footer.php +++ b/app/Views/layout/footer.php @@ -136,6 +136,7 @@ + \ No newline at end of file From 33a07a816ed1d5298e213c9468bec5e695e05320 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 24 Jun 2024 17:38:16 +0530 Subject: [PATCH 14/14] FIX_LEVEL_CONTACT_QUERY : RV --- app/Controllers/ClientController.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 7b5c4e8d..02269a95 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2286,8 +2286,16 @@ class ClientController extends AdminController public function checkHRNumber($mobileNumber) { try { - $mobileNumberCount = $this->levelContactModel->where('mobile', $mobileNumber)->countAllResults(); - return $this->respond(['status' => true, 'data' => $mobileNumberCount], 200); + $mobileNumberCount = $this->levelContactModel + ->join('client_branch', 'client_branch.id = level_contacts.ref_id') + ->join('clients', 'clients.id = client_branch.client_id') + ->where('clients.is_active', 1) + ->where('client_branch.is_active', 1) + ->where('level_contacts.is_active', 1) + ->where('level_contacts.contact_type', 'client') + ->where('level_contacts.mobile', $mobileNumber) + ->countAllResults(); + return $this->respond(['status' => true, 'data' => $mobileNumberCount, 'message' => "try"], 200); } catch (\Exception $e) { log_message('error', 'Error checking mobile number: ' . $e->getMessage()); return $this->respond(['status' => false, 'data' => 0, 'message' => 'An error occurred while checking the mobile number. Please try again later.'], 500);