From 87c6ed2d00cbfa0056300d00961fb8895d126d7f Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 24 Oct 2025 10:28:40 +0530 Subject: [PATCH] FIX_EB_EXCEL --- app/Controllers/LeadsController.php | 122 ++++++++++++++++++---------- 1 file changed, 78 insertions(+), 44 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 59608e7e..115b5176 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -1776,6 +1776,24 @@ class LeadsController extends BaseController // dd($rfq_data, $lead_id, $type, $propsal_and_insurer); // print_r($propsal_and_insurer); die; + // print_r($is_placement); die; + + $data = json_decode($rfq_data['json'], true); + $sheetName = 'Worksheet'; + if ($type == 2) { + $sheetName = 'QCR'; + // $propsal_and_insurer = "Proposal 1-ICICIPRU-ICICI001"; + $data = $this->convertJsonForQCR($data, $type); + if ($propsal_and_insurer !== null) { + list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2); + $data = $this->transformProposelData($data, $proposal_key, $insurer_key); + $is_placement = true; + $sheetName = 'Placement'; + } + } else if ($type == 1) { + $sheetName = 'RFQ'; + $data = $this->convertJsonForQCR($data, $type); + } // dd($data); if ($rfq_data['lead_type'] == 1) { @@ -1808,36 +1826,71 @@ class LeadsController extends BaseController } else { if (in_array($rfq_data['policy_type_id'], [2, 3, 4, 5])) { - $lead_data = [ + if($is_placement == true){ + $lead_data = [ - 'Insured' => $rfq_data['client_name'], - 'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "", + 'Insured' => $rfq_data['client_name'], + 'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "", - // '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 ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided", - 'Insurer' => $rfq_data['insurer_name'] ?? " - ", - 'TPA' => $rfq_data['tpa_name'] ?? " - ", + 'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided", + 'Insurer' => $rfq_data['insurer_name'] ?? " - ", + 'TPA' => $rfq_data['tpa_name'] ?? " - ", - // 'Policy Run Days' => $rfq_data['policy_run_days'], - // 'Inception Premium' => formatIndianCurrency($rfq_data['premium_at_inception']), - // 'Premium as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['premium_date']), - // 'Earned Premium' => formatIndianCurrency(intval($rfq_data['earned_premium'])), - // 'Incurred Claims as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['incurred_claims']), - // 'Annualised Claims' => formatIndianCurrency(intval($rfq_data['annualised_claims'])), - // 'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'] . " %", - // 'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'] . " %", - ]; + // 'Policy Run Days' => $rfq_data['policy_run_days'], + // 'Inception Premium' => formatIndianCurrency($rfq_data['premium_at_inception']), + // 'Premium as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['premium_date']), + // 'Earned Premium' => formatIndianCurrency(intval($rfq_data['earned_premium'])), + // 'Incurred Claims as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['incurred_claims']), + // 'Annualised Claims' => formatIndianCurrency(intval($rfq_data['annualised_claims'])), + // 'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'] . " %", + // 'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'] . " %", + ]; + }else{ + $lead_data = [ + 'Insured' => $rfq_data['client_name'], + 'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "", + + 'No of Employees at Inception' => $is_placement ? '-' : $rfq_data['incept_emp_count'], + 'No of Dependents at Inception' => $is_placement ? '-' : $rfq_data['incept_dept_count'], + 'Total Lives at Inception ' => $is_placement ? '-' : $rfq_data['incept_no_of_lives'], + + 'No of Employees at Expiry' => $is_placement ? '-' : $rfq_data['exp_emp_count'], + 'No of Dependents at Expiry' => $is_placement ? '-' : $rfq_data['exp_dept_count'], + 'Total Lives at Expiry ' => $is_placement ? '-' : $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'], + + 'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) + ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) + : "To be decided", + + 'Insurer' => $rfq_data['insurer_name'] ?? " - ", + 'TPA' => $rfq_data['tpa_name'] ?? " - ", + + 'Policy Run Days' => $is_placement ? '-' : $rfq_data['policy_run_days'], + 'Inception Premium' => $is_placement ? '-' : formatIndianCurrency($rfq_data['premium_at_inception']), + 'Premium as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => $is_placement ? '-' : formatIndianCurrency($rfq_data['premium_date']), + 'Earned Premium' => $is_placement ? '-' : formatIndianCurrency(intval($rfq_data['earned_premium'])), + 'Incurred Claims as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => $is_placement ? '-' : formatIndianCurrency($rfq_data['incurred_claims']), + 'Annualised Claims' => $is_placement ? '-' : formatIndianCurrency(intval($rfq_data['annualised_claims'])), + 'Incurred Claims Ratio' => $is_placement ? '-' : $rfq_data['incurred_claims_ratio'] . " %", + 'Earned Claims Ratio' => $is_placement ? '-' : $rfq_data['earned_claims_ratio'] . " %", + ]; + } } else if (in_array($rfq_data['policy_type_id'], [1, 6, 7])) { $lead_data = [ @@ -1857,27 +1910,8 @@ class LeadsController extends BaseController ]; } } + // print_r($lead_data); die; - $data = json_decode($rfq_data['json'], true); - // dd($data); - - $sheetName = 'Worksheet'; - if ($type == 2) { - $sheetName = 'QCR'; - // $propsal_and_insurer = "Proposal 1-ICICIPRU-ICICI001"; - $data = $this->convertJsonForQCR($data, $type); - if ($propsal_and_insurer !== null) { - list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2); - $data = $this->transformProposelData($data, $proposal_key, $insurer_key); - $is_placement = true; - $sheetName = 'Placement'; - } - } else if ($type == 1) { - $sheetName = 'RFQ'; - $data = $this->convertJsonForQCR($data, $type); - // dd($data); - } - // dd($data); $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet();