From 38e218f585032a223c885600f4c69d626d672b58 Mon Sep 17 00:00:00 2001 From: Venkatesh Date: Wed, 8 Apr 2026 17:26:30 +0530 Subject: [PATCH] FIX_RFQ_PLACEMENT_NOT_SENT_ISSUE --- app/Controllers/LeadsController.php | 72 ++++++++++++++++++----------- 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index fd5ab968..7a8636e7 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -2126,6 +2126,7 @@ class LeadsController extends BaseController $data = $this->convertJsonForQCR($data, $type); } // dd($data); + $lead_data = []; if ($rfq_data['lead_type'] == 1) { if (in_array($rfq_data['policy_type_id'], [2, 3, 4, 5])) { @@ -2152,6 +2153,12 @@ class LeadsController extends BaseController // 'TPA' => $rfq_data['tpa_name'] ?? " - ", 'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "", ]; + }else { + + $lead_data = [ + 'Insured' => $rfq_data['client_name'], + 'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "" + ]; } } else { @@ -2239,6 +2246,11 @@ class LeadsController extends BaseController // 'TPA' => $rfq_data['tpa_name'] ?? " - ", // 'Total Lives at Inception' => $rfq_data['total_lives_at_incept'], ]; + } else { + $lead_data = [ + 'Insured' => $rfq_data['client_name'], + 'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "" + ]; } } // print_r($lead_data); die; @@ -2274,39 +2286,43 @@ class LeadsController extends BaseController $maxWidthA = 0; $maxWidthB = 0; - foreach ($lead_data as $key => $value) { + // dd($lead_data); - // Merge A:B for key and C:D for value - $mergeRangeKey = "A{$rowNumber}:B{$rowNumber}"; - // $mergeRangeValue = "C{$rowNumber}"; - $sheet->mergeCells($mergeRangeKey); - // $sheet->mergeCells($mergeRangeValue); + if(! empty($lead_data)) { + foreach ($lead_data as $key => $value) { - // Set values in merged cells - $sheet->setCellValue("A{$rowNumber}", $key); - $sheet->setCellValue("C{$rowNumber}", $value); + // Merge A:B for key and C:D for value + $mergeRangeKey = "A{$rowNumber}:B{$rowNumber}"; + // $mergeRangeValue = "C{$rowNumber}"; + $sheet->mergeCells($mergeRangeKey); + // $sheet->mergeCells($mergeRangeValue); - // // Apply styles for alignment and bold text in A:B - // $sheet->getStyle($mergeRangeKey)->applyFromArray([ - // 'font' => ['bold' => true], - // 'alignment' => [ - // 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER, - // 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER, - // ], - // ]); + // Set values in merged cells + $sheet->setCellValue("A{$rowNumber}", $key); + $sheet->setCellValue("C{$rowNumber}", $value); - // Apply bold style to B column if the key is "Insured" - if ($key == "Insured") { - $sheet->getStyle("C{$rowNumber}")->applyFromArray([ - 'font' => ['bold' => true], - ]); + // // Apply styles for alignment and bold text in A:B + // $sheet->getStyle($mergeRangeKey)->applyFromArray([ + // 'font' => ['bold' => true], + // 'alignment' => [ + // 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER, + // 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER, + // ], + // ]); + + // Apply bold style to B column if the key is "Insured" + if ($key == "Insured") { + $sheet->getStyle("C{$rowNumber}")->applyFromArray([ + 'font' => ['bold' => true], + ]); + } + + // Track max width needed for columns + $maxWidthA = max($maxWidthA, mb_strlen($key)); + $maxWidthB = max($maxWidthB, mb_strlen($value)); + + $rowNumber++; } - - // Track max width needed for columns - $maxWidthA = max($maxWidthA, mb_strlen($key)); - $maxWidthB = max($maxWidthB, mb_strlen($value)); - - $rowNumber++; } // Set column width based on max content length (adjusted for padding)