From 528d8dcb267be4d93feb62fb3cf296e38ec742fe Mon Sep 17 00:00:00 2001 From: Venkatesh Date: Sat, 16 May 2026 09:55:02 +0530 Subject: [PATCH 1/2] FIX_CLAIM_HISTORY_SHOW_ROLL_OVER --- .../PolicyTransactionController.php | 3 +++ app/Views/leads_form.php | 21 ++++++++++++++++--- app/Views/leads_form_handler.php | 4 +++- app/Views/rfq/gpa.php | 2 +- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index b0a7cb12..26da53b2 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -5321,6 +5321,8 @@ class PolicyTransactionController extends BaseController try { + $bdsInstallmentData = []; + try { $bdsInstallmentData = $this->BdsPlacementModel->getClientInstallmentDetails(); @@ -5328,6 +5330,7 @@ class PolicyTransactionController extends BaseController $this->myLogger->logme('error', 'Exception: ' . $e->getMessage() . 'Page: ' . $e->getFile() . ' Line: ' . $e->getLine()); } + $this->myLogger->logme("error", "Data for BDS Installment " . json_encode($bdsInstallmentData)); // dd($bdsInstallmentData); diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 278fec55..36d930c8 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -1162,7 +1162,7 @@ if (lead_type == 1) { $('.claim-row').hide(); - } else { + } else if (!shouldShowClaimHistorySwitch(lead_type, policy_type_id)) { $('.claim-row').show(); if (policy_type_id == 1) { @@ -1174,6 +1174,10 @@ } } + if ($('#claim_history').length && typeof claimHistoryToggle === 'function') { + claimHistoryToggle(); + } + if (lead_type != 1 && policy_type_id != 1 && policy_type_id != 6 && policy_type_id != 7) { if (lead_type == 1) { updateRenewalFields(dataIncrement); @@ -2188,6 +2192,14 @@ // toggleRequiredFields(); // } + function isClaimHistoryPolicyType(policyTypeId) { + return ['1', '6', '7'].includes(String(policyTypeId)); + } + + function shouldShowClaimHistorySwitch(leadType, policyTypeId) { + return (leadType == 2 || leadType == 3) && isClaimHistoryPolicyType(policyTypeId); + } + function appendThreeYearsClaims(count) { // let count = $('#appendAreaForClaim').data('count'); @@ -2197,7 +2209,7 @@ console.log('policy_type_id', policy_type_id); let lead_type = $('#lead_type').val(); - let showClaimHistorySwitch = lead_type == 2 && (policy_type_id == 1 || policy_type_id == 6 || policy_type_id == 7); + let showClaimHistorySwitch = shouldShowClaimHistorySwitch(lead_type, policy_type_id); console.log('claimIndex from parent', claimIndex); let increment = claimIndex; @@ -2432,7 +2444,6 @@ } else if (value == 3) { $('.btnDiv').hide(); - $('.claim-row').show(); $('.emp_title_text').text('No of Employees at Inception') $('.depnd_title_text').text(' No of Dependents at Inception') @@ -2546,6 +2557,10 @@ } + if ($('#claim_history').length && typeof claimHistoryToggle === 'function') { + claimHistoryToggle(); + } + toggleRequiredFields(); restoreActualLeadGstNumber(); restoreActualLeadContactDetails(); diff --git a/app/Views/leads_form_handler.php b/app/Views/leads_form_handler.php index 426f43fe..0b12c3af 100644 --- a/app/Views/leads_form_handler.php +++ b/app/Views/leads_form_handler.php @@ -851,7 +851,9 @@ if (isset($selected_lead_type)) { if (lead_type == 1 || lead_type == 3) { - $('.claim-row').hide(); + if (lead_type == 1 || !shouldShowClaimHistorySwitch(lead_type, policy_type_id)) { + $('.claim-row').hide(); + } if(!isExistingClient){ $('#exixting_client').prop('checked', false); diff --git a/app/Views/rfq/gpa.php b/app/Views/rfq/gpa.php index 8d29fd05..7fe37fb4 100644 --- a/app/Views/rfq/gpa.php +++ b/app/Views/rfq/gpa.php @@ -45,7 +45,7 @@ $savedClaims = !empty($lead_edit_data['fin_years_claims_array']) ? $lead_edit_data['fin_years_claims_array'] : []; $isClaimHistoryChecked = (isset($lead_edit_data['claim_history']) && (int) $lead_edit_data['claim_history'] === 1) || !empty($savedClaims); $showClaimHistorySwitch = isset($lead_edit_data['lead_type'], $lead_edit_data['policy_type_id']) - && (int) $lead_edit_data['lead_type'] === 2 + && in_array((int) $lead_edit_data['lead_type'], [2, 3], true) && in_array((int) $lead_edit_data['policy_type_id'], [1, 6, 7], true); ?> From 21594469bc8462283f6007f5587810d66f1d61cc Mon Sep 17 00:00:00 2001 From: Venkatesh Date: Sat, 16 May 2026 10:20:36 +0530 Subject: [PATCH 2/2] FIX_ISSUE --- app/Controllers/LeadsController.php | 126 ++++++++++++++-------------- 1 file changed, 64 insertions(+), 62 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 06876db1..7f347d6f 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -571,69 +571,71 @@ class LeadsController extends BaseController } - // $leadFormType = (int) ($postData['lead_form_type'] ?? 1); - // $postedPolicyTypeIds = array_map('intval', (array) ($postData['policy_type_id'] ?? [])); - // $isEbRenewalGpaClaimHistory = $leadFormType === 1 - // && (int) ($postData['lead_type'] ?? 0) === 2 - // && in_array(1, $postedPolicyTypeIds, true) - // && (int) ($postData['claim_history'] ?? 0) === 1; + $leadFormType = (int) ($postData['lead_form_type'] ?? 1); + $postedPolicyTypeIds = array_map('intval', (array) ($postData['policy_type_id'] ?? [])); + $claimHistoryPolicyTypes = [1, 6, 7]; + $hasClaimHistoryPolicy = count(array_intersect($postedPolicyTypeIds, $claimHistoryPolicyTypes)) > 0; + $isEbClaimHistory = $leadFormType === 1 + && in_array((int) ($postData['lead_type'] ?? 0), [2, 3], true) + && $hasClaimHistoryPolicy + && (int) ($postData['claim_history'] ?? 0) === 1; - // if ($isEbRenewalGpaClaimHistory) { - // $rules['first_year.*'] = [ - // 'rules' => 'required|regex_match[/^\d{4}-\d{4}$/]', - // 'errors' => [ - // 'required' => 'Claim Year is required for all entries.', - // 'regex_match' => 'Year must be in format YYYY-YYYY.', - // ], - // ]; - // $rules['emp_id.*'] = [ - // 'rules' => 'required', - // 'errors' => ['required' => 'Employee ID is required in Claim History.'], - // ]; - // $rules['emp_name.*'] = [ - // 'rules' => 'required', - // 'errors' => ['required' => 'Employee Name is required in Claim History.'], - // ]; - // $rules['gender.*'] = [ - // 'rules' => 'required|in_list[Female,Male]', - // 'errors' => [ - // 'required' => 'Gender is required in Claim History.', - // 'in_list' => 'Gender must be Female or Male.', - // ], - // ]; - // $rules['designation.*'] = [ - // 'rules' => 'required', - // 'errors' => ['required' => 'Designation is required in Claim History.'], - // ]; - // $rules['sum_insured.*'] = [ - // 'rules' => 'required|numeric', - // 'errors' => [ - // 'required' => 'Sum Insured is required in Claim History.', - // 'numeric' => 'Sum Insured must be a number.', - // ], - // ]; - // $rules['first_death_date.*'] = [ - // 'rules' => 'required|regex_match[/^[0-9]{2}-([0-9]{2}|[A-Za-z]{3})-[0-9]{4}$/]', - // 'errors' => [ - // 'required' => 'Date of Death is required.', - // 'regex_match' => 'Date of Death must be in DD-MM-YYYY or DD-MMM-YYYY format.', - // ], - // ]; - // $rules['first_cause_of_death.*'] = [ - // 'rules' => 'required|in_list[natural_death,suicide,accident,cardiac_arrest,septic_shock,heart_attack]', - // 'errors' => [ - // 'required' => 'Nature/Cause Of Death is required.', - // 'in_list' => 'Nature/Cause Of Death is invalid.', - // ], - // ]; - // $rules['first_claim_amount.*'] = [ - // 'rules' => 'required|numeric', - // 'errors' => [ - // 'required' => 'Claim/Settled Amount is required.', - // 'numeric' => 'Claim/Settled Amount must be a number.', - // ], - // ]; - // } + if ($isEbClaimHistory) { + $rules['first_year.*'] = [ + 'rules' => 'required|regex_match[/^\d{4}-\d{4}$/]', + 'errors' => [ + 'required' => 'Claim Year is required for all entries.', + 'regex_match' => 'Year must be in format YYYY-YYYY.', + ], + ]; + $rules['emp_id.*'] = [ + 'rules' => 'required', + 'errors' => ['required' => 'Employee ID is required in Claim History.'], + ]; + $rules['emp_name.*'] = [ + 'rules' => 'required', + 'errors' => ['required' => 'Employee Name is required in Claim History.'], + ]; + $rules['gender.*'] = [ + 'rules' => 'required|in_list[Female,Male]', + 'errors' => [ + 'required' => 'Gender is required in Claim History.', + 'in_list' => 'Gender must be Female or Male.', + ], + ]; + $rules['designation.*'] = [ + 'rules' => 'required', + 'errors' => ['required' => 'Designation is required in Claim History.'], + ]; + $rules['sum_insured.*'] = [ + 'rules' => 'required|numeric', + 'errors' => [ + 'required' => 'Sum Insured is required in Claim History.', + 'numeric' => 'Sum Insured must be a number.', + ], + ]; + $rules['first_death_date.*'] = [ + 'rules' => 'required|regex_match[/^[0-9]{2}-([0-9]{2}|[A-Za-z]{3})-[0-9]{4}$/]', + 'errors' => [ + 'required' => 'Date of Death is required.', + 'regex_match' => 'Date of Death must be in DD-MM-YYYY or DD-MMM-YYYY format.', + ], + ]; + $rules['first_cause_of_death.*'] = [ + 'rules' => 'required|in_list[natural_death,suicide,accident,cardiac_arrest,septic_shock,heart_attack]', + 'errors' => [ + 'required' => 'Nature/Cause Of Death is required.', + 'in_list' => 'Nature/Cause Of Death is invalid.', + ], + ]; + $rules['first_claim_amount.*'] = [ + 'rules' => 'required|numeric', + 'errors' => [ + 'required' => 'Claim/Settled Amount is required.', + 'numeric' => 'Claim/Settled Amount must be a number.', + ], + ]; + } // 1. MANUALLY VALIDATE FILES BEFORE PROCESSING // $allFiles = $this->request->getFiles();