From d36b0b05ed8207d5fadfada86f4bbc9a529a3bcc Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 30 Jul 2024 08:11:56 +0530 Subject: [PATCH] FIX_RACK_RATE_ISSUE : RV --- app/Views/policy_grid.php | 125 ++++++++++++++++++++++++++------------ 1 file changed, 87 insertions(+), 38 deletions(-) diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index b050ff05..342f9261 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -368,38 +368,9 @@ $('body').on('click', '.btnPolicyModel', function() var premium_type_for_primary_rr = []; var first = 0; - premiumData = []; + var premiumData = groupedData.Primary ?? []; + console.log('----- premiumData for primary rack rate -----', premiumData); - try { - if (policy_type_string == 'GMC') { - $.each(groupedData, function(index, item) { - if (index !== 'Primary') { - appendNewTab(index, item); - } else { - premiumData = item; - } - }); - } else { - $.each(groupedData, function(index, item) { - if (index == 'Primary') { - premiumData = item; - } - }); - } - } catch (error) { - console.error('An error occurred:', error); - console.error('Error Name:', error.name); - console.error('Error Message:', error.message); - console.error('Error Stack:', error.stack); - - // Optional: handle the error in a user-friendly way - console.error('An error occurred while processing the data. Please try again.'); - } - - - console.log('premiumData for primary rack rate', premiumData); - - if (premiumData.length > 0 && premiumData != 'undefined') { $.each(premiumData, function(index, item) { @@ -416,6 +387,7 @@ $('body').on('click', '.btnPolicyModel', function() } }); } + console.log('premiumData for primary rack rate', premiumData); console.log('additional_relationship for primary rack rate', additional_relationship); @@ -465,6 +437,24 @@ $('body').on('click', '.btnPolicyModel', function() console.log("res.premiumData is undefined, null, or empty."); } + try { + if (policy_type_string == 'GMC') { + $.each(groupedData, function(index, item) { + if (index !== 'Primary') { + appendNewTab(index, item); + } + }); + } + } catch (error) { + console.error('An error occurred:', error); + console.error('Error Name:', error.name); + console.error('Error Message:', error.message); + console.error('Error Stack:', error.stack); + + // Optional: handle the error in a user-friendly way + console.error('An error occurred while processing the data. Please try again.'); + } + $('#bs-example-modal-lg').modal('show'); $("#gpa_si").trigger("keyup"); $("#gpa_si_9").trigger("keyup"); @@ -3089,19 +3079,24 @@ function appendNewTab(tabNameData = null, data = null) 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) + + if (data[0].policy_grid_id == 4 || data[0].policy_grid_id == 6) { + + appendFourthAndSixthRackRate(data[0], tabId); + policy_grid_id = data[0].policy_grid_id + additional_relationship = data[0].additional_relationship; + premium_type = data[0].premium_type; + + data.shift(); + } + $.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; - - // 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); }); } @@ -3409,4 +3404,58 @@ function checkFamiliFloatersKeysDuplicate(rarc_rate_json_array, formObject) } + +function appendFourthAndSixthRackRate(data = null, uniqueId = null) +{ + console.log('appendFourthAndSixthRackRate function called'); + console.log('appendFourthAndSixthRackRate function uniqueId', uniqueId); + console.log('appendFourthAndSixthRackRate function data', data); + + + grid_html = ` +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+
`; + + grid_container_id = 'grid_content_input_for_additional_' + uniqueId; + console.log('appendFourthAndSixthRackRate function', grid_container_id); + grid_container = document.getElementById(grid_container_id); + console.log('appendFourthAndSixthRackRate function', grid_container); + grid_container.insertAdjacentHTML('beforeend', grid_html); + + if(unit_length == 1 || unit_length == 0){ + $('.unitDiv').hide(); + $('.unitDiv').find('input').removeAttr('required'); + }else{ + $('.unitDiv').show(); + $('.unitDiv').find('input').attr('required', true); + } +} \ No newline at end of file