diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 5c79e589..0e618c6f 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -1354,6 +1354,7 @@ class EmpDataServiceController extends BaseController $employee_data = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($ref_data, 1); + // dd($employee_data, $excel_data); // ->select(' // employee_polices.id as emp_policy_id, @@ -1475,17 +1476,22 @@ class EmpDataServiceController extends BaseController } if ($insurer_or_tpa == 'tpa') { + if ($excel_data[$key][13] === null) { $missing_id[$key][] = [ 'row' => $key, - 'column' => 15, + 'column' => 13, + 'db_data' => "TPA ID is Must", + 'excel_data' => $excel_data[$key][13] ]; } } else if ($insurer_or_tpa == 'insurer') { if ($excel_data[$key][14] === null) { $missing_id[$key][] = [ 'row' => $key, - 'column' => 16, + 'column' => 14, + 'db_data' => "UHID or Risk ID is Must", + 'excel_data' => $excel_data[$key][14] ]; } } @@ -1591,6 +1597,7 @@ class EmpDataServiceController extends BaseController } if ($emp_value['gst'] != $excel_data[$key][16]) { + $errors[$key][] = [ 'row' => $key, 'column' => 16, @@ -1632,7 +1639,7 @@ class EmpDataServiceController extends BaseController $missing_id_count = count($missing_id); $json_missing_id = json_encode($missing_id); - // dd($error_count, $missing_id_count, $json_errors, $json_missing_id); + // dd($error_count, $missing_id_count, $json_errors, $json_missing_id, $employee_data, $excel_data); if ($missing_id_count > 0) { diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index eb2523f4..0733b1bc 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -194,11 +194,9 @@ class LeadsController extends BaseController foreach($data['policy_type_id'] as $index => $value){ - // Separate the insurer and insurer branch, handle missing or invalid data if (isset($data['insurer'][$index]) && strpos($data['insurer'][$index], '-') !== false) { list($insurer_branch_id, $insurer_id) = explode('-', $data['insurer'][$index]); - } else { $insurer_branch_id = 0; $insurer_id = 0; } @@ -210,7 +208,6 @@ class LeadsController extends BaseController $tpa_id = 0; } - // Separate the insurer and insurer branch, handle missing or invalid data if (isset($data['proposed_insurer'][$index]) && strpos($data['proposed_insurer'][$index], '-') !== false) { list($proposed_insurer_branch_id, $proposed_insurer_id) = explode('-', $data['proposed_insurer'][$index]); @@ -252,6 +249,11 @@ class LeadsController extends BaseController } $file_name = file_Upload($files[$index], $uploadFilePath); + + $last_3_years_claims = null; + if($value != 2){ + $last_3_years_claims = $data['finyear']; + } $processedData[] = [ 'lead_type' => $data['lead_type'], @@ -308,6 +310,9 @@ class LeadsController extends BaseController 'annualised_claims' => $data['annualised_claims'][$index] ?? 0, 'incurred_claims_ratio' => $data['incurred_claims_ratio'][$index] ?? 0, 'earned_claims_ratio' => $data['earned_claims_ratio'][$index] ?? 0, + 'total_si_at_incept' => $data['total_si_at_incept'][$index] ?? 0, + 'total_si_at_renewal' => $data['total_si_at_renewal'][$index] ?? 0, + 'fin_years_claims' => $last_3_years_claims, 'file_name' => $file_name, @@ -573,48 +578,71 @@ class LeadsController extends BaseController if($rfq_data['lead_type'] == 1){ - $lead_data = [ + if($rfq_data['policy_type_id'] == 2){ + $lead_data = [ - 'Insured' => $rfq_data['client_name'], - 'Policy Status' => $rfq_data['status'], + 'Insured' => $rfq_data['client_name'], + 'Policy Status' => $rfq_data['status'], - 'No of Employees' => $rfq_data['incept_emp_count'], - 'No of Dependents' => $rfq_data['incept_dept_count'], - 'Total Lives' => $rfq_data['incept_no_of_lives'], + 'No of Employees' => $rfq_data['incept_emp_count'], + 'No of Dependents' => $rfq_data['incept_dept_count'], + 'Total Lives' => $rfq_data['incept_no_of_lives'], - 'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])), - 'Policy Run Days' => $rfq_data['policy_run_days'], - ]; + 'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])), + 'Policy Run Days' => $rfq_data['policy_run_days'], + ]; + }else if($rfq_data['policy_type_id'] == 1){ + $lead_data = [ + 'Insured' => $rfq_data['client_name'], + 'No of Employees at Inception' => $rfq_data['incept_emp_count'], + 'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'], + 'Policy Period' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])), + 'Policy Status' => $rfq_data['status'], + 'Existing Insurer' => $rfq_data['insurer_name'], + 'TPA ' => $rfq_data['tpa_name'], + ]; + } }else{ + if($rfq_data['policy_type_id'] == 2){ + $lead_data = [ - $lead_data = [ + 'Insured' => $rfq_data['client_name'], + 'Policy Status' => $rfq_data['status'], - 'Insured' => $rfq_data['client_name'], - 'Policy Status' => $rfq_data['status'], + 'No of Employees at Inception' => $rfq_data['incept_emp_count'], + 'No of Dependents at Inception' => $rfq_data['incept_dept_count'], + 'Total Lives at Inception ' => $rfq_data['incept_no_of_lives'], - 'No of Employees at Inception' => $rfq_data['incept_emp_count'], - 'No of Dependents at Inception' => $rfq_data['incept_dept_count'], - 'Total Lives at Inception ' => $rfq_data['incept_no_of_lives'], + 'No of Employees at Expiry' => $rfq_data['exp_emp_count'], + 'No of Dependents at Expiry' => $rfq_data['exp_dept_count'], + 'Total Lives at Expiry ' => $rfq_data['exp_no_of_lives'], - 'No of Employees at Expiry' => $rfq_data['exp_emp_count'], - 'No of Dependents at Expiry' => $rfq_data['exp_dept_count'], - 'Total Lives at Expiry ' => $rfq_data['exp_no_of_lives'], + 'No of Employees at Renewal' => $rfq_data['renewal_emp_count'], + 'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'], + 'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'], - 'No of Employees at Renewal' => $rfq_data['renewal_emp_count'], - 'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'], - 'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'], - - 'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])), - 'Policy Run Days' => $rfq_data['policy_run_days'], - 'Inception Premium' => $rfq_data['premium_at_inception'], - 'Premium as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['premium_date'], - 'Earned Premium' => $rfq_data['earned_premium'], - 'Incurred Claims as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['incurred_claims_date'], - 'Annualised Claims' => $rfq_data['annualised_claims'], - 'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'], - 'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'], - ]; + 'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])), + 'Policy Run Days' => $rfq_data['policy_run_days'], + 'Inception Premium' => $rfq_data['premium_at_inception'], + 'Premium as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['premium_date'], + 'Earned Premium' => $rfq_data['earned_premium'], + 'Incurred Claims as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['incurred_claims_date'], + 'Annualised Claims' => $rfq_data['annualised_claims'], + 'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'], + 'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'], + ]; + }else if($rfq_data['policy_type_id'] == 1){ + $lead_data = [ + 'Insured' => $rfq_data['client_name'], + 'No of Employees at Renewal' => $rfq_data['renewal_emp_count'], + 'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'], + 'Policy Period' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])), + 'Policy Status' => $rfq_data['status'], + 'Existing Insurer' => $rfq_data['insurer_name'], + 'TPA ' => $rfq_data['tpa_name'], + ]; + } } $data = json_decode($rfq_data['json'], true); diff --git a/app/Models/LeadsModel.php b/app/Models/LeadsModel.php index c9cdccbb..5867a5d0 100644 --- a/app/Models/LeadsModel.php +++ b/app/Models/LeadsModel.php @@ -80,6 +80,10 @@ class LeadsModel extends Model 'premium_amount', 'total_amount', 'cd_amount', + + 'total_si_at_incept', + 'total_si_at_renewal', + 'fin_years_claims', ]; diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 3cc264e6..10f6e264 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -384,7 +384,7 @@ function getLeadsDataForEdit(input) { $('#contact_person_name').val(res.data.contact_person_name); $('#contact_person_mobile').val(res.data.contact_person_mobile); $('#contact_person_email').val(res.data.contact_person_email); - + $('#policy_type_id_1').val(res.data.policy_type_id).change(); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); }, 1000) @@ -397,7 +397,6 @@ function getLeadsDataForEdit(input) { var proposed_insurer = res.data.proposed_insurer_branch_id + '-' + res.data.proposed_insurer_id; var proposed_tpa = res.data.proposed_tpa_branch_id + '-' + res.data.proposed_tpa_id; - $('#policy_type_id_1').val(res.data.policy_type_id).change(); $('#insurer_1').val(insurer).select2(); $('#tpa_1').val(tpa).select2(); $('#proposed_insurer_1').val(proposed_insurer).select2(); @@ -433,6 +432,9 @@ function getLeadsDataForEdit(input) { $('#file_name_display').text('Upload File Name : ' + res.data.file_name); // $('#file_name').val(res.data.file_name); + $('#total_si_at_incept_' + increment).val(res.data.total_si_at_incept); + $('#total_si_at_renewal_' + increment).val(res.data.total_si_at_renewal); + if (res.data.salse_person_id) { selecSalsePerson(res.data.salse_person_id); @@ -477,6 +479,33 @@ function getLeadsDataForEdit(input) { } } + if(res.data.policy_type_id != 2){ + + $('.gpa_hide_div_'+increment).hide(); + $('.gpa_show_div_'+increment).show(); + $('.gpa_div_elements_'+increment).show(); + $('.emp_title').text('No of Employees at Inception'); + + let claimExperience = JSON.parse(res.data.fin_years_claims); + + claimExperience[0].finyear.forEach((data, index) => { + const year = document.querySelector(`#${["first", "second", "third"][index]}_year_${increment}`); + const claimAmount = document.querySelector(`#${["first", "second", "third"][index]}_claim_amount_${increment}`); + const claimStatus = document.querySelector(`#${["first", "second", "third"][index]}_claim_status_${increment}`); + const causeOfDeath = document.querySelector(`#${["first", "second", "third"][index]}_casue_of_death_${increment}`); + const deathDate = document.querySelector(`#${["first", "second", "third"][index]}_death_date_${increment}`); + + if (year) year.value = data.year; + if (claimAmount) claimAmount.value = data.claim_amount; + if (claimStatus) claimStatus.value = data.status; + if (causeOfDeath) causeOfDeath.value = data.cause_of_death; + if (deathDate) deathDate.value = data.death_date; + }); + + }else{ + $('.gpa_hide_div_'+increment).show(); + } + } else { console.log('No data found'); @@ -625,7 +654,6 @@ function getPolicyData(client_policy_id, increment_count) { } } - // Salse team user list data function selecSalsePerson(salse_person_ids) { @@ -671,6 +699,22 @@ function addHTMLInput(check) { const newRow8 = document.createElement('div'); newRow8.className = 'form-row dynamic-form-row'; + const newRow6 = document.createElement('div'); + newRow6.className = `form-row dynamic-form-row gpa_div_elements_${increment}`; + newRow6.style.display = 'none'; + + const newRow9 = document.createElement('div'); + newRow9.className = `form-row dynamic-form-row gpa_div_elements_${increment}`; + newRow9.style.display = 'none'; + + const newRow10 = document.createElement('div'); + newRow10.className = `form-row dynamic-form-row gpa_div_elements_${increment}`; + newRow10.style.display = 'none'; + + const newRow11 = document.createElement('div'); + newRow11.className = `form-row dynamic-form-row gpa_div_elements_${increment}`; + newRow11.style.display = 'none'; + // Add an
element const hrElement = document.createElement('hr'); container.appendChild(hrElement); @@ -680,7 +724,7 @@ function addHTMLInput(check) {
-
-
+ -
+ + + `; //inception div @@ -853,15 +902,20 @@ function addHTMLInput(check) {
-
+ -
+ + + `; //expiry div @@ -893,9 +947,86 @@ function addHTMLInput(check) {
`; + newRow9.innerHTML +=`
Claims Experience for last 3 Years
`; + + //Last 3 years claims expirence div + newRow6.innerHTML += ` + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ `; + + //Last 3 years claims expirence div + newRow10.innerHTML += ` + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ `; + + //Last 3 years claims expirence div + newRow11.innerHTML += ` + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ `; + //button div newRow5.innerHTML += ` - +
x + @@ -903,25 +1034,44 @@ function addHTMLInput(check) { `; - container.appendChild(newRow); container.appendChild(newRow8); const hrElement2 = document.createElement('hr'); container.appendChild(hrElement2); + //inception div container.appendChild(newRow3); + + //renewal div container.appendChild(newRow2); + + //expiry div container.appendChild(newRow4); + const hrElement3 = document.createElement('hr'); + hrElement3.className = "gpa_div_elements"; // Set class to hrElement3 + container.appendChild(hrElement3); // Append hrElement3 to container + + + container.appendChild(newRow9); + + //Last 3 years claims expirence div + container.appendChild(newRow6); + container.appendChild(newRow10); + container.appendChild(newRow11); + + //file upload div container.appendChild(newRow7); + //button div container.appendChild(newRow5); var lead_type = $('#lead_type').val(); if (lead_type == 2) { + // $('.proposed_div').show().find('select, input').attr('required', 'required'); $('.proposed_div').show(); $('.freashDiv').show() @@ -930,11 +1080,13 @@ function addHTMLInput(check) { $('.emp_title').text('No of Employees at Inception') $('.depnd_title').text(' No of Dependents at Inception') $('.total_title').text('Total Lives at Inception') + $('.gpa_div_elements').show(); } else { // $('.proposed_div').hide().find('select, input').removeAttr('required'); $('.proposed_div').hide() + $('.gpa_div_elements').hide(); if(lead_type == 1){ $('.freashDiv').hide() @@ -948,6 +1100,7 @@ function addHTMLInput(check) { $('.emp_title').text('No of Employees at Inception') $('.depnd_title').text(' No of Dependents at Inception') $('.total_title').text('Total Lives at Inception') + $('.gpa_div_elements').show(); } } @@ -1040,8 +1193,7 @@ function addHTMLInput(check) { increment++; // Increment after adding the input } -function removeHTMLInput(element) -{ +function removeHTMLInput(element) { const container = document.getElementById('dynamic-form-container'); const rows = container.querySelectorAll('.dynamic-form-row'); @@ -1129,7 +1281,6 @@ function incurredClaimSum(input) { $('#earned_claims_ratio_' + increment).val(earned_claims_ratio); } - function earnedPremiumCalc(input) { let increment = input.id.split('_').pop(); // Extract the increment part @@ -1150,7 +1301,6 @@ function earnedPremiumCalc(input) { $('#earned_premium_' + increment).val(earned_premium.toFixed(2)); } - //--------------------------------------------------------------------------------------------------------- $("#leads_form_id").submit(function(event) { @@ -1187,6 +1337,11 @@ $("#leads_form_id").submit(function(event) { // Append the JSON string to the FormData object formData.append('salse_person_id', jsonString); + // Convert the claim experience array to JSON + const finyearJsonString = gatherClaimExperienceData(); + console.log('finyearJsonString', finyearJsonString); + formData.append('finyear', finyearJsonString); + $.ajax({ data: formData, url: form_action, @@ -1239,6 +1394,7 @@ $('#lead_type').change(function() { $('#freshDiv').hide(); $('.freashDiv').show() $('.renewalDiv').hide() + $('.gpa_div_elements').show(); $('#gst').val(''); $('#pan').val(''); @@ -1280,6 +1436,8 @@ $('#lead_type').change(function() { $('.emp_title').text('No of Employees') $('.depnd_title').text('No of Dependents') $('.total_title').text('Total Lives') + $('.gpa_div_elements').show(); + }else{ $('.freashDiv').show() $('.renewalDiv').hide() @@ -1287,6 +1445,7 @@ $('#lead_type').change(function() { $('.emp_title').text('No of Employees at Inception') $('.depnd_title').text(' No of Dependents at Inception') $('.total_title').text('Total Lives at Inception') + $('.gpa_div_elements').show(); } } @@ -1315,6 +1474,79 @@ function tpaChange(input, unique_id) { function sumOfLives(input){ +} +function gatherClaimExperienceData() { + // Initialize an empty array for the claim experience data + let claimExperience = []; + + // Loop through the rows and extract data for each year + $('input[name="first_year[]"]').each(function(index) { + // Extract values for the first, second, and third year claims + const firstYear = $(this).val(); + const firstClaimAmount = $(`input[name="first_claim_amount[]"]`).eq(index).val(); + const firstClaimStatus = $(`input[name="first_claim_status[]"]`).eq(index).val(); + const firstCauseOfDeath = $(`input[name="first_casue_of_death[]"]`).eq(index).val() || null; + const firstDeathDate = $(`input[name="first_death_date[]"]`).eq(index).val() || null; + + const secondYear = $(`input[name="second_year[]"]`).eq(index).val(); + const secondClaimAmount = $(`input[name="second_claim_amount[]"]`).eq(index).val(); + const secondClaimStatus = $(`input[name="second_claim_status[]"]`).eq(index).val(); + const secondCauseOfDeath = $(`input[name="second_casue_of_death[]"]`).eq(index).val() || null; + const secondDeathDate = $(`input[name="second_death_date[]"]`).eq(index).val() || null; + + const thirdYear = $(`input[name="third_year[]"]`).eq(index).val(); + const thirdClaimAmount = $(`input[name="third_claim_amount[]"]`).eq(index).val(); + const thirdClaimStatus = $(`input[name="third_claim_status[]"]`).eq(index).val(); + const thirdCauseOfDeath = $(`input[name="third_casue_of_death[]"]`).eq(index).val() || null; + const thirdDeathDate = $(`input[name="third_death_date[]"]`).eq(index).val() || null; + + // Push each year's data into the array + claimExperience.push({ + "finyear": [ + { + "year": firstYear, + "claim_amount": firstClaimAmount, + "status": firstClaimStatus, + "cause_of_death": firstCauseOfDeath, + "death_date": firstDeathDate + }, + { + "year": secondYear, + "claim_amount": secondClaimAmount, + "status": secondClaimStatus, + "cause_of_death": secondCauseOfDeath, + "death_date": secondDeathDate + }, + { + "year": thirdYear, + "claim_amount": thirdClaimAmount, + "status": thirdClaimStatus, + "cause_of_death": thirdCauseOfDeath, + "death_date": thirdDeathDate + } + ] + }); + + }); + + return JSON.stringify(claimExperience); +} + +function showGpaColumns(input){ + + let policy_type_id = $(input).val() + let increment = input.id.split("_").pop(); + if(policy_type_id != 2){ + $('.gpa_hide_div_'+increment).hide(); + $('.gpa_show_div_'+increment).show(); + $('.gpa_div_elements_'+increment).show(); + $('.emp_title').text('No of Employees at Inception') + $('.total_title').text('Total Sum Insured at Inception') + }else{ + $('.gpa_hide_div_'+increment).show(); + } + + } //----------------------------------------------------------------------------------------------------------- diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index 13fc0933..76f0bafd 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -518,7 +518,7 @@
@@ -1281,15 +1281,16 @@ $(document).on('change', 'input[type="checkbox"][name="co_share_type[]"]', funct let isAnyChecked = $('input[type="checkbox"][name="co_share_type[]"]:checked').length > 1; - var unique_id = $(this).data('count') - console.log(unique_id); - if (isAnyChecked) { toastr.warning('Only one leader can be selected.', 'WARNING!'); $(this).prop('checked', false); } }); +function checkLeaderSelected(){ + +} + // $(document).on('input', '[name="cgst[]"]', function() { // let val = $(this).val(); @@ -1813,9 +1814,9 @@ function amountCalculation(input) { // console.log(standard_bp_per, standard_tp_per, standard_tep_per); - let co_premium_amt = ((bp + tp + tep) * co_share_per) / 100; + // let co_premium_amt = ((bp + tp + tep) * co_share_per) / 100; - $('#co_premium_' + input).val(!isNaN(co_premium_amt) && isFinite(co_premium_amt) ? co_premium_amt.toFixed(2) : '0.00'); + // $('#co_premium_' + input).val(!isNaN(co_premium_amt) && isFinite(co_premium_amt) ? co_premium_amt.toFixed(2) : '0.00'); // Calculate GST percentage @@ -1833,7 +1834,7 @@ function amountCalculation(input) { console.log('sgst', sgst); // Calculate the total premium (Base + TP + Co-Premium) - let tpTotal = bp + tp + tep + cop; + let tpTotal = bp + tp + tep; console.log('bp', bp); console.log('tp', tp); @@ -2400,6 +2401,48 @@ function co_share_percentage_calculation(input, extra = null){ // console.log('Final input values:', inputValues); // } +// $(document).on('change', '[name="base_premium[]"]', function(e) { + + +// console.log('############################################################'); +// console.log(e) + +// // Get the index of the changed input field +// const index = $('input[name="base_premium[]"]').index(this); + +// // Get the corresponding co_share_per value +// const coSharePer = parseFloat($('input[name="co_share_per[]"]').eq(index).val()) || 0; + +// // Get the base_premium value +// const basePremium = parseFloat($(this).val()) || 0; + +// // Calculate the co_premium value using the formula +// const coPremium = (basePremium * coSharePer) / 100; + +// // Set the calculated value to the corresponding co_premium field +// $('input[name="co_premium[]"]').eq(index).val(coPremium.toFixed(2)); // Limiting to two decimal places +// }); + +$(document).on('change', '[name="base_premium[]"], [name="co_share_per[]"]', function(e) { + + // Get the base premium value (assuming there's only one) + const basePremium = parseFloat($('input[name="base_premium[]"]').val()) || 0; // Get base_premium value + console.log('basePremium', basePremium); + + + // Loop through all co_share_per[] fields + $('input[name="co_share_per[]"]').each(function(index) { + const coSharePer = parseFloat($(this).val()) || 0; // Get co_share_per value + + // Calculate co_premium using the formula: base_premium * co_share_per / 100 + const coPremium = (basePremium * coSharePer) / 100; + + // Set the calculated value in the corresponding co_premium input + $('input[name="co_premium[]"]').eq(index).val(coPremium.toFixed(2)); // Limiting to two decimal places + }); +}); + + function select_leader_disable_premium_amt(input, value) { @@ -2420,6 +2463,7 @@ function select_leader_disable_premium_amt(input, value) { $('input[name="co_premium[]"]').addClass('readonly-select'); $('#co_premium_' + value).removeClass('readonly-select'); + } else { // Enable and remove readonly-select class from all premiums except the one with the given value $('input[name="base_premium[]"]').removeClass('readonly-select'); @@ -3305,7 +3349,7 @@ $('#cop_yes').change(function() { } else { $('#add_more_row').addClass('d-none'); $('.payby').addClass('d-none'); - $('#bro_payable_by').prop('checked', false); + // $('#bro_payable_by').prop('checked', false); $('#table_tr_2').hide() $('#table_tr_3').hide() $('#table_tr_7').hide()