diff --git a/app/Config/Routes.php b/app/Config/Routes.php index ede8146b..dfe10c9b 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -19,7 +19,7 @@ $routes->get("update_rack_rate_json", "ClientController::updateRackRateJson"); $routes->get("updatajson", "EmpDataServiceController::updatajson"); $routes->get("view", "EmployeeController::viewECard/$1"); // $routes->get("exportQCRandRFQ", "LeadsController::exportQCRandRFQ"); - +$routes->get("smapletest", "ClientController::smapletest"); $routes->post("add_advertise_image", "AppContentManagementController::add_advertise_image"); @@ -301,7 +301,6 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("get_client_policy_list_for_remainder/(:any)", "EmployeeController::get_client_policy_list_for_remainder/$1"); $routes->get("get_client_branch_data/(:any)", "ClientController::get_client_branch_data/$1"); $routes->get("getLevelContects", "LeadsController::getLevelContects"); - }); $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { @@ -347,6 +346,7 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) { $routes->get("list/(:any)", "LeadsController::getLeadDataForEdit/$1"); $routes->get("sendMail", "LeadsController::sendMailWithAttachement"); $routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1"); + $routes->get("featchLeadDataAndInsertClient/(:any)", "LeadsController::featchLeadDataAndInsertClient/$1"); }); $routes->group("rfq", ["filter" => "authMVC"], function ($routes) { @@ -371,12 +371,12 @@ $routes->cli('cli/check_bounce_mail_cli', 'MasterController::testCheckBounceMail $routes->cli('cli/app_check_list', 'MasterController::appCheckList'); $routes->cli('cli/new_gdrive_token', 'GoogleDriveController::generateNewGoogleDriveAccessToken'); - //Employee login api's $routes->post("/employeeRest/verifyEmployeeNumber", "RestAuthenticationController::verifyEmployeeWithMobileNumber"); $routes->post("/employeeRest/getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); $routes->post("/employeeRest/verifyMpin", "RestAuthenticationController::verifyMpin"); $routes->post("/employeeRest/checkMpin", "RestAuthenticationController::checkMpin"); + //HR login api's $routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber"); $routes->post("/employeeRest/getVerifiedHrData", "RestAuthenticationController::getVerifiedHrData"); @@ -386,9 +386,6 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) { $routes->post("getId", "RestAuthenticationController::getUserIdFromToken"); }); - - - $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); @@ -431,17 +428,9 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { }); $routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification"); - - - - $routes->post("sendEmail", "EmployeeRestController::send_email"); - - - - // Ticketing System // Ticketing System End's diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index c6b3f152..78c8c7a5 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -38,6 +38,7 @@ use App\Models\PolicyTypeModel; use App\Models\PolicyTransactionModel; use App\Models\PolicyTransactionStatusModel; use App\Models\VehicleModel; +use App\Models\LeadsModel; use App\Controllers\EmpDataServiceController; use App\Controllers\GoogleDriveController; @@ -78,6 +79,7 @@ class ClientController extends AdminController protected $policyTransactionModel; protected $policyTransactionStatusModel; protected $vehicleModel; + protected $leadsModel; @@ -113,6 +115,14 @@ class ClientController extends AdminController $this->policyTransactionModel = new PolicyTransactionModel(); $this->policyTransactionStatusModel = new PolicyTransactionStatusModel(); $this->vehicleModel = new VehicleModel(); + $this->leadsModel = new LeadsModel(); + } + + public function smapletest(){ + + $headers = ['S.No','EMP ID','EMP NAME','DOB','GENDER','RELATIONSHIP','SUM INSURED','Date of Leaving','Policy End Date','No Of Days','Premium','Pro Rata Premium','GST','Total','Claim Status','ENDORSEMENT_ID']; + $filePath = generateExcelWithHeader($headers); + echo "Excel file created at: $filePath"; } public function testingForReviewMail($client_id = 77, $emp_code = 'MGL-004', $mail_active = 0) //this function for only tsesting some logics not use for business logic @@ -238,6 +248,7 @@ class ClientController extends AdminController $headerData['page_name'] = 'Client List'; $data['clientList'] = $this->clientModel->getCreatedByUserName(); $data['client_rm'] = $this->clientRMModel->getAllClientRM(); + $data['lead_data'] = $this->leadsModel->getLeadForInsertClientList(); // dd($data); @@ -1705,15 +1716,6 @@ class ClientController extends AdminController } - public function editUploadVehicleFile() {} - - public function listVehicleFiles() {} - - public function deleteVehicleFiles() {} - - - - public function getKycDocsById($id = null) { diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 569f1c65..27b68354 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -1417,7 +1417,11 @@ class EmployeeController extends AdminController $excelErrorData['excel_header'] = $excel_data[0]; unset($excel_data[0]); - if($event_type == 'inception' || $event_type == 'deletion'){ + // if($event_type == 'inception' || $event_type == 'deletion'){ + // array_pop($excel_data); + // } + + if($event_type == 'deletion'){ array_pop($excel_data); } diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index d359c7d9..2d4a68ef 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -215,6 +215,7 @@ class LeadsController extends BaseController 'branch_code' => $data['branch_code'], 'contact_person_name' => $data['contact_person_name'], 'contact_person_mobile' => $data['contact_person_mobile'], + 'contact_person_email' => $data['contact_person_email'], 'client_id' => $data['client_id'] ?? 0, 'client_branch_id' => $data['client_branch_id'] ?? 0, 'source_policy_id' => $data['source_policy_id'] ?? 0, @@ -394,8 +395,10 @@ class LeadsController extends BaseController return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create QCR", 'data' =>$data], 200); } + //-----RFQ and QCR EXPORT------------------------------------------------------------------------------------------------ + //export main route function public function exportQCRandRFQ($lead_id, $type, $export_type){ @@ -654,7 +657,8 @@ class LeadsController extends BaseController } - public function getLevelContects(){ + public function getLevelContects() + { $data = $this->levelContactModel->getContectForRFQ(); @@ -667,4 +671,134 @@ class LeadsController extends BaseController } + //----- Featch Lead data and insert Client ------------------------------------------------------------------------------------------- + + + + public function featchLeadDataAndInsertClient($lead_id) + { + $data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first(); + + if (!$data) { + return $this->respond(['status' => false, 'message' => 'Failed to create Client', 'data' => null], 200); + } + + $result = $this->createClientWithLeadData($data); + + if ($result) { + return $this->respond(['status' => true, 'message' => 'New Client created successfully', 'client_id' => $result, 'data' => $data], 200); + } + + return $this->respond(['status' => false, 'message' => 'Failed to create client', 'data' => $data], 200); + } + + public function createClientWithLeadData($data) + { + $client_data = $this->prepareClientData($data); + $client_id = $this->clientModel->insert($client_data); + + if ($client_id) { + $this->createClientBranchAndContactWithLeadData($data, $client_id); + } + + return $client_id; + } + + private function prepareClientData($data) + { + return [ + 'client_type' => $data['client_type'], + 'entity_type_id' => $data['entity_type_id'], + 'client_code' => $data['client_code'], + 'client_name' => $data['client_name'], + 'short_name' => $data['client_short_name'], + 'pan' => $data['pan'], + ]; + } + + public function createClientBranchAndContactWithLeadData($data, $client_id) + { + $branch_data = $this->prepareClientBranchData($data, $client_id); + $branch_id = $this->clientBranchModel->insert($branch_data); + + if ($branch_id) { + + $contact_data = $this->prepareContactData($data, $branch_id); + $this->levelContactModel->insert($contact_data); + + $this->createClientPolicyWithLeadData($data, $client_id, $branch_id); + } + + return $branch_id; + } + + + private function prepareClientBranchData($data, $client_id) + { + $default_unit = trim(($data['client_short_name'] ?? '') . '-' . ($data['branch_code'] ?? ''), '-'); + + return [ + 'client_id' => $client_id, + 'branch_name' => $data['branch_name'], + 'branch_code' => $data['branch_code'], + 'gst' => $data['gst'], + 'units' => json_encode([$default_unit]), + ]; + } + + private function prepareContactData($data, $branch_id) + { + return [ + 'name' => $data['contact_person_name'], + 'mobile' => $data['contact_person_mobile'], + 'email' => $data['contact_person_email'], + 'contact_type' => 'client', + 'ref_id' => $branch_id, + ]; + } + + public function createClientPolicyWithLeadData($data, $client_id, $branch_id) + { + $client_policy_data = $this->prepareClientPolicyData($data, $client_id, $branch_id); + return $this->clientPolicyModel->insert($client_policy_data); + } + + private function prepareClientPolicyData($data, $client_id, $branch_id) + { + $client_policy_data = [ + 'client_id' => $client_id, + 'client_branch_id' => $branch_id, + 'policy_type_id' => $data['policy_type_id'], + 'insurer_id' => $data['insurer_id'], + 'insurer_branch_id' => $data['insurer_branch_id'], + 'tpa_id' => $data['tpa_id'], + 'tpa_branch_id' => $data['tpa_branch_id'], + 'policy_start_date' => $data['policy_start_date'], + 'policy_end_date' => $data['policy_end_date'], + 'policy_status' => 1, + ]; + + $policy_type_id = $data['policy_type_id']; + if (in_array($policy_type_id, [1, 2, 6, 7])) { + $client_policy_data['is_addon'] = 1; // Base Policy + } elseif (in_array($policy_type_id, [4, 5])) { + $client_policy_data['is_addon'] = 2; // SI TOPUP + } elseif ($policy_type_id == 3) { + // if ($base_policy) { + // $data['is_addon'] = 3; // Dependent Addon + // } else { + $data['is_addon'] = 1; + // } + } + + return $client_policy_data; + } + + private function preparePolicyTermsFromRFQ($data) + { + + } + + + } diff --git a/app/Helpers/excel_import_export_helper.php b/app/Helpers/excel_import_export_helper.php index b7eb87c8..3355253e 100755 --- a/app/Helpers/excel_import_export_helper.php +++ b/app/Helpers/excel_import_export_helper.php @@ -972,3 +972,39 @@ if(!function_exists('query_construct_second_stage')){ } } +if (!function_exists('generateExcelWithHeader')) { + /** + * Generate an Excel file with the specified headers + * + * @param array $header The header row for the Excel file + * @param string $filename The name of the Excel file to be created + * @return string Path to the generated Excel file + */ + function generateExcelWithHeader(array $header, string $filename = 'InceptionHeader.xlsx') + { + // Create a new Spreadsheet + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + + // Set header row + $column = 'A'; + foreach ($header as $headerText) { + $sheet->setCellValue($column . '1', $headerText); + $column++; + } + + // // Style the header row (optional) + // $sheet->getStyle('A1:' . $column . '1')->getFont()->setBold(true); + // $sheet->getStyle('A1:' . $column . '1')->getAlignment()->setHorizontal('center'); + + // Define the file path + $filePath = WRITEPATH . 'uploads/' . $filename; // WRITEPATH is typically for writable directories + + // Save the file + $writer = new Xlsx($spreadsheet); + $writer->save($filePath); + + return $filePath; + } +} + diff --git a/app/Models/LeadsModel.php b/app/Models/LeadsModel.php index 9de34d05..705f1587 100644 --- a/app/Models/LeadsModel.php +++ b/app/Models/LeadsModel.php @@ -24,6 +24,7 @@ class LeadsModel extends Model 'branch_code', 'contact_person_name', 'contact_person_mobile', + 'contact_person_email', 'client_id', 'client_branch_id', 'source_policy_id', @@ -85,7 +86,8 @@ class LeadsModel extends Model return $data; } - public function getLeadDataForLising(){ + public function getLeadDataForLising() + { return $this->select(' leads.*, @@ -116,6 +118,14 @@ class LeadsModel extends Model ->findAll(); } + + public function getLeadForInsertClientList() + { + return $this + ->where('leads.is_active', 1) + ->where('leads.status', 'won') + ->findAll(); + } } diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 9cb36865..c9caf4c1 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -193,24 +193,30 @@ placeholder="Enter Branch Name" required> -
+
-
+
-
- +
+
+
+ + +
+
@@ -374,10 +380,9 @@ function getLeadsDataForEdit(input) { $('#gst').val(res.data.gst); $('#branch_name').val(res.data.branch_name); $('#branch_code').val(res.data.branch_code); - $('#contact_person_name').val(res.data - .contact_person_name); - $('#contact_person_mobile').val(res.data - .contact_person_mobile); + $('#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); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); @@ -461,6 +466,7 @@ function getBranchData(input) { $('#branch_code').val(res.data.branch_code); $('#contact_person_name').val(res.contact.name); $('#contact_person_mobile').val(res.contact.mobile); + $('#contact_person_email').val(res.contact.email); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); @@ -473,6 +479,7 @@ function getBranchData(input) { $('#branch_code').val(''); $('#contact_person_name').val(''); $('#contact_person_mobile').val(''); + $('#contact_person_email').val(''); console.log(res.message, 'warning'); } @@ -512,6 +519,7 @@ function getPolicyData(input) { $('#branch_code').val(res.data.branch_code); $('#contact_person_name').val(res.contact.name); $('#contact_person_mobile').val(res.contact.mobile); + $('#contact_person_email').val(res.contact.email); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); @@ -524,6 +532,7 @@ function getPolicyData(input) { $('#branch_code').val(''); $('#contact_person_name').val(''); $('#contact_person_mobile').val(''); + $('#contact_person_email').val(''); console.log(res.message, 'warning'); } @@ -827,6 +836,7 @@ $('#lead_type').change(function() { $('#branch_code').val(''); $('#contact_person_name').val(''); $('#contact_person_mobile').val(''); + $('#contact_person_email').val(''); } else { @@ -842,6 +852,7 @@ $('#lead_type').change(function() { $('#branch_code').val(''); $('#contact_person_name').val(''); $('#contact_person_mobile').val(''); + $('#contact_person_email').val(''); $('#client_type').val(''); $('#client_name').val(''); diff --git a/app/Views/view_rfq.php b/app/Views/view_rfq.php index 0874cb18..bd6f2240 100644 --- a/app/Views/view_rfq.php +++ b/app/Views/view_rfq.php @@ -179,6 +179,17 @@ body { color:red; } +.select2-selection__choice { + background-color: #0a8794 !important; + color: white !important; + font-weight: bold; +} + +.select2-selection__choice__remove { + color: white !important; + margin-right: 5px; +} + @@ -297,13 +308,13 @@ body {
@@ -374,6 +385,7 @@ $(document).ready(function() { $('#submitMail').attr('data-url', mail_url); console.log('RFQ_or_QCR:', RFQ_or_QCR); + }); $(document).ready(function() { @@ -430,13 +442,14 @@ const closeDialogBtn = document.getElementById('closeDialogBtn'); $('.remove-icon').on('click', function() { $('#familyFloaterDialog').css('display', 'none'); }); + var currentThrdottedMenu = ''; var proposal_colum_count = 1; var over_all_column_data = { "Proposal 1": { - "qcr": 0, - "stc": 0, + "qcr": 1, + "stc": 1, 'insurers': [] } }; @@ -468,7 +481,7 @@ function showFamilyFloaterDialogBox(target) { let hiddenInput = target.querySelector('input[type="hidden"]'); // alert(hiddenInput); let inputValue = hiddenInput ? hiddenInput.value : null; - console.log('hidden input value'); + // console.log('hidden input value'); console.log(inputValue); if (inputValue !== null && inputValue !== '') { //get stored familiy composition json if any in hidden input and display it @@ -723,12 +736,23 @@ function addSuggestionsToTable() { // Function to move add row button to last row function moveAddRowButton() { - + + console.log('table', rfqTable) const lastRow = rfqTable.rows[rfqTable.rows.length - 1]; - const actionCell = lastRow.cells[lastRow.cells.length - 1]; - actionCell.innerHTML = - ' QCR Client '; - document.getElementById('addRow').addEventListener('click', addRow); + const actionCell = lastRow.querySelector('.action'); + + if (actionCell && !actionCell.querySelector('#addRow')) { + actionCell.innerHTML += ' '; + document.getElementById('addRow').addEventListener('click', addRow); + } + + // const actionCell = lastRow.cells[lastRow.cells.length - 1]; + // actionCell.innerHTML = + // ' QCR Client '; + // document.getElementById('addRow').addEventListener('click', addRow); + + // const lastRow = rows[rows.length - 1]; + } // Event listener to handle row removal @@ -799,8 +823,8 @@ addQuoteButton.addEventListener('click', function() { //add new proposal in gobal array var new_proposal_array = {} over_all_column_data[new_proposal_name] = { - "ocr": 0, - "stc": 0, + "qcr": 1, + "stc": 1, 'insurers': [] }; console.log(over_all_column_data); @@ -1006,6 +1030,7 @@ function hideSuggestionBox() { } function addRow(e) { + let columnCount = rfqTable.rows[1].cells.length; const newRow = rfqTable.insertRow(); @@ -1246,8 +1271,8 @@ function addInsurer(event) { //add insurer into over all column data pushInsurerInArray(proposal_name, { 'ins_name': (insurerName.split('-')[0]), - 'qcr': 0, - 'stc': 0, + 'qcr': 1, + 'stc': 1, 'display_name': insurerName }); } @@ -1524,6 +1549,9 @@ function checkExistingInsurer(proposal_name, insurer_name) { } function pushInsurerInArray(proposal_name, insurer_arr) { + + console.log('pushInsurerInArray function called'); + proposal_name = proposal_name.trim(); if (over_all_column_data[proposal_name]) { over_all_column_data[proposal_name].insurers.push(insurer_arr); @@ -1638,6 +1666,7 @@ function changeState(event) { console.log(type); if (['qcrProposal', 'sendClientProposal'].includes(type)) { + console.log('Proposal'); const closestTh = event.target.closest('th'); let proposal_name = closestTh.innerText.split('⋮')[0].trim(); @@ -2166,15 +2195,15 @@ function appendInput(data) { const url = '?lead_id=' +lead_id; html = ` -
+
- +
`; if (!data.contact_person_email) { html += ` -
+ `; @@ -2208,7 +2237,13 @@ function appendInput(data) { // Initialize select2 for the dropdown if insurerContact is present if ($('#insurerContact').length) { - $('#insurerContact').select2(); + + $('#insurerContact').select2({ + placeholder: 'Select an insurer', + }); + + $("textarea.select2-search__field").attr('rows', '1'); + $("textarea.select2-search__field").css('resize', 'none'); } } @@ -2266,6 +2301,7 @@ function ajaxRequest(url){ }); } + //-------------------------------------------------------------------------------------------------------------------------------------------- function tableToJson() { @@ -2363,7 +2399,7 @@ function tableToJson() { if (input) { content = input.value; - console.log('hidden input value', content); + // console.log('hidden input value', content); } else { content = cells[dataIndex].innerText; } @@ -2435,10 +2471,12 @@ function tableToJson() { }); localStorage.setItem('data', d); + console.log({ headers, data }); + jsonToTable(JSON.parse(d)); } @@ -2597,7 +2635,7 @@ function jsonToTable(json) { }); }); - console.log('proposel_color_count', proposel_color_count); + // console.log('proposel_color_count', proposel_color_count); thead.appendChild(parentHeaderRow); thead.appendChild(subHeaderRow); @@ -2704,6 +2742,8 @@ function jsonToTable(json) { $(document).ready(function () { $('#submitData').on('click', async function () { + console.log(over_all_column_data); + try { $('.loader').fadeIn(); @@ -2760,8 +2800,11 @@ function jsonToTable(json) { }); }); - $(document).ready(function () { + $(document).ready(function () { $('#submitQCRData').on('click', async function () { + + console.log(over_all_column_data); + try { $('.loader').fadeIn(); @@ -2820,7 +2863,6 @@ function jsonToTable(json) { async function tableToJsonForFormSubmit() { return new Promise((resolve) => { - const headers = []; const data = []; const table = document.getElementById('rfqTable'); @@ -2861,7 +2903,9 @@ function jsonToTable(json) { header.subHeaders.forEach(subHeader => { const cell = cells[dataIndex]; let content = cells[dataIndex]?.innerText || ''; - const inputType = suggestions[rowId]['type']; + + // Ensure suggestions[rowId] exists + const inputType = suggestions[rowId]?.type; // Handle 'text' input types if (inputType === "text") { @@ -2874,11 +2918,9 @@ function jsonToTable(json) { }; } else { const input = cell.querySelector('input'); - // console.log('input cell', input) - if (input) { content = input.value; - console.log('hidden input value', content); + // console.log('hidden input value', content); } else { content = cells[dataIndex].innerText; } @@ -2936,10 +2978,13 @@ function jsonToTable(json) { const first_json = JSON.parse(JSON.stringify(json)); // Deep copy console.log("Original JSON:", json); + let rowIndexArray = []; + let rowIndexArray2 = []; + // Column-wise Check: Remove headers and relevant data if qcr == 0 Object.entries(json.proposal_data.over_all_column_data).forEach(([proposalKey, proposalData], index) => { - console.log(index); + // console.log('over_all_column_data index', index); if (proposalData.qcr == 0 || proposalData.qcr == false) { @@ -2947,42 +2992,75 @@ function jsonToTable(json) { const headerIndex = first_json.table_data.headers.findIndex(header => header.parentHeader === proposalKey); if (headerIndex !== -1) first_json.table_data.headers.splice(headerIndex, 1); - // Remove data entries with matching parentth - Object.values(first_json.table_data.data).forEach(dataEntry => { - const dataArray = dataEntry.data; - if (dataArray) { - const dataIndex = dataArray.findIndex(dataItem => dataItem.parentth === proposalKey); - if (dataIndex !== -1) dataArray.splice(dataIndex, 1); - } + first_json.table_data.data.forEach(item => { + item.data = item.data.filter(entry => entry.parentth !== proposalKey); }); + // Remove data entries with matching parentth + // Object.values(first_json.table_data.data).forEach(dataEntry => { + // const dataArray = dataEntry.data; + // if (dataArray) { + // const dataIndex = dataArray.findIndex(dataItem => dataItem.parentth === proposalKey); + // if (dataIndex !== -1) dataArray.splice(dataIndex, 1); + // } + // }); + // Remove proposalKey from over_all_column_data - // console.log() // Object.entries(first_json.proposal_data.over_all_column_data).splice(index, 1); + + + const updatedData = Object.keys(first_json.proposal_data.over_all_column_data) + .filter(key => key !== proposalKey) + .reduce((acc, key) => { + acc[key] = first_json.proposal_data.over_all_column_data[key]; + return acc; + }, {}); + + // Assign the updated data back if needed + first_json.proposal_data.over_all_column_data = updatedData; } // Insurer Check: Remove subHeaders and relevant data for insurers with qcr == 0 proposalData.insurers.forEach((insurer, insurerIndex) => { - if (insurer.qcr === 0) { + // console.log('insurer', insurer) + if (insurer.qcr === 0 || insurer.qcr == false) { + + console.log(insurer.qcr) + first_json.table_data.headers.forEach(header => { const subHeaderIndex = header.subHeaders.findIndex(sub => sub === insurer.display_name); if (subHeaderIndex !== -1) header.subHeaders.splice(subHeaderIndex, 1); }); - Object.values(first_json.table_data.data).forEach(dataEntry => { - const dataArray = dataEntry.data; - if (dataArray) { - const dataIndex = dataArray.findIndex(dataItem => dataItem.subth === insurer.display_name); - if (dataIndex !== -1) dataArray.splice(dataIndex, 1); - } + first_json.table_data.data.forEach(item => { + item.data = item.data.filter(entry => entry.subth !== insurer.display_name); }); + // Object.values(first_json.table_data.data).forEach(dataEntry => { + // const dataArray = dataEntry.data; + // if (dataArray) { + // const dataIndex = dataArray.findIndex(dataItem => dataItem.subth === insurer.display_name); + // if (dataIndex !== -1) dataArray.splice(dataIndex, 1); + // } + // }); + // Remove insurer from proposal's insurers array + console.log('insurerIndex', insurerIndex) first_json.proposal_data.over_all_column_data[proposalKey].insurers.splice(insurerIndex, 1); } + }); }); + // rowIndexArray.sort((a, b) => b - a); + + // rowIndexArray2.forEach((index) => { + // rowIndexArray.forEach((index2) => { + // first_json.table_data.data[index].data.splice(index2, 1); + // }) + // }); + + // Row-wise Check: Remove rows if qcr == 0 for actions Object.entries(first_json.table_data.data).forEach(([rowKey, rowData]) => { const actionData = rowData.data.find(data => data.parentth === "Action" && data.input_value.qcr === 0);