From 0e03faea09f67620f1e83630e9e9f518735d80d6 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 29 Jul 2024 18:04:00 +0530 Subject: [PATCH 1/2] FIX_ADDITIONAL_RELIONSHIP_JSON : RV --- app/Controllers/ClientController.php | 34 ++++++------- app/Views/client_policy.php | 36 ++++++++++--- app/Views/policy_grid.php | 75 +++++++++++++++++----------- 3 files changed, 91 insertions(+), 54 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index e113a8c0..0a21c731 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -1021,28 +1021,28 @@ class ClientController extends AdminController $policy_grid_id = $this->request->getPost('policy_grid_id'); $rack_rate_name = $this->request->getPost('rack_rate_name'); - $self = $this->request->getPost('self') ? 1 : 0; - $spouse = $this->request->getPost('spouse'); - $childrens = $this->request->getPost('childrens'); - $parents = $this->request->getPost('parents'); - $parents_in_law = $this->request->getPost('parents-in-law'); + $relation_data = [ + 'self' => $this->request->getPost('self'), + 'spouse' => $this->request->getPost('spouse'), + 'childrens' => $this->request->getPost('childrens'), + 'parents' => $this->request->getPost('parents'), + 'parents-in-law'=> $this->request->getPost('parents-in-law'), + ]; - if($policy_grid_id == 1 || $policy_grid_id == 2){ - $self = 1; - $spouse = 'NA'; - $childrens = 'NA'; - $parents = 'NA'; - $parents_in_law = 'NA'; + if ($policy_grid_id == 1 || $policy_grid_id == 2 || $policy_grid_id == 6 || $policy_grid_id == 7) { + $relation_data = [ + 'self' => 1, + 'spouse' => 'NA', + 'childrens' => 'NA', + 'parents' => 'NA', + 'parents-in-law'=> 'NA', + ]; } - $relation_data['self'] = $self; - $relation_data['spouse'] = $spouse; - $relation_data['childrens'] = $childrens; - $relation_data['parents'] = $parents; - $relation_data['parents-in-law'] = $parents_in_law; - + // Convert to JSON $jsonDataForRelation = json_encode($relation_data); + $si_or_bp = $this->request->getPost('si_or_bp'); $basic_multiplier = str_replace(',', '', $this->request->getPost('basic_multiplier')); $premium_multiplier = str_replace(',', '', $this->request->getPost('premium_multiplier')); diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index 86baa139..1ca428b1 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -488,6 +488,9 @@ $('#policy_table tr').remove(); var policyTable = ''; + var role = res.data.role + delete res.data.role; + $.each(res.data, function(index, item) { var patternGMC = /gmc/i; // Case insensitive pattern for 'gmc' @@ -543,9 +546,9 @@ ${item.insurer_short} - ${item.insurer_branch_name} ${policy_name_data} - ${item.branch_name} + ${item.branch_name ? item.branch_name : ' - '} ${tpaValue} - ${rearrangeDateFormat(item.policy_start_date)} / ${rearrangeDateFormat(item.policy_end_date)} + ${(item.policy_start_date)} / ${(item.policy_end_date)} ${(enrollmentStatus)} ${checkDateStatus(item.policy_end_date, 1)} @@ -554,8 +557,15 @@ @@ -990,16 +1000,26 @@ //for date convert to indian formate like this 'yyyy-mm-dd' to this 'dd-mm-yyyy' function rearrangeDateFormat(inputDate) { - - if (inputDate !== null) { + console.log('inputDate', inputDate) + // Check if inputDate is a string and not empty + if (typeof inputDate === 'string' && inputDate.trim() !== '') { var dateComponents = inputDate.split("-"); - var rearrangedDate = dateComponents[2] + "-" + dateComponents[1] + "-" + dateComponents[0]; - return rearrangedDate; + + // Check if dateComponents has the expected number of parts + if (dateComponents.length === 3) { + var rearrangedDate = dateComponents[2] + "-" + dateComponents[1] + "-" + dateComponents[0]; + return rearrangedDate; + } else { + // Handle unexpected date format + return '00-00-0000'; + } } else { + // Handle the case where inputDate is not a valid string return '00-00-0000'; } } + function checkDateStatus(inputDate, bg = false) { var givenDate = new Date(inputDate); diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index 0110412c..1c9a96e7 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -1246,8 +1246,13 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa console.log('grid_container step 4', grid_container) // console.log('grid_html', grid_html) - $(grid_container).empty(); + if(data == false){ + $(grid_container).empty(); + } grid_container.insertAdjacentHTML('beforeend', grid_html); + console.log('grid_container step 5'); + console.log('grid_container step 6', grid_container); + if (dataIdValue == '1') { $('#gpa_sum_si').trigger('keyup'); @@ -1283,24 +1288,24 @@ var Count = 1 function appendGridtHtml(ui_type = false, secondary = false, data = false) { console.log('appendGridtHtml function data', data); - console.log('appendGridtHtml ui_type', ui_type); - - console.log('secondary', secondary) - console.log('typeof secondary', typeof secondary) + console.log('appendGridtHtml function ui_type', ui_type); + console.log('appendGridtHtml function secondary', secondary); + console.log('appendGridtHtml function typeof secondary', typeof secondary) var html = ''; Count++; var container = document.getElementById('grid_content_input'); - // console.log('container', container); + console.log('appendGridtHtml function container step 1', container); if (secondary != false && secondary != 'false' && secondary != null && secondary != 'null') { container_id = 'grid_content_input_for_additional_' + secondary; - console.log('container', container_id); container = document.getElementById(container_id); - console.log('container', container); + console.log('appendGridtHtml function container step 2', container); } + console.log('appendGridtHtml function container step 3', container); + if (ui_type == '1') { // console.log('step 1') @@ -1444,7 +1449,7 @@ function appendGridtHtml(ui_type = false, secondary = false, data = false)
- +
@@ -1743,8 +1748,9 @@ function appendGridtHtml(ui_type = false, secondary = false, data = false)
`; } - console.log('container', container); + console.log('appendGridtHtml function container step 4', container); container.insertAdjacentHTML('beforeend', html); + console.log('appendGridtHtml function container step 5', container); // $('#gmc_add_more').hide(); // $('#gmc_add_more2').hide(); @@ -1840,11 +1846,17 @@ function checkDuplicate(unique_id = null) // Extract values from input arrays siInputs.each(function() { - siValues.push($(this).val()); + var value = $(this).val(); + var cleanedValue = value.replace(/,/g, ''); + var numericValue = parseFloat(cleanedValue); + siValues.push(numericValue); }); premiumInputs.each(function() { - premiumValues.push($(this).val()); + var value = $(this).val(); + var cleanedValue = value.replace(/,/g, ''); + var numericValue = parseFloat(cleanedValue); + premiumValues.push(numericValue); }); for (var i = 0; i < siValues.length; i++) { @@ -2623,7 +2635,7 @@ function createCheckboxes(obj, additional_relationship = [], unique_id = null, p `; if (obj['self'] > 0) { - let selfValue = additional_relationship['self'] || 'NA'; + let selfValue = additional_relationship['self'] || '1'; console.log('selfValue', selfValue); html += ` @@ -2649,7 +2661,7 @@ function createCheckboxes(obj, additional_relationship = [], unique_id = null, p } if (obj['spouse'] > 0) { - let spouseValue = additional_relationship['spouse'] || 'NA'; + let spouseValue = additional_relationship['spouse'] || 'any'; html += `
@@ -2675,7 +2687,7 @@ function createCheckboxes(obj, additional_relationship = [], unique_id = null, p if (obj['childrens'] > 0) { - let childrensValue = additional_relationship['childrens'] || 'NA'; + let childrensValue = additional_relationship['childrens'] || 'any'; html += `
@@ -2712,7 +2724,7 @@ function createCheckboxes(obj, additional_relationship = [], unique_id = null, p } if (obj['parents'] > 0) { - let parentsValue = additional_relationship['parents'] || 'NA'; + let parentsValue = additional_relationship['parents'] || 'any'; html += `
@@ -2741,7 +2753,7 @@ function createCheckboxes(obj, additional_relationship = [], unique_id = null, p } if (obj['parents-in-law'] > 0) { - let parentsInLawValue = additional_relationship['parents-in-law'] || 'NA'; + let parentsInLawValue = additional_relationship['parents-in-law'] || 'any'; html += `
@@ -2960,8 +2972,8 @@ function checkPolicyTermsSI(unique_id = null) function appendNewTab(tabNameData = null, data = null) { console.log('appendNewTab function called'); - console.log('tabNameData', tabNameData); - console.log('data', data); + console.log('appendNewTab function tabNameData', tabNameData); + console.log('appendNewTab function data', data); let tabName = tabNameData; @@ -3072,23 +3084,28 @@ function appendNewTab(tabNameData = null, data = null) var policy_grid_id = null; var additional_relationship = []; var premium_type = null; - if(data){ + var si_or_bp_value = '' + if(data.length > 0){ + + console.log('appendNewTab function first index data', data[0]) + console.log('appendNewTab function first index data[0].policy_grid_id', data[0].policy_grid_id) - addGridHTML(false, data[0], data[0].policy_grid_id, false, tabId); - policy_grid_id = data[0].policy_grid_id - additional_relationship = data[0].additional_relationship; - premium_type = data[0].premium_type; - // data.shift(); - // if(data.length > 1){ $.each(data, function(index, item) { - // console.log(item) + + console.log('appendNewTab function index', index) policy_grid_id = item.policy_grid_id additional_relationship = item.additional_relationship; premium_type = item.premium_type; + + // if(index == 0){ + // addGridHTML(false, item, item.policy_grid_id, si_or_bp_value, tabId); + // }else{ + // appendGridtHtml(item.policy_grid_id, tabId, item); + // } + appendGridtHtml(item.policy_grid_id, tabId, item); }); - // } } appendGridData(rack_rate_array, policy_grid_id, tabId); @@ -3184,7 +3201,7 @@ function removeTab(input, tabID, tabName) Swal.fire({ title: "Are you sure?", - text: "You want to remove this Rack Rate.", + text: "Do you want to remove this Rack Rate.", icon: "info", showCancelButton: true, confirmButtonColor: "#3085d6", From 26f27ccc47603df93c3fbec72fe80e8bc7a218ce Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 29 Jul 2024 18:12:05 +0530 Subject: [PATCH 2/2] FIX_RACK_RATE : RV --- app/Views/policy_grid.php | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index 1c9a96e7..b050ff05 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -3085,27 +3085,25 @@ function appendNewTab(tabNameData = null, data = null) var additional_relationship = []; var premium_type = null; var si_or_bp_value = '' - if(data.length > 0){ + if(data){ console.log('appendNewTab function first index data', data[0]) console.log('appendNewTab function first index data[0].policy_grid_id', data[0].policy_grid_id) + $.each(data, function(index, item) { + console.log('appendNewTab function index', index) + policy_grid_id = item.policy_grid_id + additional_relationship = item.additional_relationship; + premium_type = item.premium_type; - $.each(data, function(index, item) { + // if(index == 0){ + // addGridHTML(false, item, item.policy_grid_id, si_or_bp_value, tabId); + // }else{ + // appendGridtHtml(item.policy_grid_id, tabId, item); + // } - console.log('appendNewTab function index', index) - policy_grid_id = item.policy_grid_id - additional_relationship = item.additional_relationship; - premium_type = item.premium_type; - - // if(index == 0){ - // addGridHTML(false, item, item.policy_grid_id, si_or_bp_value, tabId); - // }else{ - // appendGridtHtml(item.policy_grid_id, tabId, item); - // } - - appendGridtHtml(item.policy_grid_id, tabId, item); - }); + appendGridtHtml(item.policy_grid_id, tabId, item); + }); } appendGridData(rack_rate_array, policy_grid_id, tabId);