diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 8ecd1e50..d3bc9b8b 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -100,7 +100,9 @@ class LeadsController extends BaseController $this->issuer = [1 => 'JIBS', 2 => 'Nhance']; $this->clientType = [1 => 'Group', 2 => 'Individual']; $this->leadType = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over']; - $this->buisnessType = [1 => 'Industrial', 2 => 'Non Industrial']; + $data = $this->kycEntityTypeModel->where('is_active', 1)->findAll(); + $this->buisnessType = array_column($data, 'name', 'id'); + // $this->buisnessType = [1 => 'Public Sector', 2 => 'Private Sector',3=> 'Trust',4 => 'Proprietorship',5 => 'Partnership',6 => 'Private',7 => 'Individual']; $this->leadsStatus = [ 'queued' => 'In-Queued', 'qcr_sent' => 'QCR sent', @@ -730,9 +732,11 @@ class LeadsController extends BaseController $data['product'] = $this->leadsModel->select("policy_type.policy_type")->join('policy_type', 'leads.policy_type_id = policy_type.id')->where('leads.id', $id)->first()['policy_type']; // $data['lead_register_data'] = json_decode($data['lead_data']['custom_fields']); // dd($data['lead_register_data']); + // $data['entity_type'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll(); + $data['buisness_type'] = $this->buisnessType; + // dd($data); $data['client_type'] = $this->clientType; - $data['buisness_type'] = $this->buisnessType; $this->loadLayout('view_rfq_non_eb', $data); } } @@ -2076,6 +2080,7 @@ class LeadsController extends BaseController ->where('leads.id', $lead_id) ->first(); + // log_message('error', 'Lead Data' . json_encode($lead_data)); // print_r($lead_data ); die; $cc_mails = []; @@ -2236,9 +2241,9 @@ class LeadsController extends BaseController foreach ($recipient_data as $recipient) { $message = $original_message; - $message = str_replace("{{RECIPIENT_NAME}}", $recipient['name'], $message); - $message = str_replace("{{CLIENT_NAME}}", $lead_data['client_name'], $message); - $message = str_replace("{{POLICY_LONG_NAME}}", $lead_data['long_name'], $message); + $message = str_replace("{{RECIPIENT_NAME}}", $recipient['name'] != "" ? $recipient['name'] :" ", $message); + $message = str_replace("{{CLIENT_NAME}}", $lead_data['client_name'] != "" ? $lead_data['client_name'] : "", $message); + $message = str_replace("{{POLICY_LONG_NAME}}",$lead_data['long_name'] != ""? $lead_data['long_name'] : "", $message); $message = str_replace("{{POLICY_START_DATE}}", change_date_format($lead_data['policy_start_date'], 'Y-m-d', 'd-m-Y'), $message); $message = str_replace("{{DURATION}}", calculate_days_bw_dates($lead_data['policy_end_date'] ?? "", $lead_data['policy_start_date'] ?? "")->days, $message) ?? '--'; @@ -2809,7 +2814,7 @@ class LeadsController extends BaseController $value = $cellData['display_content'] ?? ''; // Skip unwanted keys - if (in_array($parentth, ['SNO', 'Particulars', 'Action']) || $subth === 'Quote Asked') { + if (in_array($parentth, ['SNO', 'Particulars', 'Action']) || $subth === 'Sum Insured' || $subth === 'Fidelity Limit') { continue; } @@ -3217,11 +3222,11 @@ class LeadsController extends BaseController $sheet->getColumnDimension('B')->setWidth($maxWidthA * 1.2); $sheet->getColumnDimension('C')->setWidth($maxWidthB * 1.2); - $rowNumber += 2; + $rowNumber += 1; //Policy Registration if (!empty($policy_registration_data)) { foreach ($policy_registration_data as $key => $value) { - + // kint::dump($value); $startRow = $rowNumber; // Track where the block starts // Title Row @@ -3308,6 +3313,24 @@ class LeadsController extends BaseController $rowNumber++; } + if (isset($value['policyDetails']) && !empty($value['policyDetails'])) { + // Type of Business + $sheet->mergeCells("A{$rowNumber}:B{$rowNumber}"); + $sheet->setCellValue("A{$rowNumber}", "Terrorism"); + $sheet->setCellValue("C{$rowNumber}", ucfirst($value['policyDetails']['terrorism'] ?? 'No')); + + $sheet->getStyle("A{$rowNumber}")->applyFromArray([ + 'font' => ['bold' => true], + 'alignment' => [ + 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER, + 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER, + ], + ]); + + $rowNumber++; + + } + $endRow = $rowNumber - 1; // Block ends at previous row // Apply border to the whole block @@ -3320,8 +3343,9 @@ class LeadsController extends BaseController ], ]); - $rowNumber += 2; // Add space before the next block + $rowNumber += 1; // Add space before the next block } + // die(); } //Table Data @@ -3425,6 +3449,18 @@ class LeadsController extends BaseController } } + // For the subheader row, merge B and C and set the value + $sheet->setCellValue("B{$subHeaderRow}", "Sum Insured"); + $sheet->mergeCells("B{$subHeaderRow}:C{$subHeaderRow}"); + $sheet->getStyle("B{$subHeaderRow}:C{$subHeaderRow}")->applyFromArray([ + 'font' => ['bold' => true], + 'alignment' => [ + 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER, + 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER, + ], + ]); + + // Apply border to the header range $prevColumn4 = $this->getPreviousColumn($columnLetter); $headerRange = "A{$rowNumber}:" . "{$prevColumn4}" . "{$subHeaderRow}"; @@ -3441,7 +3477,9 @@ class LeadsController extends BaseController $sheet->getRowDimension($rowNumber)->setRowHeight(25); // Header row height $sheet->getRowDimension($subHeaderRow)->setRowHeight(20); // Subheader row height - $rowNumber = $subHeaderRow + 2; + // $rowNumber = $subHeaderRow + 2; + $rowNumber = $subHeaderRow + 1; + $column_data = $data['table_data']['data']; // dd($column_data); $serial_no = 1; @@ -3729,7 +3767,7 @@ class LeadsController extends BaseController $row['data'] = array_filter( $row['data'], function ($item) { - return in_array($item['subth'], ['Quote asked', '-']); + return in_array($item['subth'], ['Sum Insured', '-',"Liability Limit"]); } ); @@ -3818,7 +3856,7 @@ class LeadsController extends BaseController if ($subHeader === $insurer) { $headerData[] = [ 'parentHeader' => $header['parentHeader'], - 'subHeaders' => ['Quote asked', $subHeader] + 'subHeaders' => ['Sum Insured', $subHeader] ]; break 2; // Exit both loops after match is found } @@ -3851,8 +3889,8 @@ class LeadsController extends BaseController $filteredData[] = $item; } - // Include Proposal with Quote Asked - if ($item['parentth'] === $proposal && $item['subth'] === "Quote asked") { + // Include Proposal with Sum Insured + if ($item['parentth'] === $proposal && ($item['subth'] === "Sum Insured" || $item['subth'] === "Liability Limit")) { $filteredData[] = $item; } diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index fc2ee0f0..265d1f32 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -884,7 +884,7 @@ " . $value['policy_type'] . ""; } } diff --git a/app/Views/policyRegisterModel.php b/app/Views/policyRegisterModel.php index 88b8f14c..fc5170e3 100644 --- a/app/Views/policyRegisterModel.php +++ b/app/Views/policyRegisterModel.php @@ -217,11 +217,11 @@
-
+
@@ -579,11 +579,12 @@ policyRiskAddress = groupedData; console.log("Grouped Data as Objects: ", policyRiskAddress); - if (productSelectionData.singleProduct == 'on') { - savePolicyDataLocal(); - } else { + // if (productSelectionData.singleProduct == 'on') { + // savePolicyDataLocal(); + // } else { riskSplitup(); - } + // } + }); $("#policyDetailsForm").submit(function(event) { @@ -652,6 +653,14 @@ hideAndShowBurglary(); }) + }else{ + // alert("you got ir"); + policyRiskAddress.forEach(function() { + // console.log("increment count is ", increment2) + addHTMLInputForRiskSplitUP(); + validatePolicyBasedOnProductSelection(); + hideAndShowBurglary(); + }) } } else { if (contianertoCheck.innerHTML == "") { @@ -713,23 +722,23 @@
- +
-
+
- +
- +
- +
- +

@@ -872,7 +881,7 @@
- +
@@ -920,26 +929,13 @@ `; - // newRow2.innerHTML += ` - //
- //
- // - //
- //
- //
- //
- // - //
- //
- - // `; - container.appendChild(newRow); // container.appendChild(newRow2); const selectElement = document.getElementById(`select_location_${increment}`); selectElement.innerHTML = ""; for (let i = 1; i <= policyDetailsData.location_no; i++) { + console.log("location no : ", policyDetailsData.location_no); const option = document.createElement('option'); option.value = `Location ${i}`; option.textContent = `Location ${i}`; @@ -957,37 +953,33 @@ }); - $(document).on('click', '.duplicate-btn', function() { - - - // console.log("button is clicked"); - // console.log("increment cout ", increment); - + $(document).on('click', '.duplicate-btn', function () { if (policyDetailsData.location_no >= increment) { const $rowToClone = $(this).closest('.form-row'); + // Destroy Select2 for the current and previous occupancy fields + $(`#occupancy_${increment}`).select2('destroy'); + $(`#occupancy_${increment - 1}`).select2('destroy'); + // Clone the row const $clone = $rowToClone.clone(); - $clone.find('.select2-hidden-accessible').each(function() { + // Clean up select2 artifacts from the clone + $clone.find('.select2-hidden-accessible').each(function () { $(this).select2('destroy'); }); - $clone.find('.select2-container').remove(); - // Increment the counter - - - // Update all IDs and reset values in the clone - $clone.find('[id]').each(function() { + // Update all IDs in the clone + $clone.find('[id]').each(function () { const oldId = $(this).attr('id'); const newId = oldId.replace(/_(\d+)$/, `_${increment}`); $(this).attr('id', newId); }); - // Update labels to match new IDs - $clone.find('label').each(function() { + // Update all labels + $clone.find('label').each(function () { const oldFor = $(this).attr('for'); if (oldFor) { const newFor = oldFor.replace(/_(\d+)$/, `_${increment}`); @@ -998,18 +990,35 @@ // Insert the cloned row after the original $clone.insertAfter($rowToClone); - let selectedLocation = $(`#select_location_${increment}`).val(); - $(`#select_location_${increment} option[value="${selectedLocation}"]`).remove(); - $(`#occupancy_${increment}`).select2(); + // Refill and update the select_location dropdown + const selectElement = document.getElementById(`select_location_${increment}`); + selectElement.innerHTML = ""; + for (let i = 1; i <= policyDetailsData.location_no; i++) { + const option = document.createElement('option'); + option.value = `Location ${i}`; + option.textContent = `Location ${i}`; + selectElement.appendChild(option); + } + + for (let i = 1;i; var contact_email = ""; var panNo = ; + var buisnessType = ; // console.log("client_type : ".client_type); if (lead_data) { // lead_data = JSON.parse(lead_data); @@ -1407,11 +1420,15 @@ } } + $("#client_type").val(client_type).trigger("change"); $("#insured_name").val(clientName); $("#address1").val(lead_data.address); + $("#pin_code").val(lead_data.pincode); $("#mobile").val(mobile); $("#email").val(contact_email); + console.log("buisness type : ", buisnessType); + $("#type_of_buisness").val(buisnessType); // var policy_type = lead_data.policy_type_id; } } @@ -1544,23 +1561,26 @@ } - function hideShowBasement(incrementFromBasement) { - let isBasement = $(`#isBasement_${incrementFromBasement}`).is(":checked"); + function hideShowBasement(element) { + let elementID = element.id; + let increment = elementID.split("_").pop(); + + let isBasement = $(`#isBasement_${increment}`).is(":checked"); // Get the label associated with the input - let label = $(`label[for='basementSI_${incrementFromBasement}']`); + let label = $(`label[for='basementSI_${increment}']`); if (isBasement) { - $(`#basementSI_${incrementFromBasement}`).parent().show(); - $(`#basementSI_${incrementFromBasement}`).prop("required", "required"); + $(`#basementSI_${increment}`).parent().show(); + $(`#basementSI_${increment}`).prop("required", "required"); // Add * if not already there if (label.find(".text-danger").length === 0) { label.append('*'); } } else { - $(`#basementSI_${incrementFromBasement}`).parent().hide(); - $(`#basementSI_${incrementFromBasement}`).removeAttr("required"); + $(`#basementSI_${increment}`).parent().hide(); + $(`#basementSI_${increment}`).removeAttr("required"); // Remove * if exists label.find(".text-danger").remove(); diff --git a/app/Views/rfq/attachment_files.php b/app/Views/rfq/attachment_files.php index 711fbe84..1b77cfb6 100644 --- a/app/Views/rfq/attachment_files.php +++ b/app/Views/rfq/attachment_files.php @@ -4,7 +4,7 @@
- + diff --git a/app/Views/rfq/blu.php b/app/Views/rfq/blu.php index 93a1f048..c1dccbcb 100644 --- a/app/Views/rfq/blu.php +++ b/app/Views/rfq/blu.php @@ -20,7 +20,11 @@
-
+
+ + +
+
diff --git a/app/Views/rfq/bsu.php b/app/Views/rfq/bsu.php index 93a1f048..c1dccbcb 100644 --- a/app/Views/rfq/bsu.php +++ b/app/Views/rfq/bsu.php @@ -20,7 +20,11 @@
-
+
+ + +
+
diff --git a/app/Views/rfq/burglary.php b/app/Views/rfq/burglary.php index 93a1f048..c1dccbcb 100644 --- a/app/Views/rfq/burglary.php +++ b/app/Views/rfq/burglary.php @@ -20,7 +20,11 @@
-
+
+ + +
+
diff --git a/app/Views/rfq/car.php b/app/Views/rfq/car.php index 7dfc106b..f179e081 100644 --- a/app/Views/rfq/car.php +++ b/app/Views/rfq/car.php @@ -68,7 +68,11 @@
-
+
+ + +
+
diff --git a/app/Views/rfq/cgl.php b/app/Views/rfq/cgl.php index d007dd7d..9468b8d5 100644 --- a/app/Views/rfq/cgl.php +++ b/app/Views/rfq/cgl.php @@ -81,7 +81,11 @@
-
+
+ + +
+
diff --git a/app/Views/rfq/cpm.php b/app/Views/rfq/cpm.php index 532554f2..ac3a5341 100644 --- a/app/Views/rfq/cpm.php +++ b/app/Views/rfq/cpm.php @@ -68,7 +68,11 @@
-
+
+ + +
+
diff --git a/app/Views/rfq/cyber_crime.php b/app/Views/rfq/cyber_crime.php index 5cc31107..27fcac5a 100644 --- a/app/Views/rfq/cyber_crime.php +++ b/app/Views/rfq/cyber_crime.php @@ -14,7 +14,11 @@
-
+
+ + +
+
diff --git a/app/Views/rfq/do.php b/app/Views/rfq/do.php index e9c4e4a8..01efd463 100644 --- a/app/Views/rfq/do.php +++ b/app/Views/rfq/do.php @@ -35,7 +35,11 @@
-
+
+ + +
+
diff --git a/app/Views/rfq/eo.php b/app/Views/rfq/eo.php index 85da140a..8832716e 100644 --- a/app/Views/rfq/eo.php +++ b/app/Views/rfq/eo.php @@ -35,7 +35,11 @@
-
+
+ + +
+
diff --git a/app/Views/rfq/marine.php b/app/Views/rfq/marine.php index a4d68fba..528b6e7b 100644 --- a/app/Views/rfq/marine.php +++ b/app/Views/rfq/marine.php @@ -178,7 +178,11 @@
-
+
+ + +
+
diff --git a/app/Views/rfq/money.php b/app/Views/rfq/money.php index e010d772..59c6ea89 100644 --- a/app/Views/rfq/money.php +++ b/app/Views/rfq/money.php @@ -67,7 +67,11 @@
-
+
+ + +
+
diff --git a/app/Views/rfq/office.php b/app/Views/rfq/office.php index 237bfd29..b958a131 100644 --- a/app/Views/rfq/office.php +++ b/app/Views/rfq/office.php @@ -27,6 +27,10 @@
+
+ + +
diff --git a/app/Views/rfq/sfsp.php b/app/Views/rfq/sfsp.php index f17ee676..54f39441 100644 --- a/app/Views/rfq/sfsp.php +++ b/app/Views/rfq/sfsp.php @@ -35,7 +35,11 @@
-
+
+ + +
+
diff --git a/app/Views/rfq/wc.php b/app/Views/rfq/wc.php index cd374464..150eae7b 100644 --- a/app/Views/rfq/wc.php +++ b/app/Views/rfq/wc.php @@ -33,7 +33,11 @@
-
+
+ + +
+
diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index fc6193a6..e0abbc8c 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -516,10 +516,13 @@
\ No newline at end of file