From b794120ed3beadd65632a124b78924b529c49538 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 21 Mar 2025 20:37:04 +0530 Subject: [PATCH 001/169] CHANGE_EXCEL : RV --- app/Controllers/ClientController.php | 4 + app/Controllers/LeadsController.php | 447 +++++++++++---------------- app/Views/leads_form_handler.php | 43 ++- app/Views/leads_non_eb.php | 27 +- app/Views/view_rfq_non_eb.php | 45 ++- 5 files changed, 295 insertions(+), 271 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index ca43f2d2..fb78c67b 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4711,6 +4711,10 @@ class ClientController extends AdminController // $empmodel = new EmployeeModel(); // $data = $empmodel->getEmployeePolicy(348); // dd($data); + + + // $LeadsController = new LeadsController(); + // $LeadsController->constructNonEbExcelToSaveTemp(92, 2, "Proposal 2-ICICIPRU-ICICI001"); } // ------------------------------------------------------------------------------------------------------- diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 6260124c..4c70308a 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -2401,76 +2401,6 @@ class LeadsController extends BaseController $this->loadLayout('view_rfq_non_eb'); } - // public function getLeadNonEB($type, $id = null) - // { - // // Set basic data - // $data['issuer'] = $this->issuer; - // $data['client_type'] = $this->clientType; - // $data['lead_type'] = $this->leadType; - // $data['lead_status'] = $this->leadsStatus; - - // // Fetch policy types and entity data - // $data['policy_type'] = $this->policyTypeModel->where('is_active', 1)->findAll(); - // $data['entity'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll(); - - // // Fetch insurer and TPA branch data - // $data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames(); - // $data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames(); - // // print_r($data['tpa']);die(); - // // Fetch sales team members who are active in team 5 - // $data['salse_team'] = $this->userModel - // ->select('user_profiles.*') - // ->join('user_teams', 'user_profiles.id = user_teams.user_id') - // ->where('user_teams.team_id', 5) - // ->where('user_teams.is_active', 1) - // ->where('user_profiles.is_active', 1) - // ->findAll(); - - // // dd($data); - // $data['lastFiveYears'] = $this->getLastFiveFinancialYears(); - // $data['gpaClaimType'] = $this->claim_type_for_gpa; - // $data['causeOfDeath'] = $this->cause_of_death; - // $data['selected_lead_type'] = $type; - - // if(!empty($id)){ - - // $data['lead_edit_data'] = $this->leadsModel->where('id', $id)->first(); - - // if (!empty($data['lead_edit_data'])) { - // $data['lead_edit_data']['policy_start_date'] = !empty($data['lead_edit_data']['policy_start_date']) - // ? change_date_format($data['lead_edit_data']['policy_start_date'], 'Y-m-d', 'd/m/Y') - // : null; - - // $data['lead_edit_data']['policy_end_date'] = !empty($data['lead_edit_data']['policy_end_date']) - // ? change_date_format($data['lead_edit_data']['policy_end_date'], 'Y-m-d', 'd/m/Y') - // : null; - - // $data['lead_edit_data']['incurred_claims_date'] = !empty($data['lead_edit_data']['incurred_claims_date']) - // ? change_date_format($data['lead_edit_data']['incurred_claims_date'], 'Y-m-d', 'd/m/Y') - // : null; - - // $data['lead_edit_data']['premium_date'] = !empty($data['lead_edit_data']['premium_date']) - // ? change_date_format($data['lead_edit_data']['premium_date'], 'Y-m-d', 'd/m/Y') - // : null; - // } else { - // $data['lead_edit_data'] = []; - // } - - // if (!empty($data['lead_edit_data']['fin_years_claims'])) { - // $decoded = json_decode($data['lead_edit_data']['fin_years_claims'], true); - // $data['lead_edit_data']['fin_years_claims_array'] = isset($decoded['finyear']) ? $decoded['finyear'] : []; - // } else { - // $data['lead_edit_data']['fin_years_claims_array'] = []; - // } - - // $data['lead_edit_data']['html'] = $this->generateViewPageHtml($data['lead_edit_data']['policy_type_id'], $data) ?? ""; - // } - - // // dd($data); - - // return $this->loadLayout('leads_form_handler', $data); - // } - public function getLeadNonEB($type, $id = null) { // Set basic data @@ -2586,7 +2516,15 @@ class LeadsController extends BaseController $lead_data = []; } $lead_data = array_merge(['Insured' => $rfq_data['client_name']], $lead_data); - // dd($lead_data); + + // if(!empty($rfq_data['fin_years_claims'])){ + // $claim_details = json_decode($rfq_data['fin_years_claims'], true) ?? []; + // if(!empty($claim_details['finyear'])){ + // $lead_data['claim_details'] = $claim_details['finyear']; + // } + // Kint::dump($claim_details); + // } + $jsonData = json_decode($rfq_data['json'], true); $proposalData = end($jsonData); @@ -2681,21 +2619,29 @@ class LeadsController extends BaseController $rowNumber += 2; + // Kint::dump($jsonData); + foreach ($jsonData as $key => $data) { + // Kint::dump($data, 'First'); + if ($type == 2) { - $data = $this->convertNonEbJsonForQCR($data, $type, $proposalData); - unset($data['proposalData']); + + $data = $this->convertNonEbJsonForQCR($data, $type, $proposalData, $key); + + // Kint::dump($data, 'Second'); if ($propsal_and_insurer !== null) { list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2); - $data = $this->transformProposelData($data, $proposal_key, $insurer_key); + $data = $this->transformNonEbProposelData($data, $proposal_key, $insurer_key, $key); } + unset($data['proposalData']); } else if ($type == 1) { - $data = $this->convertNonEbJsonForQCR($data, $type, $proposalData); + $data = $this->convertNonEbJsonForQCR($data, $type, $proposalData, $key); unset($data['proposalData']); } + // dd($data); // Add headers and subheaders $headers = $data['table_data']['headers']; // dd($headers); @@ -2714,7 +2660,7 @@ class LeadsController extends BaseController $sheet->getColumnDimension($columnLetter)->setWidth(60); - if ($header['parentHeader'] == '') { + if ($header['parentHeader'] == 'Policy') { // $header['parentHeader'] = 'S.No.'; $sheet->getColumnDimension('A')->setWidth(10); } @@ -2728,7 +2674,7 @@ class LeadsController extends BaseController $sheet->getColumnDimension('D')->setWidth(35); } - + $startColumn = $columnLetter; // Start of the current header range $subHeaderCount = count($header['subHeaders']); // Number of subheaders for this parent header @@ -2808,7 +2754,7 @@ class LeadsController extends BaseController if ($cellData['parentth'] == 'SNO') { $sheet->setCellValue("{$columnLetter}{$rowNumber}", $serial_no); - } else if ($cellData['parentth'] == '') { + } else if ($cellData['parentth'] == 'Policy') { $mergeStart = $rowNumber; // Start row for merging $mergeEnd = $rowNumber + ($cellData['rowspan'] - 1); // End row for merging @@ -2817,7 +2763,7 @@ class LeadsController extends BaseController $sheet->getStyle("{$columnLetter}{$mergeStart}:{$columnLetter}{$mergeEnd}") ->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER); } else { - $sheet->setCellValue("{$columnLetter}{$rowNumber}", $cellData['display_value']); + $sheet->setCellValue("{$columnLetter}{$rowNumber}", $cellData['display_content']); } $columnLetter++; @@ -2885,6 +2831,7 @@ class LeadsController extends BaseController ]); } + // dd($rowNumber); // Set filename $string = ($type == 2) ? 'QCR' : 'RFQ'; $filename = "{$string}_{$rfq_data['client_short_name']}_{$rfq_data['policy_type']}_" . date('YmdHis') . '.xlsx'; @@ -2900,241 +2847,223 @@ class LeadsController extends BaseController ]; } - public function convertNonEbJsonForQCR($jsonArr, $type, $proposeldata) + public function convertNonEbJsonForQCR($jsonArr, $type, $proposeldata, $indexOfTheTable) { - - $first_json = $jsonArr; - $first_json = array_merge($first_json, $proposeldata); - - if($type == 2){ - // Column-wise Check: Remove headers and relevant data if qcr == 0 - foreach ($first_json['proposal_data']['over_all_column_data'] as $proposalKey => $proposalData) { + $first_json = $jsonArr; + $first_json = array_merge($first_json, $proposeldata); - if (($proposalData['qcr'] == 0 || $proposalData['qcr'] === false) || ($proposalData['stc'] == 0 || $proposalData['stc'] === false)) { + if ($type == 2) { - // Remove matching parentHeader in headers - foreach ($first_json['table_data']['headers'] as $index => $header) { - if ($header['parentHeader'] === $proposalKey) { - unset($first_json['table_data']['headers'][$index]); + // Column-wise Check: Remove headers and relevant data if qcr == 0 + foreach ($first_json['proposal_data']['over_all_column_data'] as $proposalKey => $proposalData) { + + if ((isset($proposalData['qcr']) && isset($proposalData['stc'])) && ($proposalData['qcr'] == 0 || $proposalData['qcr'] === false) || ($proposalData['stc'] == 0 || $proposalData['stc'] === false)) { + + // Remove matching parentHeader in headers + foreach ($first_json['table_data']['headers'] as $index => $header) { + if ($header['parentHeader'] === $proposalKey) { + unset($first_json['table_data']['headers'][$index]); + } + } + + // Remove data entries with matching parentth + foreach ($first_json['table_data']['data'] as &$item) { + $item['data'] = array_values(array_filter($item['data'], function ($entry) use ($proposalKey) { + return $entry['parentth'] !== $proposalKey; + })); + } + + // Remove proposalKey from over_all_column_data + unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]); + + if ($type == 2) { + // Remove proposalKey from premium_data + unset($first_json['premium_data']['data'][$proposalKey]); + } + } + + // Insurer Check: Remove subHeaders and relevant data for insurers with qcr == 0 + foreach ($proposalData['insurers'] as $insurerIndex => $insurer) { + + $qcr = $insurer['qcr'] ?? null; + $stc = $insurer['stc'] ?? null; + + if (($qcr === 0 || $qcr === false) || ($stc === 0 || $stc === false)) { + + foreach ($first_json['table_data']['headers'] as &$header) { + if (isset($header['subHeaders'])) { + $header['subHeaders'] = array_values(array_filter($header['subHeaders'], function ($sub) use ($insurer) { + return $sub !== $insurer['display_name']; + })); } } - // Remove data entries with matching parentth + foreach ($first_json['table_data']['data'] as &$item) { - $item['data'] = array_values(array_filter($item['data'], function ($entry) use ($proposalKey) { - return $entry['parentth'] !== $proposalKey; + $item['data'] = array_values(array_filter($item['data'], function ($entry) use ($insurer) { + return $entry['subth'] !== $insurer['display_name']; })); } - // Remove proposalKey from over_all_column_data - unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]); - - if($type == 2){ - // Remove proposalKey from premium_data - unset($first_json['premium_data']['data'][$proposalKey]); - } - } + // Remove insurer from proposal's insurers array + unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]['insurers'][$insurerIndex]); - // Insurer Check: Remove subHeaders and relevant data for insurers with qcr == 0 - foreach ($proposalData['insurers'] as $insurerIndex => $insurer) { - if (($insurer['qcr'] === 0 || $insurer['qcr'] === false) || ($insurer['stc'] === 0 || $insurer['stc'] === false) ) { - foreach ($first_json['table_data']['headers'] as &$header) { - if (isset($header['subHeaders'])) { - $header['subHeaders'] = array_values(array_filter($header['subHeaders'], function ($sub) use ($insurer) { - return $sub !== $insurer['display_name']; - })); - } - } - - - foreach ($first_json['table_data']['data'] as &$item) { - $item['data'] = array_values(array_filter($item['data'], function ($entry) use ($insurer) { - return $entry['subth'] !== $insurer['display_name']; - })); - } - - // Remove insurer from proposal's insurers array - unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]['insurers'][$insurerIndex]); - - if($type == 2){ - unset($first_json['premium_data']['data'][$proposalKey][$insurer['display_name']]); - } + if ($type == 2) { + unset($first_json['premium_data']['data'][$proposalKey][$insurer['display_name']]); } } } - - // Row-wise Check: Remove rows if qcr == 0 for actions - foreach ($first_json['table_data']['data'] as $rowKey => $rowData) { - foreach ($rowData['data'] as $data) { - if ( - isset($data['parentth']) && $data['parentth'] === "Action" && - ( - (isset($data['input_value']['qcr']) && $data['input_value']['qcr'] == 0) || - (isset($data['input_value']['stc']) && $data['input_value']['stc'] == 0) - ) - ) { - - unset($first_json['table_data']['data'][$rowKey]); - break; // Stop checking other columns for this row - } - } - } - - // Reindex arrays to maintain proper structure - $first_json['table_data']['headers'] = array_values($first_json['table_data']['headers']); - $first_json['table_data']['data'] = array_values($first_json['table_data']['data']); - $first_json['proposal_data']['over_all_column_data'] = array_map(function ($proposal) { - $proposal['insurers'] = array_values($proposal['insurers']); - return $proposal; - }, $first_json['proposal_data']['over_all_column_data']); - - }else{ - - //remove insurer as Subheaders for RFQ - foreach ($first_json['table_data']['headers'] as &$header) { - // Ensure 'subHeaders' exists and is an array before filtering - if (isset($header['subHeaders']) && is_array($header['subHeaders'])) { - $header['subHeaders'] = array_filter($header['subHeaders'], function ($subHeader) { - return in_array($subHeader, ['Quote asked', '-'], true); - }); - } - } - - //Remove insurer Row wise data for RFQ - foreach ($first_json['table_data']['data'] as &$row) { - - // Filter the inner data array - $row['data'] = array_filter( - $row['data'], - function ($item) { - return in_array($item['subth'], ['Quote asked', '-']); - } - ); - - $row['data'] = array_values($row['data']); - } - - // Ensure to unset the reference after the loop - unset($row); - - // Remove insurers from Proposal Data key for RFQ - foreach ($proposeldata['proposal_data']['over_all_column_data'] as $key => &$proposal) { - if (isset($proposal['insurers'])) { - // Set the insurers array to empty - $proposal['insurers'] = []; - } - } - - // Ensure to reset the reference - unset($proposal); - } - return $first_json; + + // Row-wise Check: Remove rows if qcr == 0 for actions + foreach ($first_json['table_data']['data'] as $rowKey => $rowData) { + foreach ($rowData['data'] as $data) { + + if ($indexOfTheTable == 0) { + + if ($data['parentth'] == "Policy" && $data['input_value'] != "Checked") { + unset($first_json['table_data']['data'][$rowKey]); + break; + } + } else { + if ( + isset($data['parentth'], $data['input_value']['qcr'], $data['input_value']['stc']) && + $data['parentth'] === "Action" && + ($data['input_value']['qcr'] == 0 || $data['input_value']['stc'] == 0) + ) { + unset($first_json['table_data']['data'][$rowKey]); + break; + } + } + } + } + + // Reindex arrays to maintain proper structure + $first_json['table_data']['headers'] = array_values($first_json['table_data']['headers']); + $first_json['table_data']['data'] = array_values($first_json['table_data']['data']); + $first_json['proposal_data']['over_all_column_data'] = array_map(function ($proposal) { + $proposal['insurers'] = array_values($proposal['insurers']); + return $proposal; + }, $first_json['proposal_data']['over_all_column_data']); + } else { + + //remove insurer as Subheaders for RFQ + foreach ($first_json['table_data']['headers'] as &$header) { + // Ensure 'subHeaders' exists and is an array before filtering + if (isset($header['subHeaders']) && is_array($header['subHeaders'])) { + $header['subHeaders'] = array_filter($header['subHeaders'], function ($subHeader) { + return in_array($subHeader, ['Quote asked', '-'], true); + }); + } + } + + //Remove insurer Row wise data for RFQ + foreach ($first_json['table_data']['data'] as &$row) { + + // Filter the inner data array + $row['data'] = array_filter( + $row['data'], + function ($item) { + return in_array($item['subth'], ['Quote asked', '-']); + } + ); + + $row['data'] = array_values($row['data']); + } + + // Ensure to unset the reference after the loop + unset($row); + + // Remove insurers from Proposal Data key for RFQ + foreach ($proposeldata['proposal_data']['over_all_column_data'] as $key => &$proposal) { + if (isset($proposal['insurers'])) { + // Set the insurers array to empty + $proposal['insurers'] = []; + } + } + + // Ensure to reset the reference + unset($proposal); + } + return $first_json; return null; } - public function transformNonEbProposelData($data, $proposel, $insurer) + public function transformNonEbProposelData(&$data, $proposal, $insurer, $tableCount) { + // Kint::dump($data, $proposal, $insurer, $tableCount); - // print_r($data['premium_data']['data']); die; - + // Initialize headers with defaults $headerData = []; - // Default headers: S. No and Particulars - $defaultHeaders = [ - [ - 'parentHeader' => 'Sno', - 'subHeaders' => ['-'] - ], - [ - 'parentHeader' => 'Particulars', - 'subHeaders' => ['-'] - ] + // Add the first two default headers only once + $headerData[] = [ + 'parentHeader' => $data['table_data']['headers'][0]['parentHeader'], + 'subHeaders' => ['-'] + ]; + $headerData[] = [ + 'parentHeader' => $data['table_data']['headers'][1]['parentHeader'], + 'subHeaders' => ['-'] ]; - // Add default headers to the result - $headerData = array_merge($headerData, $defaultHeaders); + $second_table_name = $data['table_data']['headers'][1]['parentHeader'] ?? ""; + // Loop through the headers to find matching proposal and insurer foreach ($data['table_data']['headers'] as $header) { - // Check if the parentHeader matches the target proposal - if ($header['parentHeader'] === $proposel) { - // Check if subHeaders contain the target insurer key + if ($header['parentHeader'] === $proposal) { foreach ($header['subHeaders'] as $subHeader) { if ($subHeader === $insurer) { $headerData[] = [ 'parentHeader' => $header['parentHeader'], - 'subHeaders' => [ - 'Quote asked', // Default value - $subHeader // Matched insurer key - ] + 'subHeaders' => ['Quote asked', $subHeader] ]; - break; + break 2; // Exit both loops after match is found } } } } - $columnData = []; + // Update the original data's headers + $data['table_data']['headers'] = $headerData; - foreach ($data['table_data']['data'] as $entry) { + foreach ($data['table_data']['data'] as &$entry) { $sno = $entry['SNO']; $items = $entry['items']; $row_id = $entry['row_id']; - $dataEntry = $entry['data']; - $result = [ - "SNO" => $sno, - "items" => $items, - "items" => $row_id, - "data" => [] - ]; + $filteredData = []; - foreach ($dataEntry as $item) { + foreach ($entry['data'] as $item) { - // Include Sno and Particulars by default - if (in_array($item['parentth'], ['Sno', 'Particulars'])) { - $result['data'][] = [ - "parentth" => $item['parentth'], - "subth" => $item['subth'], - "value" => $item['value'], - "input_value" => $item['input_value'], - "display_value" => $item['display_value'], - "rowspan" => $item['rowspan'], - ]; + // Always include SNO and Particulars + if (in_array($item['parentth'], ['S.NO', "Policy", "", 'Particulars', $second_table_name])) { + $filteredData[] = $item; } - // Include Proposal with Quote Asked by default - if ($item['parentth'] === $proposel && $item['subth'] === "Quote asked") { - $result['data'][] = [ - "parentth" => $item['parentth'], - "subth" => $item['subth'], - "value" => $item['value'], - "input_value" => $item['input_value'], - "display_value" => $item['display_value'], - "rowspan" => $item['rowspan'], - ]; + // Include Proposal with Quote Asked + if ($item['parentth'] === $proposal && $item['subth'] === "Quote asked") { + $filteredData[] = $item; } - // Example of including matching specific proposals and insurers - if ($item['parentth'] === $proposel && $item['subth'] === $insurer) { - $result['data'][] = [ - "parentth" => $item['parentth'], - "subth" => $item['subth'], - "value" => $item['value'], - "input_value" => $item['input_value'], - "display_value" => $item['display_value'], - "rowspan" => $item['rowspan'], - ]; + // Include specific proposal and insurer + if ($item['parentth'] === $proposal && $item['subth'] === $insurer) { + $filteredData[] = $item; } } - // Add to the final result - $columnData[] = $result; + // Update the entry with filtered data + $entry['SNO'] = $sno; + $entry['items'] = $items; + $entry['row_id'] = $row_id; + $entry['data'] = $filteredData; } + unset($entry); + // kint::dump($data); return $data; } + } diff --git a/app/Views/leads_form_handler.php b/app/Views/leads_form_handler.php index 4554ef63..dff317ef 100644 --- a/app/Views/leads_form_handler.php +++ b/app/Views/leads_form_handler.php @@ -83,7 +83,8 @@ if (isset($selected_lead_type)) { var client_list = ''; // local variable for storing the client branch list var branch_list = ''; // local variable for storing the client branch list var policy_list = ''; // local variable for storing the client policy list - + var temp_client_id = 0; + var temp_branch_id = 0; // select2 document ready $(document).ready(function() { @@ -222,7 +223,21 @@ if (isset($selected_lead_type)) { let data = branch_list[client_id]; appendBranch(data); } else { - toastr.warning("No Branch Found for the selected Client", 'Warning'); + if (temp_client_id == 0) { + console.log("Step 1: temp_client_id is 0 - No Branch Found for the selected Client"); + console.log('second client_id', client_id); + if (client_id == null || client_id == 0) { + console.log("Step 2: client_id is null or 0 - Setting temp_client_id to 0"); + temp_client_id = 0; + } else { + console.log("Step 3: client_id exists - Assigning temp_client_id = client_id"); + temp_client_id = client_id; + toastr.warning("No Branch Found for the selected Client", 'Warning'); + } + } else { + console.log("Step 4: temp_client_id is not 0 - Showing warning"); + toastr.warning("No Branch Found for the selected Client", 'Warning'); + } } }) @@ -230,6 +245,7 @@ if (isset($selected_lead_type)) { $('#client_branch_id').change(function() { let client_branch_id = $(this).val(); + console.log('client_branch_id', client_branch_id); if (policy_list[client_branch_id] != '' && policy_list[client_branch_id] != null && client_branch_id != '' && client_branch_id != null) { @@ -238,7 +254,22 @@ if (isset($selected_lead_type)) { appendRenewalPolicies(data); } else { $('#source_policy_id').empty(); - toastr.warning("No Policies Found for the selected Branch", 'Warning'); + + if (temp_branch_id == 0) { + console.log("Step 1: temp_branch_id is 0 - No Policies Found for the selected branch"); + console.log('second client_branch_id', client_branch_id); + if (client_branch_id == null || client_branch_id == 0) { + console.log("Step 2: client_branch_id is null or 0 - Setting temp_branch_id to 0"); + temp_branch_id = 0; + } else { + console.log("Step 3: v exists - Assigning temp_branch_id = client_branch_id"); + temp_branch_id = client_id; + toastr.warning("No Policies Found for the selected Branch", 'Warning'); + } + } else { + console.log("Step 4: temp_branch_id is not 0 - Showing warning"); + toastr.warning("No Policies Found for the selected Branch", 'Warning'); + } } }) @@ -453,6 +484,12 @@ if (isset($selected_lead_type)) { leadTypeBsedHideAndShow(lead_type); + if(data.client_id == 0 || data.client_id == null){ + temp_client_id = 0; + }else{ + temp_client_id = data.client_id + } + $('#page_title').text('Edit Lead'); $('#leads_primarykey').val(data.id || ''); diff --git a/app/Views/leads_non_eb.php b/app/Views/leads_non_eb.php index 9150b378..1ee910fa 100644 --- a/app/Views/leads_non_eb.php +++ b/app/Views/leads_non_eb.php @@ -354,9 +354,17 @@ hr.solid { $(document).ready(function(){ + var today = new Date(); + var policy_start_datePicker = flatpickr("#policy_start_date", { dateFormat: "d/m/Y", - allowInput: false + allowInput: false, + onChange: function(selectedDates, dateStr, instance) { + var endDate = new Date(selectedDates[0]); + endDate.setFullYear(endDate.getFullYear() + 1); + endDate.setDate(endDate.getDate() - 1); // Set end date to last day of selected year + policy_end_datePicker.setDate(endDate); + } }); var policy_end_datePicker = flatpickr("#policy_end_date", { dateFormat: "d/m/Y", @@ -705,7 +713,22 @@ function getPolicyData(input) { $(`#policy_type_id`).val(res.data.policy_type_id).trigger('change'); $(`#insurer`).val(insurer).trigger('change'); $(`#tpa`).val(tpa).trigger('change'); - $('#policy_start_date').val(res.new_start_date); + + if ($('#policy_start_date').hasClass('flatpickr-input')) { + const fpInstance = $('#policy_start_date')[0]._flatpickr; + if (fpInstance) { + fpInstance.destroy(); // Remove Flatpickr instance + } + } + + if ($('#policy_end_date').hasClass('flatpickr-input')) { + const fpInstance = $('#policy_end_date')[0]._flatpickr; + if (fpInstance) { + fpInstance.destroy(); // Remove Flatpickr instance + } + } + + $('#policy_start_date').val(res.new_start_date); // Set new value $('#policy_end_date').val(res.end_date); diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index cc1a2d00..f14e6eb0 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -182,11 +182,11 @@
- - Export Excel - - - + + Export Excel + + +
@@ -391,6 +391,8 @@ rfq_data = rfq_data ? JSON.parse(rfq_data) : {}; // Convert to object if not already var rfq_or_qcr = 1; + var proposalDataForDropDown = {}; + var policyConfig = { 1: ['Quote asked'] }; @@ -414,8 +416,10 @@ }); var tableCount = 0; const policies = ; + console.log('policies', policies); const child_table_data = ; + console.log('child_table_data', child_table_data); const policyOrder = [{ 'fire': { @@ -1326,8 +1330,9 @@ } ${tableData ? policy_question : policy.description} + ${Object.values(quotesConfig).flatMap(codes => - codes.map(() => `${tableData ? (default_value === '-' ? `${default_value} ` : `${default_answer} `) + codes.map(() => `${tableData ? (default_value === '-' ? `${default_value} ` : `${default_answer} `) : policy.quote_asked}`) ).join('')} @@ -1470,10 +1475,13 @@ const newUrl = segments.join("/"); // Rebuild the URL rfq_or_qcr = 1; history.pushState(null, "", newUrl); // Change the URL without reloading + if (rfq_data.length) { console.log("inside if conditoon"); localStorage.setItem('allTablesJsonData', JSON.stringify(rfq_data)); jsonToTables(); + proposalDataForDropDown = rfq_data[rfq_data.length - 1].proposal_data; + console.log("proposalDataForDropDown", proposalDataForDropDown); // generateTable(document.getElementById('tablesContainer')); // console.log("polices Length ", policies.length); @@ -1936,9 +1944,17 @@ success: function(response) { if (response.status == true) { toastr.success(response.message, "Success"); + console.log(rfq_data.length); + + $('.actionBtns').show(); + if(rfq_or_qcr == 2){ + $("#openQCR").hide(); + } + // window.location.reload(); } else { toastr.error(response.message, "Error"); + $('.actionBtns').hide(); } $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); @@ -2156,6 +2172,7 @@ } function openQCR() { + const url = window.location.pathname; // Get the path (e.g., "/nhance/rfq/list/75/1") const segments = url.split("/"); // Split by "/" segments[segments.length - 1] = "2"; // Change the last segment @@ -2171,6 +2188,7 @@ jsonToTables(); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); + // $('#rfq_qcr_page_title').text('QCR'); hideProposalOptionsForChild(); showOrHideFieldsBasedOnRFQorQCR(); } @@ -2561,6 +2579,7 @@ $(".rfqbtn").show(); $(".qcrbtn").hide(); $("#saveRFQ").css("margin-right", "10px"); + $('#rfq_qcr_page_title').text('RFQ'); } else if (rfq_or_qcr == 2) { $(".newInsurer").show(); @@ -2582,9 +2601,21 @@ $(".rfqbtn").hide(); $(".qcrbtn").show(); $("#saveRFQ").css("margin-right", "20px"); + $('#rfq_qcr_page_title').text('QCR'); } + if(rfq_data.length){ + $('.actionBtns').show(); + if(rfq_or_qcr == 2){ + $("#openQCR").hide(); + $("#submitPlacement").show(); + }else{ + $("#submitPlacement").hide(); + } + }else{ + $('.actionBtns').hide(); + } makeQuoteAskedColumnNonEditableorEditable(); } @@ -2918,7 +2949,7 @@ \ No newline at end of file diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index cc1a2d00..a86f850d 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -215,7 +215,7 @@
- +
@@ -243,12 +243,12 @@ +
@@ -256,12 +256,12 @@ +
@@ -278,7 +278,7 @@

- +
@@ -300,7 +300,7 @@
- +
@@ -335,16 +335,16 @@
- - +
- +
@@ -353,12 +353,12 @@ +
@@ -403,11 +403,18 @@ } }; var suggestions = {}; - var storedData = JSON.parse(localStorage.getItem('policyData')); - var policySummary; - if (!$.isEmptyObject(storedData)) { - policySummary = addPolicySummaryTable(storedData); + var policyInformationData = ; + var storedData = {}; + console.log("stored data : ", typeof(policyInformationData)) + + if (policyInformationData.length) { + + localStorage.setItem('policyData', (policyInformationData)); + storedData = policyInformationData; } + + var policySummary = []; + console.log("policy summary is set :", !$.isEmptyObject(policySummary) ? "no" : "yes") $(document).ready(function() { myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel')); @@ -482,37 +489,7 @@ 1: ['Quote asked'] }; // Stores quote columns for each proposal - // Generate a random quote code (e.g., abc123) - function generateRandomCode() { - const chars = 'abcdefghijklmnopqrstuvwxyz'; - const nums = '0123456789'; - return Array.from({ - length: 3 - }, () => chars[Math.floor(Math.random() * 26)]).join('') + - Array.from({ - length: 3 - }, () => nums[Math.floor(Math.random() * 10)]).join(''); - } - // Add a new quote column to a specific proposal - // function addNewQuote(proposalNumber) { - // console.log("this doesnt work"); - // let increaseBy = 25; - // increaseTableWidth(increaseBy) - // console.log('ADD NEW QUOTE proposalNumber' + proposalNumber); - // console.log('ADD NEW QUOTE overall quotesConfig'); - // console.log(quotesConfig); - // if (!quotesConfig[proposalNumber]) { - // quotesConfig[proposalNumber] = ['Quote asked']; // Initialize with default quote - // } - // const newQuote = generateRandomCode(); - // quotesConfig[proposalNumber].push(newQuote); // Add new quote to the proposal - - // // Update all tables (parent and child) with the new quote column - // updateAllTables(proposalNumber, newQuote); - // // hideProposalOptionsForChild(); - - // } // Update all tables with the new quote column function updateAllTables_old(proposalNumber, newQuote) { @@ -722,6 +699,7 @@ // console.log('Row id for excess table',rowId); $("#excess .three-dot-menu").hide(); moveExcessTableLast(); + } } else { // Handle regular table @@ -729,6 +707,9 @@ generateTable(childContainer, true, rowId, childTable); // console.log('Row id for excess table', rowId); $(childContainer).find(".three-dot-menu").hide(); + + // alert(`${rowId.toUpperCase()}_register`); + $(`#${rowId.toUpperCase()}_register`).prop("disabled", false); moveExcessTableLast(); } }); @@ -738,7 +719,10 @@ container.appendChild(childContainer); } + + arrangeTables(); + alignTableColumn(); } else { console.log('UNCHECKED:', rowId); selectedPolicies.delete(rowId); @@ -747,6 +731,7 @@ regularContainers.forEach(container => { console.log(" contaitner ", container); + $(`#${rowId.toUpperCase()}_register`).prop("disabled", true); container.remove(); }); console.log("row id ", rowId); @@ -1134,6 +1119,10 @@ ${newQuote} @@ -1183,7 +1172,7 @@ const headerRow1 = document.createElement('tr'); headerRow1.innerHTML = ` - ${isChildTable ? 'S.NO' : ''} + ${isChildTable ? 'S.NO' : 'Policy'} ${tableName} ${Object.keys(quotesConfig).map(proposal => ` @@ -1210,13 +1199,15 @@ - ${Object.entries(quotesConfig).flatMap(([proposal, codes]) => codes.map(code => ` - - ${code} - - - + + ${code} + + + + `) ).join('')} -`; @@ -1258,7 +1249,7 @@ ${policy.name} ${policy.name === 'Fire' || policy.name === 'Burglary' ? - `
` : + `
` : ''} ${desc} @@ -1299,13 +1290,14 @@ suggestions[rowID] = row_fields[rowID].answer_type; if (answer_type == 'dropdown') { default_answers_array = row_fields[rowID].default_answer; - + console.log("default ans array : ", typeof(default_answers_array)) // createDropdown(default_answers_array); default_value = default_answers_array[0].key; default_answer = default_answers_array[0].display_value; } else { default_answers_array = row_fields[rowID].default_answer ? row_fields[rowID].default_answer : "-"; + console.log("default ans array else: ", default_answers_array) // console.log("defaultansetgoa : ",default_answers_array); default_value = default_answers_array; default_answer = default_answers_array; @@ -1321,15 +1313,43 @@ ${isChildTable ? `${SNO}` : `${policy.name}${policy.name == 'Fire' || policy.name == 'Burglary' - ? `
@@ -2487,7 +2585,7 @@ } // console.log("insude the function value ", value); return ` ${cellData.SNO} ${cellData.SNO == 'Fire' || cellData.SNO == 'Burglary' - ? `
+ + +
+ + +
+
+ + +
- -
- - -
-
- - -
diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index a86f850d..7d50957e 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -1501,7 +1501,7 @@ policySummary[key] = addPolicySummaryTable(data[key], key); - prependTable(policySummary[key],key); + // prependTable(policySummary[key],key); }); @@ -1866,7 +1866,6 @@ storedData.locations[i].policyRisk['occupancy'] + "- " + storedData.locations[i].policyRisk['address1'] + " " + storedData.locations[i].policyRisk['address2'], - "answer_type": "free-text", table_row_contents: [{ [`fire_plantMachineries_${locationIndex}`]: { "display_value": "Plant & Machineries and Accessories", @@ -2422,10 +2421,15 @@ // Handle regular cells else { td.innerHTML = processCellContent(cellData.input_value, rowData, cellData.display_content); + if (cellData.parentth.startsWith("Proposal")) { td.onclick = () => getAnswer(table.id, tr.id); if (cellData.subth != "Quote asked") { + console.log("debug 1: ","table id : ",table.id,"Cell data parent header :",cellData.parentth,"others: ",cellData); + console.log("debug 1 : ",td.innerHTML) + // console.log("debug 1: ",cellData," "); td.classList.add("insurer_proposal"); + console.log("debug 1: ",td.className); } } td.contentEditable = true; @@ -2538,6 +2542,7 @@ console.log("trying to find something : ", matchedInsurer.stc); console.log("this is the subheader : ", subHeader); + console.log("debug 2: ",subHeader,"parent header : ",header.parentHeader); th2.classList.add("insurer_proposal"); th2.innerHTML = ` ${subHeader} @@ -3025,7 +3030,7 @@ tables.forEach(table => { if (table.id.includes("summary")) { - table.remove(); // Move summary table to the top + table.remove(); // reMove summary table from the top } }); @@ -3035,6 +3040,9 @@ moveSummaryTableToTop(policyName); + hideProposalOptionsForChild(); + showOrHideFieldsBasedOnRFQorQCR(); + } @@ -3050,6 +3058,7 @@ tables.forEach(table => { if (table.id.includes("summary")) { parentDiv.prepend(table); // Move summary table to the top + updateSNO(table.id); } }); } From 761f5cc9bb6d40d6169a7eb9e0263a913a881ff5 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Sat, 22 Mar 2025 12:16:39 +0530 Subject: [PATCH 004/169] FEAT_RFQ_NONEB --- app/Views/policyRegisterModel.php | 44 ++++++++++++++++++++++++++++--- app/Views/view_rfq_non_eb.php | 4 +++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/app/Views/policyRegisterModel.php b/app/Views/policyRegisterModel.php index 9900b905..680b2b12 100644 --- a/app/Views/policyRegisterModel.php +++ b/app/Views/policyRegisterModel.php @@ -9,6 +9,7 @@
+ From 3b6733e3bb0485c23ce82aae6aefdba14ce6d9b3 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Thu, 27 Mar 2025 13:14:22 +0530 Subject: [PATCH 014/169] FIX_RFQ_PROPOSAL_COUNT --- app/Views/view_rfq_non_eb.php | 95 ++++++++++++++++++++++++++--------- 1 file changed, 72 insertions(+), 23 deletions(-) diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index 31f7250c..da988735 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -481,10 +481,19 @@ var rfq_or_qcr = 1; var proposalDataForDropDown = {}; + var lead_type = ""; + // alert(lead_type); + var rollover_or_renewal = ""; + + if (lead_type != 1){ + + rollover_or_renewal = lead_type == 2 ? "Existing Renewal" : "Existing Roll Over"; + } var policyConfig = { 1: ['Quote asked'] }; + let myModal; var over_all_column_data = { "Proposal 1": { @@ -638,7 +647,10 @@ // console.log('removeProposal'); console.log(quotesConfig); if (!quotesConfig[proposalNumber]) return; // If proposal doesn't exist, exit - + if(Object.keys(quotesConfig).length == 1){ + toastr.warning("You cannot Delete All the Proposals","Warning"); + return; + } // Remove all child columns for the proposal const tables = document.querySelectorAll('table'); tables.forEach(table => { @@ -1574,6 +1586,7 @@ // console.log("Subheader th: colinded : ",colIndex); // Get the subheader (assuming it's the second inside ) let subHeaderThList = [...document.querySelectorAll("thead tr:nth-child(2) th")]; + console.log("subHeaderThList", subHeaderThList); // Filter elements that have a valid 'data-proposal' attribute let validSubHeaders = subHeaderThList.filter(th => { @@ -1583,18 +1596,23 @@ }); - // console.log("Subheader th: subHeaderThList",subHeaderThList); + console.log("Subheader th: validSubHeaders",validSubHeaders); // let validSubHeaders = subHeaderThList.filter(th => th.hasAttribute("data-proposal")); // console.log("Subheader th: validSubHeaders",validSubHeaders); - let subHeaderTh = validSubHeaders.find(th => th.textContent.trim() === codeValue) || null; - // console.log("Subheader th: subHeaderTh",subHeaderTh); + + + let subHeaderTh = validSubHeaders.find(th => th.textContent.trim()); + console.log("Subheader th: codeValue",codeValue); + console.log("Subheader th: subHeaderTh",subHeaderTh); // if (subHeaderTh.classList.contains("insurer_proposal")) { // alert(subHeaderTh); // } let subHeaderText = subHeaderTh ? subHeaderTh.textContent.trim() : ''; - // console.log("Subheader th: ",subHeaderText); + console.log("Subheader th: below code",subHeaderText); // Check if subheader is NOT "Quote asked" - let className = subHeaderText !== "Quote asked" && subHeaderText != "-" ? "insurer_proposal" : ""; + let className = !subHeaderText.startsWith("Quote asked") && subHeaderText != "-" ? + "insurer_proposal" : ""; + console.log("className", className); // alert(subHeaderText); let defaultJsonString = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array); @@ -2699,18 +2717,19 @@ } function addSuggestion(rowData) { - // console.log("child table data ", rowData); - // console.log("child table data ", rowData.row_id); - // console.log("child table data ", child_table_data[rowData.row_id]); + console.log("child table data rowData", rowData); + console.log("child table data rowData.id", rowData.row_id); + console.log("child table data child_table_data", child_table_data[rowData.row_id]); var table_data = child_table_data[rowData.row_id]; + table_data.forEach(table => { table.table_row_contents.forEach(row => { const key = Object.keys(row)[0]; // Get the first key in the row object const answerType = row[key].answer_type; // Get the answer_type suggestions[key] = answerType; // Store in suggestions object }); - }); + }); // console.log("child table data ", suggestions); // child_table_data[rowData.rowID] @@ -2743,13 +2762,16 @@ let keys = Object.keys(quotesConfig); let lastKey = keys[keys.length - 1]; proposalCount = lastKey; + proposalCountForTableINcrease = keys.length; console.log(proposalCount); // Calculate width increase let increaseBy = rfq_or_qcr == 2 ? getTotalCount(proposalDataArray) * 150 : - proposalCount * 150; + proposalCountForTableINcrease * 150; + console.log("Quotes COnfig : ",quotesConfig); + console.log("policy COnfig :", policyConfig); // // console.log("trying to find checkbox data : : : ", increaseBy); @@ -2833,12 +2855,21 @@ // td.onclick = () => getAnswer(table.id, tr.id); td.innerHTML = processCellContent(cellData.input_value, rowData, cellData.display_content); // console.log("DEBUG ISSUE : ",cellData.parentth) - if (cellData.parentth.startsWith("Proposal")) { - td.onclick = () => getAnswer(table.id, tr.id); - if (cellData.subth != "Quote asked") { + if (cellData.parentth.startsWith("Proposal") || cellData.parentth.startsWith("Existing")) { + + if (lead_type == 1){ td.onclick = () => getAnswer(table.id, tr.id); - td.classList.add("insurer_proposal"); + if (cellData.subth != "Quote asked") { + td.onclick = () => getAnswer(table.id, tr.id); + td.classList.add("insurer_proposal"); + } + }else{ + + if (cellData.subth != "Quote asked") { + td.classList.add("insurer_proposal"); + } } + } td.contentEditable = true; @@ -2929,11 +2960,29 @@ // Parent header const th1 = document.createElement('th'); th1.textContent = header.parentHeader; - if (header.parentHeader.startsWith('Proposal')) { - var headerName = header.parentHeader; - // console.log("header name : ", th1.textContent.trim()); - // console.log("over all column data : ", over_all_column_data) - matchedKey = Object.keys(overallColumnDataProposal).find(key => headerName.startsWith(key)); + if (header.parentHeader.startsWith('Proposal') || header.parentHeader.startsWith("Existing")) { + if (lead_type == 1){ + var headerName = header.parentHeader; + }else{ + var headerName = rollover_or_renewal; + } + + if (lead_type == 1){ + + matchedKey = Object.keys(overallColumnDataProposal).find(key => headerName.startsWith(key)); + + }else{ + + if (header.parentHeader.startsWith("Proposal")){ + var tempHeader = header.parentHeader; + matchedKey = Object.keys(overallColumnDataProposal).find(key => tempHeader.startsWith(key)); + }else{ + matchedKey = Object.keys(overallColumnDataProposal).find(key => headerName.startsWith(key)); + } + + } + + if (matchedKey) { // console.log("something wrong : ", overallColumnDataProposal[matchedKey]); var headerCheckBoxProperties = overallColumnDataProposal[matchedKey]; @@ -2965,7 +3014,7 @@ // Sub headers header.subHeaders.forEach(subHeader => { const th2 = document.createElement('th'); - if (header.parentHeader.startsWith("Proposal")) { + if (header.parentHeader.startsWith("Proposal") || header.parentHeader.startsWith("Existing")) { var insurers = overallColumnDataProposal[matchedKey].insurers; const matchedInsurer = insurers.find(ins => ins.ins_name == subHeader); @@ -3378,8 +3427,8 @@ if (rfq_or_qcr == 2) { cell.attr("contenteditable", "false"); removeOnClickFromColumnCells(cell); - - if (!cell.text().trim().startsWith("Proposal")){ + + if (!cell.text().trim().startsWith("Proposal") && !cell.text().trim().startsWith("Existing")){ cell.addClass("readonly-select"); } } else if (rfq_or_qcr == 1) { From 527c399cc6c3779d410c3085594e4f3bac533c5b Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Thu, 27 Mar 2025 19:25:56 +0530 Subject: [PATCH 015/169] FEAT_RFQ_NONEB_RENEWAL_AND_ROLLOVER --- app/Controllers/ClientController.php | 12 +- app/Controllers/LeadsController.php | 7 +- app/Views/view_rfq_non_eb.php | 781 ++++++++++++++++----------- 3 files changed, 487 insertions(+), 313 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 53de23a7..6c491bf9 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4737,12 +4737,12 @@ class ClientController extends AdminController // echo "File does not exist."; // } - // $data = $this->leadsModel->where('leads.id', 115)->where('leads.is_active', 1)->first(); - // $RFQdata = $RFQModel->getRFQTableDataWithLeadIDAndType(115, 2); - // Kint::dump($RFQdata['json']); - // $returnData = $LeadsController->getPlacementJson($data); - // $this->clientPolicyModel->where('id', 6050)->set('placement_json', $returnData)->update(); - // dd($returnData); + $data = $this->leadsModel->where('leads.id', 125)->where('leads.is_active', 1)->first(); + $RFQdata = $RFQModel->getRFQTableDataWithLeadIDAndType(125, 2); + Kint::dump($RFQdata['json']); + $returnData = $LeadsController->getPlacementJson($data); + $this->clientPolicyModel->where('id', 6050)->set('placement_json', $returnData)->update(); + dd($returnData); } diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index c9f6a26a..a858ff7d 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -549,7 +549,7 @@ class LeadsController extends BaseController // dd($lead_data); - if ($lead_data['lead_type'] == 2) { + if ($lead_data['lead_type'] != 1) { $client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first(); $data['policy_terms'] = $client_policy_data['policy_terms']; } @@ -576,7 +576,7 @@ class LeadsController extends BaseController $data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']); - // dd($data); + if ($data['lead_data']['lead_form_type'] == 1) { $this->loadLayout('view_rfq.php', $data); @@ -585,7 +585,7 @@ class LeadsController extends BaseController $data['occupancy'] = $this->occupancyModel->findAll(); // dd($data['occupancy']); - if($lead_data['lead_type'] == 2){ + if($lead_data['lead_type'] != 1 && $data['rfq_count'] == 0){ $client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first(); $data['rfq_data']['json'] = $client_policy_data['placement_json']; } @@ -597,6 +597,7 @@ class LeadsController extends BaseController // $data['lead_register_data'] = json_decode($data['lead_data']['custom_fields']); // dd($data['lead_register_data']); + // dd($data); $data['client_type'] = $this->clientType; $data['buisness_type'] = $this->buisnessType; $this->loadLayout('view_rfq_non_eb', $data); diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index da988735..d30969de 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -29,6 +29,14 @@ } + table thead tr:nth-child(1) th { + background-color: #bfe0e2; + border: 1px solid #007bff; + } + table thead tr:nth-child(2) th { + background-color: #bfe0e2; + border: 1px solid #007bff; + } /* Apply styles to the first column, accounting for rowspan */ @@ -484,11 +492,15 @@ var lead_type = ""; // alert(lead_type); var rollover_or_renewal = ""; + + var rfq_count = ""; + // alert(rfq_count); if (lead_type != 1){ rollover_or_renewal = lead_type == 2 ? "Existing Renewal" : "Existing Roll Over"; } + // alert(rollover_or_renewal); var policyConfig = { 1: ['Quote asked'] @@ -505,7 +517,7 @@ var suggestions = {}; var policyInformationData = ; var storedData = {}; - // console.log("stored data : ", typeof(policyInformationData)) + // // console.log("stored data : ", typeof(policyInformationData)) if (policyInformationData.length) { @@ -515,16 +527,16 @@ var policySummary = []; - // console.log("policy summary is set :", !$.isEmptyObject(policySummary) ? "no" : "yes") + // // console.log("policy summary is set :", !$.isEmptyObject(policySummary) ? "no" : "yes") $(document).ready(function() { myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel')); }); var tableCount = 0; const policies = ; - // console.log('policies', policies); + // // console.log('policies', policies); const child_table_data = ; - // console.log('child_table_data', child_table_data); + // // console.log('child_table_data', child_table_data); const policyOrder = [{ 'fire': { @@ -586,7 +598,7 @@ let selectedPolicies = new Set(); let proposalCount = 1; - // console.log("Proposal count changed", proposalCount); + // // console.log("Proposal count changed", proposalCount); let quotesConfig = { 1: ['Quote asked'] }; // Stores quote columns for each proposal @@ -613,7 +625,7 @@ } insertPosition += quotesConfig[proposalNumber].length - 1; let table_id = table.id ? table.id : 'parent'; - // console.log('insert position of ' + table.id + ' - ' + insertPosition); + // // console.log('insert position of ' + table.id + ' - ' + insertPosition); // Add new quote sub-header const newQuoteHeader = document.createElement('th'); newQuoteHeader.textContent = newQuote; @@ -632,20 +644,27 @@ // Show dropdown menu function showDropdown(event) { - // console.log("dropdown function triggered"); + // // console.log("dropdown function triggered"); const dropdown = event.target.nextElementSibling; - // console.log(dropdown); + // // console.log(dropdown); dropdown.style.display = dropdown.style.display === 'block' ? 'none' : 'block'; event.stopPropagation(); } // Remove a proposal column function removeProposal(proposalNumber) { - let startIndex = 0; - console.log("Remove Proposal : startIndex 1 ",startIndex); - // console.log('removeProposal'); - console.log(quotesConfig); + // alert(proposalNumber); + var rowIdCount = {}; + + let startIndex = 0; + // console.log("Remove Proposal startIndex : ",startIndex); + // console.log("Remove Proposal proposalNumber : ",proposalNumber); + + + // // console.log('removeProposal'); + // console.log("quotesConfig",quotesConfig); + if (!quotesConfig[proposalNumber]) return; // If proposal doesn't exist, exit if(Object.keys(quotesConfig).length == 1){ toastr.warning("You cannot Delete All the Proposals","Warning"); @@ -654,42 +673,80 @@ // Remove all child columns for the proposal const tables = document.querySelectorAll('table'); tables.forEach(table => { + const headerRow1 = table.querySelector('thead tr:first-child'); const headerRow2 = table.querySelector('thead tr:last-child'); // Find the proposal header and calculate its colspan const proposalHeader = headerRow1.querySelector(`th[data-proposal="${proposalNumber}"]`); if (proposalHeader) { - console.log("Remove Proposal : quotesConfig ",quotesConfig[proposalNumber]); - console.log("Remove Proposal : proposalHeader ",proposalHeader); + // console.log("Remove Proposal : quotesConfig ",quotesConfig[proposalNumber]); + // console.log("Remove Proposal : proposalHeader ",proposalHeader); if (rfq_or_qcr == 1){ var colspan = parseInt(quotesConfig[proposalNumber].length); }else{ var colspan = parseInt(proposalHeader.getAttribute('colspan'), 10); } - console.log("Remove Proposal : colspan ",colspan); + // console.log("Remove Proposal : colspan ",colspan); // Remove the proposal header proposalHeader.remove(); // Remove corresponding sub-headers in the second header row const subHeaders = headerRow2.querySelectorAll(`th`); startIndex = 2; // Start after the first two columns (checkbox and Particulars) - console.log("Remove Proposal : startIndex 2",startIndex); - for (let i = 1; i < proposalNumber; i++) { - startIndex += quotesConfig[i]?.length || 0; - console.log("Remove Proposal : startIndex 3",startIndex); + // console.log("Remove Proposal : startIndex 2",startIndex); + // if (lead_type != 1){ + // proposalNumber = proposalNumber + 1; + // }else{ + + // } + if (lead_type != 1){ + for (let i = 0; i < proposalNumber; i++) { + // // console.log("quotesConfig[i] be", quotesConfig[i]) + // // console.log("quotesConfig[i] length", quotesConfig[i]?.length) + + + startIndex += quotesConfig[i]?.length || 0; + + + // console.log("quotesConfig[i] after", quotesConfig[i]); + // console.log("Remove Proposal : startIndex 3",startIndex); + } + }else{ + for (let i = 1; i < proposalNumber; i++) { + // // console.log("quotesConfig[i] be", quotesConfig[i]) + // // console.log("quotesConfig[i] length", quotesConfig[i]?.length) + + + startIndex += quotesConfig[i]?.length || 0; + + + // console.log("quotesConfig[i] after", quotesConfig[i]); + // console.log("Remove Proposal : startIndex 3",startIndex); + } } + for (let i = 0; i < colspan; i++) { - console.log("Remove Proposal : colspan ",colspan); - console.log("Remove Proposal : startIndex 4",startIndex) + // console.log("Remove Proposal : colspan ",colspan); + // console.log("Remove Proposal : startIndex 4",startIndex) headerRow2.removeChild(headerRow2.children[startIndex]); } // Remove corresponding cells in all rows table.querySelectorAll('tbody tr').forEach(row => { for (let i = 0; i < colspan; i++) { - row.removeChild(row.children[startIndex]); + var rowId = row.id; + if (rowIdCount[rowId] === undefined) { + rowIdCount[rowId] = 0; + } else { + rowIdCount[rowId]++; + } + // console.log("rowIdCount[rowId]", rowIdCount[rowId]); + newStartIndex = rowIdCount[rowId] > 0 ? startIndex-1 : startIndex; + // console.log("newStartIndex", newStartIndex) + row.removeChild(row.children[newStartIndex]); + } }); } @@ -699,21 +756,22 @@ delete quotesConfig[proposalNumber]; delete policyConfig[proposalNumber]; - // console.log("DELETE INSURE : policyConfig",policyConfig); - // console.log("DELETE INSURE : quotesConfig",quotesConfig); + // // console.log("DELETE INSURE : policyConfig",policyConfig); + // // console.log("DELETE INSURE : quotesConfig",quotesConfig); // alert(quotesConfig); // alert(policyConfig) + // console.log('End of the functions') } // Add a new row function addRow(event, element) { - // console.log(' event ', element); + // // console.log(' event ', element); const button = event.target; const row = button.closest('tr'); const table = row.closest('table'); const newRow = row.cloneNode(true); - // console.log("old Row ", row); + // // console.log("old Row ", row); // return false; var tableID = table.id; @@ -721,7 +779,7 @@ // Clear input values and generate new IDs newRow.querySelectorAll('td').forEach((td, index) => { if (index === 0) { - // console.log("Trying to set sno"); + // // console.log("Trying to set sno"); td.innerHTML = ""; td.innerHTML = `${nextSNO}`; } @@ -738,7 +796,7 @@ const row = button.closest('tr'); const table = row.closest('table'); if (row && row.parentElement.children.length > 1) { - // console.log("Row Removed"); + // // console.log("Row Removed"); row.remove(); updateSNO(table.id); } @@ -746,23 +804,23 @@ //function to hide all the 3 dot actions for the child table function hideProposalOptionsForChild() { - // // console.log('function called'); + // // // console.log('function called'); const parentTable = document.querySelector("table"); const tables = document.querySelectorAll('table'); - // // console.log('parentTable : ',parentTable); + // // // console.log('parentTable : ',parentTable); tables.forEach(table => { if (table !== parentTable) { // Hide .three-dot-menu in all other tables $(table).find(".three-dot-menu").hide(); - // // console.log("hided 3 dot menu in the table",table); + // // // console.log("hided 3 dot menu in the table",table); } }); } document.addEventListener("change", function(event) { const checkbox = event.target; if (checkbox.classList.contains("qcr-checkbox")) { - // // console.log("QCR checkbox change detected"); + // // // console.log("QCR checkbox change detected"); // Get the row containing the checkbox const row = checkbox.closest('tr'); @@ -776,15 +834,15 @@ // Optionally, you can trigger any additional logic here if (checkbox.checked) { - // // console.log("QCR checkbox is checked, client-checkbox is also checked"); + // // // console.log("QCR checkbox is checked, client-checkbox is also checked"); } else { - // // console.log("QCR checkbox is unchecked, client-checkbox is also unchecked"); + // // // console.log("QCR checkbox is unchecked, client-checkbox is also unchecked"); } } else { - // console.warn("No client-checkbox found in the same row"); + // // console.warn("No client-checkbox found in the same row"); } } else if (checkbox.classList.contains("client-checkbox")) { - // console.log("trying to change"); + // // console.log("trying to change"); const row = checkbox.closest('tr'); const qcrCheckbox = row.querySelector('.qcr-checkbox'); @@ -809,7 +867,7 @@ child_table_data[rowId]?.forEach(childTable => { if (childTable.table_type == "append") { var tableName = childTable.table_id; - // console.log("table name ", tableName); + // // console.log("table name ", tableName); // Handle excess table const excessContainer = document.createElement('div'); excessContainer.setAttribute('data-parent-row', tableName); @@ -819,7 +877,7 @@ if (result) { generateTable(excessContainer, true, rowId, childTable); container.appendChild(excessContainer); - // // console.log('Row id for excess table',rowId); + // // // console.log('Row id for excess table',rowId); $("#excess .three-dot-menu").hide(); moveExcessTableLast(); } @@ -827,7 +885,7 @@ // Handle regular table childContainer.setAttribute('data-parent-row', rowId); generateTable(childContainer, true, rowId, childTable); - // // console.log('Row id for excess table', rowId); + // // // console.log('Row id for excess table', rowId); $(childContainer).find(".three-dot-menu").hide(); // alert(`${rowId.toUpperCase()}_register`); @@ -845,17 +903,17 @@ arrangeTables(); alignTableColumn(); } else { - // console.log('UNCHECKED:', rowId); + // // console.log('UNCHECKED:', rowId); selectedPolicies.delete(rowId); // Remove regular child tables const regularContainers = container.querySelectorAll(`div[data-parent-row="${rowId}"]:not([data-excess-container])`); regularContainers.forEach(container => { - // console.log(" contaitner ", container); + // // console.log(" contaitner ", container); $(`#${rowId.toUpperCase()}_register`).prop("disabled", true); container.remove(); }); - // console.log("row id ", rowId); + // // console.log("row id ", rowId); // Handle excess table rows const excessTable = document.getElementById('excess'); if (excessTable) { @@ -865,7 +923,7 @@ // Check if excess table is empty const remainingRows = excessTable.querySelector('tbody').children; - // // console.log(remainingRows); + // // // console.log(remainingRows); if (remainingRows.length === 0) { // Remove the entire excess table container // const excessContainer = excessTable.closest('div[data-excess-container]'); @@ -881,7 +939,7 @@ } } } else if (checkbox.classList.contains("qcr-checkbox")) { - // console.log("QCR checkbox change detected"); + // // console.log("QCR checkbox change detected"); // Get the row containing the checkbox const row = checkbox.closest('tr'); @@ -895,20 +953,20 @@ // Optionally, you can trigger any additional logic here if (checkbox.checked) { - // console.log("QCR checkbox is checked, client-checkbox is also checked"); + // // console.log("QCR checkbox is checked, client-checkbox is also checked"); } else { - // console.log("QCR checkbox is unchecked, client-checkbox is also unchecked"); + // // console.log("QCR checkbox is unchecked, client-checkbox is also unchecked"); } } else { - console.warn("No client-checkbox found in the same row"); + // console.warn("No client-checkbox found in the same row"); } } }); // Add a new proposal document.getElementById('addProposal').addEventListener('click', () => { - // console.log("proposal count before ", proposalCount); + // // console.log("proposal count before ", proposalCount); proposalCount++; - // console.log("proposal count after ", proposalCount); + // // console.log("proposal count after ", proposalCount); quotesConfig[proposalCount] = ['Quote asked']; policyConfig[proposalCount] = ['Quote asked']; @@ -982,9 +1040,9 @@ targetCell = cells[cells.length - 1]; } - // console.log("ADD PROPOSAL : targetCell", targetCell); + // // console.log("ADD PROPOSAL : targetCell", targetCell); const newCell = targetCell.cloneNode(true); - // console.log("ADD PROPOSAL : newCell", newCell); + // // console.log("ADD PROPOSAL : newCell", newCell); newCell.contentEditable = true; newCell.onclick = () => getAnswer(table.id, row.id); @@ -993,6 +1051,9 @@ }); }); + // console.log(quotesConfig); + // console.log(policyConfig); + hideProposalOptionsForChild(); showOrHideFieldsBasedOnRFQorQCR(); // styleTableColumns(); @@ -1001,7 +1062,7 @@ // ################################################################################# function addNewQuote(proposalNumber) { - // console.log("add new Quote start : ", quotesConfig); + // // console.log("add new Quote start : ", quotesConfig); const insurers = ; selectInsurer(insurers).then(result => { insurer = result.selectedInsurer; @@ -1012,16 +1073,16 @@ let increaseBy = 100; increaseTableWidth(increaseBy); - // // console.log("Selected Insurer:", insurerName); - // // console.log("Entered Version:", version); - // // console.log("Entered data id:", dataId); - // console.log("add new Quote : ", proposalNumber); - // console.log("add new Quote : ", quotesConfig); - // console.log("Add new quote insurer name : ", insurerName); + // // // console.log("Selected Insurer:", insurerName); + // // // console.log("Entered Version:", version); + // // // console.log("Entered data id:", dataId); + // // console.log("add new Quote : ", proposalNumber); + // // console.log("add new Quote : ", quotesConfig); + // // console.log("Add new quote insurer name : ", insurerName); if (!quotesConfig[proposalNumber]) return; - // console.log("add new quote ", quotesConfig[proposalNumber]); + // // console.log("add new quote ", quotesConfig[proposalNumber]); if (quotesConfig[proposalNumber].includes(insurerName)) { - // console.log("add new quote is duplicate"); + // // console.log("add new quote is duplicate"); Swal.fire({ title: "Insurer Dublicate Found?", text: "Do you want version control!", @@ -1041,7 +1102,7 @@ for (let i = 0; i < quotesConfig[proposalNumber].length; i++) { if (quotesConfig[proposalNumber][i].startsWith(baseInsurerName)) { count++; - // console.log("add count ", count); + // // console.log("add count ", count); } } @@ -1049,12 +1110,12 @@ if (version === "") { insurerName = `${baseInsurerName} v${count + 1}`; version = count + 1; - // console.log("add inurer name ", insurerName); + // // console.log("add inurer name ", insurerName); } else { // If user already specified version, append count to make it unique insurerName = `${baseInsurerName} v${version}_${count + 1}`; version = `${version}_${count + 1}`; - // console.log("add inurer name else", insurerName); + // // console.log("add inurer name else", insurerName); } var insurerDetails = { @@ -1065,7 +1126,7 @@ policyConfig[proposalNumber].push(insurerDetails); const newQuote = insurerName; quotesConfig[proposalNumber].push(newQuote); - // console.log("add Quotes config", quotesConfig); + // // console.log("add Quotes config", quotesConfig); updateAllTables(proposalNumber, insurerName); var proposalName = `Proposal ${proposalNumber}`; @@ -1085,13 +1146,13 @@ policyConfig[proposalNumber].push(insurerDetails); const newQuote = insurerName; quotesConfig[proposalNumber].push(newQuote); - // console.log("add Quotes config", quotesConfig); + // // console.log("add Quotes config", quotesConfig); updateAllTables(proposalNumber, insurerName); var proposalName = `Proposal ${proposalNumber}`; const proposalHeader = document.querySelector(`th[data-proposal="${proposalNumber}"]`); if (proposalHeader) { - // console.log("Proposal heade length : ", quotesConfig[proposalNumber].length) + // // console.log("Proposal heade length : ", quotesConfig[proposalNumber].length) proposalHeader.colSpan = quotesConfig[proposalNumber].length; } } @@ -1108,7 +1169,7 @@ function changeInsurer(event, proposalNumber, currentInsurer) { // Stop event propagation event.stopPropagation(); - // console.log("insurer change function called ", quotesConfig[proposalNumber]); + // // console.log("insurer change function called ", quotesConfig[proposalNumber]); if (!quotesConfig[proposalNumber]) return; const insurers = ; @@ -1125,24 +1186,24 @@ newInsurerName = `${newInsurerName}-${newversion.trim()}`.replace(/\s+/g, ''); } - // console.log('insurer newInsurerName', newInsurerName); - // console.log('insurer newversion', newversion); + // // console.log('insurer newInsurerName', newInsurerName); + // // console.log('insurer newversion', newversion); if (newInsurerName) { - // // console.log("insurer inside new insurer name : ",headerRow2); + // // // console.log("insurer inside new insurer name : ",headerRow2); // Update all tables with the new insurer document.querySelectorAll('table').forEach(table => { const headerRow2 = table.querySelector('thead tr:last-child'); - // console.log("insurer inside ", headerRow2); + // // console.log("insurer inside ", headerRow2); // Find the header cells that match our criteria Array.from(headerRow2.children).forEach(th => { // Check if this cell contains our insurer and proposal - // console.log("insurer proposal number : ", proposalNumber); - // console.log("insurer header proposal number : ", th); + // // console.log("insurer proposal number : ", proposalNumber); + // // console.log("insurer header proposal number : ", th); if (th.getAttribute('data-proposal') === proposalNumber.toString()) { // Get the first text node (the insurer name part) let content = th.innerHTML; - // console.log("insurer inside ", content); + // // console.log("insurer inside ", content); // Only replace the exact insurer name, not any menu text if (content.includes(currentInsurer)) { // Create a regex to match just the insurer name @@ -1166,10 +1227,10 @@ // Generate new quote code based on new insurer const newQuoteCode = oldQuoteCode.replace(currentInsurer, newInsurerName); quotesConfig[proposalNumber][quoteIndex] = newQuoteCode; - // console.log("Existing policy data ", policyConfig[proposalNumber][quoteIndex]); + // // console.log("Existing policy data ", policyConfig[proposalNumber][quoteIndex]); policyConfig[proposalNumber][quoteIndex] = insurerDetailsChange; - // console.log("quote index ", quoteIndex); - // console.log("changed like this ", insurerDetailsChange); + // // console.log("quote index ", quoteIndex); + // // console.log("changed like this ", insurerDetailsChange); // Update data-quote attribute th.setAttribute('data-quote', newQuoteCode); } @@ -1203,11 +1264,13 @@ function removeQuote(event, proposalNumber, quoteCode) { event.stopPropagation(); + var rowIdCount = {}; + if (!quotesConfig[proposalNumber]) return; // Remove quote from config const quoteIndex = quotesConfig[proposalNumber].indexOf(quoteCode); - // console.log("quote index ", quoteIndex); + // // console.log("quote index ", quoteIndex); if (quoteIndex !== -1) { quotesConfig[proposalNumber].splice(quoteIndex, 1); policyConfig[proposalNumber].splice(quoteIndex, 1); @@ -1227,19 +1290,19 @@ th.textContent.includes(quoteCode) && th.getAttribute('data-proposal') === proposalNumber.toString() ); - // console.log("quote target index ", targetIndex); + // // console.log("quote target index ", targetIndex); if (targetIndex !== -1) { - // console.log("quote target index inside if", targetIndex); + // // console.log("quote target index inside if", targetIndex); // Remove from header row 2 headerRow2.removeChild(headerRow2.children[targetIndex]); // Update proposal header colspan const proposalHeader = headerRow1.querySelector(`th[data-proposal="${proposalNumber}"]`); - // console.log("quote target index inside if proposal header", proposalHeader); + // // console.log("quote target index inside if proposal header", proposalHeader); if (proposalHeader) { const newColspan = parseInt(proposalHeader.colSpan) - 1; - // console.log("Quote new colspan : ", newColspan); + // // console.log("Quote new colspan : ", newColspan); if (newColspan > 0) { proposalHeader.colSpan = newColspan; } else { @@ -1250,10 +1313,21 @@ // Remove from data rows table.querySelectorAll('tbody tr').forEach(row => { const cellIndex = targetIndex; // No need to add 2 since we're using children array - // console.log("quote target index inside if proposal header", cellIndex); + // console.log("quote target index", cellIndex); + + var rowId = row.id; + if (rowIdCount[rowId] === undefined) { + rowIdCount[rowId] = 0; + } else { + rowIdCount[rowId]++; + } + // console.log("rowIdCount[rowId]", rowIdCount[rowId]); + newStartIndex = rowIdCount[rowId] > 0 ? cellIndex-1 : cellIndex; + // console.log("quote target index inside if proposal header", newStartIndex); + if (row.children[cellIndex]) { - row.removeChild(row.children[cellIndex]); - // console.log("quote target index inside if proposal header", row); + row.removeChild(row.children[newStartIndex]); + // // console.log("quote target index inside if proposal header", row); } }); @@ -1262,17 +1336,17 @@ } function updateAllTables(proposalNumber, newQuote) { - + // alert(proposalNumber); document.querySelectorAll('table').forEach(table => { const headerRow1 = table.querySelector('thead tr:first-child'); const headerRow2 = table.querySelector('thead tr:last-child'); - // console.log('headerRow2 data', headerRow2); - // console.log('headerRow2 headerRow2.children', headerRow2.children); + // // console.log('headerRow2 data', headerRow2); + // // console.log('headerRow2 headerRow2.children', headerRow2.children); const proposalHeader = headerRow1.querySelector(`th[data-proposal="${proposalNumber}"]`); - // console.log("Proposal Header : ", proposalNumber); + console.log("Proposal proposalNumber : ", proposalNumber); // Create new quote header const newQuoteHeader = document.createElement('th'); newQuoteHeader.innerHTML = ` @@ -1292,25 +1366,31 @@ // Calculate header insert position let insertPosition = 2; - for (let i = 1; i < proposalNumber; i++) { - insertPosition += quotesConfig[i]?.length || 0; + if (lead_type == 1){ + for (let i = 1; i < proposalNumber; i++) { + insertPosition += quotesConfig[i]?.length || 0; + } + }else{ + for (let i = 0; i < proposalNumber; i++) { + insertPosition += quotesConfig[i]?.length || 0; + } } + insertPosition += quotesConfig[proposalNumber].length - 1; - // console.log("Header insert position : ", insertPosition); + // // console.log("Header insert position : ", insertPosition); if (headerRow2.children[insertPosition - 1]) { let referenceChild = headerRow2.children[insertPosition - 1]; // Get the target child - // console.log("referenceChild", referenceChild); + // // console.log("referenceChild", referenceChild); let computedStyle = window.getComputedStyle(referenceChild); - // console.log("computedStyle", computedStyle); + // // console.log("computedStyle", computedStyle); // Copy all computed styles - for (let prop of computedStyle) { - // console.log("prop", prop); - newQuoteHeader.style[prop] = computedStyle.getPropertyValue(prop); - } + let backgroundColor = computedStyle.getPropertyValue("background-color"); + newQuoteHeader.style.backgroundColor = backgroundColor; + } headerRow2.insertBefore(newQuoteHeader, headerRow2.children[insertPosition]); @@ -1452,7 +1532,7 @@ } tableName = tableData ? tableData.table_name : "Particulars"; - // // console.log("table Name ",tableName); + // // // console.log("table Name ",tableName); // Header setup const thead = document.createElement('thead'); const headerRow1 = document.createElement('tr'); @@ -1493,11 +1573,11 @@ thead.append(headerRow1, headerRow2); table.appendChild(thead); let latestWidth = $("table").last().width(); - // // console.log('Latest width', latestWidth); + // // // console.log('Latest width', latestWidth); if (tableData) { - // // console.log("table ",$(table)); + // // // console.log("table ",$(table)); $(table).width(latestWidth); // Convert to jQuery object using $(table) - // // console.log('table data',tableData); + // // // console.log('table data',tableData); } @@ -1583,42 +1663,42 @@ ${Object.values(quotesConfig).flatMap(codes => codes.map((codeValue, colIndex) => { - // console.log("Subheader th: colinded : ",colIndex); + // // console.log("Subheader th: colinded : ",colIndex); // Get the subheader (assuming it's the second inside ) let subHeaderThList = [...document.querySelectorAll("thead tr:nth-child(2) th")]; - console.log("subHeaderThList", subHeaderThList); + // // console.log("subHeaderThList", subHeaderThList); // Filter elements that have a valid 'data-proposal' attribute let validSubHeaders = subHeaderThList.filter(th => { let dataProposal = th.getAttribute("data-proposal"); - // console.log("Subheader th: dataProposal : ",dataProposal); + // // console.log("Subheader th: dataProposal : ",dataProposal); return dataProposal !== null && dataProposal !== undefined && dataProposal.trim() !== ""; }); - console.log("Subheader th: validSubHeaders",validSubHeaders); + // // console.log("Subheader th: validSubHeaders",validSubHeaders); // let validSubHeaders = subHeaderThList.filter(th => th.hasAttribute("data-proposal")); - // console.log("Subheader th: validSubHeaders",validSubHeaders); + // // console.log("Subheader th: validSubHeaders",validSubHeaders); let subHeaderTh = validSubHeaders.find(th => th.textContent.trim()); - console.log("Subheader th: codeValue",codeValue); - console.log("Subheader th: subHeaderTh",subHeaderTh); + // // console.log("Subheader th: codeValue",codeValue); + // // console.log("Subheader th: subHeaderTh",subHeaderTh); // if (subHeaderTh.classList.contains("insurer_proposal")) { // alert(subHeaderTh); // } let subHeaderText = subHeaderTh ? subHeaderTh.textContent.trim() : ''; - console.log("Subheader th: below code",subHeaderText); + // // console.log("Subheader th: below code",subHeaderText); // Check if subheader is NOT "Quote asked" let className = !subHeaderText.startsWith("Quote asked") && subHeaderText != "-" ? "insurer_proposal" : ""; - console.log("className", className); + // console.log("className", className); // alert(subHeaderText); let defaultJsonString = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array); - // // console.log("defaultJsonString", defaultJsonString); - // // console.log("defaultJsonString type", typeof defaultJsonString); - // // console.log("defaultJsonString string", String(defaultJsonString)); + // // // console.log("defaultJsonString", defaultJsonString); + // // // console.log("defaultJsonString type", typeof defaultJsonString); + // // // console.log("defaultJsonString string", String(defaultJsonString)); @@ -1672,7 +1752,7 @@ if (excessTable) { // If table exists, append new rows to it const tbody = excessTable.querySelector('tbody'); - // // console.log("table data ",tableData); + // // // console.log("table data ",tableData); // Add new rows from tableData tableData.table_row_contents.forEach((rowData, index) => { let rowID = Object.keys(rowData)[0]; @@ -1687,36 +1767,36 @@ ${question} ${Object.values(quotesConfig).flatMap(codes => codes.map((codeValue, colIndex) => { - // console.log("Subheader th: colinded : ",colIndex); + // // console.log("Subheader th: colinded : ",colIndex); // Get the subheader (assuming it's the second inside ) let subHeaderThList = [...document.querySelectorAll("thead tr:nth-child(2) th")]; // Filter elements that have a valid 'data-proposal' attribute let validSubHeaders = subHeaderThList.filter(th => { let dataProposal = th.getAttribute("data-proposal"); - // console.log("Subheader th: dataProposal : ",dataProposal); + // // console.log("Subheader th: dataProposal : ",dataProposal); return dataProposal !== null && dataProposal !== undefined && dataProposal.trim() !== ""; }); - // console.log("Subheader th: subHeaderThList",subHeaderThList); + // // console.log("Subheader th: subHeaderThList",subHeaderThList); // let validSubHeaders = subHeaderThList.filter(th => th.hasAttribute("data-proposal")); - // console.log("Subheader th: validSubHeaders",validSubHeaders); + // // console.log("Subheader th: validSubHeaders",validSubHeaders); let subHeaderTh = validSubHeaders.find(th => th.textContent.trim() === codeValue) || null; - // console.log("Subheader th: subHeaderTh",subHeaderTh); + // // console.log("Subheader th: subHeaderTh",subHeaderTh); // if (subHeaderTh.classList.contains("insurer_proposal")) { // alert(subHeaderTh); // } let subHeaderText = subHeaderTh ? subHeaderTh.textContent.trim() : ''; - // console.log("Subheader th: ",subHeaderText); + // // console.log("Subheader th: ",subHeaderText); // Check if subheader is NOT "Quote asked" let className = subHeaderText !== "Quote asked" && subHeaderText != "-" ? "insurer_proposal" : ""; // alert(subHeaderText); let defaultJsonString = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array); - // // console.log("defaultJsonString", defaultJsonString); - // // console.log("defaultJsonString type", typeof defaultJsonString); - // // console.log("defaultJsonString string", String(defaultJsonString)); + // // // console.log("defaultJsonString", defaultJsonString); + // // // console.log("defaultJsonString type", typeof defaultJsonString); + // // // console.log("defaultJsonString string", String(defaultJsonString)); @@ -1753,7 +1833,7 @@ } // Initialize the parent table document.addEventListener('DOMContentLoaded', () => { - // // console.log("bjnglfkrg ", rfq_data.length); + // // // console.log("bjnglfkrg ", rfq_data.length); const url = window.location.pathname; // Get the path (e.g., "/nhance/rfq/list/75/1") const segments = url.split("/"); // Split by "/" segments[segments.length - 1] = "1"; // Change the last segment @@ -1762,13 +1842,14 @@ history.pushState(null, "", newUrl); // Change the URL without reloading if (rfq_data.length) { - // console.log("inside if conditoon"); + // // console.log("inside if conditoon"); localStorage.setItem('allTablesJsonData', JSON.stringify(rfq_data)); jsonToTables(); + styleTableColumns(); proposalDataForDropDown = rfq_data[rfq_data.length - 1].proposal_data; - // console.log("proposalDataForDropDown", proposalDataForDropDown); + // // console.log("proposalDataForDropDown", proposalDataForDropDown); if (!$.isEmptyObject(storedData)) { - // console.log("DATA FROM DB : ", JSON.parse(storedData)); + // // console.log("DATA FROM DB : ", JSON.parse(storedData)); let data = JSON.parse(storedData); Object.keys(data).forEach(key => { @@ -1779,23 +1860,23 @@ }); - // // console.log("policy summary : ",child_table_data[key]) + // // // console.log("policy summary : ",child_table_data[key]) - // console.log("generate policy summary : ", policySummary); + // // console.log("generate policy summary : ", policySummary); styleTableColumns(); } // generateTable(document.getElementById('tablesContainer')); - // // console.log("polices Length ", policies.length); + // // // console.log("polices Length ", policies.length); } else { generateTable(document.getElementById('tablesContainer')); styleTableColumns(); - // console.log("polices Length ", policies.length); + // // console.log("polices Length ", policies.length); if (policies.length == 1) { setTimeout(() => { $(".sno-checkbox").each(function() { - // console.log("time completed function called"); + // // console.log("time completed function called"); $(".sno-checkbox").prop("checked", true); this.dispatchEvent(new Event("change", { bubbles: true @@ -1818,25 +1899,28 @@ function getAnswer(table_id, rowID) { event.stopPropagation(); - // console.log("Function called", table_id); + // alert(); + // // console.log("Function called"); + + // // console.log("Function called", table_id); var policy = table_id.split('_').slice(0, -1).join('_'); // var policy = 'policy_' + table; - // console.log('policy ', rowID); + // // console.log('policy ', rowID); Object.entries(child_table_data).forEach(([key, value]) => { if (key == policy) { var table_data = value; - // // console.log("table data ",table_data); + // // // console.log("table data ",table_data); // Loop through all available table data (removing hardcoded [0]) table_data.forEach(table => { var table_row = table['table_row_contents']; - // // console.log("table Row ",table_row); + // // // console.log("table Row ",table_row); Object.entries(table_row).forEach(([key, value]) => { var question_id = Object.keys(value)[0]; - // // console.log("Question ID : ",question_id," row ID : ",rowID); + // // // console.log("Question ID : ",question_id," row ID : ",rowID); if (question_id == rowID) { let questionData = value[question_id]; - // console.log("question data", questionData); + // // console.log("question data", questionData); if (questionData.answer_type == 'dropdown') { var answerAndValues = questionData.answers; @@ -1853,7 +1937,7 @@ function createDropdown(answerAndValues) { - // // console.log(answerAndValues); + // // // console.log(answerAndValues); const originalTd = event.target; const dropdown = document.createElement("div"); dropdown.classList.add("simple-dropdown"); @@ -1906,7 +1990,7 @@ const overallContainer = document.getElementById('allTableContainer'); if (!excessTable) { - // console.log("Excess table not found."); + // // console.log("Excess table not found."); return; } @@ -1962,9 +2046,9 @@ } function updateSNO(tableID) { - // console.log("Function Called Update Sno"); + // // console.log("Function Called Update Sno"); const table = document.getElementById(tableID); - // console.log("table : ", table); + // // console.log("table : ", table); if (!table) return; const rows = table.querySelectorAll("tbody tr"); @@ -1986,17 +2070,17 @@ $('.table-collapsible-bar').each(function() { let currentWidth = ($(this).width()); - // // console.log('table width ', typeof (currentWidth)); + // // // console.log('table width ', typeof (currentWidth)); let increaseTableWidth = (currentWidth + increaseBy); - // // console.log(increaseTableWidth); + // // // console.log(increaseTableWidth); $(this).width(currentWidth + increaseBy); }); - // // console.log("function called tablewidth increase"); + // // // console.log("function called tablewidth increase"); $("table").each(function() { let currentWidth = ($(this).width()); - // // console.log('table width ', typeof(currentWidth)); + // // // console.log('table width ', typeof(currentWidth)); let increaseTableWidth = (currentWidth + increaseBy); - // // console.log(increaseTableWidth); + // // // console.log(increaseTableWidth); $(this).width(currentWidth + increaseBy); }); } @@ -2005,7 +2089,7 @@ // Target the container const container = document.getElementById('tablesContainer'); if (!container) { - console.error('Error: tablesContainer not found'); + // console.error('Error: tablesContainer not found'); return; } @@ -2028,7 +2112,7 @@ const selectedContainers = containerArray.filter(container => selectedPolicies.has(container.policyName) ); - // // console.log('container selected ',selectedContainers); + // // // console.log('container selected ',selectedContainers); // Sort by priority selectedContainers.sort((a, b) => a.priority - b.priority); @@ -2041,11 +2125,11 @@ function setValueForHiddenField(element, answer_type) { // alert("hi"); if (answer_type != 'dropdown') { - // // console.log(element); + // // // console.log(element); const hiddenInput = element.querySelector("input[type='hidden']"); const updatedText = element.textContent.trim(); var updated_Text = element.textContent.trim(); - // // console.log('updated text ',updated); + // // // console.log('updated text ',updated); if (hiddenInput) { hiddenValue = updated_Text; @@ -2053,9 +2137,9 @@ // Convert it back to a JSON string and set the value hiddenInput.value = JSON.stringify(hiddenValue); - // console.log("Updated Hidden Input Value:", hiddenInput.value); + // // console.log("Updated Hidden Input Value:", hiddenInput.value); } else { - console.warn("No hidden input found inside the element."); + // console.warn("No hidden input found inside the element."); } } checkCellValueAndHighlight(); @@ -2126,11 +2210,11 @@ }); function getPolicyInfo(policyName) { - // console.log("anchor link clicked ", policyName); + // // console.log("anchor link clicked ", policyName); myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel')); - // console.log("inside if condition"); + // // console.log("inside if condition"); var leadID = $("#lead_id").val(); let policy = policies.find(p => p.name === policyName); @@ -2211,13 +2295,13 @@ } var policySummary = tableRowContent; - // console.log("policy summary ", policySummary); + // // console.log("policy summary ", policySummary); return policySummary; } async function selectInsurer(insurers) { - // console.log("Async function called"); + // // console.log("Async function called"); // Build the HTML for the Select2 dropdown and the input text field const selectHTML = `
@@ -2278,9 +2362,9 @@ } function saveRFQ() { - // console.log("save button clicked"); + // // console.log("save button clicked"); leadJson = tablesToJson(); - // console.log("json from function ", leadJson); + // // console.log("json from function ", leadJson); var policyJson = localStorage.getItem("policyData") ?? null; saveRFQTODB(leadJson, policyJson); } @@ -2310,7 +2394,7 @@ localStorage.removeItem('policyData'); toastr.success(response.message, "Success"); - // console.log(rfq_data.length); + // // console.log(rfq_data.length); $('.actionBtns').show(); if (rfq_or_qcr == 2) { @@ -2329,16 +2413,25 @@ error: function(xhr, status, error) { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - console.error(xhr.responseText); - console.error(status, error); + // console.error(xhr.responseText); + // console.error(status, error); } }) } function prepareOverallData() { + var proposalKey = ""; const overAllData = {}; Object.entries(policyConfig).forEach(([proposalNumber, insurers]) => { - const proposalKey = `Proposal ${proposalNumber}`; + if (lead_type == 1){ + proposalKey = `Proposal ${proposalNumber}`; + }else{ + if (proposalNumber == 0){ + proposalKey = `${rollover_or_renewal} ${proposalNumber}`; + }else{ + proposalKey = `Proposal ${proposalNumber}`; + } + } overAllData[proposalKey] = { qcr: 0, stc: 0, @@ -2352,7 +2445,7 @@ overAllData[proposalKey].qcr = qcrSelected ? 1 : 0; overAllData[proposalKey].stc = stcSelected ? 1 : 0; } - // console.log("Insurers Found", insurers); + // // console.log("Insurers Found", insurers); const uniqueInsurers = []; insurers.forEach(insurer => { @@ -2362,11 +2455,11 @@ insurerHeaders.forEach(header => { const headerProposalCount = header.getAttribute("data-proposal"); if (headerProposalCount == proposalNumber) { - // console.log("Found the subheader we are searching"); + // // console.log("Found the subheader we are searching"); if (header.querySelector('.sendInsurerClientProposal .fa-check-square') !== null) { stcInsurerSelected = true; } - // console.log("STC selected for insurer:", stcInsurerSelected); + // // console.log("STC selected for insurer:", stcInsurerSelected); } }); uniqueInsurers.push({ @@ -2378,10 +2471,10 @@ }); } }); - // console.log("Unique Insurers Found", uniqueInsurers); + // // console.log("Unique Insurers Found", uniqueInsurers); overAllData[proposalKey].insurers = Array.from(uniqueInsurers.values()); }); - // console.log("overalll data created is ", overAllData); + // // console.log("overalll data created is ", overAllData); return overAllData; } @@ -2402,7 +2495,7 @@ var headers = []; const data = []; const tableId = table.id; // Ensure each table has a unique ID - // // console.log('Processing table:', tableId); + // // // console.log('Processing table:', tableId); // Get parent headers and subheaders for the current table const parentHeaders = table.querySelectorAll('thead tr:nth-child(1) th'); @@ -2410,34 +2503,34 @@ let headerIndex = 0; parentHeaders.forEach(header => { - // console.log("Found header ", header); - if (header.innerText.trim().startsWith("Proposal")) { + // // console.log("Found header ", header); + if (header.innerText.trim().startsWith("Proposal") || header.innerText.trim().startsWith("Existing")) { var policyNumber = header.getAttribute("data-proposal"); var colspan = parseInt(quotesConfig[policyNumber].length); - // console.log("Found header true colspan : ", colspan); + // // console.log("Found header true colspan : ", colspan); } else { var colspan = parseInt(header.getAttribute('colspan')) || 1; } const subHeaderArray = []; // console.log("processing save function header : ", header); - // // console.log("processing save colspn : ",colspan); + // // // console.log("processing save colspn : ",colspan); for (let i = 0; i < colspan; i++) { const subheaderHTML = subHeaders[headerIndex].innerHTML; const subheaderText = subheaderHTML.replace(//g, '').trim(); subHeaderArray.push(subheaderText); headerIndex++; } - // console.log("inside save colspn : ", colspan); + // // console.log("inside save colspn : ", colspan); const headerHTML = header.innerHTML; const headerText = headerHTML.replace(//g, '').trim(); // console.log("processing sub header array : ", subHeaderArray); - // console.log("HEader : ", header.innerText == " " ? header.innerText.trim() : headerText); + // // console.log("HEader : ", header.innerText == " " ? header.innerText.trim() : headerText); headers.push({ // parentHeader: header.innerText.replace('⋮', '').split('\n')[0].replace(/:.*/, '').trim(), parentHeader: headerText, subHeaders: subHeaderArray }); - // console.log("processing sub header array : ", headers); + // // console.log("processing sub header array : ", headers); }); // Process each row in the current table @@ -2447,11 +2540,11 @@ let rowIdForRemoveFirstIndex = ""; rows.forEach(row => { const rowId = row.id; - // console.log("row id : ", rowId); - // console.log("Suggestions :", suggestions); + // // console.log("row id : ", rowId); + // // console.log("Suggestions :", suggestions); const inputType = suggestions[rowId]?.answer_type || 'text'; // Default to 'text' if undefined const cells = row.querySelectorAll('td'); - // // console.log("row id going to submit us ", ); + // // // console.log("row id going to submit us ", ); const rowData = { SNO: cells[0] ? getTextExcludingButton(cells[0]) : '', items: cells[1]?.innerText || '', @@ -2459,11 +2552,11 @@ data: [] }; if (tableId == "excess") { - // console.log("row Trying to set : ", row); - // console.log("row Trying to set : ", row.outerHTML); + // // console.log("row Trying to set : ", row); + // // console.log("row Trying to set : ", row.outerHTML); rowData['parentPolicy'] = row.getAttribute("data-excess-row-parent") } - // console.log("Row data foint to submit ", rowData); + // // console.log("Row data foint to submit ", rowData); let dataIndex = 0; if (rowIdCount[rowId] === undefined) { rowIdCount[rowId] = 0; @@ -2471,15 +2564,15 @@ rowIdCount[rowId]++; } const occurrence = rowIdCount[rowId]; - // console.log("NEw Method : rowIdCount",rowIdCount) - // console.log("NEw Method : occurrence",occurrence) + // // console.log("NEw Method : rowIdCount",rowIdCount) + // // console.log("NEw Method : occurrence",occurrence) let rowspan_row_id = ''; if (occurrence > 0) { var headers2 = headers; headers2 = headers2.filter((header, index) => !(index === 0 && header.parentHeader === "Policy")); - // console.log("Header 2 ",headers2); + // // console.log("Header 2 ",headers2); headers2.forEach((header2, TableDataHeaderIndex) => { header2.subHeaders.forEach(subHeader => { @@ -2490,7 +2583,7 @@ if (inputType === "text" && header2.parentHeader === 'Action') { const qcrInput = cell.querySelector('input[name="qcr"]'); const clientInput = cell.querySelector('input[name="stc"]'); - // console.log("QCR INPUT : ", qcrInput); + // // console.log("QCR INPUT : ", qcrInput); content = { qcr: qcrInput?.checked ? 1 : 0, @@ -2499,7 +2592,7 @@ } else { const input = cell.querySelector('input, select, textarea'); if (input) { - // console.log("Input type:", input.type); + // // console.log("Input type:", input.type); if (input.type === "checkbox") { content = input.checked ? "Checked" : "Not Checked"; // Handling checkboxes @@ -2507,7 +2600,7 @@ } else { content = input.value; // Handling other input types like text, select, textarea display_content = cell.innerText.trim(); - // console.log("processing sub header array : ", content); + // // console.log("processing sub header array : ", content); } } else { content = cell.innerText.trim(); // If no input is found, use the cell's text @@ -2536,11 +2629,11 @@ // let parentThDataText; // if (headers[TableDataHeaderIndex + headerIndexOffset]) { // parentThDataText = headers[TableDataHeaderIndex + headerIndexOffset].parentHeader; - // // console.log("NEw Method : parentThDataText",parentThDataText) + // // // console.log("NEw Method : parentThDataText",parentThDataText) // } else { // parentThDataText = header.parentHeader; // Fallback if there are no more headers // } - // // console.log(`Row ${rowId} occurrence ${occurrence} using header: `, parentThDataText); + // // // console.log(`Row ${rowId} occurrence ${occurrence} using header: `, parentThDataText); header.subHeaders.forEach(subHeader => { @@ -2551,7 +2644,7 @@ if (inputType === "text" && header.parentHeader === 'Action') { const qcrInput = cell.querySelector('input[name="qcr"]'); const clientInput = cell.querySelector('input[name="stc"]'); - // console.log("QCR INPUT : ", qcrInput); + // // console.log("QCR INPUT : ", qcrInput); content = { qcr: qcrInput?.checked ? 1 : 0, @@ -2560,7 +2653,7 @@ } else { const input = cell.querySelector('input, select, textarea'); if (input) { - // console.log("Input type:", input.type); + // // console.log("Input type:", input.type); if (input.type === "checkbox") { content = input.checked ? "Checked" : "Not Checked"; // Handling checkboxes @@ -2568,7 +2661,7 @@ } else { content = input.value; // Handling other input types like text, select, textarea display_content = cell.innerText.trim(); - // console.log("processing sub header array : ", content); + // // console.log("processing sub header array : ", content); } } else { content = cell.innerText.trim(); // If no input is found, use the cell's text @@ -2581,14 +2674,14 @@ // if(rowId == rowspan_row_id){ // parentThDataText = rowspan_row_id == rowId ? headers[TableDataHeaderIndex + 1].parentHeader : header.parentHeader; - // // console.log('rowspan_row_id parentThDataText', parentThDataText); - // // console.log('rowspan_row_id', rowspan_row_id); + // // // console.log('rowspan_row_id parentThDataText', parentThDataText); + // // // console.log('rowspan_row_id', rowspan_row_id); // rowspan_row_id = rowspan_row_id - 1; - // // console.log('rowspan_row_id after decrement', rowspan_row_id); + // // // console.log('rowspan_row_id after decrement', rowspan_row_id); // } - // // console.log("trying to find what this is ",cell); + // // // console.log("trying to find what this is ",cell); rowData.data.push({ parentth: header.parentHeader, subth: subHeader, @@ -2603,11 +2696,11 @@ }); data.push(rowData); - // // console.log("processing sub header array : ",content); + // // // console.log("processing sub header array : ",content); }); tablePolicyName = [...selectedPolicies].find(policy => tableId.startsWith(policy)) || null; - // console.log(selectedPolicies); - // console.log(tablePolicyName); + // // console.log(selectedPolicies); + // // console.log(tablePolicyName); // Get table-specific over_all_column_data (adjust based on your data structure) @@ -2631,7 +2724,7 @@ }); // Save all tables' data to localStorage localStorage.setItem('allTablesJsonData', JSON.stringify(allTablesData)); - // console.log('All tables data saved:', allTablesData); + // // console.log('All tables data saved:', allTablesData); // toastr.success("RFQ Saved Successfully", "SUCCESS"); // If needed, reconstruct tables from JSON (implement jsonToTable accordingly) @@ -2645,7 +2738,7 @@ segments[segments.length - 1] = "2"; // Change the last segment const newUrl = segments.join("/"); // Rebuild the URL - // console.log('newUrl', newUrl) + // // console.log('newUrl', newUrl) history.pushState(null, "", newUrl); // Change the URL without reloading @@ -2669,9 +2762,19 @@ Object.entries(overAllColumnData).forEach(([proposalKey, proposalData]) => { // Extract proposal number from the key (ensuring it's properly extracted) let match = proposalKey.match(/\d+/); // Extracts the number from "Proposal X" - let proposalNumber = match ? match[0] : undefined; + let proposalNumber = ""; + if (lead_type == 1){ + proposalNumber = match ? match[0] : undefined; + }else{ + if (rfq_count == 0){ + proposalNumber = 0; + }else{ + // alert(proposalData); + proposalNumber = match ? match[0] : undefined; + } + } - if (!proposalNumber) return; // Skip if extraction fails + // if (!proposalNumber) return; // Skip if extraction fails // Initialize with "Quote asked" result[proposalNumber] = ["Quote asked"]; @@ -2696,15 +2799,22 @@ function setQuotesConfig(overallColumnData) { let quotesConfiguration = {}; // Stores the transformed output let index = 1; // Keeps track of proposal index - // console.log(overallColumnData); + // // console.log(overallColumnData); Object.keys(overallColumnData).forEach((proposalKey) => { let parts = proposalKey.split(" "); let lastNumber = parseInt(parts[parts.length - 1], 10); - index = lastNumber; - // console.log(proposalKey); - // console.log(index); - // console.log(value); + + if (lead_type == 1){ + index = lastNumber; + }else{ + if (rfq_count == 0){ + index = 0; + }else{ + index = lastNumber; + } + } + let proposal = overallColumnData[proposalKey]; let insurersList = proposal.insurers.map(ins => ins.ins_name); // Extract insurer names @@ -2717,9 +2827,9 @@ } function addSuggestion(rowData) { - console.log("child table data rowData", rowData); - console.log("child table data rowData.id", rowData.row_id); - console.log("child table data child_table_data", child_table_data[rowData.row_id]); + // // console.log("child table data rowData", rowData); + // // console.log("child table data rowData.id", rowData.row_id); + // // console.log("child table data child_table_data", child_table_data[rowData.row_id]); var table_data = child_table_data[rowData.row_id]; @@ -2731,7 +2841,7 @@ }); }); - // console.log("child table data ", suggestions); + // // console.log("child table data ", suggestions); // child_table_data[rowData.rowID] } @@ -2761,18 +2871,28 @@ quotesConfig = setQuotesConfig(proposalDataArray.proposal_data.over_all_column_data); let keys = Object.keys(quotesConfig); let lastKey = keys[keys.length - 1]; - proposalCount = lastKey; + if (lead_type == 1){ + proposalCount = lastKey; + }else{ + if (rfq_count == 0){ + proposalCount = 0; + }else{ + proposalCount = keys.length-1; + } + } + + proposalCountForTableINcrease = keys.length; - console.log(proposalCount); + // console.log(proposalCount); // Calculate width increase let increaseBy = rfq_or_qcr == 2 ? getTotalCount(proposalDataArray) * 150 : proposalCountForTableINcrease * 150; - console.log("Quotes COnfig : ",quotesConfig); - console.log("policy COnfig :", policyConfig); - // // console.log("trying to find checkbox data : : : ", increaseBy); + // console.log("Quotes COnfig : ",quotesConfig); + // console.log("policy COnfig :", policyConfig); + // // // console.log("trying to find checkbox data : : : ", increaseBy); suggestions = {}; @@ -2854,7 +2974,7 @@ else { // td.onclick = () => getAnswer(table.id, tr.id); td.innerHTML = processCellContent(cellData.input_value, rowData, cellData.display_content); - // console.log("DEBUG ISSUE : ",cellData.parentth) + // // console.log("DEBUG ISSUE : ",cellData.parentth) if (cellData.parentth.startsWith("Proposal") || cellData.parentth.startsWith("Existing")) { if (lead_type == 1){ @@ -2864,8 +2984,9 @@ td.classList.add("insurer_proposal"); } }else{ - + td.onclick = () => getAnswer(table.id, tr.id); if (cellData.subth != "Quote asked") { + td.onclick = () => getAnswer(table.id, tr.id); td.classList.add("insurer_proposal"); } } @@ -2956,40 +3077,70 @@ const headerRow2 = document.createElement('tr'); var overallColumnDataProposal = proposal_data.proposal_data.over_all_column_data; var matchedKey = ""; + var headerName = ''; headers.forEach(header => { // Parent header const th1 = document.createElement('th'); th1.textContent = header.parentHeader; if (header.parentHeader.startsWith('Proposal') || header.parentHeader.startsWith("Existing")) { if (lead_type == 1){ - var headerName = header.parentHeader; + headerName = header.parentHeader; }else{ - var headerName = rollover_or_renewal; - } + if (rfq_count == 0){ + headerName = rollover_or_renewal; + }else{ + headerName = header.parentHeader; + } + } + var proposalHTMLNumber = ""; + console.log("Header Name : ",header.parentHeader); + // alert(headerName); if (lead_type == 1){ + console.log("Header Name lead type 1 : ",header.parentHeader); matchedKey = Object.keys(overallColumnDataProposal).find(key => headerName.startsWith(key)); + proposalHTMLNumber = header.parentHeader.split(' ')[1]; }else{ + console.log("Header Name lead type not 1 : ",header.parentHeader); + + if (rfq_count == 0 && header.parentHeader.startsWith("Proposal")){ + console.log("Header Name lead type not 1 proposal: ",header.parentHeader); - if (header.parentHeader.startsWith("Proposal")){ var tempHeader = header.parentHeader; matchedKey = Object.keys(overallColumnDataProposal).find(key => tempHeader.startsWith(key)); + proposalHTMLNumber = 0; + }else{ - matchedKey = Object.keys(overallColumnDataProposal).find(key => headerName.startsWith(key)); + + console.log("Header Name lead type not 1 noy proposal: ",header.parentHeader); + + if (header.parentHeader.startsWith("Existing")){ + var tempHeader2 = lead_type == 2 ?"Existing Renewal 0":"Existing Roll Over 0"; + matchedKey = Object.keys(overallColumnDataProposal).find(key => tempHeader2.startsWith(key)); + proposalHTMLNumber = 0; + // alert(tempHeader2); + }else if (header.parentHeader.startsWith("Proposal")){ + matchedKey = Object.keys(overallColumnDataProposal).find(key => headerName.startsWith(key)); + proposalHTMLNumber = header.parentHeader.split(' ')[1]; + } + + // alert(matchedKey); } } if (matchedKey) { - // console.log("something wrong : ", overallColumnDataProposal[matchedKey]); + // // console.log("something wrong : ", overallColumnDataProposal[matchedKey]); var headerCheckBoxProperties = overallColumnDataProposal[matchedKey]; + // // console.log("something wrong :headerCheckBoxProperties ", headerCheckBoxProperties); } + th1.innerHTML = ` - ${header.parentHeader} + ${headerName} `; th1.colSpan = header.subHeaders.length; - // // console.log("insurer data proposal set : ",th1); // See the element's attributes in the console + // // // console.log("insurer data proposal set : ",th1); // See the element's attributes in the // console } headerRow1.appendChild(th1); - // // console.log("this is the header : ", header); + // // // console.log("this is the header : ", header); // Sub headers header.subHeaders.forEach(subHeader => { const th2 = document.createElement('th'); if (header.parentHeader.startsWith("Proposal") || header.parentHeader.startsWith("Existing")) { var insurers = overallColumnDataProposal[matchedKey].insurers; + // // console.log("trying to find something :header.parentHeader ", header.parentHeader); + // // console.log("trying to find something :insurers ", insurers); + // // console.log("trying to find : subHeader",subHeader) const matchedInsurer = insurers.find(ins => ins.ins_name == subHeader); + if (subHeader != "Quote asked") { - // console.log("trying to find something : ", matchedInsurer.stc); + // // console.log("trying to find something : matchedInsurer", matchedInsurer); + // // console.log("trying to find something :matchedInsurer stc ", matchedInsurer.stc); + // // console.log("trying to find something : ", matchedInsurer.stc); - // console.log("this is the subheader : ", subHeader); - // console.log("debug 2: ", subHeader, "parent header : ", header.parentHeader); + // // console.log("this is the subheader : ", subHeader); + // // console.log("debug 2: ", subHeader, "parent header : ", header.parentHeader); th2.classList.add("insurer_proposal"); th2.innerHTML = ` ${subHeader} @@ -3032,19 +3189,34 @@ style="background-color: rgb(221, 221, 221);">Send to Client ${matchedInsurer.stc == 1 ? ``: ""} - - + +
`; } else { th2.textContent = subHeader; } + if (lead_type == 1){ + + th1.setAttribute('data-proposal', header.parentHeader.split(' ')[1]); + th2.setAttribute('data-proposal', header.parentHeader.split(' ')[1]); - th2.setAttribute('data-proposal', header.parentHeader.split(' ')[1]); + }else{ + if (headerName.startsWith("Existing")){ + th1.setAttribute('data-proposal',0); + th2.setAttribute('data-proposal',0); + + }else{ + th1.setAttribute('data-proposal', header.parentHeader.split(' ')[1]); + th2.setAttribute('data-proposal', header.parentHeader.split(' ')[1]); + + } + + } th2.setAttribute("data-quote", subHeader); - th1.setAttribute('data-proposal', header.parentHeader.split(' ')[1]); - // // console.log("header insert position ",th1.getAttribute()) + + // // // console.log("header insert position ",th1.getAttribute()) } else { th2.textContent = subHeader; @@ -3068,7 +3240,7 @@ if (value == "Checked") { addSuggestion(cellData); } - // // console.log("insude the function value ", value); + // // // console.log("insude the function value ", value); return ` ${cellData.SNO} ${cellData.SNO == 'Fire' || cellData.SNO == 'Burglary' ? `
+ + + +
+ +
+ + +
+
+ /assets/images/nhance-loader-fast.gif" height="40" width="40" alt="Loading..."> +
+
+ + + +
+

© 2025 Nhance India Pvt Ltd. All Rights Reserved.

+
+ + + + + + \ No newline at end of file diff --git a/app/Views/ticket_feedback_list.php b/app/Views/ticket_feedback_list.php new file mode 100644 index 00000000..f4de0f73 --- /dev/null +++ b/app/Views/ticket_feedback_list.php @@ -0,0 +1,148 @@ + + + + + +
+
+
+
+
+

Claim Feedback List

+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + +
Claim NumberEmp CodeEmp nameCorporate name
+ +
+
+
+
+
+
+ + + + + + \ No newline at end of file From 240c821f20e84b4e6735b413dfca76b6b552198b Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 3 Apr 2025 17:39:06 +0530 Subject: [PATCH 041/169] CHANGE_CLAIM_CR : RV --- app/Controllers/TicketController.php | 44 ++++++++++++++++++++++++++-- app/Views/ticket_history.php | 3 +- app/Views/ticket_list.php | 2 +- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index a783fa2f..6c2942c9 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -121,6 +121,7 @@ class TicketController extends BaseController '((AUTO_QUERY_CONTENT))' => 'auto_query_content', '((CLAIM_FORM_LINK))' => 'claim_form_link', '((CLAIM_FEEDBACK_FORM))' => 'claim_feedback_form', + '((SETTLED_LETTER))' => 'settle_letter', ]; $this->extraFields = [ 1 => ['non_id_reason'], @@ -233,6 +234,7 @@ class TicketController extends BaseController 'tcs.claim_status AS status', 'tm.claim_number AS claim_no', 'tm.tpa_id', + 'tm.tpa_no', 'tm.emp_name', 'tm.emp_code', 'i.name AS insurer_name', @@ -274,6 +276,7 @@ class TicketController extends BaseController 'tm.claim_status_id', 'tm.is_head_approved', 'tm.tpa_id', + 'tm.tpa_no', 'tm.emp_name', 'tm.emp_code', 'i.name AS insurer_name', @@ -857,7 +860,7 @@ class TicketController extends BaseController } // Construct Mail Data - $mailData = [ + $mailData[] = [ 'mail' => $ticket_data['emp_mail'], 'subject' => $subject, 'message' => $message, @@ -865,6 +868,17 @@ class TicketController extends BaseController 'attachments' => [] ]; + // if the employee personal mail is not empty then send the mail to the employee personal mail + if(!empty($ticket_data['emp_personal_mail'])){ + $mailData[] = [ + 'mail' => $ticket_data['emp_personal_mail'], + 'subject' => $subject, + 'message' => $message, + 'cc' => $ticket_data['common_mails'] ?? '', + 'attachments' => [] + ]; + } + // print_r($mailData); die; $this->myLogger->logme('error', "Final Email Data"); @@ -891,6 +905,8 @@ class TicketController extends BaseController $replaceData = 'Click here to download Claim Form'; } else if ($value == "claim_feedback_form"){ $replaceData = 'Click to open Claim Feedback Form'; + } else if ($value == "settle_letter"){ + $replaceData = ' View Settlement Letter '; }else { $replaceData = isset($ticket_data[$value]) ? $ticket_data[$value] : ''; } @@ -949,6 +965,27 @@ class TicketController extends BaseController $this->myLogger->logme('error', "Fetched ACM emails"); + + if(!empty($ticket_data['emp_personal_mail'])){ + + $this->myLogger->logme('error', "Send employee personal mail start"); + + $emailPersonalData = [ + 'mail' => $ticket_data['emp_personal_mail'], + 'subject' => $mail_data['mail_subject'], + 'message' => $mail_data['mail_content'], + 'common' => [], + 'cc' => $acm_mails['common_mails'], + 'attachments' => [] + ]; + + $this->sendTrigger($emailPersonalData); + + $this->myLogger->logme('error', "Send employee personal mail successfully"); + }else{ + $this->myLogger->logme('error', "Send employee personal mail is empty"); + } + $emailData = [ 'mail' => $mail_data['emp_mail'], 'subject' => $mail_data['mail_subject'], @@ -972,7 +1009,10 @@ class TicketController extends BaseController if (!empty($auto_mail_enable) && $auto_mail_enable['is_auto_mail'] == 1) { $mail_content = $this->constructMailContent($ticket_id); // print_r($mail_content); die; - $mail_responce = $this->sendTrigger($mail_content); + foreach ($mail_content as $key => $value) { + $mail_responce = $this->sendTrigger($value); + $this->myLogger->logme('error', '{data} - Auto Mail Sent, Successfully', ['data' => $key + 1]); + } } elseif (!empty($auto_mail_enable) && $auto_mail_enable['is_auto_mail'] == 0) { $this->myLogger->logme('error', 'Auto Mail Not Sent, Reason: Automail Not Enabled'); } else { diff --git a/app/Views/ticket_history.php b/app/Views/ticket_history.php index 0a783d26..c0e5bfea 100644 --- a/app/Views/ticket_history.php +++ b/app/Views/ticket_history.php @@ -21,7 +21,8 @@ '.$row['new_value']; ?> - + + diff --git a/app/Views/ticket_list.php b/app/Views/ticket_list.php index fa5c8fcc..f0410316 100644 --- a/app/Views/ticket_list.php +++ b/app/Views/ticket_list.php @@ -114,7 +114,7 @@ table.dataTable tbody td { - + From 27817789addc68b17d6aefc8669fc3c4200ea062 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Fri, 4 Apr 2025 14:25:21 +0530 Subject: [PATCH 042/169] DEBUG_CHATBOT --- .../Chatbot/EcardDownloadConversation.php | 2 ++ app/Controllers/Chatbot/MainMenuConversation.php | 8 ++++++++ .../Chatbot/NetworkHospitalConversation.php | 3 +++ app/Controllers/Chatbot/policyConversation.php | 3 +++ app/Controllers/ChatbotControllerNew.php | 14 +++++++------- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/app/Controllers/Chatbot/EcardDownloadConversation.php b/app/Controllers/Chatbot/EcardDownloadConversation.php index b0cb78ae..84617af1 100644 --- a/app/Controllers/Chatbot/EcardDownloadConversation.php +++ b/app/Controllers/Chatbot/EcardDownloadConversation.php @@ -17,6 +17,8 @@ class EcardDownloadConversation extends Conversation protected function showEcardMenu() { + log_message('error', ('showEcardMenu function called')); + $chat_session_info = get_chatbot_session_info(); $policy_list = ChatbotHelper::getListOfPolicies($chat_session_info); $buttons = []; diff --git a/app/Controllers/Chatbot/MainMenuConversation.php b/app/Controllers/Chatbot/MainMenuConversation.php index 87d9a4ef..875ecba4 100644 --- a/app/Controllers/Chatbot/MainMenuConversation.php +++ b/app/Controllers/Chatbot/MainMenuConversation.php @@ -46,9 +46,14 @@ class MainMenuConversation extends Conversation $this->bot->reply($message); } + log_message('error', ('user_reponse before: ' . $user_reponse)); + + if (!$answer->isInteractiveMessageReply()) { $user_reponse = null; } + + // Get just the existing path array $path = $this->bot->userStorage()->get('path') ?? []; @@ -60,6 +65,9 @@ class MainMenuConversation extends Conversation 'path' => $path ]); + log_message('error', ('user_reponse : ' . $user_reponse)); + + switch ($user_reponse) { case "ecard_download": diff --git a/app/Controllers/Chatbot/NetworkHospitalConversation.php b/app/Controllers/Chatbot/NetworkHospitalConversation.php index 2e59f896..4a1e991c 100644 --- a/app/Controllers/Chatbot/NetworkHospitalConversation.php +++ b/app/Controllers/Chatbot/NetworkHospitalConversation.php @@ -59,7 +59,10 @@ class NetworkHospitalConversation extends Conversation $this->bot->userStorage()->save([ 'path' => $path ]); + log_message('error', ('user_reponse : ' . $answer->getValue())); + switch ($answer->getValue()) { + case is_string($answer->getValue()) && is_array(explode('#',$answer->getValue())) && count((explode('#',$answer->getValue()))) == 2: $client_poilicy_id = explode('#',$answer->getValue())[1]; diff --git a/app/Controllers/Chatbot/policyConversation.php b/app/Controllers/Chatbot/policyConversation.php index 04c8d9a5..f2fe91c1 100644 --- a/app/Controllers/Chatbot/policyConversation.php +++ b/app/Controllers/Chatbot/policyConversation.php @@ -46,6 +46,9 @@ class policyConversation extends Conversation if (!$answer->isInteractiveMessageReply()) { $user_reponse = null; } + + log_message('error', ('user_reponse : ' . $answer->getValue())); + $path = $this->bot->userStorage()->get('path'); array_push($path, $answer->getValue() diff --git a/app/Controllers/ChatbotControllerNew.php b/app/Controllers/ChatbotControllerNew.php index 610f2bda..2f6ca404 100644 --- a/app/Controllers/ChatbotControllerNew.php +++ b/app/Controllers/ChatbotControllerNew.php @@ -89,7 +89,7 @@ class ChatbotControllerNew extends BaseController $user = $this->botman->getUser(); $id = $user->getId(); - // $this->myLogger->logme('error', ('TEST' . $id)); + $this->myLogger->logme('error', ('TEST' . $id)); $this->session->set('CHATBOT_RANDOM_USER_ID', $id); } @@ -128,14 +128,14 @@ class ChatbotControllerNew extends BaseController $this->botman->listen(); } - private function registerHandlers() - { - // Handling Policy and Claims - $this->botman->hears('group:policy:{option}', [\App\Controllers\Chatbot\PolicyHandler::class, 'handle']); - $this->botman->hears('group:claim:{option}', [\App\Libraries\Chatbot\ClaimHandler::class, 'handle']); + // private function registerHandlers() + // { + // // Handling Policy and Claims + // $this->botman->hears('group:policy:{option}', [\App\Controllers\Chatbot\PolicyHandler::class, 'handle']); + // $this->botman->hears('group:claim:{option}', [\App\Libraries\Chatbot\ClaimHandler::class, 'handle']); - } + // } public function chatbot() { From 1897b8760711415cb008d8da3120fd69b8695c7d Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Fri, 4 Apr 2025 17:59:03 +0530 Subject: [PATCH 043/169] FIX_EXCEL_MERGE_AND_FEAT_CAL_SRI --- app/Controllers/LeadsController.php | 2 +- app/Helpers/ExcelMergeHelper.php | 26 +++++++++--- app/Views/leads_form.php | 65 ++++++++++++++++++++++++++++- app/Views/rfq/gmc.php | 4 +- 4 files changed, 88 insertions(+), 9 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 1c5e9f80..bde79243 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -1801,7 +1801,7 @@ class LeadsController extends BaseController ['file_path' => $temp_file_path, 'sheets' => []], ['file_path' => $lead_file_path, 'sheets' => []] ]; - $outputPath = dirname($temp_file_path) . '/' . 'merged_' . $temp_file_name; + $outputPath = dirname($temp_file_path) . '/' . $temp_file_name; $result = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath); // print_rr($result); } diff --git a/app/Helpers/ExcelMergeHelper.php b/app/Helpers/ExcelMergeHelper.php index 36306692..405c4762 100644 --- a/app/Helpers/ExcelMergeHelper.php +++ b/app/Helpers/ExcelMergeHelper.php @@ -17,10 +17,13 @@ class ExcelMergeHelper { { try { log_message('debug', 'Attempting merge with original file order'); + // echo "Attempting merge with original file order\n"; return self::processFiles($filePaths, $outputPath); } catch (Exception $e) { log_message('error', 'First attempt failed: ' . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine()); + // echo "First attempt failed: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine() . "\n"; log_message('debug', 'Retrying with reversed file order'); + // echo "Retrying with reversed file order\n"; // Reverse the file order and try again $reversedFiles = array_reverse($filePaths); @@ -29,6 +32,7 @@ class ExcelMergeHelper { return self::processFiles($reversedFiles, $outputPath); } catch (Exception $e2) { log_message('error', 'Both attempts failed. Last error: ' . $e2->getMessage() . ' in ' . $e2->getFile() . ' on line ' . $e2->getLine()); + // echo "Both attempts failed. Last error: " . $e2->getMessage() . ' in ' . $e2->getFile() . ' on line ' . $e2->getLine() . "\n"; return null; } } @@ -45,7 +49,9 @@ class ExcelMergeHelper { private static function processFiles(array $filePaths, string $outputPath): string { log_message('debug', 'Starting Excel merge process'); + // echo "Starting Excel merge process\n"; log_message('debug', 'Files to process: ' . json_encode($filePaths)); + // echo "Files to process: " . json_encode($filePaths) . "\n"; if (empty($filePaths)) { throw new Exception("No files provided to merge"); @@ -66,6 +72,7 @@ class ExcelMergeHelper { // Save the merged file log_message('debug', "Saving merged file to: {$outputPath}"); + // echo "Saving merged file to: {$outputPath}\n"; $writer = IOFactory::createWriter($mergedSpreadsheet, 'Xlsx'); $writer->setPreCalculateFormulas(false); $writer->save($outputPath); @@ -76,6 +83,7 @@ class ExcelMergeHelper { gc_collect_cycles(); log_message('debug', 'Excel merge process completed successfully'); + // echo "Excel merge process completed successfully\n"; return $outputPath; } @@ -87,15 +95,17 @@ class ExcelMergeHelper { * @param int|null $index * @throws Exception */ - private static function processSingleFile(array $fileInfo, Spreadsheet $mergedSpreadsheet, int $index = null) + private static function processSingleFile(array $fileInfo, Spreadsheet $mergedSpreadsheet, ?int $index = null) { if (!isset($fileInfo['file_path']) || !file_exists($fileInfo['file_path'])) { $path = $fileInfo['file_path'] ?? 'undefined'; log_message('error', "File " . ($index ?? 'base') . ": Invalid or missing file path: {$path}"); + // echo "File " . ($index ?? 'base') . ": Invalid or missing file path: {$path}\n"; return; } log_message('debug', "Processing file " . ($index ?? 'base') . ": " . $fileInfo['file_path']); + // echo "Processing file " . ($index ?? 'base') . ": " . $fileInfo['file_path'] . "\n"; try { // Load the source spreadsheet @@ -105,6 +115,7 @@ class ExcelMergeHelper { $worksheets = $sourceSpreadsheet->getAllSheets(); $totalSheets = count($worksheets); log_message('debug', "Total sheets in file: " . $totalSheets); + // echo "Total sheets in file: " . $totalSheets . "\n"; $sheetsToMerge = $fileInfo['sheets'] ?? []; @@ -114,26 +125,30 @@ class ExcelMergeHelper { try { $sheetName = $worksheet->getTitle(); log_message('debug', "Processing sheet: {$sheetName}"); + // echo "Processing sheet: {$sheetName}\n"; // Generate unique sheet name before cloning $newName = $sheetName; $counter = 1; while (in_array($newName, $mergedSpreadsheet->getSheetNames())) { - $newName = $sheetName . "_" . $counter++; + // $newName = $sheetName . "_" . $counter++; log_message('debug', "Sheet name already exists. Trying new name: {$newName}"); + // echo "Sheet name already exists. Trying new name: {$newName}\n"; } // Clone the worksheet and set the new name - $clonedSheet = clone $worksheet; - $clonedSheet->setTitle($newName); + // $clonedSheet = clone $worksheet; + // $clonedSheet->setTitle($newName); // Add as external sheet - $mergedSpreadsheet->addExternalSheet($clonedSheet); + $mergedSpreadsheet->addExternalSheet($worksheet); log_message('debug', "Successfully added sheet: {$newName}"); + // echo "Successfully added sheet: {$newName}\n"; } catch (Exception $e) { log_message('error', "Error processing sheet {$sheetName} as new name {$newName}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine()); + // echo "Error processing sheet {$sheetName} as new name {$newName}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine() . "\n"; } } } @@ -145,6 +160,7 @@ class ExcelMergeHelper { } catch (Exception $e) { log_message('error', "Error processing file {$fileInfo['file_path']}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine()); + // echo "Error processing file {$fileInfo['file_path']}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine() . "\n"; } } } \ No newline at end of file diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 003e8d96..e3be624c 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -1064,7 +1064,7 @@ console.log('incurredClaimDate', incurredClaimDate) if (policyStartDate && incurredClaimDate) { - var timeDiff = incurredClaimDate - policyStartDate; // Time difference in milliseconds + var timeDiff = (policyStartDate - incurredClaimDate) + 1; // Time difference in milliseconds console.log('timeDiff', timeDiff); var daysDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24)); // Convert to days and add 1 console.log('daysDiff', daysDiff); @@ -1145,6 +1145,69 @@ $('#earned_premium_' + increment).val(earned_premium_roundoff); } + $(document).on("input", "#incept_emp_count, #incept_dept_count, #renewal_emp_count, #renewal_dept_count, #exp_emp_count, #exp_dept_count", function() { + calculateTotalLives(this); + }); + + function calculateTotalLives(input) { + + var lead_type = $('#lead_type').val(); + + if (lead_type == 1) { + + let formRow = input.closest('.form-row'); + + if (formRow) { + // Get the employee count and dependent count within the same row + let empCountInput = formRow.querySelector('[name="incept_emp_count[]"]'); + let depCountInput = formRow.querySelector('[name="incept_dept_count[]"]'); + let totalLivesInput = formRow.querySelector('[name="incept_no_of_lives[]"]'); + + // Parse the input values as integers, defaulting to 0 if empty + let empCount = empCountInput ? parseInt(empCountInput.value) || 0 : 0; + let depCount = depCountInput ? parseInt(depCountInput.value) || 0 : 0; + + // Calculate total lives + let totalLives = empCount + depCount; + + // Set the total lives input value + if (totalLivesInput) { + totalLivesInput.value = totalLives; + } + } + + + } else { + console.log("Function Called"); + + if (input.id === "incept_emp_count" || input.id === "incept_dept_count") { + var incept_emp_count = parseInt($("#incept_emp_count").val()) || 0; + var incept_dept_count = parseInt($("#incept_dept_count").val()) || 0; + + var totalCount = incept_emp_count + incept_dept_count; + $("#incept_no_of_lives").val(totalCount); + + } else if (input.id === "renewal_emp_count" || input.id === "renewal_dept_count") { + var renewal_emp_count = parseInt($("#renewal_emp_count").val()) || 0; + var renewal_dept_count = parseInt($("#renewal_dept_count").val()) || 0; + + var totalCount = renewal_emp_count + renewal_dept_count; + $("#renewal_no_of_lives").val(totalCount); + + } else { + var exp_emp_count = parseInt($("#exp_emp_count").val()) || 0; + var exp_dept_count = parseInt($("#exp_dept_count").val()) || 0; + + var totalCount = exp_emp_count + exp_dept_count; + $("#exp_no_of_lives").val(totalCount); + } + } + + + } + + + //------------------------ FORM SUBMIT --------------------------------------------------------------------------------- $("#leads_form_id").submit(function(event) { diff --git a/app/Views/rfq/gmc.php b/app/Views/rfq/gmc.php index 09d28d3e..9c99df08 100644 --- a/app/Views/rfq/gmc.php +++ b/app/Views/rfq/gmc.php @@ -116,14 +116,14 @@ + placeholder="Enter Lives" required oninput="calculateTotalLives(this)">
+ placeholder="Enter Lives" required oninput="calculateTotalLives(this)">
From 12e74fc877d1c58fc8f14f86d0486b1df071f14f Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Sat, 5 Apr 2025 10:08:51 +0530 Subject: [PATCH 044/169] FEAT_MULTI_FILE_UPLOAD_IN_LEAD_AND_SEND_ATTACHMENTS_RFQ : RV --- app/Config/Routes.php | 1 + app/Controllers/LeadsController.php | 179 +++++++++++++++++++++++----- app/Models/LeadFilesModel.php | 55 +++++++++ app/Views/leads_form.php | 14 ++- app/Views/leads_form_handler.php | 143 +++++++++++++++++++++- app/Views/leads_non_eb.php | 10 +- app/Views/rfq/attachment_files.php | 14 +++ app/Views/rfq/multi_files.php | 50 ++++++++ app/Views/view_rfq.php | 132 ++++++++++++++------ app/Views/view_rfq_non_eb.php | 56 +++++++++ 10 files changed, 578 insertions(+), 76 deletions(-) create mode 100644 app/Models/LeadFilesModel.php create mode 100644 app/Views/rfq/attachment_files.php create mode 100644 app/Views/rfq/multi_files.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 0059a7a1..4f3f4223 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -348,6 +348,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get('getTheEmpDataForClaimSearchByMobile/(:any)', 'ClientController::getTheEmpDataForClaimSearchByMobile/$1'); $routes->get('getLeadNonEB/(:any)', 'LeadsController::getLeadNonEB/$1'); $routes->get('getPolicyTypeFields', 'LeadsController::getPolicyTypeFields'); + $routes->get('removeMultiFile', 'LeadsController::removeMultiFile'); }); $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 1c5e9f80..9c35bc48 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -29,6 +29,7 @@ use App\Models\TPABranchModel; use App\Models\RFQModel; use App\Models\InsurerModel; use App\Models\OccupancyMasterModel; +use App\Models\LeadFilesModel; use App\Helpers\MailHelper; use App\Helpers\ExcelMergeHelper; @@ -62,6 +63,7 @@ class LeadsController extends BaseController protected $RFQModel; protected $insurerModel; protected $occupancyModel; + protected $leadFilesModel; //variables for storing array protected $issuer; @@ -92,6 +94,7 @@ class LeadsController extends BaseController $this->RFQModel = new RFQModel(); $this->insurerModel = new InsurerModel(); $this->occupancyModel = new OccupancyMasterModel(); + $this->leadFilesModel = new LeadFilesModel(); $this->issuer = [1 => 'JIBS', 2 => 'Nhance']; $this->clientType = [1 => 'Group', 2 => 'Individual']; @@ -206,13 +209,12 @@ class LeadsController extends BaseController private function prepareSingleLeadData($data) { // print_r($data); die; - $uploadFilePath = WRITEPATH . 'uploads/lead_files/'; - - // Get all uploaded files for 'file_name[]' - $files = $this->request->getFileMultiple('file_name'); - - // print_r($files); die; - + $index_plus_one = 1; + $form_file_name = "file_name_".$index_plus_one; + $form_docs_name = "docs_name_".$index_plus_one; + $leads_file_primary_key = $data['leads_file_id'] ?? []; + $files = $this->request->getFileMultiple($form_file_name); + $multi_file_data = $this->uploadMultiFiles($files, $data[$form_docs_name], $leads_file_primary_key); // Separate the insurer and insurer branch, handle missing or invalid data if (isset($data['insurer']) && strpos($data['insurer'], '-') !== false) { @@ -249,7 +251,9 @@ class LeadsController extends BaseController $data['policy_end_date'] = null; } - $data['file_name'] = file_Upload($files, $uploadFilePath); + // $data['file_name'] = file_Upload($files, $uploadFilePath); + $data['multi_file_data']= $multi_file_data ?? null; + $processcedData[] = $data; // print_r($data);die(); @@ -260,15 +264,16 @@ class LeadsController extends BaseController { // print_r($data); die; $processedData = []; - $uploadFilePath = WRITEPATH . 'uploads/lead_files/'; - - // Get all uploaded files for 'file_name[]' - $files = $this->request->getFileMultiple('file_name'); - - // print_r($files); die; foreach ($data['policy_type_id'] as $index => $value) { + $index_plus_one = $index + 1; + $form_file_name = "file_name_".$index_plus_one; + $form_docs_name = "docs_name_".$index_plus_one; + $leads_file_primary_key = $data['leads_file_id'] ?? []; + $files = $this->request->getFileMultiple($form_file_name); + $multi_file_data = $this->uploadMultiFiles($files, $data[$form_docs_name], $leads_file_primary_key); + // Separate the insurer and insurer branch, handle missing or invalid data if (isset($data['insurer'][$index]) && strpos($data['insurer'][$index], '-') !== false) { list($insurer_branch_id, $insurer_id) = explode('-', $data['insurer'][$index]); @@ -324,7 +329,7 @@ class LeadsController extends BaseController $premium_date = null; } - $file_name = file_Upload($files[$index], $uploadFilePath); + // $file_name = file_Upload($files[$index], $uploadFilePath); $last_3_years_claims = $data['finyear']; @@ -387,7 +392,8 @@ class LeadsController extends BaseController 'total_si_at_renewal' => $data['total_si_at_renewal'][$index] ?? 0, 'fin_years_claims' => $last_3_years_claims, - 'file_name' => $file_name, + // 'file_name' => $file_name, + 'multi_file_data' => $multi_file_data ?? null, 'status' => $data['status'] ?? null, 'notes' => $data['notes'] ?? null, @@ -405,6 +411,11 @@ class LeadsController extends BaseController $insertCount = []; foreach ($data as $value) { $insert = $this->leadsModel->insert($value); + + if ($insert) { + $this->insertMultiFilesData($value['multi_file_data'], $insert); + } + $insertCount[] = $insert; $this->insertLeadStatus($insert, $value['status'], 3); @@ -427,13 +438,15 @@ class LeadsController extends BaseController private function updateOldLead($id, $data) { if ($this->leadsModel->where('id', $id)->set($data[0])->update()) { + + $this->insertMultiFilesData($data[0]['multi_file_data'], $id); $this->insertLeadStatus($id, $data[0]['status'], 3); return $this->respond(['status' => true, 'lead_id' => $id, 'message' => "Lead updated successfully", 'data' => $data], 200); } return $this->respond(['status' => false, 'lead_id' => $id, 'message' => "Failed to update Lead", 'data' => $data], 200); } - // Get the Single Lead data for edit + // Get the Single Lead data for edit uisng ajax ( do not delete) public function getLeadDataForEdit($id) { @@ -472,6 +485,8 @@ class LeadsController extends BaseController $data['premium_date'] = null; } + $data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->first() ?? null; + $data['lastFiveYears'] = $this->getLastFiveFinancialYears(); $data['gpaClaimType'] = $this->claim_type_for_gpa; $data['causeOfDeath'] = $this->cause_of_death; @@ -485,6 +500,8 @@ class LeadsController extends BaseController $data['html'] = $this->generateViewPageHtml($data['policy_type_id'], $data) ?? ""; + // print_r($data); die; + if ($data) { return $this->respond(['status' => true, 'data' => $data], 200); } else { @@ -503,6 +520,77 @@ class LeadsController extends BaseController $this->policyTransactionStatusModel->insert($statusData); } + public function uploadMultiFiles($files, $docs_names, $primaryKey) + { + $uploadFilePath = WRITEPATH . 'uploads/lead_files/'; + + $multi_file_data = []; + foreach ($files as $index => $value) { + $file_name = file_Upload($value, $uploadFilePath); + $multi_file_data[] = [ + 'file_name' => $file_name, + 'docs_name' => $docs_names[$index], + 'id' => $primaryKey[$index] ?? "", + ]; + } + + return $multi_file_data; + } + + public function insertMultiFilesData($data, $lead_id) + { + // print_r($data); die; + + if(!empty($data)){ + foreach ($data as $key => $value) { + + if(!empty($value['id'])){ + + $lead_file_data = [ + 'lead_id' => $lead_id, + 'docs_name' => $value['docs_name'], + ]; + + if(!empty($value['file_name'])) { + $lead_file_data['file_name'] = $value['file_name']; + } + + $this->leadFilesModel->where('id', $value['id'])->set($lead_file_data)->update(); + + }else{ + + $lead_file_data = [ + 'lead_id' => $lead_id, + 'docs_name' => $value['docs_name'], + 'file_name' => $value['file_name'], + ]; + $this->leadFilesModel->insert($lead_file_data); + } + + if($key == 0 && !empty($value['file_name'])) { + $this->leadsModel->where('id', $lead_id)->set('file_name', $value['file_name'])->update(); + } + } + } + + return true; + } + + public function removeMultiFile() + { + $id = $this->request->getGet('lead_file_id'); + if(!empty($id)){ + $this->leadFilesModel->where('id', $id)->set(['is_active' => 0])->update(); + return $this->respond(['status' => true, 'message' => 'File removed successfully'], 200); + }else{ + return $this->respond(['status' => false, 'message' => 'File could not be removed.'], 200); + } + } + + public function updateLeadTableFields() + { + + } //--------RFQ----------------------------------------------------------------------------------------------- @@ -575,8 +663,11 @@ class LeadsController extends BaseController $data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']); $data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']); + $data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null; + $data['attachment_html'] = view('rfq/attachment_files', $data) ?? ""; + + // dd($data); - if ($data['lead_data']['lead_form_type'] == 1) { $this->loadLayout('view_rfq.php', $data); @@ -635,7 +726,6 @@ class LeadsController extends BaseController } } - public function createRFQ() { $data = $this->request->getPost(); @@ -691,7 +781,6 @@ class LeadsController extends BaseController ], 200); } - public function createQCR() { @@ -1693,6 +1782,7 @@ class LeadsController extends BaseController $propsal_and_insurer = isset($params['proposal_insurer']) ? $params['proposal_insurer'] : null; $mail_content = $params['mail_content']; $mail_subject = $params['subject']; + $attachment_file_ids = $params['selected_attachment_files']; $result_data = []; // dd($recipient_mail); @@ -1817,7 +1907,12 @@ class LeadsController extends BaseController $file_path = $result; $file_name = basename($result); + + // Attacments part $attachments = [['fileName' => $file_name, 'filePath' => $file_path]]; + $other_attachments = $this->handleMultiFileAttachments($attachment_file_ids, $lead_id); + $attachments = array_merge($attachments, $other_attachments); + // print_r($attachments); die; //get recipient address if ($recipient_type == 'insurer' || $recipient_type == 'placement') { @@ -2579,6 +2674,7 @@ class LeadsController extends BaseController $this->loadLayout('view_rfq_non_eb'); } + // get lead data for edit bot EB and NON-EB public function getLeadNonEB($type, $id = null) { // Set basic data @@ -2606,9 +2702,15 @@ class LeadsController extends BaseController ->where('user_profiles.is_active', 1) ->findAll(); + + if (!empty($id)) { + $data['lead_edit_data'] = $this->leadsModel->where('id', $id)->first() ?? []; + $data['lead_edit_data']['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null; + $data['lead_edit_data']['lead_file_count'] = count($data['lead_edit_data']['multi_file_data']); + // Decode and merge custom fields if present $custom_fields_data = !empty($data['lead_edit_data']['custom_fields']) ? json_decode($data['lead_edit_data']['custom_fields'], true) @@ -2633,6 +2735,8 @@ class LeadsController extends BaseController $data['lead_edit_data']['policy_type_id'] ?? null, $data ) ?? ""; + + $data['lead_edit_data']['multi_file_html'] = view('rfq/multi_files', $data) ?? ""; } if ($data['lead_edit_data']['lead_type'] != 1 && $data['lead_edit_data']['lead_form_type'] == 2) { @@ -3477,19 +3581,34 @@ class LeadsController extends BaseController return $data; } - // function getPreviousColumn($columnLetter) - // { - // $colIndex = Coordinate::columnIndexFromString($columnLetter); - // if ($colIndex > 1) { - // $colIndex--; - // } - // return Coordinate::stringFromColumnIndex($colIndex); - // } - - function getPreviousColumn($columnLetter, $decrement = 1) { + public function getPreviousColumn($columnLetter, $decrement = 1) + { $colIndex = Coordinate::columnIndexFromString($columnLetter); $colIndex = max(1, $colIndex - $decrement); // ensure column index doesn't go below 1 return Coordinate::stringFromColumnIndex($colIndex); } + public function handleMultiFileAttachments($json_string, $lead_id) + { + $attachments = []; + + if (!empty($json_string)) { + $fileIds = json_decode($json_string, true); + $lead_file_path = WRITEPATH . 'uploads/lead_files/'; + + foreach ($fileIds as $id) { + $lead_file = $this->leadFilesModel->where('lead_id', $lead_id)->where('id', $id)->where('is_active', 1)->first(); + + if ($lead_file) { + $attachments[] = [ + 'fileName' => $lead_file['file_name'], + 'filePath' => $lead_file_path . $lead_file['file_name'] + ]; + } + } + } + + return $attachments; + } + } diff --git a/app/Models/LeadFilesModel.php b/app/Models/LeadFilesModel.php new file mode 100644 index 00000000..37db8e16 --- /dev/null +++ b/app/Models/LeadFilesModel.php @@ -0,0 +1,55 @@ +
-
- - - -
- +
+
x + @@ -931,6 +927,8 @@ container.appendChild(newRow); + //append mutli file html + addFileField(increment); var lead_type = $('#lead_type').val(); leadTypeBsedHideAndShow(lead_type) @@ -1540,4 +1538,8 @@ } }); } + + //----------------------------------------------------------------------------------------------------------- + + \ No newline at end of file diff --git a/app/Views/leads_form_handler.php b/app/Views/leads_form_handler.php index 93a82b96..30bb0d02 100644 --- a/app/Views/leads_form_handler.php +++ b/app/Views/leads_form_handler.php @@ -86,6 +86,8 @@ if (isset($selected_lead_type)) { var temp_client_id = 0; var temp_branch_id = 0; var selected_lead_form_type = ; + var fileIndex = 1; // Initialize index + // select2 document ready $(document).ready(function() { @@ -327,6 +329,122 @@ if (isset($selected_lead_type)) { } + // -------------------------------------------------------------------------------------------------------- + + function addFileField(increment) { + + console.log('addFileField function called'); + + const container = document.getElementById(`multiFileAppendArea_${increment}`); + if (!container) return; + + const div = document.createElement("div"); + div.className = "form-row d-flex align-items-end"; + div.setAttribute("id", `fileField_${fileIndex}`); + + let isFirstField = container.childElementCount === 0; // Check if it's the first field + let placeholder = isFirstField ? 'First file must be Demography.' : ''; + let accept = isFirstField ? '.xls,.xlsx' : ''; + + div.innerHTML = ` +
+ + +
+
+ + +
+
+ + +
+ `; + container.appendChild(div); + fileIndex++; + } + + function removeFileField(index, lead_file_id = null) { + + if(index == 1){ + toastr.warning("You can't remove the first file field", 'WARNING'); + return false; + } + + if(lead_file_id != null) { + + Swal.fire({ + title: "Do you want to remove this file?", + // text: "Do you want Save this!", + icon: "warning", + showCancelButton: true, + confirmButtonColor: "#3085d6", + cancelButtonColor: "#d33", + confirmButtonText: "Yes, Procced!" + }).then((result) => { + + if (result.isConfirmed) { + + let url = ''; + + let requestData = { + lead_file_id: lead_file_id + }; + + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + + // Send AJAX request + sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) { + console.log('Data fetched successfully:', response); + + if (response.status == true) { + toastr.success(response.message, 'SUCCESS'); + + //remove the file field + const field = document.getElementById(`fileField_${index}`); + if(index != 1){ + if (field) field.remove(); + } + + } else { + toastr.error(response.message, 'WARNING'); + } + + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + + }, function(xhr, status, error) { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + console.error('Error fetching data:', error); + console.error(xhr.responseText); + toastr.error('An error occurred while checking the CD amount.', 'ERROR'); + }); + + }else{ + return false; + } + + }); + + }else{ + const field = document.getElementById(`fileField_${index}`); + if(index != 1){ + if (field) field.remove(); + } + } + + } + + function showFileName(input, index) { + if (input.files.length > 0) { + document.getElementById(`file_name_display_${index}`).textContent = input.files[0].name; + } else { + document.getElementById(`file_name_display_${index}`).textContent = "No file chosen"; + } + } + @@ -337,7 +455,7 @@ if (isset($selected_lead_type)) { setTimeout(function(){ handleEbAndNonEbEdit( ); - }, 1000) + }, 2000) function handleEbAndNonEbEdit(data){ if(data.lead_form_type == 1){ @@ -353,6 +471,7 @@ if (isset($selected_lead_type)) { console.log('Received data:', data); let dataIncrement = 1; + fileIndex = data.lead_file_count + 1; if (!data || typeof data !== 'object') { console.error('Invalid data received for editing.'); @@ -361,6 +480,7 @@ if (isset($selected_lead_type)) { $('.btnDiv').hide(); $('#appendArea_' + dataIncrement).empty(); + $('#multiFileAppendArea_' + dataIncrement).empty(); if (data.html) { $('#appendArea_' + dataIncrement).append(data.html); @@ -368,6 +488,15 @@ if (isset($selected_lead_type)) { console.warn('HTML content missing in data.'); } + if (data.multi_file_html) { + console.log(data.multi_file_html); + setTimeout(function(){ + $('#multiFileAppendArea_' + dataIncrement).append(data.multi_file_html); + }, 2000) + } else { + console.warn('MULTI FILE HTML content missing in data.'); + } + let policy_type_id = data.policy_type_id || null; let lead_type = data.lead_type || null; @@ -498,6 +627,7 @@ if (isset($selected_lead_type)) { console.log('########### THIS IS NON EB LEAD ###############') console.log('Received data:', data); let dataIncrement = 1; + fileIndex = data.lead_file_count + 1; if (!data || typeof data !== 'object') { console.error('Invalid data received for editing.'); @@ -505,6 +635,8 @@ if (isset($selected_lead_type)) { } $('#appendArea').empty(); + $('#multiFileAppendArea_' + dataIncrement).empty(); + if (data.html) { $('#appendArea').append(data.html); @@ -512,6 +644,15 @@ if (isset($selected_lead_type)) { console.warn('HTML content missing in data.'); } + if (data.multi_file_html) { + console.log(data.multi_file_html); + setTimeout(function(){ + $('#multiFileAppendArea_' + dataIncrement).append(data.multi_file_html); + }, 2000) + } else { + console.warn('MULTI FILE HTML content missing in data.'); + } + let policy_type_id = data.policy_type_id || null; let lead_type = data.lead_type || null; diff --git a/app/Views/leads_non_eb.php b/app/Views/leads_non_eb.php index 1ee910fa..fef3f394 100644 --- a/app/Views/leads_non_eb.php +++ b/app/Views/leads_non_eb.php @@ -290,14 +290,18 @@ hr.solid {
+
+ +
+
-
+
@@ -370,6 +374,8 @@ $(document).ready(function(){ dateFormat: "d/m/Y", allowInput: false }); + + addFileField(1); }) function getPolicyTypeFields(input) { diff --git a/app/Views/rfq/attachment_files.php b/app/Views/rfq/attachment_files.php new file mode 100644 index 00000000..711fbe84 --- /dev/null +++ b/app/Views/rfq/attachment_files.php @@ -0,0 +1,14 @@ + +
+ + +
+ + + +
+ +
+ diff --git a/app/Views/rfq/multi_files.php b/app/Views/rfq/multi_files.php new file mode 100644 index 00000000..a071172b --- /dev/null +++ b/app/Views/rfq/multi_files.php @@ -0,0 +1,50 @@ + + + $value) { + $isFirstField = ($index === 0); // First file must be Demography + $placeholder = $isFirstField ? 'First file must be Demography.' : ''; + $accept = $isFirstField ? '.xls,.xlsx' : ''; + $index = $index + 1; +?> + +
+ + + + +
+ + +
+ + +
+ + + +
+ + + +
+ + +
+
+ + \ No newline at end of file diff --git a/app/Views/view_rfq.php b/app/Views/view_rfq.php index 3922cdf6..950e9b45 100644 --- a/app/Views/view_rfq.php +++ b/app/Views/view_rfq.php @@ -373,6 +373,16 @@
+ +
+

Attachments Files

+
+ +
+
+ +
+
@@ -394,47 +404,58 @@ -
+ +
+

Attachments Files

+
+ +
+
+ +
+
+ +
+
@@ -535,6 +556,16 @@
+
+

Attachments Files

+
+ +
+
+ +
+
+
@@ -557,6 +588,7 @@ var premium_data_check = false; var user_role_id = ; var jsonDataForHide = null; + var multi_file_data = []; const editorConfig = { buttons: [ @@ -595,7 +627,8 @@ console.log('Type:', type); let titile_client_name = ""; - + multi_file_data = ; + appendMultiFileData(multi_file_data) RFQ_or_QCR = type; var type_for_url = 1; @@ -3452,6 +3485,11 @@ function constructURL_ForInsurerAndClientMailSend() { bcc = bcc.map(Number); bcc = JSON.stringify(bcc); + var selectedFiles = []; + $('#insurer_or_clinet_mail_attachment .multi_file_attachment:checked').each(function () { + selectedFiles.push($(this).val()); + }); + // Prepare FormData object var formData = new FormData(); formData.append('lead_id', lead_id); @@ -3459,6 +3497,8 @@ function constructURL_ForInsurerAndClientMailSend() { formData.append('subject', subject); formData.append('cc', cc); formData.append('bcc', bcc); + formData.append('selected_attachment_files', JSON.stringify(selectedFiles)); + if (RFQ_or_QCR == 2) { formData.append('file_type', 'qcr'); @@ -3493,6 +3533,11 @@ function constructURL_ForInternalMailSend() { // Determine file type var file_type = RFQ_or_QCR == 2 ? 'qcr' : 'rfq'; + var selectedFiles = []; + $('#internal_mail_attachment .multi_file_attachment:checked').each(function () { + selectedFiles.push($(this).val()); + }); + // Create FormData var formData = new FormData(); formData.append('lead_id', lead_id); @@ -3503,6 +3548,7 @@ function constructURL_ForInternalMailSend() { formData.append('subject', subject); formData.append('mail_content', mail_content); formData.append('recipient_mail', ''); // Empty value as per logic + formData.append('selected_attachment_files', JSON.stringify(selectedFiles)); ajaxRequest(formData) @@ -3528,6 +3574,11 @@ function constructURL_ForPlacementMailSend() { to = to.split(',').map(email => email.trim()); cc = cc.map(Number); // or split if it's a string: `cc.split(',').map(email => email.trim())` + var selectedFiles = []; + $('#placement_mail_attachment .multi_file_attachment:checked').each(function () { + selectedFiles.push($(this).val()); + }); + // Prepare FormData var formData = new FormData(); formData.append('lead_id', lead_id); @@ -3544,6 +3595,8 @@ function constructURL_ForPlacementMailSend() { formData.append('total_amount', total_amount); formData.append('cd_amount', cd_amount); formData.append('mail_content', mail_content); + formData.append('selected_attachment_files', JSON.stringify(selectedFiles)); + ajaxRequest(formData); @@ -5157,6 +5210,11 @@ function autoCaluculationForPremiumChildTable(input) { } +function appendMultiFileData(data) { + + console.log('appendMultiFileData function called'); + console.log(data) +} diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index 6a182769..5f9aba17 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -309,11 +309,22 @@
+
+

Attachments Files

+
+ +
+
+ +
+
+
@@ -475,6 +496,16 @@
+
+

Attachments Files

+
+ +
+
+ +
+
+
@@ -4550,6 +4581,11 @@ bcc = bcc.map(Number); bcc = JSON.stringify(bcc); + var selectedFiles = []; + $('#insurer_or_clinet_mail_attachment .multi_file_attachment:checked').each(function () { + selectedFiles.push($(this).val()); + }); + // Prepare FormData object var formData = new FormData(); formData.append('lead_id', lead_id); @@ -4557,6 +4593,8 @@ formData.append('subject', subject); formData.append('cc', cc); formData.append('bcc', bcc); + formData.append('selected_attachment_files', JSON.stringify(selectedFiles)); + if (rfq_or_qcr == 2) { formData.append('file_type', 'qcr'); @@ -4591,6 +4629,12 @@ // Determine file type var file_type = rfq_or_qcr == 2 ? 'qcr' : 'rfq'; + var selectedFiles = []; + $('#internal_mail_attachment .multi_file_attachment:checked').each(function () { + selectedFiles.push($(this).val()); + }); + + // Create FormData var formData = new FormData(); formData.append('lead_id', lead_id); @@ -4601,6 +4645,8 @@ formData.append('subject', subject); formData.append('mail_content', mail_content); formData.append('recipient_mail', ''); // Empty value as per logic + formData.append('selected_attachment_files', JSON.stringify(selectedFiles)); + ajaxRequest(formData) @@ -4626,6 +4672,13 @@ to = to.split(',').map(email => email.trim()); cc = cc.map(Number); // or split if it's a string: `cc.split(',').map(email => email.trim())` + + var selectedFiles = []; + $('#placement_mail_attachment .multi_file_attachment:checked').each(function () { + selectedFiles.push($(this).val()); + }); + + // Prepare FormData var formData = new FormData(); formData.append('lead_id', lead_id); @@ -4642,11 +4695,14 @@ formData.append('total_amount', total_amount); formData.append('cd_amount', cd_amount); formData.append('mail_content', mail_content); + formData.append('selected_attachment_files', JSON.stringify(selectedFiles)); + ajaxRequest(formData); } + function ajaxRequest(formData) { var apiURL = ''; From c928f238ef8fc89d5e4786d64a7a9d4740bad223 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Sat, 5 Apr 2025 11:44:45 +0530 Subject: [PATCH 045/169] FIX_ALIGNMENT_IN_EXCEL : RV --- app/Controllers/LeadsController.php | 23 ++++++++++++----------- app/Views/leads_form_handler.php | 5 +++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 02134611..c432c921 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -966,7 +966,7 @@ class LeadsController extends BaseController // Start with lead_data at the top $rowNumber = 1; - $mergeRange1 = "A{$rowNumber}:C{$rowNumber}"; + $mergeRange1 = "A{$rowNumber}:B{$rowNumber}"; $sheet->mergeCells($mergeRange1); $sheet->setCellValue("A{$rowNumber}", "Nhance India Insurance Broking Pvt Ltd"); $sheet->getStyle("A{$rowNumber}")->applyFromArray([ @@ -981,13 +981,13 @@ class LeadsController extends BaseController ]); // Set column width to fit the image properly - $sheet->getColumnDimension('D')->setWidth(20); // Adjust as needed + $sheet->getColumnDimension('C')->setWidth(20); // Adjust as needed $sheet->getRowDimension($rowNumber)->setRowHeight(40); // Adjust as needed $drawing = new Drawing(); $path = ROOTPATH . "public/assets/images/Nhance-Logo-Final.png"; // Use FCPATH for server path $drawing->setPath($path); - $drawing->setCoordinates("D{$rowNumber}"); // Set position in column B + $drawing->setCoordinates("C{$rowNumber}"); // Set position in column B $drawing->setHeight(35); // Adjust image height // Center align the image in the cell @@ -997,8 +997,8 @@ class LeadsController extends BaseController $drawing->setWorksheet($sheet); // Apply center alignment to the cell - $sheet->getStyle("D{$rowNumber}")->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getStyle("D{$rowNumber}")->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER); + $sheet->getStyle("C{$rowNumber}")->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getStyle("C{$rowNumber}")->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER); $rowNumber = $rowNumber + 1; @@ -1011,7 +1011,7 @@ class LeadsController extends BaseController // Merge A:B for key and C:D for value $mergeRangeKey = "A{$rowNumber}:B{$rowNumber}"; - $mergeRangeValue = "C{$rowNumber}:D{$rowNumber}"; + $mergeRangeValue = "C{$rowNumber}"; $sheet->mergeCells($mergeRangeKey); $sheet->mergeCells($mergeRangeValue); @@ -1044,9 +1044,9 @@ class LeadsController extends BaseController // Set column width based on max content length (adjusted for padding) $sheet->getColumnDimension('A')->setWidth($maxWidthA * 1.2); - $sheet->getColumnDimension('B')->setWidth($maxWidthA * 1.2); + $sheet->getColumnDimension('B')->setWidth($maxWidthA * 5); $sheet->getColumnDimension('C')->setWidth($maxWidthB * 1.2); - $sheet->getColumnDimension('D')->setWidth($maxWidthB * 1.2); + // $sheet->getColumnDimension('D')->setWidth($maxWidthB * 1.2); // $rowNumber += 2; @@ -1105,7 +1105,7 @@ class LeadsController extends BaseController } if ($header['parentHeader'] === 'Particulars') { - $sheet->getColumnDimension('B')->setWidth(40); + $sheet->getColumnDimension('B')->setWidth(80); } $startColumn = $columnLetter; // Start of the current header range @@ -1289,7 +1289,7 @@ class LeadsController extends BaseController } $lastRow = count($lead_data) + 1; - $leadRange = "A1:D{$lastRow}"; + $leadRange = "A1:C{$lastRow}"; $sheet->getStyle($leadRange)->applyFromArray([ 'borders' => [ @@ -2736,7 +2736,8 @@ class LeadsController extends BaseController $data ) ?? ""; - $data['lead_edit_data']['multi_file_html'] = view('rfq/multi_files', $data) ?? ""; + $html = view('rfq/multi_files', $data); + $data['lead_edit_data']['multi_file_html'] = trim($html) !== '' ? $html : null; } if ($data['lead_edit_data']['lead_type'] != 1 && $data['lead_edit_data']['lead_form_type'] == 2) { diff --git a/app/Views/leads_form_handler.php b/app/Views/leads_form_handler.php index 30bb0d02..fdf3de07 100644 --- a/app/Views/leads_form_handler.php +++ b/app/Views/leads_form_handler.php @@ -480,7 +480,7 @@ if (isset($selected_lead_type)) { $('.btnDiv').hide(); $('#appendArea_' + dataIncrement).empty(); - $('#multiFileAppendArea_' + dataIncrement).empty(); + if (data.html) { $('#appendArea_' + dataIncrement).append(data.html); @@ -488,7 +488,8 @@ if (isset($selected_lead_type)) { console.warn('HTML content missing in data.'); } - if (data.multi_file_html) { + if (data.multi_file_html && data.multi_file_html != '') { + $('#multiFileAppendArea_' + dataIncrement).empty(); console.log(data.multi_file_html); setTimeout(function(){ $('#multiFileAppendArea_' + dataIncrement).append(data.multi_file_html); From 374b382bfac110172b82c58c18dffb1aa2a51e6d Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Sat, 5 Apr 2025 17:17:08 +0530 Subject: [PATCH 046/169] FIX_USER_NAME_NULL : RV --- app/Controllers/TicketController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index ec574927..03224684 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -1034,7 +1034,7 @@ class TicketController extends BaseController th.old_value, th.new_value, th.created_at, - CONCAT(creator.first_name, ' ', creator.last_name) as modified_by, + CONCAT_WS(' ', creator.first_name, creator.last_name) AS modified_by, -- Claim Status old_status.claim_status as old_status_value, new_status.claim_status as new_status_value, @@ -1094,6 +1094,7 @@ class TicketController extends BaseController ORDER BY th.created_at DESC"; $data = $this->ticketHistoryModel->query($sql)->getResultArray(); + // dd(db_connect()->getLastQuery()); $priorityType = $this->priorityType; $relationshipType = $this->relationshipType; $modeOFIntimate = $this->modeOFIntimate; From dfe04f5539a67ae6df2daa7560eff58e3e781fba Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Sat, 5 Apr 2025 17:31:54 +0530 Subject: [PATCH 047/169] FIX_USER_NAME : RV --- app/Views/ticket_history.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Views/ticket_history.php b/app/Views/ticket_history.php index c0e5bfea..b181408c 100644 --- a/app/Views/ticket_history.php +++ b/app/Views/ticket_history.php @@ -20,7 +20,7 @@ '.$row['new_value']; ?> - + From dffc1a8508f80f4088c1d08c82c3caf85915a3fa Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Sun, 6 Apr 2025 09:55:01 +0530 Subject: [PATCH 048/169] FIX_CLAIM_API_DATE_ISSUE_AND_USER_LOGIN_NAME_SHOWING_ISSUE : RV --- app/Controllers/EmployeeRestController.php | 12 ++++++++++++ app/Controllers/TicketController.php | 17 ++++++++++++----- app/Views/ticket_conversation.php | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index e86f5de7..199505a7 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -3124,6 +3124,18 @@ class EmployeeRestController extends AdminController $client_policy_id = $received_data['client_policy_id']; $insured_emp_id = $received_data['insured_emp_id']; + if (empty($received_data['doa'])) { + $received_data['doa'] = null; + } else{ + $ticket_data['doa'] = change_date_format($received_data['doa']); + } + + if (empty($received_data['dod'])) { + $received_data['dod'] = null; + } else{ + $ticket_data['dod'] = change_date_format($received_data['dod']); + } + $sql = " select cp.policy_type_id, diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 03224684..f6999bdf 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -774,13 +774,20 @@ class TicketController extends BaseController { // log_message('error','Function called');die(); // $ticket_master_id = $this->request->getPost('id'); - $user_id = get_session_userid(); - $logged_user = $this->userModel->select('first_name,last_name,profile')->where('id', $user_id)->first(); $dataToSend = []; - $dataToSend['user_name'] = $logged_user['first_name'] . ' ' . $logged_user['last_name']; - $dataToSend['messages'] = $this->ticketMessageModel->where('is_active', 1) - ->where('ticket_id', $ticket_master_id)->orderBy('created_at', 'DESC') + + $user_id = get_session_userid(); + // $logged_user = $this->userModel->select('first_name,last_name,profile')->where('id', $user_id)->first(); + // $dataToSend['user_name'] = $logged_user['first_name'] . ' ' . $logged_user['last_name']; + + $dataToSend['messages'] = $this->ticketMessageModel + ->select('ticket_messages.*,up.first_name as user_name') + ->join('user_profiles up', 'up.id = ticket_messages.created_by', 'left') + ->where('ticket_messages.is_active', 1) + ->where('ticket_messages.ticket_id', $ticket_master_id) + ->orderBy('ticket_messages.created_at', 'DESC') ->findAll(); + foreach ($dataToSend['messages'] as $message) { $mail_content_converted = $this->convertHtmlToText($message['mail_content']); $message['mail_content'] = $mail_content_converted; diff --git a/app/Views/ticket_conversation.php b/app/Views/ticket_conversation.php index e0e67c6a..d2fa00c3 100644 --- a/app/Views/ticket_conversation.php +++ b/app/Views/ticket_conversation.php @@ -49,7 +49,7 @@
-
+
Staff From e67f49fc5d4c992b31d5c60be9cd19d4bc0a915a Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 7 Apr 2025 09:40:27 +0530 Subject: [PATCH 049/169] CHANGE_CLAIMS_INITIATECLAIM_API_CHANGES : RV --- app/Controllers/EmployeeRestController.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 199505a7..9b137fda 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -3178,11 +3178,19 @@ class EmployeeRestController extends AdminController if(!empty($emp_ticket_data)){ $fetchData = $emp_ticket_data[0]; - $fetchData['claim_status_id'] = $this->claimStatusModel - ->select('id') - ->where('ticket_type', $fetchData['ticket_type_id']) - ->orderBy('id', 'asc') - ->first()['id']; + + $claimStatusQuery = $this->claimStatusModel + ->select('id') + ->where('ticket_type', $fetchData['ticket_type_id']) + ->orderBy('id', 'asc'); + + if ($fetchData['ticket_type_id'] == 1 && !empty($fetchData['tpa_no'])) { + $results = $claimStatusQuery->findAll(2); + $fetchData['claim_status_id'] = $results[1]['id'] ?? $results[0]['id']; + } else { + $fetchData['claim_status_id'] = $claimStatusQuery->first()['id']; + } + $fetchData['priority'] = 1; $fetchData['mode_of_intimation'] = 3; From cad50efdf2eaae6b48920f18c6390faa61c74f9c Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Tue, 8 Apr 2025 14:08:54 +0530 Subject: [PATCH 050/169] FEAT_RFQ_NEW_REQ_SRI --- .../Chatbot/EcardDownloadConversation.php | 2 + .../Chatbot/MainMenuConversation.php | 11 +- app/Controllers/ChatbotControllerNew.php | 2 + app/Controllers/LeadsController.php | 69 ++- app/Models/LeadsModel.php | 2 + app/Models/UserModel.php | 15 + app/Views/chatbot.php | 2 +- app/Views/layout/header.php | 3 + app/Views/view_rfq.php | 392 +++++++++++++----- 9 files changed, 384 insertions(+), 114 deletions(-) diff --git a/app/Controllers/Chatbot/EcardDownloadConversation.php b/app/Controllers/Chatbot/EcardDownloadConversation.php index 84617af1..c38d6977 100644 --- a/app/Controllers/Chatbot/EcardDownloadConversation.php +++ b/app/Controllers/Chatbot/EcardDownloadConversation.php @@ -23,6 +23,8 @@ class EcardDownloadConversation extends Conversation $policy_list = ChatbotHelper::getListOfPolicies($chat_session_info); $buttons = []; $question = 'Choose Policy to Download Ecard:'; + log_message('error', ('policy_list : ' . json_encode($policy_list))); + if(is_array($policy_list) && count($policy_list)) { foreach($policy_list as $policy) diff --git a/app/Controllers/Chatbot/MainMenuConversation.php b/app/Controllers/Chatbot/MainMenuConversation.php index 875ecba4..f06fd078 100644 --- a/app/Controllers/Chatbot/MainMenuConversation.php +++ b/app/Controllers/Chatbot/MainMenuConversation.php @@ -53,6 +53,8 @@ class MainMenuConversation extends Conversation $user_reponse = null; } + log_message('error', ('user_reponse is interactive: ' . $answer->isInteractiveMessageReply())); + // Get just the existing path array $path = $this->bot->userStorage()->get('path') ?? []; @@ -65,28 +67,35 @@ class MainMenuConversation extends Conversation 'path' => $path ]); - log_message('error', ('user_reponse : ' . $user_reponse)); + log_message('error', ('user_reponse after: ' . $user_reponse)); switch ($user_reponse) { case "ecard_download": $this->bot->startConversation(new EcardDownloadConversation()); + log_message('error', 'ecard_download clicked '); + break; case "network_hospital": $this->bot->startConversation(new NetworkHospitalConversation()); + log_message('error', 'network_hospital clicked '); break; case "reimbursement_claim": $this->bot->startConversation(new ReimbursementClaimProcessConversation()); + log_message('error', 'reimbursement_claim clicked '); break; case "reimbursement_status": $this->bot->startConversation(new ReimbursementClaimStatusConversation()); + log_message('error', 'reimbursement_status clicked '); break; case "new_policy": case "renew_policy": $this->bot->startConversation(new policyConversation()); + log_message('error', 'renew_policy || new_policy clicked '); break; default: + log_message('error', 'default shown '); $this->say("Invalid selection. Please choose an option."); $this->bot->startConversation(new MainMenuConversation()); break; diff --git a/app/Controllers/ChatbotControllerNew.php b/app/Controllers/ChatbotControllerNew.php index 2f6ca404..dc38a3c9 100644 --- a/app/Controllers/ChatbotControllerNew.php +++ b/app/Controllers/ChatbotControllerNew.php @@ -84,6 +84,7 @@ class ChatbotControllerNew extends BaseController public function index() { + if($this->session->get('CHATBOT_RANDOM_USER_ID') == '-' || $this->session->get('CHATBOT_RANDOM_USER_ID') == '') { @@ -100,6 +101,7 @@ class ChatbotControllerNew extends BaseController } $this->botman->hears('.*', function ($bot) { + log_message("error","Inside Bot Type Function"); $bot->types(); // Typing indicator for the first message sleep(0.5); // Delay diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index c432c921..c5854a06 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -40,6 +40,7 @@ use Kint\Kint; use App\Controllers\Jobs; use App\Controllers\JobWorker; use Google\Service\FactCheckTools\Resource\Claims; +use GPBMetadata\Google\Type\Datetime; class LeadsController extends BaseController { @@ -646,6 +647,7 @@ class LeadsController extends BaseController $data['page_name'] = $type == 2 ? 'QCR' : 'RFQ'; $data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames(); $data['userList'] = $this->userModel->getUserListForRFQ(); + $data['exclusiveUserList'] = $this->userModel->getexclusiveUserListForRFQ(); $data['lead_data'] = $lead_data; $mail_content = " @@ -654,18 +656,32 @@ class LeadsController extends BaseController

Please find attached the {{RFQ_OR_QCR}} for {{POLICY_TYPE}} policy pertaining to {{CLIENT_NAME}}.

Kindly request you to share the competitive quotes at the earliest.

In case of any query, please feel free to contact us.

-

Thank You!

+

Thank You!


+

Best regards,

+ +
+
{{LOGGED_USER_NAME}}
+
Email: {{LOGGED_USER_EMAIL}}
+
Mobile: {{LOGGED_USER_MOBILE}}
+
+ + + "; + if ($data['lead_data']['policy_end_date'] != null){ + $subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}} {{POLICY_END_DATE}}"; + }else{ + $subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}}"; - $subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}}"; + } $data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']); $data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']); $data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null; $data['attachment_html'] = view('rfq/attachment_files', $data) ?? ""; - + $data['user_team'] = $this->userModel->select("ut.team_id")->join("user_teams ut","ut.user_id = user_profiles.id and ut.is_active = 1")->where("user_profiles.is_active",1)->first()['team_id']; // dd($data); if ($data['lead_data']['lead_form_type'] == 1) { @@ -880,7 +896,7 @@ class LeadsController extends BaseController if ($rfq_data['policy_type_id'] == 2) { $lead_data = [ - + 'policy_end_date' => $rfq_data['policy_end_date'], 'Insured' => $rfq_data['client_name'], 'Policy Status' => $rfq_data['status'], @@ -893,6 +909,7 @@ class LeadsController extends BaseController ]; } else if ($rfq_data['policy_type_id'] == 1) { $lead_data = [ + 'policy_end_date' => $rfq_data['policy_end_date'], 'Insured' => $rfq_data['client_name'], 'No of Employees at Inception' => $rfq_data['incept_emp_count'], 'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'], @@ -905,6 +922,7 @@ class LeadsController extends BaseController } else { if ($rfq_data['policy_type_id'] == 2) { $lead_data = [ + 'policy_end_date' => $rfq_data['policy_end_date'], 'Insured' => $rfq_data['client_name'], 'Policy Status' => $rfq_data['status'], @@ -933,6 +951,7 @@ class LeadsController extends BaseController ]; } else if ($rfq_data['policy_type_id'] == 1) { $lead_data = [ + 'policy_end_date' => $rfq_data['policy_end_date'], 'Insured' => $rfq_data['client_name'], 'No of Employees at Renewal' => $rfq_data['renewal_emp_count'], 'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'], @@ -1300,9 +1319,25 @@ class LeadsController extends BaseController ], ]); + + // Set filename $string = ($type == 2) ? 'QCR' : 'RFQ'; - $filename = "{$string}_{$rfq_data['client_short_name']}_{$rfq_data['policy_type']}_" . date('YmdHis') . '.xlsx'; + $current_year = date('Y'); + $next_year = $current_year + 1; + $policy_year = "$current_year-$next_year"; + + if (!empty($rfq_data['policy_end_date'])){ + $policy_expiry = strtotime($lead_data['policy_end_date']); + + $formatted_policy = date("d-m-Y",$policy_expiry); + + $filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" .$policy_year.'(Due On '.$formatted_policy . ')' .'.xlsx'; + + }else{ + $filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_".$policy_year.'_' . '.xlsx'; + } + // Save to temporary location $uploadFilePath = WRITEPATH . 'tmp/' . $filename; @@ -1927,13 +1962,20 @@ class LeadsController extends BaseController // print_r($recipient_data); die; } else if ($recipient_type == 'client') { - $recipient_data = [['name' => $lead_data['contact_person_name'], 'email' => $lead_data['contact_person_email']]]; + + $mailIDS = explode(',',$params['contact_mail']); + $recipient_data = []; + foreach ($mailIDS as $mail){ + $recipient_data[] = ['name' => $lead_data['contact_person_name'], 'email' => $mail]; + } + } else { $recipient_data = [['name' => "Team", 'email' => $params['to']]]; } // print_r($recipient_data); die; $subject = $file_type == 'rfq' ? 'Request for Quotation from ' . $lead_data['client_name'] . ' for ' . $lead_data['policy_type'] : 'Quotation Comparison Report for ' . $lead_data['policy_type']; + $original_message = '

Request for Quotation (RFQ)

Dear {{RECIPIENT_NAME}},

We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.

RFQ Details

Client name{{CLIENT_NAME}}
Coverage Type{{POLICY_LONG_NAME}}
Policy Start Date{{POLICY_START_DATE}}
Policy Duration{{DURATION}}
Please note: Additional terms and details are included in the attachment for your reference.

Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.

Best regards,

Nhance India Pvt Ltd

© Nhance India Pvt Ltd. All rights reserved.

'; //for mail content @@ -1982,7 +2024,9 @@ class LeadsController extends BaseController 'proposel_data' => json_encode($lead_update_data), 'status' => 'won', 'placement_date' => change_date_format($params['placement_date'], 'd/m/Y', 'Y-m-d'), + 'payment_date' => change_date_format($params['payment_date'], 'd/m/Y', 'Y-m-d'), 'utr_no' => $params['utr_no'], + 'is_cd' => $params['is_cd'], 'premium_amount' => $params['premium_amount'], 'total_amount' => $params['total_amount'], 'cd_amount' => $params['cd_amount'], @@ -2629,6 +2673,13 @@ class LeadsController extends BaseController $next_year = $current_year + 1; $policy_year = "$current_year-$next_year"; + $policy_expiry = strtotime($lead_data['policy_end_date']); + + $formatted_policy = date("d-m-Y",$policy_expiry); + $logged_user_id = get_session_userid(); + + $logged_user_data = $this->userModel->where("id",$logged_user_id)->where("is_active",1)->first(); + if ($lead_data) { // Replacing placeholders with actual values @@ -2638,6 +2689,11 @@ class LeadsController extends BaseController $message = str_replace("{{POLICY_TYPE}}", $lead_data['policy_type'] ?? "Insurance Policy", $message); $message = str_replace("{{RFQ_OR_QCR}}", $page_name, $message); $message = str_replace("{{POLICY_YEAR}}", $policy_year, $message); + $message = str_replace("{{POLICY_END_DATE}}"," (Due On ".$formatted_policy.")",$message); + + $message = str_replace("{{LOGGED_USER_NAME}}",ucfirst($logged_user_data['first_name'])." ".ucfirst($logged_user_data['last_name']),$message); + $message = str_replace("{{LOGGED_USER_EMAIL}}",$logged_user_data['email'],$message); + $message = str_replace("{{LOGGED_USER_MOBILE}}",$logged_user_data['mobile'],$message); return $message; } else { @@ -2645,6 +2701,7 @@ class LeadsController extends BaseController } } + function getLastFiveFinancialYears() { $currentYear = date('Y'); diff --git a/app/Models/LeadsModel.php b/app/Models/LeadsModel.php index 84e9c9bf..c2ae9492 100644 --- a/app/Models/LeadsModel.php +++ b/app/Models/LeadsModel.php @@ -87,6 +87,8 @@ class LeadsModel extends Model 'lead_form_type', 'custom_fields', + 'payment_date', + 'is_cd' ]; diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index 49b84400..ed5a8ace 100755 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -134,5 +134,20 @@ class UserModel extends Model ->getResultArray(); } + public function getexclusiveUserListForRFQ(){ + $data = $this->db->table('user_profiles') + ->select('user_profiles.*,user_teams.team_id') + ->select('roles.role as user_role') + ->join('roles', 'roles.id = user_profiles.role') + ->join('user_teams', 'user_teams.user_id = user_profiles.id') + ->get() + ->getResultArray(); + + + // dd($data); + + return $data; + } + } ?> \ No newline at end of file diff --git a/app/Views/chatbot.php b/app/Views/chatbot.php index 94373196..95bf5cde 100644 --- a/app/Views/chatbot.php +++ b/app/Views/chatbot.php @@ -41,7 +41,7 @@ origin: "mobile", // origin emp_code:"HTL-007", client_id:159, - client_branch_id:125 + client_branch_id:126 } }; diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index f7ccabb4..8db290b2 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -80,6 +80,9 @@ + + + diff --git a/app/Views/view_rfq.php b/app/Views/view_rfq.php index 950e9b45..adc432b8 100644 --- a/app/Views/view_rfq.php +++ b/app/Views/view_rfq.php @@ -225,12 +225,15 @@ - +       Export Excel - + + + @@ -421,12 +424,15 @@
@@ -484,30 +490,45 @@
+
+ + "> +
+
- + ">
- + "> +
+ +
+ + + >
- + "> +
+ + + +
+ + ">
- + ">
-
- - -
+

@@ -530,12 +551,15 @@
@@ -797,6 +821,11 @@ allowInput: false, }); + var payment_date_datePicker = flatpickr("#payment_date", { + dateFormat: "d/m/Y", + allowInput: false, + }); + }) @@ -830,6 +859,24 @@ var over_all_column_data = { 'insurers': [] } }; +document.addEventListener('DOMContentLoaded', function () { + const textarea = document.getElementById('placement_mail_content'); + const textarea2 = document.getElementById("placement_subject"); + + if (textarea) { + let content = textarea.value; + if (content.includes('QCR')) { + textarea.value = content.replace(/QCR/g, 'Placement'); + } + } + + if (textarea2){ + let content = textarea2.value; + if (content.includes('QCR')) { + textarea2.value = content.replace(/QCR/g, 'Placement'); + } + } +}); // document.addEventListener("DOMContentLoaded", function () { const rfqTable = document.getElementById('rfqTable'); @@ -1283,19 +1330,34 @@ function moveAddRowButton() { rfqTable.addEventListener('click', function(e) { if (e.target.classList.contains('removeRow')) { - const row = e.target.closest('tr'); // Get the row to be removed - const rowKey = row.getAttribute('id'); + Swal.fire({ + title: 'Are you sure?', + text: "Do you want to remove the row?", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#d33', + cancelButtonColor: '#3085d6', + confirmButtonText: 'Yes, remove it!', + cancelButtonText: 'Cancel' + }).then((result) => { + if (result.isConfirmed) { + const row = e.target.closest('tr'); // Get the row to be removed + const rowKey = row.getAttribute('id'); - console.log(suggestionKeys); - // Remove the key from suggestionKeys - suggestionKeys = suggestionKeys.filter(key => key !== rowKey); - row.remove(); - console.log(suggestionKeys); - updateRowNumbers(); // Update row numbers - moveAddRowButton(); // Move the add row button to the last row - realignSpecialConditions(); + console.log(suggestionKeys); + // Remove the key from suggestionKeys + suggestionKeys = suggestionKeys.filter(key => key !== rowKey); + row.remove(); + console.log(suggestionKeys); + updateRowNumbers(); // Update row numbers + moveAddRowButton(); // Move the add row button to the last row + realignSpecialConditions(); - isFormDataModified = true; // if any value changeing in the table to set true + isFormDataModified = true; // if any value changeing in the table to set true + } + }) + + } }); @@ -1441,7 +1503,6 @@ function showSuggestions(input) { // Function to handle answers suggestion box function showAnswersSuggestions(input) { - console.log(input.parentElement.id); console.log(input); //return; @@ -2142,7 +2203,17 @@ function removeProposal(event) { let rfqTable = document.getElementById('rfqTable'); console.log(rfqTable) - if (confirm("Are you sure you want to remove this column?")) { + Swal.fire({ + title: 'Are you sure?', + text: "Do you want to remove the Proposal?", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#d33', + cancelButtonColor: '#3085d6', + confirmButtonText: 'Yes, remove it!', + cancelButtonText: 'Cancel' + }).then((result) => { + if (result.isConfirmed) { const headerRows = rfqTable.querySelectorAll('thead tr'); const parentTh = headerRows[0].children[colIndex]; @@ -2187,69 +2258,83 @@ function removeProposal(event) { console.log(`${proposal_name} does not exist.`); } } + + }) } function removeInsurer(event) { - if (confirm("Are you sure you want to remove this column?")) { - // function removeSubColumnByIndex(tableId, subThIndex) { - const table = document.getElementById('rfqTable'); - const headerRows = table.querySelectorAll('thead tr'); + Swal.fire({ + title: 'Are you sure?', + text: "Do you want to remove the insurer?", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#d33', + cancelButtonColor: '#3085d6', + confirmButtonText: 'Yes, remove it!', + cancelButtonText: 'Cancel' + }).then((result) => { + if (result.isConfirmed) { + // function removeSubColumnByIndex(tableId, subThIndex) { + const table = document.getElementById('rfqTable'); + const headerRows = table.querySelectorAll('thead tr'); - const closestTh = event.target.closest('th'); - let insurerName = closestTh.innerText.split('⋮')[0] - // alert(insurerName);return; - let subThIndex = closestTh.cellIndex; - console.log('subThIndex', subThIndex); + const closestTh = event.target.closest('th'); + let insurerName = closestTh.innerText.split('⋮')[0] + // alert(insurerName);return; + let subThIndex = closestTh.cellIndex; + console.log('subThIndex', subThIndex); - // Get the sub TH from the second header row - const subTh = headerRows[1].children[subThIndex]; - console.log('subTh', subTh); + // Get the sub TH from the second header row + const subTh = headerRows[1].children[subThIndex]; + console.log('subTh', subTh); - let accumulatedColspan = 0; - let parentTh = null; - const firstHeaderRow = headerRows[0]; - // Find the parent TH for the specified sub TH index - for (let i = 0; i < firstHeaderRow.children.length; i++) { - const currentParentTh = firstHeaderRow.children[i]; - const currentColspan = parseInt(currentParentTh.getAttribute('colspan')) || 1; + let accumulatedColspan = 0; + let parentTh = null; + const firstHeaderRow = headerRows[0]; + // Find the parent TH for the specified sub TH index + for (let i = 0; i < firstHeaderRow.children.length; i++) { + const currentParentTh = firstHeaderRow.children[i]; + const currentColspan = parseInt(currentParentTh.getAttribute('colspan')) || 1; - accumulatedColspan += currentColspan; + accumulatedColspan += currentColspan; - if (subThIndex < accumulatedColspan) { - parentTh = currentParentTh; - break; + if (subThIndex < accumulatedColspan) { + parentTh = currentParentTh; + break; + } + } + console.log('parentth' + parentTh); + console.log('sub col indexOf' + subThIndex); + + + // Get the starting position of the sub TH + const startIndex = Array.from(headerRows[1].children).indexOf(subTh); + + // Remove the sub TH + headerRows[1].removeChild(subTh); + + // Reduce colspan of parent TH + const parentColspan = parseInt(parentTh.getAttribute('colspan')) || 1; + console.log('existing colspan' + parentColspan); + parentTh.setAttribute('colspan', parentColspan - 1); + console.log('new colspan' + (parentColspan - 1)); + + // Remove the corresponding TDs from each row + table.querySelectorAll('tbody tr').forEach(row => { + row.removeChild(row.children[startIndex]); + }); + + removeInsurerFromPremiumTable(event, subThIndex) + + //remove the insurer from gobal array + let proposal_name = parentTh.innerText.split('⋮')[0]; + popInsurerInArray(proposal_name, insurerName); + + isFormDataModified = true; // if any value changeing in the table to set true } - } - console.log('parentth' + parentTh); - console.log('sub col indexOf' + subThIndex); - - - // Get the starting position of the sub TH - const startIndex = Array.from(headerRows[1].children).indexOf(subTh); - - // Remove the sub TH - headerRows[1].removeChild(subTh); - - // Reduce colspan of parent TH - const parentColspan = parseInt(parentTh.getAttribute('colspan')) || 1; - console.log('existing colspan' + parentColspan); - parentTh.setAttribute('colspan', parentColspan - 1); - console.log('new colspan' + (parentColspan - 1)); - - // Remove the corresponding TDs from each row - table.querySelectorAll('tbody tr').forEach(row => { - row.removeChild(row.children[startIndex]); - }); - - removeInsurerFromPremiumTable(event, subThIndex) - - //remove the insurer from gobal array - let proposal_name = parentTh.innerText.split('⋮')[0]; - popInsurerInArray(proposal_name, insurerName); - - isFormDataModified = true; // if any value changeing in the table to set true - } + + }) } function showThreeDottedMenu(event) { @@ -2739,8 +2824,8 @@ function handleChildQuestions(target) { let childCell = childRow.cells[currentColumnIndex]; if (childCell) { - console.log('found cell'); - + console.log('found cell',inputValue); + if (inputValue.key == disable_at.key) { childCell.innerHTML = ''; childCell.innerText = ''; @@ -2759,6 +2844,21 @@ function handleChildQuestions(target) { console.log(child.default_answer.display_value) childCell.contentEditable = false; } else { + childCell.innerHTML = ''; + childCell.innerText = ''; + //hidden text box for store choosed answers object + const hiddenInputBox = document.createElement('input'); + hiddenInputBox.type = 'hidden'; + hiddenInputBox.value = JSON.stringify(inputValue.display_value); + + childCell.appendChild(hiddenInputBox); + // alert(input.innerText); + childCell.appendChild(document.createTextNode(inputValue.display_value)); + + // Set the default answer in the child cell + // childCell.innerHTML = child.default_answer.display_value; + // console.log('setting default value'); + // console.log(child.default_answer.display_value) childCell.contentEditable = true; } } @@ -3136,7 +3236,7 @@ function ajaxRequestForGetMailData(url) { function appendInput(data) { - console.log(data); + console.log("append data:",data); var lead_id = $('#lead_id').val(); $('#input_for_row').empty(); let html = ''; @@ -3146,9 +3246,9 @@ function appendInput(data) { const url = '?lead_id=' + lead_id; html += ` -
+
- +
`; @@ -3164,29 +3264,33 @@ function appendInput(data) { html += ` -
+
-
+
`; @@ -3196,7 +3300,7 @@ function appendInput(data) { html += `
- '" placeholder="Subject"> + " placeholder="Subject">
`; @@ -3229,25 +3333,28 @@ function appendInput(data) {
@@ -3307,7 +3414,13 @@ function appendInput(data) { function constructURL(url_type) { if(url_type == 1){ - constructURL_ForInsurerAndClientMailSend() + var validationStatus = checkMailValidation(); + + if (validationStatus){ + constructURL_ForInsurerAndClientMailSend(); + }else{ + toastr.error("All Client Mail ID's Should Contain Same Domain","ERROR"); + } }else if(url_type == 2){ constructURL_ForInternalMailSend() }else if(url_type == 3){ @@ -3470,6 +3583,7 @@ function constructURL_ForInsurerAndClientMailSend() { var subject = $('#mail_subject').val(); var bcc = $('#client_bcc').val(); var cc = $('#client_cc').val(); + var contact_mail = $("#contact_mail").val(); console.log('lead_id', lead_id) console.log('subject', subject) @@ -3501,6 +3615,7 @@ function constructURL_ForInsurerAndClientMailSend() { if (RFQ_or_QCR == 2) { + formData.append('contact_mail',contact_mail); formData.append('file_type', 'qcr'); formData.append('recipient_type', 'client'); formData.append('recipient_mail', ''); @@ -3560,6 +3675,8 @@ function constructURL_ForPlacementMailSend() { var lead_id = $('#lead_id').val(); let to = $('#placement_to').val(); let placement_date = $('#placement_date').val(); + let payment_date = $('#payment_date').val(); + let is_cd = $("#is_cd_switch").is(":checked") ? 1 : 0; let utr_no = $('#utr_no').val(); let premium_amount = $('#premium_amount').val(); let total_amount = $('#total_amount').val(); @@ -3590,6 +3707,8 @@ function constructURL_ForPlacementMailSend() { formData.append('proposal_insurer', proposal_insurer); formData.append('insurer_and_branch', insurer_and_branch); formData.append('placement_date', placement_date); + formData.append('payment_date', payment_date); + formData.append("is_cd",is_cd); formData.append('utr_no', utr_no); formData.append('premium_amount', premium_amount); formData.append('total_amount', total_amount); @@ -3661,7 +3780,7 @@ function ajaxRequest(formData) { $('#placement_cc').val('').select2({ placeholder : 'select CC Mail' }); - $('#placement_subject').val(''); + // $('#placement_subject').val(''); $("textarea.select2-search__field").attr('rows', '1'); $("textarea.select2-search__field").css('resize', 'none'); @@ -3738,7 +3857,7 @@ $('.close').click(function(){ $('#placement_cc').val('').select2({ placeholder : 'select CC Mail' }); - $('#placement_subject').val(''); + // $('#placement_subject').val(''); $("textarea.select2-search__field").attr('rows', '1'); $("textarea.select2-search__field").css('resize', 'none'); @@ -5733,4 +5852,65 @@ function appendMultiFileData(data) { } + $("#is_cd_switch").change(function (){ + var switch_status = ($("#is_cd_switch").is(":checked")? "on" : "off"); + console.log("Switch status",switch_status); + if (switch_status == "on"){ + + $("#cd_amount").show(); + $("#total_amount").show(); + $("#cd_amount").closest('.form-group').show(); + $("#total_amount").closest('.form-group').show(); + + }else{ + + $("#cd_amount").hide(); + $("#total_amount").hide(); + $("#cd_amount").closest('.form-group').hide(); + $("#total_amount").closest('.form-group').hide(); + + } + }) + + $(document).on("input", "#cd_amount, #premium_amount", function() { + + // alert("Function called"); + + var cd_amount = parseInt($("#cd_amount").val()) || 0; + var premium_amount = parseInt($("#premium_amount").val()) || 0; + + var total_amount = (cd_amount + premium_amount); + $("#total_amount").val(total_amount); + + + }); + + function checkMailValidation(){ + + emailString = $("#contact_mail").val(); + + if (RFQ_or_QCR == 1){ + if (typeof emailString !== 'string' || !emailString.includes(',')) return true; + }else{ + if (typeof emailString !== 'string') return false; + } + + const invalidChars = /[;|]/; + if (invalidChars.test(emailString)) return false; + + + const emails = emailString.split(',').map(email => email.trim()); + + if (emails.length === 0) return false; + + const getDomain = email => email.split('@')[1]?.toLowerCase(); + const firstDomain = getDomain(emails[0]); + + if (!firstDomain) return false; + + return emails.every(email => getDomain(email) === firstDomain); + } + + + \ No newline at end of file From 84fb4e797152765c7de92135502e1d6e2c5ab69b Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 8 Apr 2025 15:45:26 +0530 Subject: [PATCH 051/169] CHANGE_RFQ_NEW_CR : RV --- app/Controllers/ClientController.php | 233 ++++++++++++++++- app/Controllers/LeadsController.php | 373 +++++++++++++++++++++------ app/Models/LeadsModel.php | 3 + app/Views/leads_form.php | 126 +++++---- app/Views/leads_form_handler.php | 53 ++-- app/Views/rfq/gmc.php | 32 +-- app/Views/view_rfq.php | 21 +- 7 files changed, 674 insertions(+), 167 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 0a096c82..21f0afa5 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -1994,9 +1994,22 @@ class ClientController extends AdminController if ($id) { $client_policy_data = $this->clientPolicyModel->where(['id' => $id, 'is_active' => 1])->first(); + $insurer_id = $client_policy_data['insurer_id']; $client_id = $client_policy_data['client_id']; + if (!empty($client_policy_data['policy_start_date'])) { + $client_policy_data['source_policy_start_date'] = change_date_format($client_policy_data['policy_start_date'], 'Y-m-d', 'd/m/Y'); + } else { + $client_policy_data['source_policy_start_date'] = null; + } + + if (!empty($client_policy_data['policy_end_date'])) { + $client_policy_data['source_policy_end_date'] = change_date_format($client_policy_data['policy_end_date'], 'Y-m-d', 'd/m/Y'); + } else { + $client_policy_data['source_policy_end_date'] = null; + } + $polices = $this->policesModel ->select('policies.*, policy_type.policy_type') ->join('policy_type', 'policy_type.id = policies.policy_type_id') @@ -2022,7 +2035,7 @@ class ClientController extends AdminController 'policy' => $polices, 'client_policy_list' => $client_policy_list, 'end_date' => $newDate, - 'new_start_date' => date('d/m/Y', strtotime($client_policy_data['policy_end_date'])) + 'new_start_date' => date('d/m/Y', strtotime($client_policy_data['policy_end_date'] . ' +1 day')), ], 200); } else { return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200); @@ -4740,8 +4753,7 @@ class ClientController extends AdminController // } // $data = $this->leadsModel->where('leads.id', 125)->where('leads.is_active', 1)->first(); - // $RFQdata = $RFQModel->getRFQTableDataWithLeadIDAndType(125, 2); - // // Kint::dump($RFQdata); + // $RFQdata = $RFQModel->getRFQTableDataWithLeadIDAndType(145, 2); // $returnData = $LeadsController->getPlacementJson($data); // Kint::dump($returnData); // $policy_terms = $LeadsController->convertNonEbQCRJsonToPolicyTerms(json_decode($returnData, true)); @@ -4751,6 +4763,20 @@ class ClientController extends AdminController // $this->clientPolicyModel->where('id', 6050)->set('policy_terms', $policy_terms)->update(); // dd($returnData); + // Kint::dump($RFQdata['json']); + // $inputJson = json_decode($RFQdata['json'], true); + // Kint::dump($inputJson); + // // print_rr($inputJson['table_data']); + // $sortedJson = $this->reorderProposalsByInsurerTotal($inputJson); + + // // If you want to convert back to JSON string + // $finalJson = json_encode($sortedJson, JSON_PRETTY_PRINT); + + // // $RFQModel->insert(['lead_id' => 145, 'json' => $finalJson, 'type' => 1]); + + // dd($finalJson); + + } // ------------------------------------------------------------------------------------------------------- @@ -5456,6 +5482,207 @@ class ClientController extends AdminController $id = $InsurerModel->insert($insurerData); return $id; } + + private function reorderProposalsByInsurerTotal(array $data): array { + + Kint::dump($data); + if (!isset($data['premium_data']['data'])) return $data; + $original = $data['premium_data']['data']; + $proposals = []; + $others = []; + $emptyKeyData = []; + foreach ($original as $key => $value) { + // Match only keys that look like 'Proposal X' + if (preg_match('/^Proposal\s+\d+$/', $key)) { + // Get the insurer entry (not 'Quote Asked') + foreach ($value as $subKey => $subVal) { + if ($subKey !== 'Quote Asked' && isset($subVal['Total'])) { + $proposals[$key] = $value; + break; + }else{ + $proposals[$key] = $value; + } + } + } else { + + if ($key === '' && isset($value['']) && is_array($value[''])) { + // Capture empty key to push it later + $emptyKeyData[$key] = $value; + }else{ + $others[$key] = $value; + + } + } + } + + // dd($proposals, $others, $emptyKeyData); + // Sort proposals by their insurer's total + uasort($proposals, function($a, $b) { + $totalA = 0; + $totalB = 0; + + foreach ($a as $key => $val) { + if ($key !== 'Quote Asked' && isset($val['Total'])) { + $totalA = floatval($val['Total']); + break; + } + } + + foreach ($b as $key => $val) { + if ($key !== 'Quote Asked' && isset($val['Total'])) { + $totalB = floatval($val['Total']); + break; + } + } + + return $totalA <=> $totalB; + }); + + // Merge back the sorted proposals into the full structure + $data['premium_data']['data'] = array_merge($others, $proposals, $emptyKeyData); + $data = $this->reorderProposalDataByPremiumOrder($data); + return $data; + } + + private function reorderProposalDataByPremiumOrder(array $data): array { + if (!isset($data['premium_data']['data'], $data['proposal_data']['over_all_column_data'])) { + return $data; + } + + $premiumProposals = array_keys($data['premium_data']['data']); + $filteredProposals = []; + + // Collect proposal keys that match the pattern "Proposal X" + foreach ($premiumProposals as $key) { + if (preg_match('/^Proposal\s+\d+$/', $key) && isset($data['proposal_data']['over_all_column_data'][$key])) { + $filteredProposals[$key] = $data['proposal_data']['over_all_column_data'][$key]; + } + } + + // dd($premiumProposals, $filteredProposals); + + $data['proposal_data']['over_all_column_data'] = $filteredProposals; + $data = $this->reorderProposalInHeaderAndData($data); + return $data; + } + + private function reorderProposalInHeaderAndData(array $data): array { + + // Kint::dump($data); + $tableData = $data['table_data']; + $sortedProposalOrder = $data['proposal_data']['over_all_column_data']; + $headers = $tableData['headers'] ?? []; + $dataRows = $tableData['data'] ?? []; + + // Step 1: Separate static and proposal headers + $staticHeaders = []; + $proposalHeaders = []; + $actionHeader = []; + foreach ($headers as $header) { + if (in_array($header['parentHeader'], array_keys($sortedProposalOrder))) { + $proposalHeaders[$header['parentHeader']] = $header; + } else { + if($header['parentHeader'] == "Action"){ + $actionHeader[] = $header; + }else{ + $staticHeaders[] = $header; + } + } + } + + // dd($staticHeaders, $proposalHeaders, $sortedProposalOrder); + + // Step 2: Reorder headers + $reorderedHeaders = []; + foreach ($sortedProposalOrder as $proposalKey => $proposalValue) { + if (isset($proposalHeaders[$proposalKey])) { + $reorderedHeaders[] = $proposalHeaders[$proposalKey]; + } + } + + // print_rr($reorderedHeaders); die; + foreach ($reorderedHeaders as $key => &$value) { + $value['parentHeader'] = 'Proposal ' . ($key + 1); + } + unset($value); + + + $reorderedHeaders = array_merge($staticHeaders, $reorderedHeaders, $actionHeader); + + + // Step 3: Reorder each row's `data` by matching parentth + foreach ($dataRows as $dataRowIndex => &$row) { + $staticData = []; + $proposalData = []; + $actionData = []; + + foreach ($row['data'] as $entry) { + if (in_array($entry['parentth'], array_keys($sortedProposalOrder))) { + $proposalData[$entry['parentth']][] = $entry; + } else { + if($entry['parentth'] == "Action"){ + $actionData[] = $entry; + }else{ + $staticData[] = $entry; + } + } + } + + $reorderedProposalData = []; + foreach ($sortedProposalOrder as $proposalKey => $proposalValue) { + if (isset($proposalData[$proposalKey])) { + foreach ($proposalData[$proposalKey] as $entry) { + $reorderedProposalData[] = $entry; + } + } + } + + $dubParTh = ""; + $increament = 0; + foreach ($reorderedProposalData as $key => &$value) { + + if($dubParTh == $value['parentth']){ + $value['parentth'] = 'Proposal ' . ($increament); + }else{ + $dubParTh = $value['parentth']; + $increament = $increament + 1; + $value['parentth'] = 'Proposal ' . ($increament); + } + } + unset($value); + + $row['data'] = array_merge($staticData, $reorderedProposalData, $actionData); + } + + $data['table_data']['headers'] = $reorderedHeaders; + $data['table_data']['data'] = $dataRows; + + // dd('-----', $data); + $renumberedArray = $this->renumberProposalKeys($data['proposal_data']['over_all_column_data']); + $updatedDataSet = $this->renumberProposalKeys($data['premium_data']['data']); + $data['proposal_data']['over_all_column_data'] = !empty($renumberedArray) ? $renumberedArray : $data['proposal_data']['over_all_column_data']; + $data['premium_data']['data'] = !empty($updatedDataSet) ? $updatedDataSet : $data['premium_data']['data']; + + return $data; + } + + private function renumberProposalKeys(array $input): array { + $result = []; + $counter = 1; + + foreach ($input as $key => $value) { + if (strpos($key, 'Proposal') === 0) { + $newKey = 'Proposal ' . $counter++; + $result[$newKey] = $value; + } else { + $result[$key] = $value; + } + } + + return $result; + } + + } diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index c432c921..28b856d7 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -101,7 +101,7 @@ class LeadsController extends BaseController $this->leadType = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over']; $this->buisnessType = [1 => 'Industrial', 2 => 'Non Industrial']; $this->leadsStatus = [ - 'queued' => 'Queued', + 'queued' => 'In-Queued', 'qcr_sent' => 'QCR sent', 'lost' => 'Lost', 'co_insurer_pending' => 'Co-Insurer Pending', @@ -202,6 +202,7 @@ class LeadsController extends BaseController } else { $data = $this->prepareMultipleLeadData($data); } + // print_r($data); die; return $data; } @@ -210,8 +211,8 @@ class LeadsController extends BaseController { // print_r($data); die; $index_plus_one = 1; - $form_file_name = "file_name_".$index_plus_one; - $form_docs_name = "docs_name_".$index_plus_one; + $form_file_name = "file_name_" . $index_plus_one; + $form_docs_name = "docs_name_" . $index_plus_one; $leads_file_primary_key = $data['leads_file_id'] ?? []; $files = $this->request->getFileMultiple($form_file_name); $multi_file_data = $this->uploadMultiFiles($files, $data[$form_docs_name], $leads_file_primary_key); @@ -252,7 +253,7 @@ class LeadsController extends BaseController } // $data['file_name'] = file_Upload($files, $uploadFilePath); - $data['multi_file_data']= $multi_file_data ?? null; + $data['multi_file_data'] = $multi_file_data ?? null; $processcedData[] = $data; @@ -268,8 +269,8 @@ class LeadsController extends BaseController foreach ($data['policy_type_id'] as $index => $value) { $index_plus_one = $index + 1; - $form_file_name = "file_name_".$index_plus_one; - $form_docs_name = "docs_name_".$index_plus_one; + $form_file_name = "file_name_" . $index_plus_one; + $form_docs_name = "docs_name_" . $index_plus_one; $leads_file_primary_key = $data['leads_file_id'] ?? []; $files = $this->request->getFileMultiple($form_file_name); $multi_file_data = $this->uploadMultiFiles($files, $data[$form_docs_name], $leads_file_primary_key); @@ -323,10 +324,22 @@ class LeadsController extends BaseController $incurred_claims_date = null; } - if (!empty($data['premium_date'][$index])) { - $premium_date = change_date_format($data['premium_date'][$index], 'd/m/Y', 'Y-m-d'); + // if (!empty($data['premium_date'][$index])) { + // $premium_date = change_date_format($data['premium_date'][$index], 'd/m/Y', 'Y-m-d'); + // } else { + // $premium_date = null; + // } + + if (!empty($data['source_policy_start_date'])) { + $data['source_policy_start_date'] = change_date_format($data['source_policy_start_date'], 'd/m/Y', 'Y-m-d'); } else { - $premium_date = null; + $data['source_policy_start_date'] = null; + } + + if (!empty($data['source_policy_end_date'])) { + $data['source_policy_end_date'] = change_date_format($data['source_policy_end_date'], 'd/m/Y', 'Y-m-d'); + } else { + $data['source_policy_end_date'] = null; } // $file_name = file_Upload($files[$index], $uploadFilePath); @@ -383,7 +396,7 @@ class LeadsController extends BaseController 'outstanding_claims' => $data['outstanding_claims'][$index] ?? 0, 'policy_run_days' => $data['policy_run_days'][$index] ?? 0, 'premium_at_inception' => $data['premium_at_inception'][$index] ?? 0, - 'premium_date' => $premium_date, + 'premium_date' => $data['premium_date'][$index] ?? 0, 'earned_premium' => $data['earned_premium'][$index] ?? 0, 'annualised_claims' => $data['annualised_claims'][$index] ?? 0, 'incurred_claims_ratio' => $data['incurred_claims_ratio'][$index] ?? 0, @@ -400,6 +413,9 @@ class LeadsController extends BaseController 'lead_form_type' => $data['lead_form_type'] ?? 1, 'custom_fields' => $data['custom_fields'] ?? null, + + 'source_policy_start_date' => $data['source_policy_start_date'] ?? null, + 'source_policy_end_date' => $data['source_policy_end_date'] ?? null, ]; } // print_r($processedData);die(); @@ -479,11 +495,11 @@ class LeadsController extends BaseController $data['incurred_claims_date'] = null; } - if (!empty($data['premium_date'])) { - $data['premium_date'] = change_date_format($data['premium_date'], 'Y-m-d', 'd/m/Y'); - } else { - $data['premium_date'] = null; - } + // if (!empty($data['premium_date'])) { + // $data['premium_date'] = change_date_format($data['premium_date'], 'Y-m-d', 'd/m/Y'); + // } else { + // $data['premium_date'] = null; + // } $data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->first() ?? null; @@ -538,26 +554,25 @@ class LeadsController extends BaseController } public function insertMultiFilesData($data, $lead_id) - { + { // print_r($data); die; - if(!empty($data)){ + if (!empty($data)) { foreach ($data as $key => $value) { - if(!empty($value['id'])){ + if (!empty($value['id'])) { $lead_file_data = [ 'lead_id' => $lead_id, 'docs_name' => $value['docs_name'], ]; - if(!empty($value['file_name'])) { + if (!empty($value['file_name'])) { $lead_file_data['file_name'] = $value['file_name']; } $this->leadFilesModel->where('id', $value['id'])->set($lead_file_data)->update(); - - }else{ + } else { $lead_file_data = [ 'lead_id' => $lead_id, @@ -566,8 +581,8 @@ class LeadsController extends BaseController ]; $this->leadFilesModel->insert($lead_file_data); } - - if($key == 0 && !empty($value['file_name'])) { + + if ($key == 0 && !empty($value['file_name'])) { $this->leadsModel->where('id', $lead_id)->set('file_name', $value['file_name'])->update(); } } @@ -577,22 +592,16 @@ class LeadsController extends BaseController } public function removeMultiFile() - { + { $id = $this->request->getGet('lead_file_id'); - if(!empty($id)){ + if (!empty($id)) { $this->leadFilesModel->where('id', $id)->set(['is_active' => 0])->update(); return $this->respond(['status' => true, 'message' => 'File removed successfully'], 200); - }else{ + } else { return $this->respond(['status' => false, 'message' => 'File could not be removed.'], 200); } } - - public function updateLeadTableFields() - { - - } - - //--------RFQ----------------------------------------------------------------------------------------------- + //--------RFQ----------------------------------------------------------------------------------------------- public function viewRFQ($id, $type = 1) @@ -676,14 +685,14 @@ class LeadsController extends BaseController $data['occupancy'] = $this->occupancyModel->findAll(); // dd($data['occupancy']); - if($lead_data['lead_type'] != 1 && $data['rfq_count'] == 0){ + if ($lead_data['lead_type'] != 1 && $data['rfq_count'] == 0) { $client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first(); $data['rfq_data']['json'] = $client_policy_data['placement_json']; } - if(!empty($data['question_json'])){ + if (!empty($data['question_json'])) { $data['policies'] = json_decode($data['question_json'], true)['policies']; - $data["child_table_data"] = json_decode($data['question_json'], true)['child_table_data']; + $data["child_table_data"] = json_decode($data['question_json'], true)['child_table_data']; } // $data['lead_register_data'] = json_decode($data['lead_data']['custom_fields']); @@ -735,15 +744,24 @@ class LeadsController extends BaseController return $this->respond(['status' => false, 'message' => 'Lead ID is required'], 400); } + $inputJson = json_decode($data['json'], true); + if (isset($inputJson['premium_data']) && !empty($inputJson['premium_data'])) { + $sortedJson = $this->reorderProposalsByInsurerTotal($inputJson); + $data['json'] = json_encode($sortedJson); + } + + $data['type'] = 1; // Deactivate existing RFQs for this lead and type - $this->RFQModel - ->where('lead_id', $lead_id) - ->where('type', 1) - ->where('is_active', 1) - ->set('is_active', 0) - ->update(); + if (!isset($data['rfq_primaryKey']) && empty($data['rfq_primaryKey'])) { + $this->RFQModel + ->where('lead_id', $lead_id) + ->where('type', 1) + ->where('is_active', 1) + ->set('is_active', 0) + ->update(); + } // Handle registration_json if (empty($data['registration_json'])) { @@ -759,20 +777,29 @@ class LeadsController extends BaseController } } - // Insert new RFQ - $insertId = $this->RFQModel->insert($data); + // print_r($data); die; + // $data['json'] = ""; + if (isset($data['rfq_primaryKey']) && !empty($data['rfq_primaryKey'])) { + $this->RFQModel->update($data['rfq_primaryKey'], $data); + $insertId = $data['rfq_primaryKey']; + $affectedRows = db_connect()->affectedRows(); + } else { + // Insert new RFQ + $insertId = $this->RFQModel->insert($data); + } if ($insertId) { - $message = ($data['submit_type'] ?? '') == 'QCR' ? 'QCR submitted successfully' : 'RFQ submitted successfully'; + $message = ($data['submit_type'] ?? '') == 'QCR' ? 'QCR saved successfully' : 'RFQ saved successfully'; return $this->respond([ 'status' => true, 'id' => $insertId, 'message' => $message, - 'data' => $data + 'data' => $data, + 'affectedRows' => $affectedRows ?? null, ], 200); } - $message = ($data['submit_type'] ?? '') == 'QCR' ? 'Failed to create QCR' : 'Failed to create RFQ'; + $message = ($data['submit_type'] ?? '') == 'QCR' ? 'Failed to save QCR' : 'Failed to save RFQ'; return $this->respond([ 'status' => false, 'id' => null, @@ -805,6 +832,206 @@ class LeadsController extends BaseController } + private function reorderProposalsByInsurerTotal(array $data): array + { + + if (!isset($data['premium_data']['data'])) return $data; + + $original = $data['premium_data']['data']; + $proposals = []; + $others = []; + $emptyKeyData = []; + + foreach ($original as $key => $value) { + // Match only keys that look like 'Proposal X' + if (preg_match('/^Proposal\s+\d+$/', $key)) { + // Get the insurer entry (not 'Quote Asked') + foreach ($value as $subKey => $subVal) { + if ($subKey !== 'Quote Asked' && isset($subVal['Total'])) { + $proposals[$key] = $value; + break; + }else{ + $proposals[$key] = $value; + } + } + } else { + + if ($key === '' && isset($value['']) && is_array($value[''])) { + // Capture empty key to push it later + $emptyKeyData[$key] = $value; + } else { + $others[$key] = $value; + } + } + } + + // Sort proposals by their insurer's total + uasort($proposals, function ($a, $b) { + $totalA = 0; + $totalB = 0; + + foreach ($a as $key => $val) { + if ($key !== 'Quote Asked' && isset($val['Total'])) { + $totalA = floatval($val['Total']); + break; + } + } + + foreach ($b as $key => $val) { + if ($key !== 'Quote Asked' && isset($val['Total'])) { + $totalB = floatval($val['Total']); + break; + } + } + + return $totalA <=> $totalB; + }); + + // Merge back the sorted proposals into the full structure + $data['premium_data']['data'] = array_merge($others, $proposals, $emptyKeyData); + $data = $this->reorderProposalDataByPremiumOrder($data); + return $data; + } + + private function reorderProposalDataByPremiumOrder(array $data): array + { + if (!isset($data['premium_data']['data'], $data['proposal_data']['over_all_column_data'])) { + return $data; + } + + $premiumProposals = array_keys($data['premium_data']['data']); + $filteredProposals = []; + + // Collect proposal keys that match the pattern "Proposal X" + foreach ($premiumProposals as $key) { + if (preg_match('/^Proposal\s+\d+$/', $key) && isset($data['proposal_data']['over_all_column_data'][$key])) { + $filteredProposals[$key] = $data['proposal_data']['over_all_column_data'][$key]; + } + } + + // dd($premiumProposals, $filteredProposals); + + $data['proposal_data']['over_all_column_data'] = $filteredProposals; + $data = $this->reorderProposalInHeaderAndData($data); + return $data; + } + + private function reorderProposalInHeaderAndData(array $data): array + { + $tableData = $data['table_data']; + $sortedProposalOrder = $data['proposal_data']['over_all_column_data']; + $headers = $tableData['headers'] ?? []; + $dataRows = $tableData['data'] ?? []; + + // Step 1: Separate static and proposal headers + $staticHeaders = []; + $proposalHeaders = []; + $actionHeader = []; + foreach ($headers as $header) { + if (in_array($header['parentHeader'], array_keys($sortedProposalOrder))) { + $proposalHeaders[$header['parentHeader']] = $header; + } else { + if ($header['parentHeader'] == "Action") { + $actionHeader[] = $header; + } else { + $staticHeaders[] = $header; + } + } + } + + // dd($staticHeaders, $proposalHeaders, $sortedProposalOrder); + + // Step 2: Reorder headers + $reorderedHeaders = []; + foreach ($sortedProposalOrder as $proposalKey => $proposalValue) { + if (isset($proposalHeaders[$proposalKey])) { + $reorderedHeaders[] = $proposalHeaders[$proposalKey]; + } + } + + // print_rr($reorderedHeaders); die; + foreach ($reorderedHeaders as $key => &$value) { + $value['parentHeader'] = 'Proposal ' . ($key + 1); + } + unset($value); + + + $reorderedHeaders = array_merge($staticHeaders, $reorderedHeaders, $actionHeader); + + + // Step 3: Reorder each row's `data` by matching parentth + foreach ($dataRows as $dataRowIndex => &$row) { + $staticData = []; + $proposalData = []; + $actionData = []; + + foreach ($row['data'] as $entry) { + if (in_array($entry['parentth'], array_keys($sortedProposalOrder))) { + $proposalData[$entry['parentth']][] = $entry; + } else { + if ($entry['parentth'] == "Action") { + $actionData[] = $entry; + } else { + $staticData[] = $entry; + } + } + } + + $reorderedProposalData = []; + foreach ($sortedProposalOrder as $proposalKey => $proposalValue) { + if (isset($proposalData[$proposalKey])) { + foreach ($proposalData[$proposalKey] as $entry) { + $reorderedProposalData[] = $entry; + } + } + } + + $dubParTh = ""; + $increament = 0; + foreach ($reorderedProposalData as $key => &$value) { + + if ($dubParTh == $value['parentth']) { + $value['parentth'] = 'Proposal ' . ($increament); + } else { + $dubParTh = $value['parentth']; + $increament = $increament + 1; + $value['parentth'] = 'Proposal ' . ($increament); + } + } + unset($value); + + $row['data'] = array_merge($staticData, $reorderedProposalData, $actionData); + } + + $data['table_data']['headers'] = $reorderedHeaders; + $data['table_data']['data'] = $dataRows; + + $renumberedArray = $this->renumberProposalKeys($data['proposal_data']['over_all_column_data']); + $updatedDataSet = $this->renumberProposalKeys($data['premium_data']['data']); + $data['proposal_data']['over_all_column_data'] = !empty($renumberedArray) ? $renumberedArray : $data['proposal_data']['over_all_column_data']; + $data['premium_data']['data'] = !empty($updatedDataSet) ? $updatedDataSet : $data['premium_data']['data']; + + return $data; + } + + private function renumberProposalKeys(array $input): array + { + $result = []; + $counter = 1; + + foreach ($input as $key => $value) { + if (strpos($key, 'Proposal') === 0) { + $newKey = 'Proposal ' . $counter++; + $result[$newKey] = $value; + } else { + $result[$key] = $value; + } + } + + return $result; + } + + //-----RFQ and QCR EXPORT------------------------------------------------------------------------------------------------ @@ -2394,16 +2621,15 @@ class LeadsController extends BaseController // } } - if($data['lead_form_type'] == 1){ + if ($data['lead_form_type'] == 1) { $client_policy_data['policy_terms'] = $this->preparePolicyTermsFromRFQ($data); - }else{ + } else { $placementJson = $this->getPlacementJson($data); if ($placementJson) { $client_policy_data['placement_json'] = $placementJson; $client_policy_data['policy_terms'] = $this->convertNonEbQCRJsonToPolicyTerms(json_decode($placementJson, true)); } - } // print_r($client_policy_data); die; @@ -2542,12 +2768,11 @@ class LeadsController extends BaseController } return json_encode($terms_array); - } else { return null; } } - + public function featchClientPolicyFromLead($client_id, $branch_id, $lead_id) { $data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first(); @@ -2592,7 +2817,9 @@ class LeadsController extends BaseController return $this->transformNonEbProposelData( $jsonData, $proposel_data['proposel_name'] ?? '', - $proposel_data['insurer_name'] ?? '', null, 1 + $proposel_data['insurer_name'] ?? '', + null, + 1 ); }, $jsonArray); @@ -2612,7 +2839,7 @@ class LeadsController extends BaseController } unset($proposal); // Good practice after foreach by reference } - + $placement_json_data[] = $proposalData; @@ -2721,7 +2948,7 @@ class LeadsController extends BaseController } if (!empty($data['lead_edit_data'])) { - foreach (['policy_start_date', 'policy_end_date', 'incurred_claims_date', 'premium_date'] as $dateField) { + foreach (['policy_start_date', 'policy_end_date', 'source_policy_start_date', 'source_policy_end_date', 'incurred_claims_date'] as $dateField) { $data['lead_edit_data'][$dateField] = !empty($data['lead_edit_data'][$dateField]) ? change_date_format($data['lead_edit_data'][$dateField], 'Y-m-d', 'd/m/Y') : null; @@ -2812,7 +3039,7 @@ class LeadsController extends BaseController $lead_data = array_merge(['Insured' => $rfq_data['client_name']], $lead_data); $policy_registration_data = []; - if(isset($rfq_data['registration_json']) && !empty($rfq_data['registration_json'])){ + if (isset($rfq_data['registration_json']) && !empty($rfq_data['registration_json'])) { $policy_registration_data = json_decode($rfq_data['registration_json'], true); } // dd($policy_registration_data); @@ -2960,7 +3187,7 @@ class LeadsController extends BaseController ]); $rowNumber++; - }else{ + } else { $sheet->mergeCells("A{$rowNumber}:B{$rowNumber}"); $sheet->setCellValue("A{$rowNumber}", "Policy Type"); $sheet->setCellValue("C{$rowNumber}", ucfirst($key) . " Policy"); @@ -3148,7 +3375,7 @@ class LeadsController extends BaseController $serial_no = 1; $maxColumnWidths = []; $RowSpanEnable = false; - + // Add table data rows foreach ($column_data as $dataRow) { @@ -3173,11 +3400,11 @@ class LeadsController extends BaseController $sheet->getStyle("{$columnLetter}{$mergeStart}:{$columnLetter}{$mergeEnd}") ->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER); } else { - if(!$hasPolicy && $key == 0){ + if (!$hasPolicy && $key == 0) { $RowSpanEnable = true; $columnLetter++; $sheet->setCellValue("{$columnLetter}{$rowNumber}", $cellData['display_content']); - }else{ + } else { $sheet->setCellValue("{$columnLetter}{$rowNumber}", $cellData['display_content']); } } @@ -3185,13 +3412,12 @@ class LeadsController extends BaseController if (!($key === 0 && !$hasPolicy)) { $columnLetter++; } - } $rowNumber++; $serial_no++; } - if($key == 0 && $RowSpanEnable == true){ + if ($key == 0 && $RowSpanEnable == true) { $columnLetter++; } @@ -3494,7 +3720,7 @@ class LeadsController extends BaseController return null; } - public function transformNonEbProposelData(&$data, $proposal, $insurer, $tableCount=null, $actionColumn = null) + public function transformNonEbProposelData(&$data, $proposal, $insurer, $tableCount = null, $actionColumn = null) { // Kint::dump($data, $proposal, $insurer, $tableCount); @@ -3531,7 +3757,7 @@ class LeadsController extends BaseController // Update the original data's headers $data['table_data']['headers'] = $headerData; - if(!empty($actionColumn)){ + if (!empty($actionColumn)) { $data['table_data']['headers'][] = [ 'parentHeader' => "Action", 'subHeaders' => ['-'] @@ -3563,8 +3789,8 @@ class LeadsController extends BaseController $filteredData[] = $item; } - if(!empty($actionColumn)){ - if($item['parentth'] === "Action"){ + if (!empty($actionColumn)) { + if ($item['parentth'] === "Action") { $filteredData[] = $item; } } @@ -3582,24 +3808,24 @@ class LeadsController extends BaseController return $data; } - public function getPreviousColumn($columnLetter, $decrement = 1) + public function getPreviousColumn($columnLetter, $decrement = 1) { $colIndex = Coordinate::columnIndexFromString($columnLetter); $colIndex = max(1, $colIndex - $decrement); // ensure column index doesn't go below 1 return Coordinate::stringFromColumnIndex($colIndex); } - + public function handleMultiFileAttachments($json_string, $lead_id) - { + { $attachments = []; - + if (!empty($json_string)) { $fileIds = json_decode($json_string, true); $lead_file_path = WRITEPATH . 'uploads/lead_files/'; - + foreach ($fileIds as $id) { $lead_file = $this->leadFilesModel->where('lead_id', $lead_id)->where('id', $id)->where('is_active', 1)->first(); - + if ($lead_file) { $attachments[] = [ 'fileName' => $lead_file['file_name'], @@ -3608,8 +3834,7 @@ class LeadsController extends BaseController } } } - + return $attachments; } - } diff --git a/app/Models/LeadsModel.php b/app/Models/LeadsModel.php index 84e9c9bf..d0d6d0c8 100644 --- a/app/Models/LeadsModel.php +++ b/app/Models/LeadsModel.php @@ -87,6 +87,9 @@ class LeadsModel extends Model 'lead_form_type', 'custom_fields', + + 'source_policy_start_date', + 'source_policy_end_date', ]; diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 566aa5e4..fc2ee0f0 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -162,6 +162,16 @@
+ + + +
- +
-

+
@@ -222,6 +222,7 @@
+
diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php index fd334113..6434057b 100755 --- a/app/Views/client_onboarding.php +++ b/app/Views/client_onboarding.php @@ -88,12 +88,12 @@ body { Policies -
  • Renewal Reports
  • +
  • + TAT Band Reports +
  • From 9e14f7bf9223735966c444d222dbd37ce32d8bc3 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Wed, 30 Apr 2025 14:03:09 +0530 Subject: [PATCH 075/169] FEAT_POLICY_REPORTS,FIX_DASH_BDS SRI --- app/Config/Routes.php | 1 + app/Controllers/BDSReportController.php | 183 +++++++++++++++++++++--- app/Controllers/DashboardController.php | 3 +- app/Models/PolicyTransactionModel.php | 7 +- app/Views/DashBoard.php | 8 +- app/Views/bds_multi_report.php | 122 ++++++++++++++++ app/Views/layout/header.php | 20 +++ 7 files changed, 320 insertions(+), 24 deletions(-) create mode 100644 app/Views/bds_multi_report.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 36b9a672..842adbbc 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -537,6 +537,7 @@ $routes->group("/bdsReport", ["filter" => "authMVC"], function ($routes) { $routes->get('bap_wise_data/(:any)','BDSReportController::Bap_Wise_Data/$1'); $routes->match( ['get', 'post'], 'renewal_report','BDSReportController::renewalReport'); $routes->get('getTATReport','BDSReportController::bdsTATReport'); + $routes->get("getMultiReport/(:any)", "BDSReportController::getMultiReport/$1"); }); //New Tickets diff --git a/app/Controllers/BDSReportController.php b/app/Controllers/BDSReportController.php index f0fbd79a..c3005aac 100644 --- a/app/Controllers/BDSReportController.php +++ b/app/Controllers/BDSReportController.php @@ -33,6 +33,7 @@ class BDSReportController extends AdminController protected $PTCOShareDetailsModel; protected $coShareStmtDetailsModel; protected $policyTypeModel; + protected $policyTatReportType; public function __construct() { @@ -46,6 +47,13 @@ class BDSReportController extends AdminController $this->PTCOShareDetailsModel = new PTCOShareDetailsModel(); $this->coShareStmtDetailsModel = new COShareStmtDetailsModel(); $this->policyTypeModel = new PolicyTypeModel(); + + + $this->policyTatReportType = [ + '1' => "TAT Band Wise report", + '2' => "Account Manger Status Wise Report", + '3' => "Account Manger TAT Wise Report" + ]; } // public function Insurer_wise_Data($insurerCategory, $fromDate, $toDate) @@ -209,7 +217,7 @@ class BDSReportController extends AdminController $html = view('bds_report_bap_wise_data', $viewData); return $this->respond(['status' => true, 'html' => $html], 200); - } else if($report_type == 'bapInsurer'){ + } else if ($report_type == 'bapInsurer') { //Condition for BAP Insurer wise date $category = $category == 'life' ? 1 : 0; @@ -217,8 +225,7 @@ class BDSReportController extends AdminController $html = view('irda_bap_insurer_report_list', $viewData); return $this->respond(['status' => true, 'html' => $html], 200); - - }else if($report_type == 'bapClient'){ + } else if ($report_type == 'bapClient') { //Condition for BAP Client wise date $category = $category == 'life' ? 1 : 0; @@ -226,8 +233,7 @@ class BDSReportController extends AdminController $html = view('irda_bap_client_report_list', $viewData); return $this->respond(['status' => true, 'html' => $html], 200); - - }else if($report_type == 'client'){ + } else if ($report_type == 'client') { //Condition for Client wise date $category = $category == 'life' ? 1 : 0; @@ -517,7 +523,7 @@ class BDSReportController extends AdminController if (!empty($start_date) && !empty($end_date)) { $fromDate = change_date_format($start_date); - $toDate = change_date_format($end_date); + $toDate = change_date_format($end_date); } $this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]); @@ -597,7 +603,7 @@ class BDSReportController extends AdminController // $db = db_connect(); // $builder = $db->query(" - + // select ins.id, ins.name as insurer_name, // -- Health Policies @@ -706,7 +712,7 @@ class BDSReportController extends AdminController // life_premium DESC, // marine_cargo_premium DESC, // marine_hull_premium DESC; - + // "); // // Get the query @@ -745,7 +751,7 @@ class BDSReportController extends AdminController // $db = db_connect(); // $builder = $db->query(" - + // SELECT // c.id AS client_id, // c.client_name, @@ -808,7 +814,7 @@ class BDSReportController extends AdminController // life_premium DESC, // marine_cargo_premium DESC, // marine_hull_premium DESC - + // "); // // Get the query @@ -847,11 +853,11 @@ class BDSReportController extends AdminController // $db = db_connect(); // $builder = $db->query(" - + // select // c.id as client_id, // c.client_name, - + // ( // select // count(policy_transaction.id) @@ -862,7 +868,7 @@ class BDSReportController extends AdminController // and policy_transaction.is_active = 1 // ) as policy_count, - + // COALESCE(( // select // sum(stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt) as premium @@ -873,9 +879,9 @@ class BDSReportController extends AdminController // and stmt.is_active = 1 // and ptco.is_active = 1 // and pt.is_active = 1 - + // ), 0) as premium - + // from clients c // join policy_transaction on c.id = policy_transaction.client_id AND policy_transaction.policy_issue_date >= '$fromDate' AND policy_transaction.policy_issue_date <= '$toDate' // join policy_type on policy_transaction.policy_type_id = policy_type.id and policy_type.policy_category = $category @@ -910,7 +916,6 @@ class BDSReportController extends AdminController $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance']; $data['page_name'] = "Renewal Report"; return $this->loadLayout('renewal_search', $data); - } else { $fromDate = $this->request->getPost('fromDate'); @@ -1001,6 +1006,150 @@ class BDSReportController extends AdminController // dd(db_connect()->getLastQuery(),$result); $data['data'] = $result; // dd($data, get_role_id(), ENROLLMENT_TEAM_ID, user_team()); - return $this->loadLayout('bds_tat_wise_report', $data); + // return $this->loadLayout('bds_tat_wise_report', $data); + + return $result; + } + + public function accountMangerStatusBDSReport() + { + $data['page_name'] = "Account Manager BDS Report"; + + $sql = " + SELECT + COALESCE(ACM_Name, 'Total') AS ACM_Name, + COALESCE(SUM(CASE WHEN status = 'instalment_pending' THEN 1 ELSE 0 END), 0) AS `Instalment Pending`, + COALESCE(SUM(CASE WHEN status = 'under_process' THEN 1 ELSE 0 END), 0) AS `Under Process`, + COALESCE(SUM(CASE WHEN status = 'client_pending' THEN 1 ELSE 0 END), 0) AS `Client Pending`, + COALESCE(SUM(CASE WHEN status = 'co_insurer_pending' THEN 1 ELSE 0 END), 0) AS `Co Insurer Pending`, + COALESCE(SUM(CASE WHEN status = 'tpa_pending' THEN 1 ELSE 0 END), 0) AS `TPA Pending`, + COALESCE(SUM(CASE WHEN status = 'validated' THEN 1 ELSE 0 END), 0) AS `Validated`, + COALESCE(SUM(CASE WHEN status = 'cancelled' THEN 1 ELSE 0 END), 0) AS `Cancelled`, + COALESCE(SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END), 0) AS `Completed`, + COALESCE(SUM(CASE WHEN status = 'lost' THEN 1 ELSE 0 END), 0) AS `Lost`, + COALESCE(SUM(CASE WHEN status = 'insurer_pending' THEN 1 ELSE 0 END), 0) AS `Insurer Pending` + + FROM ( + SELECT + up.first_name AS ACM_Name, + ls.status + FROM policy_transaction pt + JOIN clients c ON pt.client_id = c.id AND c.is_active = 1 + JOIN client_rm crm ON crm.client_id = c.id AND crm.is_active = 1 AND crm.level = 3 + JOIN user_profiles up ON up.id = crm.user_id AND up.is_active = 1 + LEFT JOIN ( + SELECT + pts1.policy_tran_id, + pts1.status, + pts1.created_at + FROM policy_transaction_status pts1 + INNER JOIN ( + SELECT + policy_tran_id, + MAX(created_at) AS max_created_at + FROM policy_transaction_status + WHERE is_active = 1 + GROUP BY policy_tran_id + ) pts2 + ON pts1.policy_tran_id = pts2.policy_tran_id + AND pts1.created_at = pts2.max_created_at + WHERE pts1.is_active = 1 + ) ls ON pt.id = ls.policy_tran_id + WHERE pt.is_active = 1 + AND DATEDIFF(CURDATE(), ls.created_at) >= 4 + ) AS sub + GROUP BY ACM_Name; + "; + + $db = \Config\Database::connect(); + $query = $db->query($sql); + + // Get the result + $result = $query->getResultArray(); + + return $result; + } + + public function accountManagerTatBDSReport(){ + + $sql = " + SELECT + COALESCE(ACM_Name, 'Total') AS ACM_Name, + COALESCE(SUM(CASE WHEN tat_bucket = '0-4 Days' THEN 1 ELSE 0 END), 0) AS `0-4 Days`, + COALESCE(SUM(CASE WHEN tat_bucket = '5-8 Days' THEN 1 ELSE 0 END), 0) AS `5-8 Days`, + COALESCE(SUM(CASE WHEN tat_bucket = '9-12 Days' THEN 1 ELSE 0 END), 0) AS `9-12 Days`, + COALESCE(SUM(CASE WHEN tat_bucket = 'Above 12 Days' THEN 1 ELSE 0 END), 0) AS `Above 12 Days` + FROM ( + SELECT + up.first_name AS ACM_Name, + CASE + WHEN DATEDIFF(CURDATE(), ls.created_at) BETWEEN 0 AND 4 THEN '0-4 Days' + WHEN DATEDIFF(CURDATE(), ls.created_at) BETWEEN 5 AND 8 THEN '5-8 Days' + WHEN DATEDIFF(CURDATE(), ls.created_at) BETWEEN 9 AND 12 THEN '9-12 Days' + WHEN DATEDIFF(CURDATE(), ls.created_at) > 12 THEN 'Above 12 Days' + ELSE 'Unknown' + END AS tat_bucket + FROM policy_transaction pt + JOIN clients c ON pt.client_id = c.id AND c.is_active = 1 + JOIN client_rm crm ON crm.client_id = c.id AND crm.is_active = 1 AND crm.level = 3 + JOIN user_profiles up ON up.id = crm.user_id AND up.is_active = 1 + LEFT JOIN ( + SELECT + pts1.policy_tran_id, + pts1.status, + pts1.created_at + FROM policy_transaction_status pts1 + INNER JOIN ( + SELECT + policy_tran_id, + MAX(created_at) AS max_created_at + FROM policy_transaction_status + WHERE is_active = 1 + GROUP BY policy_tran_id + ) pts2 + ON pts1.policy_tran_id = pts2.policy_tran_id + AND pts1.created_at = pts2.max_created_at + WHERE pts1.is_active = 1 + ) ls ON pt.id = ls.policy_tran_id + WHERE pt.is_active = 1 + AND ls.created_at IS NOT NULL + ) AS sub + GROUP BY ACM_Name; + + "; + + $db = \Config\Database::connect(); + $query = $db->query($sql); + + // Get the result + $result = $query->getResultArray(); + + return $result; + + } + + public function getMultiReport($report_type){ + + $data['page_name'] = "BDS Report"; + + if ($report_type == 1){ + + $data['page_title'] = "BDS TAT Report"; + $data['data'] = $this->bdsTATReport(); + }else if ($report_type == 2){ + + $data['page_title'] = "Account Manager Status Report"; + $data['data'] = $this->accountMangerStatusBDSReport(); + + }else{ + + $data['page_title'] = "Account Manager TAT Report"; + $data['data'] = $this->accountManagerTatBDSReport(); + + } + + return $this->loadLayout('bds_multi_report', $data); + } } + diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index fc154a4b..b9ed11a4 100755 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -238,6 +238,7 @@ class DashboardController extends AdminController // echo "
    ";
                 $data['pendingActionsData'] = $pendingActionsData;
                 $data['businessTeamCount'] = count($businessTeamData) ?? 0;
    +            // dd($businessTeamData);
                 $data['financeTeamCount'] = count($financeTeamData) ?? 0;
                 $data['businessTeamStatusData'] = $businessTeamStatusData;
                 $data['financeTeamStatusData'] = $financeTeamStatusData;
    @@ -257,6 +258,7 @@ class DashboardController extends AdminController
             }
     
             // dd(get_role_id(),user_team());
    +        // dd($data);
             
             $data['page_name'] = 'Dashboard';
     
    @@ -725,7 +727,6 @@ class DashboardController extends AdminController
                 'validated' => [],
                 'cancelled' => [],
                 'instalment_pending' => [],
    -            'completed' => [],
             ];
     
             // Loop through results and group them by their status
    diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php
    index 2e697698..ec355e34 100644
    --- a/app/Models/PolicyTransactionModel.php
    +++ b/app/Models/PolicyTransactionModel.php
    @@ -1335,6 +1335,8 @@ class PolicyTransactionModel extends Model
                 )
                 ->where("th.last_policy_status_change <= '{$dateThreshold}'", null, false)
                 ->where('policy_transaction.is_active', 1)
    +            ->where("policy_transaction.status is not null", null, false)
    +            ->whereNotIn("policy_transaction.status", ['completed'])
                 // ->where('policy_transaction.status', 'completed')
                 ->where('(pt_co_share_details.bp_amt IS NULL OR pt_co_share_details.bp_amt = 0)', null, false);
     
    @@ -1426,8 +1428,9 @@ class PolicyTransactionModel extends Model
                 // ->where('policy_transaction.status', 'completed')
                 ->where('COALESCE(pt_co_share_details.agreed_bp_per, 0) + COALESCE(pt_co_share_details.agreed_tp_per, 0) + COALESCE(pt_co_share_details.agreed_tep_per, 0) = 0')
                 ->where('COALESCE(pt_co_share_details.actual_bp_amt, 0) + COALESCE(pt_co_share_details.actual_tp_amt, 0) + COALESCE(pt_co_share_details.actual_tep_amt, 0) = 0')
    -            ->where('COALESCE(pt_co_share_details.actual_bp_brokerage_amt, 0) + COALESCE(pt_co_share_details.actual_tp_brokerage_amt, 0) + COALESCE(pt_co_share_details.actual_tep_brokerage_amt, 0) = 0');
    -
    +            ->where('COALESCE(pt_co_share_details.actual_bp_brokerage_amt, 0) + COALESCE(pt_co_share_details.actual_tp_brokerage_amt, 0) + COALESCE(pt_co_share_details.actual_tep_brokerage_amt, 0) = 0')
    +            ->where("policy_transaction.status is not null", null, false)
    +            ->whereNotIn("policy_transaction.status", ['completed']);
     
             if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
     
    diff --git a/app/Views/DashBoard.php b/app/Views/DashBoard.php
    index 40d25654..08e08855 100755
    --- a/app/Views/DashBoard.php
    +++ b/app/Views/DashBoard.php
    @@ -259,10 +259,10 @@
                             
                             
                         
    -
    -                    
    -                        
    -                    
    +                    
     
                         
                     
    diff --git a/app/Views/bds_multi_report.php b/app/Views/bds_multi_report.php
    new file mode 100644
    index 00000000..05b38e6c
    --- /dev/null
    +++ b/app/Views/bds_multi_report.php
    @@ -0,0 +1,122 @@
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    +
    +
    + +
    + + + + + + + + + + + + + + $value): + $numValue = is_numeric($value) ? (int) $value : 0; + if ($key != 'TAT_Category') { + $columnTotals[$key] += $numValue; + $rowTotal += $numValue; + } + ?> + + + + + + + + + + $total): ?> + + + + + +
    TOTAL
    +
    + +
    +
    +
    +
    + + diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index a7500816..a30e0d10 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -766,6 +766,26 @@ +
  • + + + Policy TAT Reports + +
    + +
    +
  • From e98b153eb24b7ca34d0fe3e7bfcb8453bb264bf2 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 30 Apr 2025 14:59:31 +0530 Subject: [PATCH 076/169] FIX_LIVE_ISSUE_DOWNLOAD_SAMLE_FILE : RV --- app/Controllers/EmployeeController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 30f012b7..de473c0a 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -434,7 +434,7 @@ class EmployeeController extends AdminController $filePath = ROOTPATH . 'public/sample_excel/sample_correction .xls'; } else if ($actionType == 'si_enhancement') { $filePath = ROOTPATH . 'public/sample_excel/sample_si_enhancement.xls'; - } else if ($actionType == 'dependent_addtion') { + } else if ($actionType == 'dependent_addition') { $filePath = ROOTPATH . 'public/sample_excel/sample_dependent_addition.xls'; } else if ($actionType == 'addition') { $filePath = ROOTPATH . 'public/sample_excel/sample_addition.xls'; From f7fce9f9a21f4c6109d2999f581cae123aff5fd1 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 30 Apr 2025 15:14:29 +0530 Subject: [PATCH 077/169] CHANGE_CHANGES : RV --- app/Config/Routes.php | 4 ++-- app/Controllers/ClientController.php | 12 ++++++++---- app/Views/notification.php | 1 + app/Views/policy_transaction_endorsement_form.php | 3 ++- app/Views/policy_transaction_inception_form.php | 3 ++- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 36b9a672..be1df23e 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -323,8 +323,8 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("test_mail", "MasterController::testGmailAPI"); $routes->post("test_mail", "MasterController::testGmailAPI"); $routes->get("check_policy_no/(:any)", "ClientController::check_policy_no/$1"); - $routes->get("get_client_policy_data_using_policy_no/(:any)", "ClientController::get_client_policy_data_using_policy_no/$1"); - $routes->get("get_client_policy_data_using_policy_no_and_endo_no/(:any)", "ClientController::get_client_policy_data_using_policy_no_and_endo_no/$1"); + $routes->get("get_client_policy_data_using_policy_no", "ClientController::get_client_policy_data_using_policy_no"); + $routes->get("get_client_policy_data_using_policy_no_and_endo_no", "ClientController::get_client_policy_data_using_policy_no_and_endo_no"); $routes->get("checkInvoiceStatus/(:any)", "PolicyTransactionController::checkInvoiceStatus/$1"); $routes->get("base_policy_for_policy_inception/(:any)", "PolicyTransactionController::getBasePolicy/$1"); $routes->get("sentTestMail/(:any)", "NotificationController::sentTestMail/$1"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 4664d543..5fa86502 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -3999,8 +3999,9 @@ class ClientController extends AdminController } } - public function get_client_policy_data_using_policy_no($policy_no) - { + public function get_client_policy_data_using_policy_no() + { + $policy_no = $this->request->getGet('policy_no'); $data = $this->clientPolicyModel ->select(" client_policy.*, @@ -4020,8 +4021,11 @@ class ClientController extends AdminController } } - public function get_client_policy_data_using_policy_no_and_endo_no($policy_no, $endorsement_no) - { + public function get_client_policy_data_using_policy_no_and_endo_no() + { + $policy_no = $this->request->getGet('policy_no'); + $endorsement_no = $this->request->getGet('endorsement_no'); + $data = $this->clientPolicyModel ->select('client_policy.*, endorsement.endorsement_type') ->join('endorsement', 'client_policy.id = endorsement.client_policy_id') diff --git a/app/Views/notification.php b/app/Views/notification.php index 6e1e0cbd..316ebae9 100755 --- a/app/Views/notification.php +++ b/app/Views/notification.php @@ -31,6 +31,7 @@ margin: 1.75rem auto; } +
    diff --git a/app/Views/policy_transaction_endorsement_form.php b/app/Views/policy_transaction_endorsement_form.php index eaa5543a..565f55de 100644 --- a/app/Views/policy_transaction_endorsement_form.php +++ b/app/Views/policy_transaction_endorsement_form.php @@ -848,8 +848,9 @@ $('#endorsement_no').on('change', function(){ if(policy_no && endorsement_no){ $.ajax({ - url: ''+ policy_no + '/' + endorsement_no, + url: '', type: "GET", + data : {policy_no : policy_no, endorsement_no : endorsement_no}, dataType: 'json', success: function (res) { diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index 0469a9d4..a8d31703 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -3721,8 +3721,9 @@ $('#policy_no').change(function(){ if($pt_id == "" && policy_no != ""){ $.ajax({ - url: ''+policy_no, + url: '', type: "GET", + data : { policy_no : policy_no }, dataType: 'json', success: function (res) { From af6d9c28e5d35c5195851ee7f8054ada92e01015 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Fri, 2 May 2025 15:41:23 +0530 Subject: [PATCH 078/169] FIX_EXCEL_WRONG_ROW_ID --- app/Controllers/EmployeeController.php | 2 +- app/Helpers/excel_util_helper.php | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 30f012b7..16b5f591 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -190,7 +190,7 @@ class EmployeeController extends AdminController // print_r($this->request->getPost('upload-action-type')); // die(); // $empServiceController = new EmployeeServiceController(); - // $res = $empServiceController->excelFileFormatValidation(['file_id' => '42']); + // $res = $empServiceController->excelFileDataValidation(['file_id' => '933']); // dd($res); // $empServiceController = new EmployeeServiceController(); diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index 593b2d05..c13ab491 100755 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -566,6 +566,15 @@ if (!function_exists('check_dependent_conflict')) $allowed_parents_count = $temp['either-parents-pil'] == 0 ? $temp['parents'] : 0; $allowed_parent_in_laws_count = $temp['either-parents-pil'] == 0 ? $temp['parents-in-law'] : 0; // dd($allowed_adults == 0); + $firstNonTemp = null; + + foreach ($family_data as $family) { + if (!isset($family['temp'])) { + $firstNonTemp = $family; + break; + } + } + // Kint::dump($firstNonTemp); foreach ($family_data as $key => $row) { // dd($family_data[0][0]); @@ -580,7 +589,7 @@ if (!function_exists('check_dependent_conflict')) if($relationship == 'self') { $self_gender = $row[4]; - $self_emp_row_id = $row[0]; + $self_emp_row_id = isset($row['temp']) ? null : $row[0]; } if($relationship == 'spouse') { @@ -612,8 +621,9 @@ if (!function_exists('check_dependent_conflict')) $repeated_count = array_intersect($repeated_relationships_count,$temp_counts); if(is_array($repeated_count) && count($repeated_count)) { + // Kint::dump($firstNonTemp);die(); $result['status'] = false; - $result['error_data'][] = ['code' => 13,'col_name' => 'relationship','msg' => 'Rule conflict: Twofold relationship found within family','row_id' => $family_data[0][0]]; + $result['error_data'][] = ['code' => 13,'col_name' => 'relationship','msg' => 'Rule conflict: Twofold relationship found within family','row_id' => $firstNonTemp[0]]; } } // print_r($repeated_count); @@ -630,26 +640,26 @@ if (!function_exists('check_dependent_conflict')) if($self_gender && $spouse_gender && $self_gender == $spouse_gender) { $result['status'] = false; - $result['error_data'][] = ['code' => 4,'col_name' => 'gender','msg' => 'Rule conflict: Self and Spouse cannot be same gender','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])]; + $result['error_data'][] = ['code' => 4,'col_name' => 'gender','msg' => 'Rule conflict: Self and Spouse cannot be same gender','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $firstNonTemp[0])]; } } if(($allowed_spouse_count < $received_spouse_count) || ($allowed_child_count < $received_child_count) ) { $result['status'] = false; - $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch + $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $firstNonTemp[0])];//dependent count mismatch } // || ($allowed_parents_count < $received_parents_count) || ($allowed_parent_in_laws_count < $received_parent_in_laws_count) if($allowed_adults == 1 && $received_parents_count && $received_parent_in_laws_count ) { $result['status'] = false; - $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: Parents and Parents in law both not allowed','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])]; + $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: Parents and Parents in law both not allowed','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $firstNonTemp[0])]; if((2 < $received_parents_count) || (2 < $received_parent_in_laws_count)) { $result['status'] = false; - $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch + $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $firstNonTemp[0])];//dependent count mismatch } } //check for any cross parents but not more than two @@ -657,7 +667,7 @@ if (!function_exists('check_dependent_conflict')) { // dd($allowed_adults); $result['status'] = false; - $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict:As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch + $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict:As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $firstNonTemp[0])];//dependent count mismatch } From d76e999c93b98d25dc165ef3fdb32b3ab0951e63 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Sat, 3 May 2025 17:35:15 +0530 Subject: [PATCH 079/169] FIX_DEPENDENT_ADD_ERROR --- app/Controllers/EmployeeServiceController.php | 16 +++- app/Controllers/LeadsController.php | 1 + app/Helpers/excel_util_helper.php | 28 ++++++- app/Views/leads_non_eb.php | 34 ++++---- app/Views/policyRegisterModel.php | 81 +++++++++++++------ app/Views/rfq/burglary.php | 28 +++++++ app/Views/rfq/money.php | 4 +- app/Views/view_rfq_non_eb.php | 42 +++++----- 8 files changed, 161 insertions(+), 73 deletions(-) create mode 100644 app/Views/rfq/burglary.php diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 035fbd37..9917796f 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -1035,6 +1035,14 @@ class EmployeeServiceController extends AdminController // kint::dump($family); $family = data_group_by_family($family)[ $emp_id ];// reason to call this again bring self to first index of the array } + $firstNonTemp = null; + + foreach ($family as $fam) { + if (!isset($fam['temp'])) { + $firstNonTemp = $fam; + break; + } + } // kint::dump($family);//die(); //check name dup within a family @@ -1070,7 +1078,7 @@ class EmployeeServiceController extends AdminController if(!count($self_details)) { array_push($result['error_summary'],14); // Self not found - $result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found in Database"; + $result['error_data'][ $firstNonTemp[0] ]['sno']['error'][] = "Self not found in Database"; } } @@ -1078,7 +1086,7 @@ class EmployeeServiceController extends AdminController if($file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'inception'|| $file['action'] == 'missed_inception' || $file['action'] == 'enrollment') { $res = check_dependent_conflict($family,$policy_terms,$file['action'],$is_lgbtq); - // dd($res); + // Kint::dump($res); if(!$res['status']) { foreach($res['error_data'] as $key => $value) @@ -1091,7 +1099,7 @@ class EmployeeServiceController extends AdminController //check dup with empid and name with db $res = name_and_empid_check_in_db($family,$file); - // dd($res); + // Kint::dump($res['del']); // echo '
    '; // print_r($res); if(count($res['del'])) @@ -1113,7 +1121,7 @@ class EmployeeServiceController extends AdminController }// end of foreach }// end of if current action I,DA,A - // return $result; + // return $result; // die(); if(isset($result['error_summary']) && count($result['error_summary'])) { diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 79ca3591..3e430d76 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -3077,6 +3077,7 @@ class LeadsController extends BaseController 3 => 'rfq/gmc', 4 => 'rfq/gmc', 5 => 'rfq/gmc', + 17=> 'rfq/burglary', 22 => 'rfq/car', 23 => 'rfq/cpm', 24 => 'rfq/cyber_crime', diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index c13ab491..d2e30828 100755 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -440,8 +440,20 @@ if (!function_exists('name_dup_check_within_family')) foreach ($family_data as $rkey => $row) { if(in_array($row[2],$temp)) - { - array_push($result,$row[0]); + { + // Kint::dump($row); + $emp_code = $row[1]; + $tempFam = null; + foreach ($family_data as $family) { + if ($family[1] == $emp_code &&!isset($family['temp'])) { + $tempFam = $family; + break; // Stop at the first match + } + } + // Kint::dump($tempFam); + // die(); + + array_push($result,$tempFam[0]); } else { @@ -449,7 +461,7 @@ if (!function_exists('name_dup_check_within_family')) } } - + // dd($result); return $result; } } @@ -519,7 +531,15 @@ if (!function_exists('name_and_empid_check_in_db')) } if(($current_action == 'inception' || $current_action == 'dependent_addition' || $current_action == 'addition' || $current_action == 'enrollment') && count($res)) { - array_push($result['i'],$row[0]); + $emp_code = $row[1]; + $tempFam = null; + foreach ($family_data as $family) { + if ($family[1] == $emp_code &&!isset($family['temp'])) { + $tempFam = $family; + break; // Stop at the first match + } + } + array_push($result['i'],$tempFam[0]); } } diff --git a/app/Views/leads_non_eb.php b/app/Views/leads_non_eb.php index fef3f394..ea8761d4 100644 --- a/app/Views/leads_non_eb.php +++ b/app/Views/leads_non_eb.php @@ -242,33 +242,33 @@ hr.solid {
    -
    + + -
    +
    diff --git a/app/Views/policyRegisterModel.php b/app/Views/policyRegisterModel.php index 4e2419d9..4eb2c08f 100644 --- a/app/Views/policyRegisterModel.php +++ b/app/Views/policyRegisterModel.php @@ -166,7 +166,21 @@ + + + + + + + + + + + + + +
    @@ -358,7 +372,7 @@ $("#policyRiskSplitUpForm").submit(function(event) { event.preventDefault(); - + var isValid = $('#policyRiskSplitUpForm').parsley().validate(); // console.log('isValid', isValid); @@ -403,25 +417,25 @@ let rawMaterial = [...document.querySelectorAll('[id^="rawMaterial_"]')].map(el => Number(el.value) || 0); let findMaterial = [...document.querySelectorAll('[id^="finishedStock_"]')].map(el => Number(el.value) || 0); - totalSI = InProcess.reduce((acc, val) => acc + val, 0) + - rawMaterial.reduce((acc, val) => acc + val, 0) + - findMaterial.reduce((acc, val) => acc + val, 0); + totalSI = InProcess.reduce((acc, val) => acc + val, 0) + + rawMaterial.reduce((acc, val) => acc + val, 0) + + findMaterial.reduce((acc, val) => acc + val, 0); let allowedSI = Number($("#policySI").val()) || 0; - if (totalSI > allowedSI) { + if (totalSI != allowedSI) { toastr.error("Sum Insured Exceeds Allowed Limit", "ERROR"); - return false; + return false; } // console.log("Total SI: ", totalSI); - }else{ + } else { let InProcess = [...document.querySelectorAll('[id^="stockInProcess_"]')].map(el => Number(el.value) || 0); let rawMaterial = [...document.querySelectorAll('[id^="rawMaterial_"]')].map(el => Number(el.value) || 0); let findMaterial = [...document.querySelectorAll('[id^="finishedStock_"]')].map(el => Number(el.value) || 0); - totalSI = InProcess.reduce((acc, val) => acc + val, 0) + - rawMaterial.reduce((acc, val) => acc + val, 0) + - findMaterial.reduce((acc, val) => acc + val, 0); + totalSI = InProcess.reduce((acc, val) => acc + val, 0) + + rawMaterial.reduce((acc, val) => acc + val, 0) + + findMaterial.reduce((acc, val) => acc + val, 0); } } @@ -465,6 +479,7 @@ // console.log("Grouped Data as Objects: ", policyRiskSplitUpData); savePolicyDataLocal(); + }); @@ -678,7 +693,7 @@
    - +
    @@ -790,11 +805,11 @@
    - +
    - + > + +
    +
    + > + +
    +
    + > + +
    + + + +
    + + +
    + + diff --git a/app/Views/rfq/money.php b/app/Views/rfq/money.php index bf8c1bca..e010d772 100644 --- a/app/Views/rfq/money.php +++ b/app/Views/rfq/money.php @@ -2,7 +2,7 @@
    -
    +
    diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index 364f2d34..fc6193a6 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -536,7 +536,7 @@ // alert(rollover_or_renewal); var policyConfig = { - 1: ['Quote asked'] + 1: ['Sum Insured'] }; let myModal; @@ -634,7 +634,7 @@ let proposalCount = 1; // // console.log("Proposal count changed", proposalCount); let quotesConfig = { - 1: ['Quote asked'] + 1: ['Sum Insured'] }; // Stores quote columns for each proposal @@ -1002,8 +1002,8 @@ proposalCount++; // // console.log("proposal count after ", proposalCount); - quotesConfig[proposalCount] = ['Quote asked']; - policyConfig[proposalCount] = ['Quote asked']; + quotesConfig[proposalCount] = ['Sum Insured']; + policyConfig[proposalCount] = ['Sum Insured']; const tables = document.querySelectorAll('table'); let increaseBy = 150; increaseTableWidth(increaseBy); @@ -1037,7 +1037,7 @@ // Add new quote sub-header const newQuoteHeader = document.createElement('th'); - newQuoteHeader.textContent = 'Quote asked'; + newQuoteHeader.textContent = 'Sum Insured'; newQuoteHeader.style.backgroundColor = randomColor; headerRow2.insertBefore(newQuoteHeader, headerRow2.querySelector('th:last-child')); @@ -1593,7 +1593,7 @@ - ${Object.entries(quotesConfig).flatMap(([proposal, codes]) => codes.map(code => ` - + ${code} - - + + + +
    @@ -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 From fcb650288acb2d8e3736ca95221021eceafc3ce3 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Wed, 7 May 2025 12:35:25 +0530 Subject: [PATCH 082/169] FIX_DROPDOWN_WIDTH_NONEB_SRI --- app/Views/policyRegisterModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Views/policyRegisterModel.php b/app/Views/policyRegisterModel.php index fc5170e3..f9b1ee91 100644 --- a/app/Views/policyRegisterModel.php +++ b/app/Views/policyRegisterModel.php @@ -858,7 +858,7 @@
    -
    +
    > - +
    Date: Wed, 7 May 2025 17:12:35 +0530 Subject: [PATCH 084/169] FIX_MIXED_INCEPTION : RV --- app/Controllers/EmpDataServiceController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index d13676aa..19d57a7d 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -949,6 +949,9 @@ class EmpDataServiceController extends BaseController $export_data['event_type'] = 'correction'; $correctionData = $this->employeePolicyModel->getCorrectionEmployeesDataForExportExcel($export_data); + }else if($value == "missed_inception"){ + $export_data['event_type'] = 'missed_inception'; + $additionData = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($export_data); } } From df5dce214ecc605c5b3eebc511ddb63eb9518f3e Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 8 May 2025 10:02:49 +0530 Subject: [PATCH 085/169] CHANGE_RFQ_CR : RV --- app/Config/Routes.php | 1 + app/Controllers/LeadsController.php | 263 +++++++--- app/Models/LeadInstallmentPaymentDetails.php | 54 +++ app/Models/LeadsModel.php | 5 +- app/Views/leads_dash.php | 322 +++++++------ app/Views/rfq/installment_fields.php | 35 ++ app/Views/view_rfq.php | 481 ++++++++++++------- 7 files changed, 768 insertions(+), 393 deletions(-) create mode 100644 app/Models/LeadInstallmentPaymentDetails.php create mode 100644 app/Views/rfq/installment_fields.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 0670bca5..9c1b388e 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -357,6 +357,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get('getLeadNonEB/(:any)', 'LeadsController::getLeadNonEB/$1'); $routes->get('getPolicyTypeFields', 'LeadsController::getPolicyTypeFields'); $routes->get('removeMultiFile', 'LeadsController::removeMultiFile'); + $routes->get('removeInstallments', 'LeadsController::removeInstallments'); }); $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 79ca3591..bcc0bc47 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -30,6 +30,7 @@ use App\Models\RFQModel; use App\Models\InsurerModel; use App\Models\OccupancyMasterModel; use App\Models\LeadFilesModel; +use App\Models\LeadInstallmentPaymentDetails; use App\Helpers\MailHelper; use App\Helpers\ExcelMergeHelper; @@ -65,6 +66,7 @@ class LeadsController extends BaseController protected $insurerModel; protected $occupancyModel; protected $leadFilesModel; + protected $leadInstallmentPaymentDetails; //variables for storing array protected $issuer; @@ -96,20 +98,26 @@ class LeadsController extends BaseController $this->insurerModel = new InsurerModel(); $this->occupancyModel = new OccupancyMasterModel(); $this->leadFilesModel = new LeadFilesModel(); + $this->leadInstallmentPaymentDetails = new LeadInstallmentPaymentDetails(); $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']; + $this->leadsStatus = [ - 'queued' => 'In-Queued', - 'qcr_sent' => 'QCR sent', - 'lost' => 'Lost', - 'co_insurer_pending' => 'Co-Insurer Pending', - 'won' => 'Won', - 'completed_with_corrections' => 'Completed with Corrections', - 'completed_without_corrections' => 'Completed w/o Corrections', + 'queued' => 'In-Queued', + 'rfq_created' => 'RFQ Created', + 'rfq_sent' => 'RFQ Sent', + 'qcr_created' => 'QCR Created', + 'qcr_sent' => 'QCR Sent', + 'lost' => 'Lost', + 'co_insurer_pending' => 'Co-Insurer Pending', + 'won' => 'Won', + 'completed_with_corrections' => 'Completed with Corrections', + 'completed_without_corrections' => 'Completed without Corrections', ]; + $this->claim_type_for_gpa = [ 'accident_death' => 'Accident Death', 'permanent_total_disablement' => 'Permanent Total Disablement', @@ -592,12 +600,14 @@ class LeadsController extends BaseController $this->leadFilesModel->where('id', $value['id'])->set($lead_file_data)->update(); } else { - $lead_file_data = [ - 'lead_id' => $lead_id, - 'docs_name' => $value['docs_name'], - 'file_name' => $value['file_name'], - ]; - $this->leadFilesModel->insert($lead_file_data); + if (!empty($value['file_name'])) { + $lead_file_data = [ + 'lead_id' => $lead_id, + 'docs_name' => $value['docs_name'], + 'file_name' => $value['file_name'], + ]; + $this->leadFilesModel->insert($lead_file_data); + } } if ($key == 0 && !empty($value['file_name'])) { @@ -619,6 +629,8 @@ class LeadsController extends BaseController return $this->respond(['status' => false, 'message' => 'File could not be removed.'], 200); } } + + //--------RFQ----------------------------------------------------------------------------------------------- @@ -676,7 +688,7 @@ class LeadsController extends BaseController $data['exclusiveUserList'] = $this->userModel->getexclusiveUserListForRFQ(); $data['lead_data'] = $lead_data; - $mail_content = " + $mail_content = '

    Dear Sir,

    Greetings From Nhance India!

    Please find attached the {{RFQ_OR_QCR}} for {{POLICY_TYPE}} policy pertaining to {{CLIENT_NAME}}.

    @@ -687,13 +699,11 @@ class LeadsController extends BaseController
    {{LOGGED_USER_NAME}}
    -
    Email: {{LOGGED_USER_EMAIL}}
    Mobile: {{LOGGED_USER_MOBILE}}
    - - - "; + Nhance Logo + '; if ($data['lead_data']['policy_end_date'] != null) { $subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}} {{POLICY_END_DATE}}"; @@ -705,6 +715,8 @@ class LeadsController extends BaseController $data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']); $data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null; + $installment_data['installments'] = $this->leadInstallmentPaymentDetails->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null; + $data['lead_data']['installment_data'] = view('rfq/installment_fields', $installment_data) ?? null; $data['attachment_html'] = view('rfq/attachment_files', $data) ?? ""; $data['user_team'] = $this->userModel->select("ut.team_id")->join("user_teams ut", "ut.user_id = user_profiles.id and ut.is_active = 1")->where("user_profiles.is_active", 1)->first()['team_id']; // dd($data); @@ -776,10 +788,13 @@ class LeadsController extends BaseController return $this->respond(['status' => false, 'message' => 'Lead ID is required'], 400); } + $rfq_created = $this->RFQModel->where('lead_id', $lead_id)->where('is_active', 1)->countAllResults(); + $qcr_created = false; $inputJson = json_decode($data['json'], true); if (isset($inputJson['premium_data']) && !empty($inputJson['premium_data'])) { $sortedJson = $this->reorderProposalsByInsurerTotal($inputJson); $data['json'] = json_encode($sortedJson); + $qcr_created = true; } @@ -821,6 +836,19 @@ class LeadsController extends BaseController } if ($insertId) { + + if(empty($rfq_created)){ + $this->leadsModel->update($lead_id, ['status' => "rfq_created"]); + } + + if($qcr_created == true){ + $this->leadsModel + ->where('id', $lead_id) + ->whereNotIn('status', ['qcr_sent', 'lost', 'co_insurer_pending', 'won', 'completed_with_corrections', 'completed_without_corrections']) + ->set(['status' => "qcr_created"]) + ->update(); + } + $message = ($data['submit_type'] ?? '') == 'QCR' ? 'QCR saved successfully' : 'RFQ saved successfully'; return $this->respond([ 'status' => true, @@ -1063,6 +1091,17 @@ class LeadsController extends BaseController return $result; } + public function removeInstallments() + { + $id = $this->request->getGet('id'); + // print_r($id); die; + if (!empty($id)) { + $this->leadInstallmentPaymentDetails->whereIn('id', $id)->set(['is_active' => 0])->update(); + return $this->respond(['status' => true, 'message' => 'Removed successfully'], 200); + } else { + return $this->respond(['status' => false, 'message' => 'Could not be removed.'], 200); + } + } //-----RFQ and QCR EXPORT------------------------------------------------------------------------------------------------ @@ -1139,36 +1178,32 @@ class LeadsController extends BaseController if ($rfq_data['policy_type_id'] == 2) { $lead_data = [ - 'policy_end_date' => $rfq_data['policy_end_date'], 'Insured' => $rfq_data['client_name'], - 'Policy Status' => $rfq_data['status'], + 'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "", 'No of Employees' => $rfq_data['incept_emp_count'], 'No of Dependents' => $rfq_data['incept_dept_count'], 'Total Lives' => $rfq_data['incept_no_of_lives'], - 'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])), + '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", 'Policy Run Days' => $rfq_data['policy_run_days'], ]; } else if ($rfq_data['policy_type_id'] == 1) { $lead_data = [ - 'policy_end_date' => $rfq_data['policy_end_date'], 'Insured' => $rfq_data['client_name'], 'No of Employees at Inception' => $rfq_data['incept_emp_count'], 'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'], - 'Policy Period' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])), - 'Policy Status' => $rfq_data['status'], - 'Existing Insurer' => $rfq_data['insurer_name'], - 'TPA ' => $rfq_data['tpa_name'], + 'Policy Period' => !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", + 'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "", ]; } + } else { if ($rfq_data['policy_type_id'] == 2) { $lead_data = [ - 'policy_end_date' => $rfq_data['policy_end_date'], 'Insured' => $rfq_data['client_name'], - 'Policy Status' => $rfq_data['status'], + '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'], @@ -1182,7 +1217,7 @@ class LeadsController extends BaseController 'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'], 'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'], - 'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])), + '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", 'Policy Run Days' => $rfq_data['policy_run_days'], 'Inception Premium' => $rfq_data['premium_at_inception'], 'Premium as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['premium_date'], @@ -1194,12 +1229,11 @@ class LeadsController extends BaseController ]; } else if ($rfq_data['policy_type_id'] == 1) { $lead_data = [ - 'policy_end_date' => $rfq_data['policy_end_date'], 'Insured' => $rfq_data['client_name'], 'No of Employees at Renewal' => $rfq_data['renewal_emp_count'], 'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'], - 'Policy Period' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])), - 'Policy Status' => $rfq_data['status'], + 'Policy Period' => !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", + 'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "", 'Existing Insurer' => $rfq_data['insurer_name'], 'TPA ' => $rfq_data['tpa_name'], ]; @@ -1209,13 +1243,16 @@ class LeadsController extends BaseController $data = json_decode($rfq_data['json'], true); // dd($data); + $sheetName = 'Worksheet'; if ($type == 2) { + $sheetName = 'QCR'; $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); } } else if ($type == 1) { + $sheetName = 'RFQ'; $data = $this->convertJsonForQCR($data, $type); // dd($data); } @@ -1223,6 +1260,7 @@ class LeadsController extends BaseController $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); + $sheet->setTitle($sheetName); // Start with lead_data at the top @@ -1242,22 +1280,6 @@ class LeadsController extends BaseController ], ]); - // Set column width to fit the image properly - $sheet->getColumnDimension('C')->setWidth(20); // Adjust as needed - $sheet->getRowDimension($rowNumber)->setRowHeight(40); // Adjust as needed - - $drawing = new Drawing(); - $path = ROOTPATH . "public/assets/images/Nhance-Logo-Final.png"; // Use FCPATH for server path - $drawing->setPath($path); - $drawing->setCoordinates("C{$rowNumber}"); // Set position in column B - $drawing->setHeight(35); // Adjust image height - - // Center align the image in the cell - $drawing->setOffsetX(30); // Adjust horizontal offset - $drawing->setOffsetY(5); // Adjust vertical offset - - $drawing->setWorksheet($sheet); - // Apply center alignment to the cell $sheet->getStyle("C{$rowNumber}")->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); $sheet->getStyle("C{$rowNumber}")->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER); @@ -1304,11 +1326,10 @@ class LeadsController extends BaseController $rowNumber++; } - // Set column width based on max content length (adjusted for padding) + // // Set column width based on max content length (adjusted for padding) $sheet->getColumnDimension('A')->setWidth($maxWidthA * 1.2); $sheet->getColumnDimension('B')->setWidth($maxWidthA * 5); - $sheet->getColumnDimension('C')->setWidth($maxWidthB * 1.2); - // $sheet->getColumnDimension('D')->setWidth($maxWidthB * 1.2); + $sheet->getColumnDimension('C')->setWidth($maxWidthB * 1.6); // $rowNumber += 2; @@ -1350,9 +1371,13 @@ class LeadsController extends BaseController ]); $sheet->mergeCells($mergeRange); + $rowNumber_for_remove_quote_asked = $rowNumber; $rowNumber = $rowNumber + 1; - - $subHeaderRow = $rowNumber + 1; + if($type == 2){ + $subHeaderRow = $rowNumber + 1; + }else{ + $subHeaderRow = $rowNumber_for_remove_quote_asked; + } $columnLetter = 'A'; foreach ($headers as $header) { @@ -1393,9 +1418,12 @@ class LeadsController extends BaseController // Add subheaders foreach ($header['subHeaders'] as $subHeader) { - $sheet->setCellValue("{$columnLetter}{$subHeaderRow}", $subHeader); - if ($columnLetter != "A" && $columnLetter != "B" && $columnLetter != "C" && $columnLetter != "D") { + if($type == 2){ + $sheet->setCellValue("{$columnLetter}{$subHeaderRow}", $subHeader); + } + + if ($columnLetter != "A" && $columnLetter != "B" && $columnLetter != "C") { $sheet->getColumnDimension($columnLetter)->setWidth(35); } else { $sheet->getColumnDimension('A')->setWidth(10); @@ -1514,6 +1542,51 @@ class LeadsController extends BaseController ]); } + + //set imgage and align the row and column + // Kint::dump($columnLetter); + if($type == 2){ + $columnLetter_img = $this->getPreviousColumn($columnLetter, 2); + }else{ + $columnLetter_img = $this->getPreviousColumn($columnLetter); + } + // dd($columnLetter_img); + + $company_name = $this->getPreviousColumn($columnLetter_img); + $mergeRange1 = "A1:{$company_name}1"; + $sheet->mergeCells($mergeRange1); + + $rowCount = count($lead_data); + for ($i = 2; $i <= $rowCount + 1; $i++) { + $mergeRange1 = "C{$i}:{$columnLetter_img}{$i}"; + $sheet->mergeCells($mergeRange1); + $sheet->getStyle($mergeRange1)->applyFromArray([ + 'borders' => [ + 'allBorders' => [ + 'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, + 'color' => ['argb' => 'FF000000'], // Black color + ], + ], + ]); + } + + $sheet->getColumnDimension($columnLetter_img)->setWidth(40); + $sheet->getRowDimension(1)->setRowHeight(40); // Adjust as needed + + $drawing = new Drawing(); + $path = ROOTPATH . "public/assets/images/Nhance-Logo-Final.png"; // Use FCPATH for server path + $drawing->setPath($path); + $drawing->setCoordinates("{$columnLetter_img}1"); // Set position in column B + $drawing->setHeight(35); // Adjust image height + + // Center align the image in the cell + $drawing->setOffsetX(110); // Adjust horizontal offset + $drawing->setOffsetY(10); // Adjust vertical offset + $drawing->setWorksheet($sheet); + + //end + + // Auto-size columns // foreach ($sheet->getColumnIterator() as $column) { // $sheet->getColumnDimension($column->getColumnIndex())->setAutoSize(true); @@ -1551,7 +1624,7 @@ class LeadsController extends BaseController } $lastRow = count($lead_data) + 1; - $leadRange = "A1:C{$lastRow}"; + $leadRange = "A1:{$columnLetter_img}{$lastRow}"; $sheet->getStyle($leadRange)->applyFromArray([ 'borders' => [ @@ -1571,12 +1644,12 @@ class LeadsController extends BaseController $policy_year = "$current_year-$next_year"; if (!empty($rfq_data['policy_end_date'])) { - $policy_expiry = strtotime($lead_data['policy_end_date']); + $policy_expiry = strtotime($rfq_data['policy_end_date']); $formatted_policy = date("d-m-Y", $policy_expiry); - $filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" . $policy_year . '(Due On ' . $formatted_policy . ')' . '.xlsx'; } else { + $filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" . $policy_year . '_' . '.xlsx'; } @@ -2081,11 +2154,12 @@ class LeadsController extends BaseController $bcc_mails = []; //get CC Mails - if ($recipient_type == 'internal' || $recipient_type == 'placement' || $recipient_type == 'insurer' || $recipient_type == 'client') { + if ($recipient_type == 'internal' || $recipient_type == 'insurer' || $recipient_type == 'client') { $cc_data = isset($params['cc']) ? $params['cc'] : ""; $param_cc_mail = json_decode($cc_data, true); + if (isset($param_cc_mail) && is_array($param_cc_mail) && count($param_cc_mail) > 0) { // Fetch user data where ID is in the param_cc_mail array $userData = $this->userModel @@ -2109,6 +2183,8 @@ class LeadsController extends BaseController // Handle case where param_cc_mail is not valid // return $this->respond(['status' => 'failed','code' => 400,'data' => '','message' => 'CC mail not found!'], 200); } + }else if($recipient_type == 'placement'){ + $cc_mails = isset($params['cc']) ? json_decode($params['cc'], true) : ""; } //get BCC Mails @@ -2176,6 +2252,7 @@ class LeadsController extends BaseController $result = $file_info['filePath']; // return $this->respond(['status' => 'fail', 'code' => 200, 'messgae' => 'File Not Found'], 200); } + // print_rr($result); die; // print_rr($file_info); // $file_path = WRITEPATH."uploads/excel/sample/correction.xls"; @@ -2194,15 +2271,11 @@ class LeadsController extends BaseController //get recipient address if ($recipient_type == 'insurer' || $recipient_type == 'placement') { - // print_r($recipient_mail); die; - $recipient_data = $this->levelContactModel ->where(['contact_type' => 'insurer', 'is_active' => 1]) ->whereIn('id', $recipient_mail) ->findAll(); - // print_r($recipient_data); die; - } else if ($recipient_type == 'client') { $mailIDS = explode(',', $params['contact_mail']); @@ -2266,14 +2339,50 @@ class LeadsController extends BaseController 'status' => 'won', 'placement_date' => change_date_format($params['placement_date'], 'd/m/Y', 'Y-m-d'), 'payment_date' => change_date_format($params['payment_date'], 'd/m/Y', 'Y-m-d'), - 'utr_no' => $params['utr_no'], - 'is_cd' => $params['is_cd'], - 'premium_amount' => $params['premium_amount'], - 'total_amount' => $params['total_amount'], - 'cd_amount' => $params['cd_amount'], + 'utr_no' => $params['utr_no'] ?? null, + 'is_cd' => $params['is_cd'] ?? null , + 'premium_amount' => $params['premium_amount'] ?? null, + 'total_amount' => $params['total_amount'] ?? null, + 'cd_amount' => $params['cd_amount'] ?? null, + 'no_of_installment' => $params['no_of_installment'] ?? null, + 'is_installment' => $params['is_installment'] ?? null, ]; $this->leadsModel->where('id', $lead_id)->set($data)->update(); + + if(isset($params['installments']) && !empty($params['installments'])){ + + $installment_data = json_decode($params['installments'], true); + if(!empty($installment_data)){ + foreach ($installment_data as $key => $value) { + $value['payment_date'] = date('Y/m/d', strtotime($value['payment_date'])) ?? null; + if(isset($value['id']) && !empty($value['id'])){ + $this->leadInstallmentPaymentDetails->where('id', $value['id'])->set($value)->update(); + }else{ + $this->leadInstallmentPaymentDetails->insert($value); + } + } + } + } + + } + + if ($recipient_type == 'client') { + + $this->leadsModel + ->where('id', $lead_id) + ->whereNotIn('status', ['lost', 'co_insurer_pending', 'won', 'completed_with_corrections', 'completed_without_corrections']) + ->set(['status' => "qcr_sent"]) + ->update(); + } + + if ($recipient_type == 'insurer') { + + $this->leadsModel + ->where('id', $lead_id) + ->whereNotIn('status', ['qcr_created', 'qcr_sent', 'lost', 'co_insurer_pending', 'won', 'completed_with_corrections', 'completed_without_corrections']) + ->set(['status' => "rfq_sent"]) + ->update(); } //delete attachment file @@ -2913,6 +3022,10 @@ class LeadsController extends BaseController $current_year = date('Y'); $next_year = $current_year + 1; $policy_year = "$current_year-$next_year"; + $page_name = $page_name == "QCR" ? "Quote Comparison Report" : $page_name; + $log_path = base_url() . '/public/assets/images/Nhance-Logo-Final.png'; + // $log_path ='https://venbait.in/nhance/dev/public/assets/images/Nhance-Logo-Final.png'; + // dd($log_path); $policy_expiry = strtotime($lead_data['policy_end_date']); @@ -2935,6 +3048,7 @@ class LeadsController extends BaseController $message = str_replace("{{LOGGED_USER_NAME}}", ucfirst($logged_user_data['first_name']) . " " . ucfirst($logged_user_data['last_name']), $message); $message = str_replace("{{LOGGED_USER_EMAIL}}", $logged_user_data['email'], $message); $message = str_replace("{{LOGGED_USER_MOBILE}}", $logged_user_data['mobile'], $message); + $message = str_replace("{{LOGO_PATH}}", $log_path, $message); return $message; } else { @@ -3898,10 +4012,15 @@ class LeadsController extends BaseController $lead_file = $this->leadFilesModel->where('lead_id', $lead_id)->where('id', $id)->where('is_active', 1)->first(); if ($lead_file) { - $attachments[] = [ - 'fileName' => $lead_file['file_name'], - 'filePath' => $lead_file_path . $lead_file['file_name'] - ]; + + $fullPath = $lead_file_path . $lead_file['file_name']; + + if (file_exists($fullPath) && !empty($fileName)) { + $attachments[] = [ + 'fileName' => $lead_file['file_name'], + 'filePath' => $fullPath + ]; + } } } } diff --git a/app/Models/LeadInstallmentPaymentDetails.php b/app/Models/LeadInstallmentPaymentDetails.php new file mode 100644 index 00000000..53657d03 --- /dev/null +++ b/app/Models/LeadInstallmentPaymentDetails.php @@ -0,0 +1,54 @@ + + body { + margin-top: 20px; + background: #FAFAFA; + } -body{ - margin-top:20px; - background:#FAFAFA; -} -.order-card { - color: #fff; -} + .order-card { + color: #fff; + } -.bg-c-blue { - background: linear-gradient(45deg,#4099ff,#73b4ff); -} + .bg-c-blue { + background: linear-gradient(45deg, #4099ff, #73b4ff); + } -.bg-c-green { - background: linear-gradient(45deg,#2ed8b6,#59e0c5); -} + .bg-c-green { + background: linear-gradient(45deg, #2ed8b6, #59e0c5); + } -.bg-c-yellow { - background: linear-gradient(45deg,#FFB64D,#ffcb80); -} + .bg-c-yellow { + background: linear-gradient(45deg, #FFB64D, #ffcb80); + } -.bg-c-pink { - background: linear-gradient(45deg,#FF5370,#ff869a); -} + .bg-c-pink { + background: linear-gradient(45deg, #FF5370, #ff869a); + } -.bg-c-red { - background: linear-gradient(45deg,#FF4E50,#F9D423); -} + .bg-c-red { + background: linear-gradient(45deg, #FF4E50, #F9D423); + } -.bg-c-purple { - background: linear-gradient(45deg,#9D50BB,#6E48AA); -} + .bg-c-purple { + background: linear-gradient(45deg, #9D50BB, #6E48AA); + } -.bg-c-orange { - background: linear-gradient(45deg,#F2994A,#F2C94C); -} + .bg-c-orange { + background: linear-gradient(45deg, #F2994A, #F2C94C); + } -.bg-c-teal { - background: linear-gradient(45deg,#1ABC9C,#16A085); -} + .bg-c-teal { + background: linear-gradient(45deg, #1ABC9C, #16A085); + } -.bg-c-cyan { - background: linear-gradient(45deg,#00C9FF,#92FE9D); -} + .bg-c-cyan { + background: linear-gradient(45deg, #00C9FF, #92FE9D); + } -.bg-c-lime { - background: linear-gradient(45deg,#A8E063,#56AB2F); -} + .bg-c-lime { + background: linear-gradient(45deg, #A8E063, #56AB2F); + } -.bg-c-indigo { - background: linear-gradient(45deg,#3F51B5,#5A55AE); -} + .bg-c-indigo { + background: linear-gradient(45deg, #3F51B5, #5A55AE); + } -.bg-c-Pelorous { - background: linear-gradient(45deg, #00d6db, #00a8b5); -} + .bg-c-Pelorous { + background: linear-gradient(45deg, #00d6db, #00a8b5); + } -.bg-c-Pelorous2 { - background: linear-gradient(45deg, #02a8b5, #017f8b); -} + .bg-c-Pelorous2 { + background: linear-gradient(45deg, #02a8b5, #017f8b); + } -.bg-c-Pelorous3 { - background: linear-gradient(45deg, #098895, #046063); -} + .bg-c-Pelorous3 { + background: linear-gradient(45deg, #098895, #046063); + } -.bg-c-Grenadier { - background: linear-gradient(45deg, #ff9d37, #ff7a10); -} + .bg-c-Grenadier { + background: linear-gradient(45deg, #ff9d37, #ff7a10); + } -.bg-c-Grenadier2 { - background: linear-gradient(45deg, #ff8010, #ff4c00); -} + .bg-c-Grenadier2 { + background: linear-gradient(45deg, #ff8010, #ff4c00); + } -.bg-c-Grenadier3 { - background: linear-gradient(45deg, #f06306, #cc4b05); -} + .bg-c-Grenadier3 { + background: linear-gradient(45deg, #f06306, #cc4b05); + } -.bg-c-SilverChalice { - background: linear-gradient(45deg, #a3a8a8, #8f9494); -} + .bg-c-SilverChalice { + background: linear-gradient(45deg, #a3a8a8, #8f9494); + } -.bg-c-SilverChalice2 { - background: linear-gradient(45deg, #7e8484, #686e6e); -} + .bg-c-SilverChalice2 { + background: linear-gradient(45deg, #7e8484, #686e6e); + } -.bg-c-SilverChalice3 { - background: linear-gradient(45deg, #5c6363, #434949); -} + .bg-c-SilverChalice3 { + background: linear-gradient(45deg, #5c6363, #434949); + } -.card { - border-radius: 5px; - -webkit-box-shadow: 0 1px 2.94px 0.06px rgba(4,26,55,0.16); - box-shadow: 0 1px 2.94px 0.06px rgba(4,26,55,0.16); - border: none; - margin-bottom: 30px; - -webkit-transition: all 0.3s ease-in-out; - transition: all 0.3s ease-in-out; -} + .card { + border-radius: 5px; + -webkit-box-shadow: 0 1px 2.94px 0.06px rgba(4, 26, 55, 0.16); + box-shadow: 0 1px 2.94px 0.06px rgba(4, 26, 55, 0.16); + border: none; + margin-bottom: 30px; + -webkit-transition: all 0.3s ease-in-out; + transition: all 0.3s ease-in-out; + } -.card .card-block { - padding-top: 10px; - padding-bottom: 10px; - padding-left: 25px; - padding-right: 25px; -} + .card .card-block { + padding-top: 10px; + padding-bottom: 10px; + padding-left: 25px; + padding-right: 25px; + } -.order-card i { - font-size: 26px; -} + .order-card i { + font-size: 26px; + } -.f-left { - float: left; -} + .f-left { + float: left; + } -.f-right { - float: right; -} + .f-right { + float: right; + } -.m-b-1{ - margin-top: 0; - margin-bottom: 5px; -} + .m-b-1 { + margin-top: 0; + margin-bottom: 5px; + }
    @@ -133,7 +133,9 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_t
    Leads
    -

    +

    +

     

     

    @@ -143,7 +145,9 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_t
    BDS Renewals
    -

    +

    +

     

     

    @@ -151,39 +155,42 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_t
    - + +
    +
    + $value) : ?> - 20 ? substr($formattedStatus, 0, 15) . '...' : $formattedStatus; - $showTooltip = strlen($formattedStatus) > 20; + $formattedStatus = strlen($key) < 5 ? strtoupper($key) : ucwords(str_replace('_', ' ', $key)); + $truncatedStatus = strlen($formattedStatus) > 20 ? substr($formattedStatus, 0, 15) . '...' : $formattedStatus; + $showTooltip = strlen($formattedStatus) > 20; ?>
    - - $value) : ?> - - $value) : ?> + 20 ? substr($formattedStatus, 0, 15) . '...' : $formattedStatus; - $showTooltip = strlen($formattedStatus) > 20; + // Initialize color set and shade indexes + $colorSetIndex = floor($index / $shadeCount) % $colorSetCount; // Reset color set after each set + $shadeIndex = $index % $shadeCount; // Cycle through shades within the set + + // Get the background color for the current tile + $bgColor = $colorShades[$colorSetIndex][$shadeIndex]; + ?> + 20 ? substr($formattedStatus, 0, 15) . '...' : $formattedStatus; + $showTooltip = strlen($formattedStatus) > 20; ?>
    \ No newline at end of file diff --git a/app/Views/rfq/installment_fields.php b/app/Views/rfq/installment_fields.php new file mode 100644 index 00000000..cc347232 --- /dev/null +++ b/app/Views/rfq/installment_fields.php @@ -0,0 +1,35 @@ + $installment) { +?> +
    + + + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + +
    +
    + diff --git a/app/Views/view_rfq.php b/app/Views/view_rfq.php index f954f3e3..1396be13 100644 --- a/app/Views/view_rfq.php +++ b/app/Views/view_rfq.php @@ -491,25 +491,14 @@
    -
    - - "> -
    - -
    - - "> -
    -
    ">
    - - - > + + >
    @@ -519,20 +508,54 @@ -
    - - "> -
    +
    + + "> +
    -
    - - "> -
    +
    + + "> +
    +
    + + > +
    + + + +
    + + "> +
    + + + + + +
    + + "> +
    + +
    + + "> +
    + + + +
    + +
    +
    +

    +
    @@ -557,7 +580,7 @@ > - @@ -694,6 +717,7 @@ policy_terms = JSON.parse(policy_terms_json); jsonDataForHide = data?.premium_data ?? null; + console.log("data", data); if(data){ proposalDataForDropDown = data.proposal_data; if(!data.premium_data){ @@ -837,7 +861,7 @@ $(document).ready(function () { setInterval(function () { submitData(1); - }, 15000); + }, 20000); }); @@ -3194,7 +3218,7 @@ function insurerAndClientMailPopUp(){ function placementMailPopUp() { - console.log(proposalDataForDropDown); + console.log("proposalDataForDropDown", proposalDataForDropDown); const selectElement = document.getElementById('proposals'); @@ -3451,137 +3475,6 @@ function constructURL(url_type) { } } -// function constructURL_ForInsurerAndClientMailSend() { - -// var lead_id = $('#lead_id').val(); -// var mail_content = $('#insurer_and_client_mail_content').val(); -// var subject = $('#mail_subject').val(); -// var apiURL; - -// if (RFQ_or_QCR == 2) { -// apiURL = '?lead_id=' + encodeURIComponent(lead_id) + -// '&file_type=qcr' + -// '&recipient_type=client' + -// '&recipient_mail='+ -// '&mail_content=' + String(mail_content) + -// '&subject=' + String(subject); - -// } else { -// var insurerContact = $('#insurerContact').val(); -// insurerContact = insurerContact.map(Number); -// console.log(insurerContact); - -// apiURL = '?lead_id=' + encodeURIComponent(lead_id) + -// '&file_type=rfq' + -// '&recipient_type=insurer' + -// '&recipient_mail=' + JSON.stringify(insurerContact)+ -// '&mail_content=' + String(mail_content) + -// '&subject=' + String(subject); -// } - -// console.log(apiURL); -// ajaxRequest(apiURL); -// } - -// function constructURL_ForInternalMailSend() { - -// var lead_id = $('#lead_id').val(); -// let to = $('#to').val(); -// let mail_content = $('#internal_mail_content').val(); -// let subject = $('#subject').val(); - - -// let cc = $('#cc').val(); -// cc = cc.map(Number); -// cc = JSON.stringify(cc) - -// var file_type = 'rfq'; -// if (RFQ_or_QCR == 2) { -// file_type = 'qcr' -// } - -// var queryParams = { -// lead_id: lead_id, -// file_type: file_type, -// recipient_type: 'internal', -// to: to, -// cc: cc, -// subject: subject, -// // mail_content: mail_content, -// recipient_mail: '', -// mail_content: mail_content, -// subject: subject, -// }; - -// const queryString = objectToQueryString(queryParams); -// console.log(queryString); - -// var apiURL = '?'+queryString - -// console.log(apiURL); -// ajaxRequest(apiURL); -// } - -// function constructURL_ForPlacementMailSend() { - -// var lead_id = $('#lead_id').val(); -// let to = $('#placement_to').val(); -// console.log('to mail', to); - -// let placement_date = $('#placement_date').val(); -// let utr_no = $('#utr_no').val(); -// let premium_amount = $('#premium_amount').val(); -// let total_amount = $('#total_amount').val(); -// let cd_amount = $('#cd_amount').val(); - -// let subject = $('#placement_subject').val(); -// // let = mail_content = $('#placement_mail_content').val(); -// let proposal_insurer = $('#proposals option:selected').data('id'); -// let insurer_and_branch = $('#proposals').val(); - -// let cc = $('#placement_cc').val(); -// cc = cc.map(Number); -// // cc = cc.split(',').map(email => email.trim()); -// cc = JSON.stringify(cc); - -// // to = to.map(String); -// // to = JSON.stringify(to) -// to = to.split(',').map(email => email.trim()); -// to = JSON.stringify(to) -// console.log('to (array):', to); - -// var file_type = 'rfq'; -// if (RFQ_or_QCR == 2) { -// file_type = 'qcr' -// } - -// var queryParams = { -// lead_id: lead_id, -// file_type: file_type, -// recipient_type: 'placement', -// to: to, -// cc: cc, -// subject: subject, -// proposal_insurer: proposal_insurer, -// insurer_and_branch: insurer_and_branch, -// recipient_mail: to, - -// placement_date: placement_date, -// utr_no: utr_no, -// premium_amount: premium_amount, -// total_amount: total_amount, -// cd_amount: cd_amount, -// }; - -// const queryString = objectToQueryString(queryParams); -// console.log(queryString); - -// var apiURL = '?'+queryString - -// console.log(apiURL); -// ajaxRequest(apiURL); -// } - // Insurer and Client Mail function constructURL_ForInsurerAndClientMailSend() { @@ -3694,16 +3587,44 @@ function constructURL_ForPlacementMailSend() { let proposal_insurer = $('#proposals option:selected').data('id'); let insurer_and_branch = $('#proposals').val(); let cc = $('#placement_cc').val(); + let no_of_installment = $('#no_of_installment').val(); + let is_installment = $("#is_installment_switch").is(":checked") ? 1 : 0; + console.log("cc1", cc); // Process `to` field to = to.split(',').map(email => email.trim()); - cc = cc.map(Number); // or split if it's a string: `cc.split(',').map(email => email.trim())` + // cc = cc.map(Number); // or split if it's a string: `cc.split(',').map(email => email.trim())` + var selectedFiles = []; $('#placement_mail_attachment .multi_file_attachment:checked').each(function () { selectedFiles.push($(this).val()); }); + let data = []; + + $('#installment_form_row .form-row').each(function () { + let installment_amount = $(this).find('input[name="installment_amount[]"]').val(); + let payment_date = $(this).find('input[name="payment_date[]"]').val(); + let utr_no = $(this).find('input[name="utr_no[]"]').val(); + let id = $(this).find('input[name="installment_primary_key[]"]').val(); + console.log('installment_primary_key', id); + + let obj = { + lead_id: lead_id, + installment_amount: installment_amount, + payment_date: payment_date, + utr_no: utr_no + }; + + if (id != undefined && id != null && id != '') { + obj.id = id; + } + + data.push(obj); + }); + + // Prepare FormData var formData = new FormData(); formData.append('lead_id', lead_id); @@ -3723,14 +3644,15 @@ function constructURL_ForPlacementMailSend() { formData.append('cd_amount', cd_amount); formData.append('mail_content', mail_content); formData.append('selected_attachment_files', JSON.stringify(selectedFiles)); + formData.append('installments', JSON.stringify(data)); + formData.append('no_of_installment', no_of_installment); + formData.append('is_installment', is_installment); ajaxRequest(formData); } - - function ajaxRequest(formData) { var apiURL = ''; @@ -3831,23 +3753,40 @@ function getInsurerBranchContacts(input){ function appendInsurerContact(data) { - console.log(data) + console.log(data); - $('#placement_to').empty(); - $('#placement_to').append($('
    @@ -472,7 +472,7 @@ >
    - +
    + + +
    -
    - - "> -
    - - From 0e4e24fd7af1b11184e2992185729ee319816044 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 9 May 2025 17:15:53 +0530 Subject: [PATCH 091/169] CHANGE_CLAIMS_CR_AND_LIVE_SUPPORT : RV --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 5 ++ .../PolicyTransactionController.php | 6 +-- app/Controllers/TicketController.php | 23 +++++++-- app/Views/insurer_statement_list.php | 2 +- app/Views/ticket_form_gmc.php | 15 +++++- app/Views/ticket_form_gpa.php | 6 +++ app/Views/ticket_list.php | 50 ++++++++++++++++++- 8 files changed, 99 insertions(+), 9 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 9c1b388e..1527b8cc 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -545,6 +545,7 @@ $routes->group("/bdsReport", ["filter" => "authMVC"], function ($routes) { $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) { $routes->match( ['get', 'post'], 'list','TicketController::ticketList'); $routes->get('feedback-list','TicketController::feedbackList'); + $routes->get('remove','TicketController::removeTicket'); $routes->get('new/(:any)','TicketController::ticket_form/$1'); $routes->post('create','TicketController::createTicket'); $routes->post('update','TicketController::updateTicket'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 39440f05..a490bddc 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -44,6 +44,7 @@ use App\Models\ClientApiModel; use App\Controllers\EmpDataServiceController; use App\Controllers\GoogleDriveController; +use App\Controllers\PolicyTransactionController; use App\Helpers\sendMailNotification; use App\Models\PTCOShareDetailsModel; @@ -4608,6 +4609,10 @@ class ClientController extends AdminController // $res = $empServiceController->excelFileDataValidation(['file_id' => '865']); // $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '829']); // $res = $empServiceController->employeeDisembark(['file_id' => '858']); + + $policyTransactionController = new PolicyTransactionController(); + // $res = $policyTransactionController->validateInsurerStatement(['file_id' => '17']); + // $res = $policyTransactionController->updateInsurerStatement(['file_id' => '22']); // dd('-----', $res); diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 310cc939..d0242215 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -2380,7 +2380,7 @@ class PolicyTransactionController extends BaseController if (($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != "")) { $total_amt += $actual_bp_brokerage; //percentage reverse calculation - if ($actual_bp_per == 0 || $actual_bp_per == "") { + if (($actual_bp_per == 0 || $actual_bp_per == 0) && !empty($actual_bp_amt)) { $actual_bp_per = round(($actual_bp_brokerage / $actual_bp_amt) * 100, 2); } } else { @@ -2395,7 +2395,7 @@ class PolicyTransactionController extends BaseController if ($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "") { $total_amt += $actual_tp_brokerage; //percentage reverse calculation - if ($actual_tp_per == 0 || $actual_tp_per == "") { + if (($actual_tp_per == 0 || $actual_tp_per == "") && !empty($actual_tp_amt)) { $actual_tp_per = ($actual_tp_brokerage / $actual_tp_amt) * 100; } } else { @@ -2410,7 +2410,7 @@ class PolicyTransactionController extends BaseController if ($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "") { $total_amt += $actual_tep_brokerage; //percentage reverse calculation - if ($actual_tep_per == 0 || $actual_tep_per == "") { + if (($actual_tep_per == 0 || $actual_tep_per == "") && !empty($actual_tep_amt)) { $actual_tep_per = ($actual_tep_brokerage / $actual_tep_amt) * 100; } } else { diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 37685b55..7cbf5766 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -954,10 +954,27 @@ class TicketController extends BaseController } public function convertHtmlToText($html) + { + if(!empty($html)){ + $dom = new DOMDocument(); + @$dom->loadHTML($html); + return strip_tags($dom->saveHTML()); + }else{ + return ''; + } + } + + public function removeTicket() { - $dom = new DOMDocument(); - @$dom->loadHTML($html); - return strip_tags($dom->saveHTML()); + $ticket_id = $this->request->getGet('ticket_id'); + if(!empty($ticket_id)){ + $data['is_active'] = 0; + $this->ticketMasterModel->where('id', $ticket_id)->set($data)->update(); + return $this->respond(['status' => true, 'code' => 200, 'message' => 'Claim removed successfully'], 200); + }else{ + return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to remove Claim'], 200); + } + } //---- Email Trigger Part---------------------------------------------------------------------------------------------- diff --git a/app/Views/insurer_statement_list.php b/app/Views/insurer_statement_list.php index be2954d7..fed5f122 100644 --- a/app/Views/insurer_statement_list.php +++ b/app/Views/insurer_statement_list.php @@ -1004,7 +1004,7 @@ maxDate.setDate(today.getDate() + 180); // Request failed, handle error console.error("Request failed:", status, error); toastr.error('Something went wrong! Try later', 'Error'); - $('#uploadForm')[0].reset(); + // $('#uploadForm')[0].reset(); $('.close').click() $('.loader').fadeOut(); $('.loader-mask').delay(10).fadeOut('slow'); diff --git a/app/Views/ticket_form_gmc.php b/app/Views/ticket_form_gmc.php index 8eb8c494..a9779a33 100644 --- a/app/Views/ticket_form_gmc.php +++ b/app/Views/ticket_form_gmc.php @@ -180,7 +180,15 @@

    -
    Claim Details
    + +
    +
    + Claim Details + + +
    +
    +
    @@ -594,6 +602,11 @@ }); } + + $field = $('#approved_description') + $field.prop('required', false); + var $parentDiv = $field.closest("div"); + $parentDiv.find("label[for='approved_description'] .text-danger").remove(); } $('#claim_status_id').on('change', function() { diff --git a/app/Views/ticket_form_gpa.php b/app/Views/ticket_form_gpa.php index 3618d1f1..0ae537f8 100644 --- a/app/Views/ticket_form_gpa.php +++ b/app/Views/ticket_form_gpa.php @@ -432,6 +432,12 @@ } else if (value == 48 || value == 54 || value == 59) { // RETURNED $('.returned').show(); } + + $field = $('#approved_description') + $field.prop('required', false); + var $parentDiv = $field.closest("div"); + $parentDiv.find("label[for='approved_description'] .text-danger").remove(); + } $('#claim_status_id').on('change', function() { diff --git a/app/Views/ticket_list.php b/app/Views/ticket_list.php index 6f49c545..d3408054 100644 --- a/app/Views/ticket_list.php +++ b/app/Views/ticket_list.php @@ -109,12 +109,13 @@ table.dataTable tbody td { TAT + ACTION $row){ ?> - + + + + @@ -294,4 +305,41 @@ function viewTicket(ticket_id){ } +function removeClaim(input, ticket_id) { + + confirmActionSweertAlert("Do you want to delete this Claim?", "Yes, Proceed!", "No, Cancel").then((confirmed) => { + if (confirmed) { + let url = ''; + + // Include `pt_id` in the AJAX request if necessary + let requestData = { ticket_id: ticket_id }; + + sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) { + console.log('Data fetched successfully:', response); + + if (response.status === true) { + toastr.success(response.message, 'SUCCESS'); + window.location.reload(); + } else { + toastr.warning(response.message, 'WARNING'); + } + }, function(xhr, status, error) { + console.error('Error fetching data:', error); + console.error(xhr.responseText); + }); + } + }); + +} + +$(document).on('click', 'tbody tr', function (e) { + // Exclude clicks on any elements inside the last column (actions) + if ($(e.target).closest('td').index() !== $(this).children('td').length - 1) { + const id = $(this).data('id'); + console.log('Ticket ID', id) + viewTicket(id); + } +}); + + \ No newline at end of file From c94550a48df942aac19d265ae00070bb5669da5a Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 12 May 2025 15:09:23 +0530 Subject: [PATCH 092/169] FIX_FAMILY_FLOATER_KEY_ISSUE : RV --- app/Controllers/EmployeeServiceController.php | 6 ++++-- app/Helpers/excel_util_helper.php | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 9917796f..4d130194 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -2077,12 +2077,14 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){ $relation = 'parent'; } else if(strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter'){ $relation = 'child'; - }else if(strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law'){ + }else if((strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law') || (strtolower(trim($value['relationship'])) === 'father-in-law' || strtolower(trim($value['relationship'])) === 'mother-in-law')){ $relation = 'parent_in_law'; }else if(strtolower(trim($value['relationship'])) === 'spouse'){ $relation = 'spouse'; - }else{ + }else if(strtolower(trim($value['relationship'])) === 'self'){ $relation = 'self'; + }else { + $relation = ''; } $value['family_floater_key'] = $relation; diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index d2e30828..67ffc9b1 100755 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -2210,12 +2210,14 @@ if (!function_exists('generate_family_floater_key')) { $relation = 'parent'; } else if (strtolower(trim($relationship)) === 'son' || strtolower(trim($relationship)) === 'daughter') { $relation = 'child'; - } else if (strtolower(trim($relationship)) === 'father in Law' || strtolower(trim($relationship)) === 'mother in Law') { + }else if((strtolower(trim($relationship)) === 'father in Law' || strtolower(trim($relationship)) === 'mother in Law') || (strtolower(trim($relationship)) === 'father-in-Law' || strtolower(trim($relationship)) === 'mother-in-Law')){ $relation = 'parent_in_law'; } else if (strtolower(trim($relationship)) === 'spouse') { $relation = 'spouse'; - } else { + } else if(strtolower(trim($relationship)) === 'self'){ $relation = 'self'; + }else{ + $relation = ''; } return $relation; From a533f06e4a82dfac397d8b48f760c1d090035896 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Mon, 12 May 2025 18:03:35 +0530 Subject: [PATCH 093/169] FEAT_TAT_AND_TPA_REDIRECT,FIX_APPROVED_AMOUNT AS DATE --- app/Controllers/TicketController.php | 38 ++- app/Models/TicketMasterModel.php | 362 +++++++++++++++--------- app/Views/claims_report_tpa_wise.php | 45 ++- app/Views/tat_report_band_wise_list.php | 39 ++- 4 files changed, 333 insertions(+), 151 deletions(-) diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 7cbf5766..005bebc4 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -198,6 +198,12 @@ class TicketController extends BaseController }else if ($isFromDashboard == 2){ $data['ticket_data'] = $this->ticketSearch(4); + }else if ($isFromDashboard == 3){ + $data['ticket_data'] = $this->ticketSearch(2); + + }else if ($isFromDashboard == 4){ + $data['ticket_data'] = $this->ticketSearch(5); + } $data['claim_status'] = $this->claimStatus->select('id,ticket_type,claim_status')->where('is_active', 1)->findAll(); $data['client_list'] = $this->clientModel->select('id,client_name')->where('is_active', 1)->findAll(); @@ -249,7 +255,7 @@ class TicketController extends BaseController ->groupBy('tm.id, tm.created_at, latest_history.created_at'); - //action 1 get last 100 rows, action 2 filter and get all rows related to that, action 3 gets according to dashboard, action 4 gets according to ACM + //action 1 get last 100 rows, action 2 filter and get all rows related to that, action 3 gets according to dashboard, action 4 gets according to ACM, action 5 tat if ($action == 1) { $query = $db->table('ticket_master tm') @@ -356,6 +362,10 @@ class TicketController extends BaseController $where = '1 = 0'; // No valid IDs, return empty result } + }else if ($action == 5) { + $search_data = $this->request->getPost(); + $where = "tm.created_at >= '" . $search_data['from_date'] . "' AND tm.created_at <= '" . $search_data['to_date'] . "'" ."and ticket_type_id = ".$search_data['ticket_type_id']; + } else { $search_data = $this->request->getPost(); // print_r($search_data); die() @@ -445,6 +455,17 @@ class TicketController extends BaseController ->orderBy('tm.id', 'DESC'); $data = $query->get()->getResultArray(); + // dd($db->getLastQuery()->getQuery()); + // dd($data); + if ($action == 5){ + + $tat = $this->request->getPost("tat_category"); + + $data = array_values(array_filter($data, function($dat) use ($tat) { + return $dat['tat'] == $tat; + })); + + } // print_rr($data); // log_message('error',' Claims Master Data '.json_encode($data));die(); // print_rr($data);die(); @@ -1068,6 +1089,10 @@ class TicketController extends BaseController $this->myLogger->logme('error', "Replacing placeholders in content"); if (!empty($ticket_data) && !empty($content)) { + // print_rr($ticket_data);die(); + if (!isset($ticket_data['id'])) { $ticket_data['id'] = $ticket_data['ticket_master_id'];} + if (!isset($ticket_data['ticket_master_id'])) {$ticket_data['ticket_master_id'] = $ticket_data['id'];} + foreach ($this->placeHolders as $key => $value) { if ($value == "emp_code") { @@ -1451,7 +1476,7 @@ class TicketController extends BaseController 'TPA_NAME', 'NON ID', 'ID NOT GENERATED', 'CDA', 'INFORMATION REQUIRED', 'UNDER PROCESS - CLAIM NO. UPDATION', 'UNDER PROCESS - QUERY DOCUMENT RECEIVED', 'APPROVED', 'PAYMENT INITIATED', - 'TOTAL', 'SETTLED', 'CLOSED', 'CANCELLED', 'RETURNED', 'CLEARED_TOTAL' + 'TOTAL', 'SETTLED', 'CLOSED', 'CANCELLED', 'RETURNED', 'CLEARED_TOTAL','TPA_ID' ]; // Reorder data based on column order @@ -1465,6 +1490,7 @@ class TicketController extends BaseController $ordered_data[] = $temp; } $viewData['tpa_wise_data'] = $ordered_data; + // print_r($ordered_data);die(); // $html = view('claims_report_tpa_wise', $viewData); $html = view('claims_report_tpa_wise',$viewData); @@ -1472,6 +1498,9 @@ class TicketController extends BaseController } else if ($received_data['report_type'] == 'tat_band_wise') { $viewData['data'] = $this->ticketMasterModel->getTATReport($policy_type, $fromDate, $toDate); + $viewData['policyType'] = $policy_type; + $viewData['fromDate'] = $fromDate; + $viewData['toDate'] = $toDate; $html = view('tat_report_band_wise_list', $viewData); return $this->respond(['status' => true, 'html' => $html], 200); } @@ -1876,9 +1905,10 @@ class TicketController extends BaseController } } - private function isDate($value) { + private function isDate($value, $format = 'Y-m-d') { // Check if the value is a valid date string (basic validation) - return strtotime($value) !== false; + $date = \DateTime::createFromFormat($format, $value); + return $date && $date->format($format) === $value; } diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 1404190e..62a5e101 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -335,159 +335,240 @@ class TicketMasterModel extends Model // return $data; // } + // public function getTATReport($ticket_type = null, $start_date = null, $end_date = null) + // { + // //set default last 3 months data date + // $fromDate = date('Y-m-d', strtotime('-90 days')); + // $toDate = date('Y-m-d 23:59:59'); + + // if (!empty($start_date) && !empty($end_date)) { + // $fromDate = change_date_format($start_date); + // $toDate = change_date_format($end_date); + // } + // $ticket_type_data_1 = ""; + // $ticket_type_data_2 = ""; + // if (!empty($ticket_type)) { + // $ticket_type_data_1 = "AND ticket_type = $ticket_type"; + // $ticket_type_data_2 = "WHERE tm.ticket_type_id = $ticket_type"; + // } + + // // Fetch claim statuses from the `ticket_claim_status` table + // $statusQuery = " SELECT + // id, claim_status, ticket_type + // FROM ticket_claim_status + // Where is_active = 1 + // $ticket_type_data_1 + // "; + // $statusResult = $this->db->query($statusQuery)->getResultArray(); + // // dd($statusResult); + + // // Initialize dynamic query parts + // $dynamicSelect = ''; + + // // Loop through each claim status and generate the COALESCE and CASE statements for the SELECT + // foreach ($statusResult as $status) { + + // $columnName = $status['claim_status']; // Default column name + + // if (empty($ticket_type)) { + // // Append the insurance type prefix based on `ticket_type` + // switch ($status['ticket_type']) { + // case 1: + // $columnName = "GMC - {$status['claim_status']}"; + // break; + // case 2: + // $columnName = "GPA - {$status['claim_status']}"; + // break; + // case 3: + // $columnName = "EDLI - {$status['claim_status']}"; + // break; + // case 4: + // $columnName = "GTLI - {$status['claim_status']}"; + // break; + // } + // } + + // $dynamicSelect .= " + // COALESCE( + // SUM( + // CASE + // WHEN subquery.status_id = {$status['id']} THEN 1 + // ELSE 0 + // END + // ), + // 0 + // ) AS `$columnName`, "; + // } + + // // Remove the trailing comma from the SELECT part + // $dynamicSelect = rtrim($dynamicSelect, ', '); + // // dd($dynamicSelect); + + + // // Construct the full SQL query + // $sql = " + // SELECT + // tc.TAT_Category, + // $dynamicSelect + // FROM + // ( + // SELECT 'Above 20 Days' AS TAT_Category + // UNION ALL + // SELECT '13-20 Days' + // UNION ALL + // SELECT '7-12 Days' + // UNION ALL + // SELECT '0-6 Days' + // ) AS tc + // LEFT JOIN ( + // SELECT + // tm.id AS ticket_id, + // latest_status.claim_status_id AS status_id, + // CASE + // WHEN DATEDIFF(CURDATE(), COALESCE(latest_status.change_date, tm.created_at)) BETWEEN 0 AND 6 THEN '0-6 Days' + // WHEN DATEDIFF(CURDATE(), COALESCE(latest_status.change_date, tm.created_at)) BETWEEN 7 AND 12 THEN '7-12 Days' + // WHEN DATEDIFF(CURDATE(), COALESCE(latest_status.change_date, tm.created_at)) BETWEEN 13 AND 20 THEN '13-20 Days' + // ELSE 'Above 20 Days' + // END AS TAT_Category + // FROM + // ticket_master tm + // LEFT JOIN ( + // SELECT + // th.ticket_id, + // th.new_value AS claim_status_id, + // MAX(th.created_at) AS change_date + // FROM + // ticket_history th + // WHERE + // th.field_name = 'claim_status_id' + // AND th.is_active = 1 + // GROUP BY + // th.ticket_id, th.new_value + // ) AS latest_status ON latest_status.ticket_id = tm.id + // WHERE tm.is_active = 1 + // AND tm.created_at >= '$fromDate' + // AND tm.created_at <= '$toDate' + // " . (!empty($ticket_type) ? " AND tm.ticket_type_id = $ticket_type" : "") . " + // GROUP BY tm.id, latest_status.claim_status_id, latest_status.change_date, tm.created_at + // ) AS subquery ON tc.TAT_Category = subquery.TAT_Category + // GROUP BY + // tc.TAT_Category + // ORDER BY + // FIELD( + // tc.TAT_Category, + // 'Above 20 Days', + // '13-20 Days', + // '7-12 Days', + // '0-6 Days' + // ); + // "; + + // // Execute the query and return the result + // $data = $this->db->query($sql)->getResultArray(); + // // dd($data); + // print_rr($data);die(); + // // print_rr($this->db->getLastQuery()->getQuery()); die; + + // return $data; + // } public function getTATReport($ticket_type = null, $start_date = null, $end_date = null) { - //set default last 3 months data date + // Set default date range (last 90 days) $fromDate = date('Y-m-d', strtotime('-90 days')); $toDate = date('Y-m-d 23:59:59'); - + if (!empty($start_date) && !empty($end_date)) { $fromDate = change_date_format($start_date); $toDate = change_date_format($end_date); } - $ticket_type_data_1 = ""; - $ticket_type_data_2 = ""; + + // Get all active claim statuses + $statusQuery = $this->db->table('ticket_claim_status') + ->select('id, claim_status') + ->where('is_active', 1) + ->orderBy('id', 'ASC'); + if (!empty($ticket_type)) { - $ticket_type_data_1 = "AND ticket_type = $ticket_type"; - $ticket_type_data_2 = "WHERE tm.ticket_type_id = $ticket_type"; + $statusQuery->where('ticket_type', $ticket_type); } - - // Fetch claim statuses from the `ticket_claim_status` table - $statusQuery = " SELECT - id, claim_status, ticket_type - FROM ticket_claim_status - Where is_active = 1 - $ticket_type_data_1 - "; - $statusResult = $this->db->query($statusQuery)->getResultArray(); - // dd($statusResult); - - // Initialize dynamic query parts - $dynamicSelect = ''; - - // Loop through each claim status and generate the COALESCE and CASE statements for the SELECT - foreach ($statusResult as $status) { - - $columnName = $status['claim_status']; // Default column name - - if (empty($ticket_type)) { - // Append the insurance type prefix based on `ticket_type` - switch ($status['ticket_type']) { - case 1: - $columnName = "GMC - {$status['claim_status']}"; - break; - case 2: - $columnName = "GPA - {$status['claim_status']}"; - break; - case 3: - $columnName = "EDLI - {$status['claim_status']}"; - break; - case 4: - $columnName = "GTLI - {$status['claim_status']}"; - break; + + $statusResult = $statusQuery->get()->getResultArray(); + + // Create a list of all TAT categories we want in the output + $tatCategories = [ + 'Above 20 Days', + '13-20 Days', + '7-12 Days', + '0-6 Days' + ]; + + // Initialize the result array with all TAT categories + $result = []; + foreach ($tatCategories as $category) { + $row = ['TAT_Category' => $category]; + foreach ($statusResult as $status) { + $row[$status['claim_status']] = 0; + } + $result[] = $row; + } + + // Get the base query for ticket counts by status and TAT category + $query = $this->db->table('ticket_master tm') + ->select([ + 'tcs.claim_status', + 'CASE + WHEN DATEDIFF(CURDATE(), COALESCE( + (SELECT MAX(th.created_at) + FROM ticket_history th + WHERE th.ticket_id = tm.id + AND th.field_name = "claim_status_id" + AND th.is_active = 1), + tm.created_at + )) BETWEEN 0 AND 6 THEN "0-6 Days" + WHEN DATEDIFF(CURDATE(), COALESCE( + (SELECT MAX(th.created_at) + FROM ticket_history th + WHERE th.ticket_id = tm.id + AND th.field_name = "claim_status_id" + AND th.is_active = 1), + tm.created_at + )) BETWEEN 7 AND 12 THEN "7-12 Days" + WHEN DATEDIFF(CURDATE(), COALESCE( + (SELECT MAX(th.created_at) + FROM ticket_history th + WHERE th.ticket_id = tm.id + AND th.field_name = "claim_status_id" + AND th.is_active = 1), + tm.created_at + )) BETWEEN 13 AND 20 THEN "13-20 Days" + ELSE "Above 20 Days"g + END AS tat_category', + 'COUNT(*) AS count' + ]) + ->join('ticket_claim_status tcs', 'tcs.id = tm.claim_status_id AND tcs.is_active = 1') + ->where('tm.is_active', 1) + ->where('tm.created_at >=', $fromDate) + ->where('tm.created_at <=', $toDate) + ->groupBy('tcs.claim_status, tat_category') + ->orderBy('FIELD(tat_category, "Above 20 Days", "13-20 Days", "7-12 Days", "0-6 Days")'); + + if (!empty($ticket_type)) { + $query->where('tm.ticket_type_id', $ticket_type); + } + + $countResults = $query->get()->getResultArray(); + + // Populate the result array with actual counts + foreach ($countResults as $row) { + foreach ($result as &$categoryRow) { + if ($categoryRow['TAT_Category'] === $row['tat_category']) { + $categoryRow[$row['claim_status']] = (int)$row['count']; + break; } } - - $dynamicSelect .= " - COALESCE( - SUM( - CASE - WHEN subquery.status_id = {$status['id']} THEN 1 - ELSE 0 - END - ), - 0 - ) AS `$columnName`, "; } - - // Remove the trailing comma from the SELECT part - $dynamicSelect = rtrim($dynamicSelect, ', '); - // dd($dynamicSelect); - - - // Construct the full SQL query - $sql = " - SELECT - tc.TAT_Category, - $dynamicSelect - FROM - ( - SELECT 'Above 20 Days' AS TAT_Category - UNION ALL - SELECT '13-20 Days' - UNION ALL - SELECT '7-12 Days' - UNION ALL - SELECT '0-6 Days' - ) AS tc - LEFT JOIN ( - - SELECT - th.ticket_id, - tcs.claim_status, - tcs.id AS status_id, - CASE - WHEN DATEDIFF( - th.created_at, - COALESCE( - (SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id), - tm.created_at - ) - ) BETWEEN 0 AND 6 THEN '0-6 Days' - WHEN DATEDIFF( - th.created_at, - COALESCE( - (SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id), - tm.created_at - ) - ) BETWEEN 7 AND 12 THEN '7-12 Days' - WHEN DATEDIFF( - th.created_at, - COALESCE( - (SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id), - tm.created_at - ) - ) BETWEEN 13 AND 20 THEN '13-20 Days' - ELSE 'Above 20 Days' - END AS TAT_Category - - FROM - ticket_master tm - JOIN ticket_history th ON tm.id = th.ticket_id - JOIN ticket_claim_status tcs ON th.field_name = 'claim_status_id' AND th.new_value = tcs.id - $ticket_type_data_2 - AND tm.created_at >= '$fromDate' - AND tm.created_at <= '$toDate' - AND tm.is_active = 1 - AND th.is_active = 1 - AND tcs.is_active = 1 - - ) AS subquery ON tc.TAT_Category = subquery.TAT_Category - GROUP BY - tc.TAT_Category - ORDER BY - FIELD( - tc.TAT_Category, - 'Above 20 Days', - '13-20 Days', - '7-12 Days', - '0-6 Days' - ); - "; - - // Execute the query and return the result - $data = $this->db->query($sql)->getResultArray(); - // print_rr($this->db->getLastQuery(), $data); die; - - // $tableData = []; - // if (!empty($data)) { - // // Extract table headers from the first row keys - // $headers = array_keys($data[0]); - // $tableData['headers'] = $headers; - // $tableData['body'] = $data; - // } - - return $data; + + return $result; } public function tpaWiseReport($policy_type = null, $start_date = null, $end_date = null) @@ -544,6 +625,7 @@ class TicketMasterModel extends Model // Construct the final SQL query $sql = " SELECT + tpa.id as TPA_ID, tpa.name AS TPA_NAME, $dynamicSelect, ($dynamicTotal) AS TOTAL, diff --git a/app/Views/claims_report_tpa_wise.php b/app/Views/claims_report_tpa_wise.php index 0a3fc65a..d473d717 100644 --- a/app/Views/claims_report_tpa_wise.php +++ b/app/Views/claims_report_tpa_wise.php @@ -37,16 +37,18 @@ - - + + + - - + + + @@ -62,7 +64,7 @@ } foreach ($column_order as $col_name) { - if ($col_name !== 'TPA_NAME') { + if ($col_name !== 'TPA_NAME' && $col_name != "TPA_ID") { echo "{$totals[$col_name]}"; } } @@ -98,4 +100,35 @@ console.error("Table not found."); } }); - + + function redirectTPAToClaimList(tpa_id){ + + // alert(tpa_id); + data = { + 'tpa_id' : tpa_id, + 'is_dashboard':3 + } + + redirectWithPost("", data); + + } + + function redirectWithPost(url, data = {}) { + const form = document.createElement('form'); + form.method = 'POST'; + form.action = url; + + for (const key in data) { + if (data.hasOwnProperty(key)) { + const input = document.createElement('input'); + input.type = 'hidden'; + input.name = key; + input.value = data[key]; + form.appendChild(input); + } + } + + document.body.appendChild(form); + form.submit(); + } + \ No newline at end of file diff --git a/app/Views/tat_report_band_wise_list.php b/app/Views/tat_report_band_wise_list.php index 0666ece7..a41ff23c 100644 --- a/app/Views/tat_report_band_wise_list.php +++ b/app/Views/tat_report_band_wise_list.php @@ -63,7 +63,7 @@ $rowTotal += $numValue; // Add to row total } ?> - + @@ -129,4 +129,41 @@ }); // ---------------------------------------------------------------------------------------------------- + + \ No newline at end of file From 50d630b1d9c33f533135cf7a3f28c04b516aefb3 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 13 May 2025 10:27:17 +0530 Subject: [PATCH 094/169] FIX_DELETION_DUBLICATE : RV --- app/Controllers/EmployeeServiceController.php | 4 ++-- app/Views/leads_form_handler.php | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index d27444b8..5d65c4a4 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -1383,11 +1383,11 @@ class EmployeeServiceController extends AdminController { // dd($employee); $existing_endorsements = $this->empEndorsementModel->where('actions','d') - ->where('table_name','employees') + ->where('table_name','employee_polices') ->where('endorsement_id is null') ->where('emp_code',$employee['emp_code']) ->where('name',$employee['name']) - ->where('field_name','emp_status') + ->where('field_name','status') ->where('status !=','truncated') ->where('is_active', 1) ->findAll(); diff --git a/app/Views/leads_form_handler.php b/app/Views/leads_form_handler.php index c6f463df..11ba47a7 100644 --- a/app/Views/leads_form_handler.php +++ b/app/Views/leads_form_handler.php @@ -458,9 +458,19 @@ if (isset($selected_lead_type)) { \ No newline at end of file + + + + + + From f1e66204bf63322d2d5a60e048d397364638c098 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Tue, 13 May 2025 17:03:43 +0530 Subject: [PATCH 096/169] FEAT_PLACEMENT_INSTALLMENTS --- app/Controllers/LeadsController.php | 4 +- app/Views/view_rfq.php | 112 ++++++-- app/Views/view_rfq_non_eb.php | 408 +++++++++++++++++++++++++++- 3 files changed, 490 insertions(+), 34 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index b001edf1..41792dbf 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -2372,7 +2372,9 @@ class LeadsController extends BaseController $installment_data = json_decode($params['installments'], true); if(!empty($installment_data)){ foreach ($installment_data as $key => $value) { - $value['payment_date'] = date('Y/m/d', strtotime($value['payment_date'])) ?? null; + $value['payment_date'] = !empty($value['payment_date']) && strtotime($value['payment_date']) + ? date('Y/m/d', strtotime($value['payment_date'])) + : null; if(isset($value['id']) && !empty($value['id'])){ $this->leadInstallmentPaymentDetails->where('id', $value['id'])->set($value)->update(); }else{ diff --git a/app/Views/view_rfq.php b/app/Views/view_rfq.php index 7ddfa80a..1fcc9688 100644 --- a/app/Views/view_rfq.php +++ b/app/Views/view_rfq.php @@ -550,7 +550,7 @@
    - +

    @@ -5826,27 +5826,92 @@ function appendMultiFileData(data) { }) $("#is_installment_switch").change(function (){ - var switch_status = ($(this).is(":checked")? "on" : "off"); - console.log("Switch status",switch_status); - if (switch_status == "on"){ - $("#no_of_installment").show(); - $("#payment_date").hide(); - $("#utr_no").hide(); - $("#no_of_installment").closest('.form-group').show(); - $("#payment_date").closest('.form-group').hide(); - $("#utr_no").closest('.form-group').hide(); - addInstallmentHTML() - }else{ - $("#no_of_installment").hide(); - $("#payment_date").show(); - $("#utr_no").show(); - $("#no_of_installment").closest('.form-group').hide(); - $("#payment_date").closest('.form-group').show(); - $("#utr_no").closest('.form-group').show(); - $('#installment_form_row').empty(); - } + + var switch_status = ($(this).is(":checked")? "on" : "off"); + console.log("Switch status",switch_status); + if (switch_status == "on"){ + $("#no_of_installment").show(); + $("#payment_date").hide(); + $("#utr_no").hide(); + $("#no_of_installment").closest('.form-group').show(); + $("#payment_date").closest('.form-group').hide(); + $("#utr_no").closest('.form-group').hide(); + let $installmentContainer = $('#installment_form_row'); + let row_count = $installmentContainer.find('.form-row').length; + + if (row_count == 0 ) { addInstallmentHTML()} + // addInstallmentHTML() + }else{ + console.log("inside else") + + let $installmentContainer = $('#installment_form_row'); + let row_count = $installmentContainer.find('.form-row').length; + let remove_count = $("#no_of_installment").val(); + console.log("row count",row_count); + if (row_count > 0 ) { + let ids = $installmentContainer.find('.form-row').slice(-remove_count).find('input[name="installment_primary_key[]"]').map(function() { + return $(this).val(); + }).get(); + Swal.fire({ + title: "Do you want to remove all the entries?", + icon: "warning", + showCancelButton: true, + confirmButtonColor: "#3085d6", + cancelButtonColor: "#d33", + confirmButtonText: "Yes, Proceed!" + }).then((result) => { + if (result.isConfirmed) { + let url = ''; + let requestData = { id: ids }; + + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + + sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) { + console.log('Data fetched successfully:', response); + + if (response.status === true) { + toastr.success(response.message, 'SUCCESS'); + $("#no_of_installment").hide(); + $("#payment_date").show(); + $("#utr_no").show(); + $("#no_of_installment").closest('.form-group').hide(); + $("#payment_date").closest('.form-group').show(); + $("#utr_no").closest('.form-group').show(); + $('#installment_form_row').empty(); + $('#no_of_installment').val(""); + } else { + toastr.error(response.message, 'WARNING'); + } + + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + + }, function(xhr, status, error) { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + console.error('Error fetching data:', error); + console.error(xhr.responseText); + toastr.error('An error occurred while removing the installment.', 'ERROR'); + }); + }else{ + // alert("Inside else"); + $('#no_of_installment').val(row_count); + // $("#is_installment_switch").bootstrapToggle('on'); + // $('#is_installment_switch').val('1').change(); + // $('#is_installment_switch').bootstrapToggle('on'); + // $('#is_installment_switch').prop('checked', true).trigger('change'); + $('#is_installment_switch').trigger('click'); // in some cases, this forces the CSS to update + + + } + }); + } + + } }) + $(document).on("input", "#cd_amount, #premium_amount", function() { // alert("Function called"); @@ -5989,8 +6054,8 @@ function appendMultiFileData(data) { console.log("Form row count:", row_count); if (row_count === 1) { - $installmentContainer.empty(); - for (let index = 0; index < no_of_installments; index++) { + // $installmentContainer.empty(); + for (let index = 0; index < no_of_installments - 1; index++) { addInstallmentHTML(); } } else if (no_of_installments === row_count) { @@ -6008,7 +6073,7 @@ function appendMultiFileData(data) { console.log('ids', ids); - if (ids != null) { + if (Object.keys(ids).length > 0) { Swal.fire({ title: "Do you want to remove the last " + (remove_count ?? "") + " entries?", icon: "warning", @@ -6067,6 +6132,7 @@ function appendMultiFileData(data) { } }); + $(document).ready(function(){ setTimeout(function(){ $('.payment_date').flatpickr({ diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index 977d1c82..183a1bb1 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -255,6 +255,12 @@ cursor: pointer; user-select: none; } + + .toggle.btn { + height: 38px !important; + line-height: 33px !important; + } + @@ -424,31 +430,66 @@
    -
    - - "> -
    +
    ">
    +
    + + > +
    +
    ">
    -
    - - "> -
    + + +
    + + "> +
    + +
    + + "> +
    + +
    - - "> + + >
    +
    + + +
    + + + +
    + + "> +
    + +
    + + "> +
    + + + +
    +
    +
    +

    @@ -4790,6 +4831,7 @@ var lead_id = $('#lead_id').val(); let to = $('#placement_to').val(); let placement_date = $('#placement_date').val(); + let payment_date = $('#payment_date').val(); let utr_no = $('#utr_no').val(); let premium_amount = $('#premium_amount').val(); let total_amount = $('#total_amount').val(); @@ -4799,6 +4841,10 @@ let proposal_insurer = $('#proposals option:selected').data('id'); let insurer_and_branch = $('#proposals').val(); let cc = $('#placement_cc').val(); + let is_cd = $("#is_cd_switch").is(":checked") ? 1 : 0; + let no_of_installment = $('#no_of_installment').val(); + let is_installment = $("#is_installment_switch").is(":checked") ? 1 : 0; + // Process `to` field to = to.split(',').map(email => email.trim()); @@ -4810,6 +4856,33 @@ selectedFiles.push($(this).val()); }); + let data = []; + + $('#installment_form_row .form-row').each(function () { + var lead_id = $('#lead_id').val(); + let installment_amount = $(this).find('input[name="installment_amount[]"]').val(); + let payment_date = $(this).find('input[name="payment_date[]"]').val(); + let utr_no = $(this).find('input[name="utr_no[]"]').val(); + let id = $(this).find('input[name="installment_primary_key[]"]').val(); + + + + console.log('installment_primary_key', id); + + let obj = { + lead_id: lead_id, + installment_amount: installment_amount, + payment_date: payment_date, + utr_no: utr_no + }; + + if (id != undefined && id != null && id != '') { + obj.id = id; + } + + data.push(obj); + }); + // Prepare FormData var formData = new FormData(); @@ -4822,12 +4895,17 @@ formData.append('proposal_insurer', proposal_insurer); formData.append('insurer_and_branch', insurer_and_branch); formData.append('placement_date', placement_date); + formData.append('payment_date', payment_date); + formData.append("is_cd",is_cd); formData.append('utr_no', utr_no); formData.append('premium_amount', premium_amount); formData.append('total_amount', total_amount); formData.append('cd_amount', cd_amount); formData.append('mail_content', mail_content); formData.append('selected_attachment_files', JSON.stringify(selectedFiles)); + formData.append('installments', JSON.stringify(data)); + formData.append('no_of_installment', no_of_installment); + formData.append('is_installment', is_installment); ajaxRequest(formData); @@ -5203,6 +5281,316 @@ return false; } + $(document).on("input", "#cd_amount, #premium_amount", function() { + + // alert("Function called"); + + var cd_amount = parseInt($("#cd_amount").val()) || 0; + var premium_amount = parseInt($("#premium_amount").val()) || 0; + + var total_amount = (cd_amount + premium_amount); + $("#total_amount").val(total_amount); + + + }); + + $("#is_cd_switch").change(function (){ + var switch_status = ($("#is_cd_switch").is(":checked")? "on" : "off"); + console.log("Switch status",switch_status); + if (switch_status == "on"){ + + $("#cd_amount").show(); + $("#total_amount").show(); + $("#cd_amount").closest('.form-group').show(); + $("#total_amount").closest('.form-group').show(); + + }else{ + + $("#cd_amount").hide(); + $("#total_amount").hide(); + $("#cd_amount").closest('.form-group').hide(); + $("#total_amount").closest('.form-group').hide(); + + } + }) + + $("#is_installment_switch").change(function (){ + + var switch_status = ($(this).is(":checked")? "on" : "off"); + console.log("Switch status",switch_status); + if (switch_status == "on"){ + $("#no_of_installment").show(); + $("#payment_date").hide(); + $("#utr_no").hide(); + $("#no_of_installment").closest('.form-group').show(); + $("#payment_date").closest('.form-group').hide(); + $("#utr_no").closest('.form-group').hide(); + let $installmentContainer = $('#installment_form_row'); + let row_count = $installmentContainer.find('.form-row').length; + + if (row_count == 0 ) { addInstallmentHTML()} + // addInstallmentHTML() + }else{ + console.log("inside else") + + let $installmentContainer = $('#installment_form_row'); + let row_count = $installmentContainer.find('.form-row').length; + let remove_count = $("#no_of_installment").val(); + console.log("row count",row_count); + if (row_count > 0 ) { + let ids = $installmentContainer.find('.form-row').slice(-remove_count).find('input[name="installment_primary_key[]"]').map(function() { + return $(this).val(); + }).get(); + Swal.fire({ + title: "Do you want to remove all the entries?", + icon: "warning", + showCancelButton: true, + confirmButtonColor: "#3085d6", + cancelButtonColor: "#d33", + confirmButtonText: "Yes, Proceed!" + }).then((result) => { + if (result.isConfirmed) { + let url = ''; + let requestData = { id: ids }; + + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + + sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) { + console.log('Data fetched successfully:', response); + + if (response.status === true) { + toastr.success(response.message, 'SUCCESS'); + $("#no_of_installment").hide(); + $("#payment_date").show(); + $("#utr_no").show(); + $("#no_of_installment").closest('.form-group').hide(); + $("#payment_date").closest('.form-group').show(); + $("#utr_no").closest('.form-group').show(); + $('#installment_form_row').empty(); + $('#no_of_installment').val(""); + } else { + toastr.error(response.message, 'WARNING'); + } + + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + + }, function(xhr, status, error) { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + console.error('Error fetching data:', error); + console.error(xhr.responseText); + toastr.error('An error occurred while removing the installment.', 'ERROR'); + }); + }else{ + // alert("Inside else"); + $('#no_of_installment').val(row_count); + // $("#is_installment_switch").bootstrapToggle('on'); + // $('#is_installment_switch').val('1').change(); + // $('#is_installment_switch').bootstrapToggle('on'); + // $('#is_installment_switch').prop('checked', true).trigger('change'); + $('#is_installment_switch').trigger('click'); // in some cases, this forces the CSS to update + + + } + }); + } + + } + }) + + $('#no_of_installment').on('change', function () { + let no_of_installments = parseInt($(this).val()); + let $installmentContainer = $('#installment_form_row'); + let row_count = $installmentContainer.find('.form-row').length; + + console.log("Form row count:", row_count); + + if (row_count === 1) { + // $installmentContainer.empty(); + for (let index = 0; index < no_of_installments - 1; index++) { + addInstallmentHTML(); + } + } else if (no_of_installments === row_count) { + console.log('Same row count, no change needed.'); + } else if (no_of_installments < row_count) { + + // Remove extra rows from the end + let remove_count = row_count - no_of_installments; + let ids = $installmentContainer.find('.form-row') + .slice(-remove_count) + .find('input[name="installment_primary_key[]"]') + .map(function() { + return $(this).val(); + }).get(); + + console.log('ids', ids); + + if (Object.keys(ids).length > 0) { + Swal.fire({ + title: "Do you want to remove the last " + (remove_count ?? "") + " entries?", + icon: "warning", + showCancelButton: true, + confirmButtonColor: "#3085d6", + cancelButtonColor: "#d33", + confirmButtonText: "Yes, Proceed!" + }).then((result) => { + if (result.isConfirmed) { + let url = ''; + let requestData = { id: ids }; + + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + + sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) { + console.log('Data fetched successfully:', response); + + if (response.status === true) { + toastr.success(response.message, 'SUCCESS'); + $installmentContainer.find('.form-row').slice(-remove_count).remove(); + } else { + toastr.error(response.message, 'WARNING'); + } + + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + + }, function(xhr, status, error) { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + console.error('Error fetching data:', error); + console.error(xhr.responseText); + toastr.error('An error occurred while removing the installment.', 'ERROR'); + }); + }else{ + $('#no_of_installment').val(row_count); + } + }); + } else { + $installmentContainer.find('.form-row').slice(-remove_count).remove(); + } + + } else if (no_of_installments > row_count) { + // Add extra rows from the end + let add_count = no_of_installments - row_count; + for (let index = 0; index < add_count; index++) { + addInstallmentHTML(); + } + } else { + // Add missing rows + let add_count = no_of_installments - row_count; + for (let index = 0; index < add_count; index++) { + addInstallmentHTML(); + } + } + }); + + function addInstallmentHTML() { + let html = ` +
    +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + +
    +
    + `; + + $('#installment_form_row').append(html); + + $('.payment_date').flatpickr({ + dateFormat: 'd/m/Y', + }); + } + + $(document).ready(function(){ + setTimeout(function(){ + $('.payment_date').flatpickr({ + dateFormat: 'd/m/Y', + }); + }, 2000) + + // $('#is_installment_switch').bootstrapToggle(); + + }) + + $(document).on('click', '.remove-installment', function () { + let $this = $(this); // Store reference to the clicked element + let row_count = $('#installment_form_row .form-row').length; + console.log("row_count", row_count); + + let id = $this.closest('.form-row').find('input[name="installment_primary_key[]"]').val() ?? null; + console.log("id", id); + let ids = id ? [id] : []; + console.log("ids", ids); + + if (id != null && row_count > 1) { + Swal.fire({ + title: "Do you want to remove this?", + icon: "warning", + showCancelButton: true, + confirmButtonColor: "#3085d6", + cancelButtonColor: "#d33", + confirmButtonText: "Yes, Proceed!" + }).then((result) => { + if (result.isConfirmed) { + let url = ''; + let requestData = { id: ids }; + + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + + sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) { + console.log('Data fetched successfully:', response); + + if (response.status === true) { + toastr.success(response.message, 'SUCCESS'); + + $this.closest('.form-row').remove(); + let updated_row_count = $('#installment_form_row .form-row').length; + $('#no_of_installment').val(updated_row_count); + console.log("after remove row_count", updated_row_count); + } else { + toastr.error(response.message, 'WARNING'); + } + + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + + }, function(xhr, status, error) { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + console.error('Error fetching data:', error); + console.error(xhr.responseText); + toastr.error('An error occurred while removing the installment.', 'ERROR'); + }); + } + }); + } else { + if (row_count > 1) { + $this.closest('.form-row').remove(); + let updated_row_count = $('#installment_form_row .form-row').length; + $('#no_of_installment').val(updated_row_count); + console.log("after remove row_count", updated_row_count); + } else { + console.log("Only one row left. Not removing."); + } + } + }); From 239c55a7e552500b989eea1041716aa1eee88725 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 13 May 2025 18:49:03 +0530 Subject: [PATCH 097/169] FEAT_GPA_AUTO_TSA_FIX_DEMOGRAPHY : RV --- app/Controllers/ClientController.php | 4 +- app/Controllers/EmployeeController.php | 2 + app/Controllers/LeadsController.php | 75 +++++++++++++++++++- app/Views/leads_form_handler.php | 9 ++- app/Views/view_rfq.php | 41 ++++++++++- public/sample_excel/Sample_Member_Data.xlsx | Bin 0 -> 19847 bytes public/sample_excel/enrollment.xlsx | Bin 7754 -> 89706 bytes 7 files changed, 127 insertions(+), 4 deletions(-) create mode 100644 public/sample_excel/Sample_Member_Data.xlsx diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index a490bddc..9bf373ce 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4685,7 +4685,7 @@ class ClientController extends AdminController // ------------- LEADS CONTROLLER ---------------------------------------------------------- - // $LeadsController = new LeadsController(); + $LeadsController = new LeadsController(); // $RFQModel = new RFQModel(); // $data = $RFQModel->where('is_active', 1)->where('lead_id', 40)->first(); @@ -4699,6 +4699,8 @@ class ClientController extends AdminController // $returndata = $LeadsController->convertQCRJsonToPolicyTerms($jsonArray, $policy_type, $proposel_name, $insurer_name); // dd($returndata); + $LeadsController->handleMemberDataGPATotalSumInsurerFromExcel(['lead_id' => 169]); + // -----------BDS REPORT CONTROLLER--------------------------------------------------------------------------------- // $BDSReportController = new BDSReportController(); diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index a11921fb..0bcc03c5 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -444,6 +444,8 @@ class EmployeeController extends AdminController $filePath = ROOTPATH . 'public/sample_excel/enrollment.xlsx'; }else if ($actionType == 'missed_inception') { $filePath = ROOTPATH . 'public/sample_excel/sample_inception.xls'; + }else if ($actionType == 'member_data') { + $filePath = ROOTPATH . 'public/sample_excel/Sample_Member_Data.xlsx'; } // Check if the file exists diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index b001edf1..199c8d3b 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -712,6 +712,12 @@ class LeadsController extends BaseController $subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}}"; } + if($lead_data['policy_type_id'] == 1){ + $data['totalSumAssured'] = $this->handleMemberDataGPATotalSumInsurerFromExcel(['lead_id' => $id]); + }else{ + $data['totalSumAssured'] = []; + } + $data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']); $data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']); @@ -1762,7 +1768,7 @@ class LeadsController extends BaseController ['file_path' => WRITEPATH . 'uploads/lead_files/' . $lead_data['file_name'], 'sheets' => [0, 1]], ['file_path' => WRITEPATH . '/uploads/lead_files/' . $result['filename'], 'sheets' => []], ]; - $outputPath = WRITEPATH . 'uploads/lead_files/Member_Data.xlsx'; + $outputPath = WRITEPATH . 'uploads/lead_files/' .$lead_data['file_name']; $result_merge = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath); if ($result_merge) { // Call the delete function after the file is successfully created @@ -4077,4 +4083,71 @@ class LeadsController extends BaseController return $attachments; } + + public function handleMemberDataGPATotalSumInsurerFromExcel($params) + { + $lead_id = $params['lead_id']; + $lead_data = $this->leadsModel->find($lead_id); + // dd($lead_data); + $file_name_with_path = WRITEPATH . "/uploads/lead_files/" . $lead_data['file_name']; + // dd($file_name_with_path); + + if (!$lead_data) { + return ['status' => 'failed', 'message' => 'Lead data not found']; + } + + if ($lead_data['file_name']) { + + //check physical file + if (!file_exists($file_name_with_path)) { + + $message = "Lead Physcial file not found"; + $this->myLogger->logme('error', ($message . ' for file ' . $file_name_with_path)); + return ['status' => 'failed', 'message' => 'no physical file']; + } + + $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path); + + //get members data + $members_sheet = $spreadsheet->getSheet(0); + $highestRowAndColumn = $members_sheet->getHighestRowAndColumn(); + // dd($highestRowAndColumn); + + $uncleaned_members = $members_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); + // dd($uncleaned_members); + + $members = ExcelSanitizeHelper::sanitizeArrayData($uncleaned_members); + // dd($members); + + + // Check column headings + $members_heading = $members[0]; + $available_col = []; + + $lower_headers = array_map('strtolower', $members_heading); + foreach ($lower_headers as $index => $header) { + if (preg_match('/^sa\s*-\s*option\s*\d*$/i', $header)) { + $column_name = $members_heading[$index]; + $sum = 0; + + for ($i = 1; $i < count($members); $i++) { + $cell_raw = $members[$i][$index] ?? ''; + $cell_clean = preg_replace('/[^0-9.\-]/', '', $cell_raw); // remove non-numeric chars + + if ($cell_clean !== '' && is_numeric($cell_clean)) { + $sum += (float) $cell_clean; + } + } + + $available_col[] = $sum; + } + } + + + // dd($available_col); + return $available_col; + } + + return []; + } } diff --git a/app/Views/leads_form_handler.php b/app/Views/leads_form_handler.php index c6f463df..363baef6 100644 --- a/app/Views/leads_form_handler.php +++ b/app/Views/leads_form_handler.php @@ -346,14 +346,21 @@ if (isset($selected_lead_type)) { let placeholder = isFirstField ? 'First file must be Demography.' : ''; let accept = isFirstField ? '.xls,.xlsx' : ''; + if(selected_lead_form_type != 1){ placeholder = ''; accept = ''; } + + let sample_dwn_link = ""; + if(selected_lead_form_type == 1 && isFirstField == 1){ + sample_dwn_link = ' [ " id="excel_download" data-toggle="tooltip" data-placement="top" title="Download Sample Excel">Sample Excel ]'; + } + div.innerHTML = `
    - +
    diff --git a/app/Views/view_rfq.php b/app/Views/view_rfq.php index 7ddfa80a..86deabef 100644 --- a/app/Views/view_rfq.php +++ b/app/Views/view_rfq.php @@ -635,6 +635,7 @@ var user_role_id = ; var jsonDataForHide = null; var multi_file_data = []; + var totalSumAssuredData = []; const editorConfig = { buttons: [ @@ -708,6 +709,9 @@ let qcr_count = ; let question_json = ; let policy_terms_json = ; + totalSumAssuredData = ; + console.log('totalSumAssuredData', totalSumAssuredData); + console.log('totalSumAssuredData.type', typeof totalSumAssuredData); // console.log('policy_terms_json', policy_terms_json); data = JSON.parse(data); @@ -1236,7 +1240,7 @@ function addSuggestionsToTable() { particularsCell.innerText = details.display_values; const columnCount = $("#rfqTable thead tr th").length; - console.log('columnCount' + columnCount); + // console.log('columnCount' + columnCount); for (let i = 3; i < columnCount - 6; i++) { @@ -1333,8 +1337,43 @@ function addSuggestionsToTable() { moveAddRowButton(); hideQCR(); isFormDataModified = false; + processTotalSumInsured(totalSumAssuredData) + } +function processTotalSumInsured(data) { + let values = []; + + if (Array.isArray(data)) { + data.forEach((value, index) => { + console.log('total - value', value); + if (index !== 0) { + $('#addQuote').click(); + } + }); + values = data + } else if (typeof data === 'object' && data !== null) { + $.each(data, function(key, value) { + console.log('total - value', value); + if (key != 0) { + $('#addQuote').click(); + } + }); + values = Object.values(data) + } else { + console.log("Data is not iterable."); + return; + } + + // Set values in td.editablecolumns in order + $('#totalSumInsured .editablecolumns').each(function(index) { + if (values[index] !== undefined) { + $(this).text(values[index]); + } + }); +} + + // Function to move add row button to last row function moveAddRowButton() { diff --git a/public/sample_excel/Sample_Member_Data.xlsx b/public/sample_excel/Sample_Member_Data.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..3adbcef7c4d8e3b514cb8f93838aa63ea727e2e2 GIT binary patch literal 19847 zcmeIaWmq0v(k+a;CAfz`a3{D0cXxMpcTMo%?gV#t*WeDpAwY1KpaD+b$(%FKJm34y zb$#=DI#&przV}Mis#UeCo8B!i1qp=#1_uWR#$i~l3HFx*5BT2QnnBOe#M+6$&Cb!v z(9X_^-rdHU9`uurxKYbKMl_MzdjzIO^~T2>jM1e8!A6@0a6uw1@zm zz=K}rce|2KX96tqyG8{4_=?9JO7g~>aL!-ZJB~2gkBJuCs!P=7(NWT75GLe>#T|#QduCyeSP>Uyd1{xJUtQ3OPa6|oyXtG;b z|NfD^ij=DpjfC^3A@kfE3C$gSv|;Q!mY8JRk$1RniD5odgc|W;`!yKhf$0%@;RQ))qGy$s3#SY|-K?0V7#HB z$FO>3y6ea2tPqN%%EhgmQw`1ZhV!+TR`_!5Ks(y&EG+?|s-x)kx6AO!xL4SA_5An@ zJ4?^?hAe9 zam6~!aZx-Cnu&he!uBcH)va3>KMhl-+WN+D5*~ie%HOe@p31&~ z8@Q2%;T*8`8Tmj@NRd6W+?2QL_Eq!OZ#hwaQAB$U0S4CaZ{>vkM^4V>CN?GvzrQkp zvTt6k$1$A|t>c#FeJeWzzV&(k1W8Fz$jwYW@taRzta18e?@C@e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PaWWmsp6^KdqQDf!-Hs zSAOm-emiB^3s3Vmd+ASz8%k3#Sn!WAkd8f8r6<-El>+R9X%F^y^(bMhO#zEWo+P+NY#zuQ* zb%>0YFT0$cM^{T1r#IKQ!CBUNVpFtTcf?UTD)G(P-P-BN_|4|EVqbDsSLgHTXo(W= zIAUd0ax~;I;^lnyt)DmE#ldJ_c9(C>lb+w2wVy}%eEQ4p{Q!txpJbkZ%`P9iAb>}T z!67if{`sz{zrIun^scFYJ^uGMPyHR|uW!=uwLwZk&G}IexH3uw$z5;XchoU4|! literal 0 HcmV?d00001 diff --git a/public/sample_excel/enrollment.xlsx b/public/sample_excel/enrollment.xlsx index 0666a6c87688e2c80785c4969af5d8cce4abf933..97cd3191d28915a6893bc17bd6223f18780690e6 100755 GIT binary patch literal 89706 zcmeIa2{_d2|Nk!(S||~xjV5J^kQ7psCB#%mMH^0w+=_;wkY()4jS(#hWftA0jgpcq zQ=&~Fl4Q#^#$NVimfv(fpWpX;&i8kI=hHdo`u(r2>;Inj)$^YF9`}3R^Sqz0$Ne64 zwaZFOTuww%Qc|RwaQlGBZypPU&wX4q9Z62Eo|@i7(#a!4;zizR6iX(ew?I7b{VtMTBJs&4Bp z*uCqRzNFXl+N&q!{d=3PIsCHs?dvt8$<+$k_R0xo7O%Sdre*JT?FABqD>9s_^sgS3 zslT{7RUXeecwuOh<7>SSLEYPSyPlZtv0Fj;Oh%C4-6)~@r$c_8ij`lN%zEXbaGpw8 zlO5vdvoc0KI=CS1u%Xk8*4^=5b3C5M_bTlEM4ou08uPMNoV;h|*wCilR^KX(+mwAQ zPwN-!Gmlw27Qfl<>q)B7-DM>qSyZ|4r_VwcZitGA?E1g@B=awye(O-&?t0QEt+@dM zc0R+>MeeJ#F3(=?lX#_RW%{f8u37h>x^Mc5EgN}bnNF#w+HiPUdLgH`uCcA-ZQiA( zb&6^^aKGN{%Mz<=!*@+x4)C*(SjXPqe)F@9T2$S1_5A&X2e0MmA3LD5>1>wko7E-9 zTc$Q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U+!`SSAodh4kFt%%4n15!a*@5~0e@dkMMxIXgqbma+jcl%G^pYrAtEJT0 z^YQj>(%g4rBKZrIMu7Nk24wt=`qOul{)L(#hTX>_`>)R1$HXa@?triFOy6Z7e>7K8 zgohcB?YG%K9S+eS7ytkULOiel(*H*NdAbPyLP?S%f-Qh_zYiE9#{x)&@|*(EXaW3Z d(6NdC=KJrdIa0#Li9rYhOCTWz6ZJ2X{{zzt Date: Wed, 14 May 2025 15:50:27 +0530 Subject: [PATCH 098/169] FEAT_PLACELEMNT_CRON --- app/Config/Routes.php | 3 + app/Controllers/MasterController.php | 2 +- .../PolicyTransactionController.php | 115 ++- app/Models/BdsPlacementModel.php | 93 ++ app/Models/TicketMasterModel.php | 2 +- app/Views/leads_form.php | 1 + app/Views/leads_form_handler.php | 5 + app/Views/leads_non_eb.php | 875 +++++++++--------- app/Views/rfq/claims_details_non_eb.php | 20 +- 9 files changed, 684 insertions(+), 432 deletions(-) create mode 100644 app/Models/BdsPlacementModel.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 1527b8cc..ef4c655c 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -360,6 +360,9 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get('removeInstallments', 'LeadsController::removeInstallments'); }); +$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail"); +$routes->cli("cli/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail"); + $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { $routes->group("inception", ["filter" => "authMVC"], function ($routes) { diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index fa094bb8..0a3c357d 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -1680,7 +1680,7 @@ class MasterController extends AdminController ["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"], ["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"] ]; - $email_id = 'srinivas.saravanan@venbainfotech.com'; + $email_id = ['srinivas.saravanan@venbainfotech.com','srinivassaravanan2002@gmail.com']; $params = ['mail'=>$email_id]; $common = ['mail_type'=>'test_mail_cli']; // $bcc = "vijayalakshmi@nhanceindia.in,vitvelz@gmail.com,velmurugan.s@venbainfotech.com,hariharan@nhanceindia.in,hariharan@jubiliant.in,srinivas.saravanan@venbainfotech.com"; diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index d0242215..d7270335 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -32,10 +32,13 @@ use App\Models\InvPaymentDetailsModel; use App\Models\BatchFileModel; use App\Models\FileModel; use App\Models\COShareStmtDetailsModel; -use Kint; +use App\Models\BdsPlacementModel; +use Kint\Kint; +use App\Helpers\MailHelper; +use Exception; class PolicyTransactionController extends BaseController -{ +{ use ResponseTrait; protected $myLogger; @@ -64,6 +67,7 @@ class PolicyTransactionController extends BaseController protected $batchFileModel; protected $filesModel; protected $coShareStmtDetailsModel; + protected $BdsPlacementModel; public function __construct() { @@ -94,6 +98,7 @@ class PolicyTransactionController extends BaseController $this->batchFileModel = new BatchFileModel(); $this->filesModel = new FileModel(); $this->coShareStmtDetailsModel = new COShareStmtDetailsModel(); + $this->BdsPlacementModel = new BdsPlacementModel(); $this->invoiceStatus = [ 'pending' => 'Pending', 'generated' => 'Generated', @@ -182,8 +187,7 @@ class PolicyTransactionController extends BaseController $issuer, $status ); - - }else{ + } else { $ids = $this->request->getPost('ids'); $ids = array_filter(explode(',', $ids)); @@ -1831,7 +1835,7 @@ class PolicyTransactionController extends BaseController if (isset($isFromDashboard) && !empty($isFromDashboard) && $isFromDashboard == 1) { $ids = $this->request->getPost('ids'); - + $ids = array_filter(explode(',', $ids)); if (!empty($ids)) { @@ -2801,4 +2805,105 @@ class PolicyTransactionController extends BaseController ->update(); return $this->respond(['dataStatus' => true, 'code' => 200], 200); } + + public function sendInstallmentRemainderMail() + { + + $this->myLogger->logme("error", "Cron Job For Send Installment Remainder Mail Started"); + + try { + + try { + + $bdsInstallmentData = $this->BdsPlacementModel->getClientInstallmentDetails(); + + }catch (Exception $e) { + + $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); + + if (empty($bdsInstallmentData)) { + + $this->myLogger->logme("error", "No Client Installment is Due in the 15th Day"); + + return false; + } + + foreach ($bdsInstallmentData as $installmentData) { + + $mailData = $this->PrepareBDSMailData($installmentData); + $to_mail = $mailData['to_mail']; + $message = $mailData['message']; + $subject = $mailData['subject']; + + $this->myLogger->logme("error", "Installment Pending for" . $subject); + + $common = ['mail_type' => 'installment_amount_due_remainder_mail']; + + $res = MailHelper::send_email(['mail' => $to_mail, 'subject' => $subject, 'message' => $message, 'common' => $common]); + + $res = json_decode($res); + $this->myLogger->logme('error', 'res: ' . json_encode($res)); + + if ($res->status == 'success') { + return true; + } else { + return false; + } + } + } catch (Exception $e) { + + $this->myLogger->logme('error', 'Exception: ' . $e->getMessage() . 'Page: ' . $e->getFile() . ' Line: ' . $e->getLine()); + } + } + + protected function PrepareBDSMailData($data) + { + + try { + + $installment_amount = $data['installment_amount']; + $payment_date = date('d-m-Y', strtotime($data['payment_date'])); + $client = $data['client_name']; + $branch = $data['branch_name']; + $sales_person_mail = $data['sales_person']; + $heads = $data['heads']; + $admins = $data['admins']; + $buisness_team = $data['buisness_team']; + $policy_no = $data['policy_no']; + $client_short_name = isset($data['short_name']) && $data['short_name'] != null ? $data['short_name'] : $data['client_name']; + + $subject = "Installment Amount Due For Client - {$client_short_name} - Policy NO({$policy_no}) is Due On - {$payment_date}"; + + $message = "Policy Installment for Client - {$client}, Branch - {$branch} is Due on {$payment_date} + with amount of {$installment_amount}.
    + Policy No : {$policy_no}"; + + + $to_mail = array_merge( + array_column($heads, 'email'), + array_column($admins, 'email'), + array_column($buisness_team, 'email'), + [$sales_person_mail] + ); + + $to_mail = array_unique($to_mail); + + $this->myLogger->logme("error", "Selected To Address : " . json_encode($to_mail)); + + // dd($to_mail); + return [ + 'to_mail' => $to_mail, + 'message' => $message, + 'subject' => $subject + ]; + + } catch (Exception $e) { + + $this->myLogger->logme('error', 'Exception: ' . $e->getMessage() . 'Page: ' . $e->getFile() . ' Line: ' . $e->getLine()); + } + } } diff --git a/app/Models/BdsPlacementModel.php b/app/Models/BdsPlacementModel.php new file mode 100644 index 00000000..2cd7c6f4 --- /dev/null +++ b/app/Models/BdsPlacementModel.php @@ -0,0 +1,93 @@ +db->table("bds_installment_payment_details bipd") + ->select("bipd.*, ct.client_name,ct.short_name, cb.branch_name, leads.salse_person_id,cp.policy_no") + ->join("policy_transaction pt", "pt.id = bipd.pt_id") + ->join("clients ct", "ct.id = pt.client_id") + ->join("client_branch cb", "cb.id = pt.client_branch_id") + ->join("leads", "leads.id = bipd.lead_id") + ->join("client_policy cp","cp.id = pt.client_policy_id") + ->where("bipd.is_active", 1) + ->where("bipd.payment_date", date('Y-m-d', strtotime('+15 days'))); + + $data = $builder->get()->getResultArray(); + + // Loop through to extract sales person details + foreach ($data as &$row) { + $sales_person_ids = json_decode($row['salse_person_id'], true); + $sales_person_id = $sales_person_ids[0] ?? null; + + if ($sales_person_id) { + $user = $this->db->table('user_profiles') + ->select('email') // or whatever field + ->where('id', $sales_person_id) + ->get() + ->getRowArray(); + + $row['sales_person'] = $user['email'] ?? 'N/A'; + } else { + $row['sales_person'] = 'Not Assigned'; + } + + $head = $this->db->table('user_profiles') + ->select('email') // or whatever field + ->where('role', 5) + ->where('is_active',1) + ->get() + ->getResultArray(); + + + $row['heads'] = $head; + + $admin = $this->db->table('user_profiles') + ->select('email') + ->where("is_active",1) + ->where("role",1) + ->get() + ->getResultArray(); + + $row['admins'] = $admin; + + $buisenessTeam = $this->db->table("user_teams ut") + ->select("up.email") + ->join('user_profiles up','up.id = ut.user_id and up.is_active = 1') + ->where("ut.team_id",7) + ->where("ut.is_active",1) + ->get() + ->getResultArray(); + + $row['buisness_team'] = $buisenessTeam; + + + } + + + return $data; + } +} diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 62a5e101..b85dad62 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -541,7 +541,7 @@ class TicketMasterModel extends Model AND th.is_active = 1), tm.created_at )) BETWEEN 13 AND 20 THEN "13-20 Days" - ELSE "Above 20 Days"g + ELSE "Above 20 Days" END AS tat_category', 'COUNT(*) AS count' ]) diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 265d1f32..25044797 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -777,6 +777,7 @@ console.log(response.message, 'SUCCESS'); $('#appendArea_' + dataIncrement).append(response.data); + console.log("Policy Type ID : ",policy_type_id); if (policy_type_id == 1 || policy_type_id == 6 || policy_type_id == 7) { let newId = 'appendAreaForClaim_' + dataIncrement; diff --git a/app/Views/leads_form_handler.php b/app/Views/leads_form_handler.php index 11ba47a7..f796ee6e 100644 --- a/app/Views/leads_form_handler.php +++ b/app/Views/leads_form_handler.php @@ -719,6 +719,11 @@ if (isset($selected_lead_type)) { $('#policy_type_id').val(data.policy_type_id || '').select2(); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); + $(".loss_date").each(function () { + flatpickr(this, { + dateFormat: "d-m-Y", + }); + }); }, 1000); }, 1000); }, 2000); diff --git a/app/Views/leads_non_eb.php b/app/Views/leads_non_eb.php index 0dc0d785..9c826359 100644 --- a/app/Views/leads_non_eb.php +++ b/app/Views/leads_non_eb.php @@ -1,41 +1,41 @@ @@ -233,8 +233,8 @@ hr.solid { " . $value['policy_type'] .""; + if (in_array($value['allocg'], ["Non-EB", "Marine"])) { + echo ""; } } } @@ -247,11 +247,11 @@ hr.solid {
    @@ -260,13 +260,19 @@ hr.solid {
    --> @@ -308,11 +314,11 @@ hr.solid {
    @@ -355,60 +361,83 @@ hr.solid {
    \ No newline at end of file diff --git a/app/Views/rfq/claims_details_non_eb.php b/app/Views/rfq/claims_details_non_eb.php index 9a7b590b..04592201 100644 --- a/app/Views/rfq/claims_details_non_eb.php +++ b/app/Views/rfq/claims_details_non_eb.php @@ -13,6 +13,21 @@ } ?>
    +
    + + +
    +
    + + +
    +
    + + +
    -
    - - -
    Date: Wed, 14 May 2025 17:28:53 +0530 Subject: [PATCH 099/169] FIX_FILE_UPLOAD : RV --- app/Helpers/utility_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index 33f504c0..0d4529c3 100755 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -55,8 +55,8 @@ if (!function_exists('file_Upload')) { function file_Upload($fileToUpload, $filepath) { if ($fileToUpload !== null && $fileToUpload->isValid() && !$fileToUpload->hasMoved()) { + $fileToUpload->move($filepath); $fileName = $fileToUpload->getName(); - $fileToUpload->move($filepath, $fileName); return $fileName; } else { return ""; From 3f0003224f16d94b064577dfce1dfd3ae85174e3 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 16 May 2025 10:47:15 +0530 Subject: [PATCH 100/169] CHANGE_CLIENT_FROM_LEADS : RV --- app/Controllers/LeadsController.php | 199 ++++++++++-------- .../PolicyTransactionController.php | 34 +-- app/Views/client_list.php | 53 ++++- 3 files changed, 170 insertions(+), 116 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 617add8f..fdeca47e 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -602,8 +602,8 @@ class LeadsController extends BaseController return $this->respond(['status' => false, 'message' => 'File could not be removed.'], 200); } } - //--------RFQ----------------------------------------------------------------------------------------------- + //--------RFQ----------------------------------------------------------------------------------------------- public function viewRFQ($id, $type = 1) { @@ -2538,64 +2538,103 @@ class LeadsController extends BaseController public function featchLeadDataAndInsertClient($lead_id) { - $data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first(); + try { + $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); + if (!$data) { + $this->myLogger->logme('featchLeadDataAndInsertClient', "Lead not found or inactive", ['lead_id' => $lead_id]); + return $this->respond(['status' => false, 'message' => 'Failed to create Client', 'data' => null], 200); + } + + $result = $this->createClientWithLeadData($data); + + if ($result) { + $policy_data = $this->clientPolicyModel->where('client_id', $result)->where('is_active', 1)->first(); + return $this->respond([ + 'status' => true, + 'message' => 'New Client created successfully', + 'client_id' => $result, + 'data' => $data, + 'client_policy_id' => $policy_data['id'] ?? null, + ], 200); + } + + $this->myLogger->logme('featchLeadDataAndInsertClient', "Client creation failed after processing", ['lead_id' => $lead_id]); + return $this->respond(['status' => false, 'message' => 'Failed to create client', 'data' => $data], 200); + } catch (\Throwable $e) { + $this->myLogger->logme('featchLeadDataAndInsertClient', $e->getMessage(), ['lead_id' => $lead_id, 'trace' => $e->getTraceAsString()]); + return $this->respond(['status' => false, 'message' => 'Internal server error', 'error' => $e->getMessage()], 500); } - - $result = $this->createClientWithLeadData($data); - - if ($result) { - - $policy_data = $this->clientPolicyModel->where('client_id', $result)->where('is_active', 1)->first(); - return $this->respond(['status' => true, 'message' => 'New Client created successfully', 'client_id' => $result, 'data' => $data, 'client_policy_id' => $policy_data['id']], 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); + try { + $client_data = $this->prepareClientData($data); + $client_id = $this->clientModel->insert($client_data); - if ($client_id) { - $this->createClientBranchAndContactWithLeadData($data, $client_id); - $this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update(); + if ($client_id) { + $this->createClientBranchAndContactWithLeadData($data, $client_id); + $this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update(); + } + + return $client_id; + } catch (\Throwable $e) { + $this->myLogger->logme('createClientWithLeadData', $e->getMessage(), ['lead_id' => $data['id'], 'trace' => $e->getTraceAsString()]); + return false; } + } - return $client_id; + public function createClientBranchAndContactWithLeadData($data, $client_id) + { + try { + $branch_data = $this->prepareClientBranchData($data, $client_id); + $branch_id = $this->clientBranchModel->insert($branch_data); + + if ($branch_id) { + $this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update(); + $contact_data = $this->prepareContactData($data, $branch_id); + $this->levelContactModel->insert($contact_data); + $this->createClientPolicyWithLeadData($data, $client_id, $branch_id); + } + + return $branch_id; + } catch (\Throwable $e) { + $this->myLogger->logme('createClientBranchAndContactWithLeadData', $e->getMessage(), ['lead_id' => $data['id'], 'trace' => $e->getTraceAsString()]); + return false; + } + } + + public function createClientPolicyWithLeadData($data, $client_id, $branch_id) + { + try { + $client_policy_data = $this->prepareClientPolicyData($data, $client_id, $branch_id); + $client_policy_id = $this->clientPolicyModel->insert($client_policy_data); + + if ($client_policy_id) { + $this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update(); + $this->leadsModel->where('id', $data['id'])->set('is_policy_created', $client_id)->update(); + } + + return $client_policy_id; + } catch (\Throwable $e) { + $this->myLogger->logme('createClientPolicyWithLeadData', $e->getMessage(), ['lead_id' => $data['id'], 'trace' => $e->getTraceAsString()]); + return false; + } } 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'], + 'client_type' => $data['client_type'] ?? null, + 'entity_type_id' => $data['entity_type_id'] ?? null, + 'client_code' => $data['client_code'] ?? null, + 'client_name' => $data['client_name'] ?? null, + 'short_name' => $data['client_short_name'] ?? null, + 'pan' => $data['pan'] ?? null, ]; } - public function createClientBranchAndContactWithLeadData($data, $client_id) - { - $branch_data = $this->prepareClientBranchData($data, $client_id); - $branch_id = $this->clientBranchModel->insert($branch_data); - - if ($branch_id) { - $this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update(); - $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'] ?? ''), '-'); @@ -2620,19 +2659,6 @@ class LeadsController extends BaseController ]; } - public function createClientPolicyWithLeadData($data, $client_id, $branch_id) - { - $client_policy_data = $this->prepareClientPolicyData($data, $client_id, $branch_id); - $client_policy_id = $this->clientPolicyModel->insert($client_policy_data); - - - if ($client_policy_id) { - $this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update(); - } - - return $client_policy_id; - } - private function prepareClientPolicyData($data, $client_id, $branch_id) { $proposel_data = json_decode($data['proposel_data'], true); @@ -2682,17 +2708,46 @@ class LeadsController extends BaseController private function preparePolicyTermsFromRFQ($data) { - $proposel_data = json_decode($data['proposel_data'], true); + try { + $proposel_data = json_decode($data['proposel_data'], true); + $QCRData = $this->RFQModel->where('is_active', 1)->where('lead_id', $data['id'])->first(); - $QCRData = $this->RFQModel->where('is_active', 1)->where('lead_id', $data['id'])->first(); + if (!$QCRData) { + throw new \Exception('RFQ Data not found'); + } - $JSON = json_decode($QCRData['json'], true); + $JSON = json_decode($QCRData['json'], true); + $converted_json = $this->transformProposelData($JSON, $proposel_data['proposel_name'], $proposel_data['insurer_name']); - $converted_json = $this->transformProposelData($JSON, $proposel_data['proposel_name'], $proposel_data['insurer_name']); - - return $this->convertQCRJsonToPolicyTerms($converted_json, $data['policy_type_id'], $proposel_data['proposel_name'], $proposel_data['insurer_name']); + return $this->convertQCRJsonToPolicyTerms($converted_json, $data['policy_type_id'], $proposel_data['proposel_name'], $proposel_data['insurer_name']); + } catch (\Throwable $e) { + $this->myLogger->logme('preparePolicyTermsFromRFQ', $e->getMessage(), ['lead_id' => $data['id'], 'trace' => $e->getTraceAsString()]); + return null; + } } + public function featchClientPolicyFromLead($client_id, $branch_id, $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 policy', 'data' => null], 200); + } + + $result = $this->createClientPolicyWithLeadData($data, $client_id, $branch_id); + // print_r($result); die; + + if ($result) { + + $policy_data = $this->clientPolicyModel->where('id', $result)->where('is_active', 1)->first(); + return $this->respond(['status' => true, 'message' => 'New Policy created successfully', 'client_policy_id' => $result, 'data' => $data, 'client_id' => $policy_data['client_id']], 200); + } + + return $this->respond(['status' => false, 'message' => 'Failed to create policy', 'data' => $data], 200); + } + + // --------------------------------------------------------------------------------------------------------------- + //Function for convert the RFQ and QCR Json to Policy Terms Json public function convertQCRJsonToPolicyTerms($data, $policy_type, $proposel_name, $insurer_name) { @@ -2817,26 +2872,6 @@ class LeadsController extends BaseController } } - public function featchClientPolicyFromLead($client_id, $branch_id, $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 policy', 'data' => null], 200); - } - - $result = $this->createClientPolicyWithLeadData($data, $client_id, $branch_id); - // print_r($result); die; - - if ($result) { - - $policy_data = $this->clientPolicyModel->where('id', $result)->where('is_active', 1)->first(); - return $this->respond(['status' => true, 'message' => 'New Policy created successfully', 'client_policy_id' => $result, 'data' => $data, 'client_id' => $policy_data['client_id']], 200); - } - - return $this->respond(['status' => false, 'message' => 'Failed to create policy', 'data' => $data], 200); - } - public function getPlacementJson(array $data): ?string { $proposel_data = json_decode($data['proposel_data'], true); @@ -2929,7 +2964,7 @@ class LeadsController extends BaseController } - function getLastFiveFinancialYears() + public function getLastFiveFinancialYears() { $currentYear = date('Y'); $currentMonth = date('m'); diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index a4721770..7b35bc86 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -327,42 +327,37 @@ class PolicyTransactionController extends BaseController return $data; } - + private function insertInceptionPolicy($data) - { + { // print_r($data); die; $insert = $this->policyTransactionModel->insert($data); + if ($insert) { + $this->insertTransactionStatus($insert, $data, 1); $emp_data = $this->processInsertIndividualMemberInEmpTable($data); - if(isset($data['follow_insurer_id']) && !empty($data['follow_insurer_id'][0])){ + if (isset($data['follow_insurer_id']) && !empty($data['follow_insurer_id'][0])) { $pt_co_share_details = $this->insertOrUpdateCoShareDetails($data, $insert); if ($data['ct_type'] == 2) { - $client_policy_insert_data = $this->prepareClientPolicyInsertData($data); $client_policy_id = $this->clientPolicyModel->insert($client_policy_insert_data); $this->policyTransactionModel->update($insert, ['client_policy_id' => $client_policy_id]); $emp_policy_insert = $this->InsertIndividualEmpPolicyTable($emp_data, $client_policy_id); - - if ($data['client_type'] == 1 && $data['status'] == 'completed' && $data['is_cd_reduce_from_bds'] == 1) { - $this->processCompletedStatus($data, $client_policy_id, $data['insurer_id']); - } } - - $data['pt_co_share_details'] = $this->PTCOShareDetailsModel->where('pt_id', $insert)->where('is_active', 1)->findAll(); + if ($data['client_type'] == 1 && $data['status'] == 'completed' && $data['is_cd_reduce_from_bds'] == 1) { + $this->processCompletedStatus($data, $client_policy_id, $data['insurer_id']); + } } - - $client_data = $this->clientModel->where('id', $data['client_id'])->first(); - $data['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $data['client_id'])->findAll(); - $data['entity_type_id'] = $client_data['entity_type_id']; return $this->respondSuccess($insert, "Policy transaction created successfully", $data); } + return $this->respondError("Failed to create policy transaction"); } @@ -397,19 +392,12 @@ class PolicyTransactionController extends BaseController } } - if ($data['status'] == 'completed' && $data['ct_type'] == 2) { - if($data['client_type'] == 1 && $data['is_cd_reduce_from_bds'] == 1){ - $this->processCompletedStatus($data, $data['client_policy_id'], $data['insurer_id']); - } + if($data['status'] == 'completed' && $data['client_type'] == 1 && $data['is_cd_reduce_from_bds'] == 1){ + $this->processCompletedStatus($data, $data['client_policy_id'], $data['insurer_id']); } - $data['pt_co_share_details'] = $this->PTCOShareDetailsModel->where('pt_id', $id)->where('is_active', 1)->findAll(); } - $client_data = $this->clientModel->where('id', $data['client_id'])->first(); - $data['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $data['client_id'])->findAll(); - $data['entity_type_id'] = $client_data['entity_type_id']; - return $this->respondSuccess($id, "Policy transaction updated successfully", $data); } diff --git a/app/Views/client_list.php b/app/Views/client_list.php index 592031dc..673c5eaf 100755 --- a/app/Views/client_list.php +++ b/app/Views/client_list.php @@ -17,6 +17,10 @@ table.dataTable thead th { max-width: 98% !important; } +.btn-filter{ + margin-left: 20px !important; +} + .custom-dropdown-menu { display: none; position: absolute; @@ -53,12 +57,12 @@ table.dataTable thead th {

    Client List

    -
    +
    @@ -269,18 +273,40 @@ table.dataTable thead th { $(document).ready(function() { $('#tickets-table').DataTable({ - dom: "<'row'<'col-sm-0'f><'col-sm-7 text-right'B>>" + + dom: "<'row'<'col-sm-2'f><'col-sm-10 text-right'B>>" + "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>", - buttons: [{ - extend: 'csv', - text: 'CSV', - title: 'ClientList', - className: 'my_class', - exportOptions: { - columns: ':not(:last-child)' + buttons: [ + { + extend: 'csv', + text: 'CSV', + title: 'ClientList', + className: 'my_class', + exportOptions: { + columns: ':not(:last-child)' + }, + }, + { + text: 'Add From Lead', + className: 'btn-filter', // custom class + action: function(e, dt, node, config) { + showModal(); + } }, - }], + { + text: 'Add', + className: 'btn-filter', // custom class + action: function(e, dt, node, config) { + addClient(); + } + } + ], + + initComplete: function() { + $('.btn-filter') + .removeClass('btn-secondary') + .addClass('btn btn-primary'); + }, language: { search: "_INPUT_", searchPlaceholder: "Search..." @@ -440,4 +466,9 @@ function featchClient(){ }); } +function addClient(){ + let url = ""; + window.location.href = url; +} + \ No newline at end of file From 9b63c61b0a1edea2a5e8e5be4bb1116ed3fa1bfc Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Fri, 16 May 2025 14:06:55 +0530 Subject: [PATCH 101/169] FEAT_ADD_CLIENT_ROLLOVER --- app/Controllers/ClientController.php | 7 +- app/Views/leads_form.php | 111 +++++++- app/Views/leads_form_handler.php | 90 ++++++ app/Views/leads_non_eb.php | 85 +++++- app/Views/newClientModal.php | 218 +++++++++++++++ .../policy_transaction_inception_form.php | 256 +++++------------- 6 files changed, 569 insertions(+), 198 deletions(-) create mode 100644 app/Views/newClientModal.php diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 9bf373ce..9d96e72b 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -3839,13 +3839,13 @@ class ClientController extends AdminController 'dob' => change_date_format($postData['dob'],'d/m/Y','Y-m-d'), 'aadhar' => $postData['aadhar'], 'phone' => $postData['phone'], - 'email' => $postData['email'], 'entity_type_id' => 7 ]); } else { $client_data['entity_type_id'] = $postData['entity_type_id']; } + // print_rr($client_data);die(); // Insert client data $client_insert = $this->clientModel->insert($client_data); @@ -3871,6 +3871,8 @@ class ClientController extends AdminController 'contact_type' => 'client', 'name' => $postData['name'], 'mobile' => $postData['mobile'], + 'email' => $postData['email'], + ]; $this->levelContactModel->insert($contact_data); } @@ -4050,7 +4052,8 @@ class ClientController extends AdminController ->join('clients', 'client_branch.client_id = clients.id') ->where(['client_branch.id' => $id, 'client_branch.is_active' => 1]) ->first(); - $branch_contact_data = $this->levelContactModel->where(['ref_id' => $id, 'contact_type' => 'client', 'is_active' => 1])->orderBy('id','asc')->first(); + $branch_contact_data = $this->levelContactModel->where(['ref_id' => $id, 'contact_type' => 'client', 'is_active' => 1])->findAll(); + // print_rr($branch_contact_data);die(); return $this->respond(['status' => true, 'code' => 200, 'data' => $branch_data, 'contact' => $branch_contact_data], 200); } else { return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200); diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 25044797..23209757 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -149,7 +149,7 @@ @@ -207,6 +207,14 @@ placeholder="Enter Branch Code" required> +
    + + + +
    +
    + + \ No newline at end of file diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index a8d31703..3621bd08 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -795,115 +795,7 @@ - - + + + + From 65b405d3e4f5d939749140baafe94facf44b665b Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Sat, 17 May 2025 12:33:20 +0530 Subject: [PATCH 107/169] FIX_ADD_CLIENT --- app/Controllers/LeadsController.php | 9 ++++- app/Views/leads_form_handler.php | 28 +++++++------- app/Views/newClientModal.php | 58 ++++++++++++++++++++++++++--- 3 files changed, 74 insertions(+), 21 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 944ab17e..77a6ba81 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -681,7 +681,9 @@ class LeadsController extends BaseController if ($lead_data['lead_type'] != 1) { $client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first(); - $data['policy_terms'] = $client_policy_data['policy_terms']; + if (isset($client_policy_data)) { + $data['policy_terms'] = $client_policy_data['policy_terms']; + } } $data['question_json'] = $lead_data['question_json']; @@ -740,7 +742,10 @@ class LeadsController extends BaseController if ($lead_data['lead_type'] != 1 && $data['rfq_count'] == 0) { $client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first(); - $data['rfq_data']['json'] = $client_policy_data['placement_json']; + if (isset($client_policy_data)) { + + $data['rfq_data']['json'] = $client_policy_data['placement_json']; + } } if (!empty($data['question_json'])) { diff --git a/app/Views/leads_form_handler.php b/app/Views/leads_form_handler.php index 023dc0d3..7d9a6006 100644 --- a/app/Views/leads_form_handler.php +++ b/app/Views/leads_form_handler.php @@ -338,24 +338,24 @@ if (isset($selected_lead_type)) { $('#salse_person_id').trigger('change'); } - function validateInput(input, table, field){ + // function validateInput(input, table, field){ - let value = $(input).val(); - let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim(); + // let value = $(input).val(); + // let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim(); - let message = "Value is duplicate!"; - if(label){ - message = label + " already exists!"; - } + // let message = "Value is duplicate!"; + // if(label){ + // message = label + " already exists!"; + // } - checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { - if (isDuplicate) { - toastr.warning(message, 'WARNING'); - $(input).val('') - } - }); + // checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { + // if (isDuplicate) { + // toastr.warning(message, 'WARNING'); + // $(input).val('') + // } + // }); - } + // } // -------------------------------------------------------------------------------------------------------- diff --git a/app/Views/newClientModal.php b/app/Views/newClientModal.php index 9f75a734..c4285aac 100644 --- a/app/Views/newClientModal.php +++ b/app/Views/newClientModal.php @@ -22,7 +22,7 @@
    - +
    @@ -39,7 +39,7 @@
    + onkeypress="return onlyNumbers(event)" onchange="validateInputForClient(this, 'clients', 'phone')">
    @@ -48,7 +48,7 @@
    - +
    @@ -96,7 +96,7 @@
    -
    @@ -113,8 +113,52 @@ @@ -395,11 +451,11 @@ function specialConditionForOthers(count = 0) { var appendElement = `
    - +
    `; console.log($(this)); $('.other_special_condition').each(function() { @@ -465,208 +521,208 @@ function appendPolicyTermsHTML(policy_type) { var termsHTML = "" $('#append_html_for_other_policy_terms').empty(); - if (policy_type == 7) { + // if (policy_type == 7) { - termsHTML = ` + // termsHTML = ` -
    + //
    -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -
    -
    + //
    + //
    + // + //
    + //
    + // + //
    + //
    + // + //
    + //
    + //
    + //
    + //
    + //
    + //
    -
    + //
    -
    -
    - -
    -
    - -
    -
    + //
    + //
    + // + //
    + //
    + // + //
    + //
    -
    -
    - -
    -
    - -
    -
    + //
    + //
    + // + //
    + //
    + // + //
    + //
    -
    -
    - -
    -
    - -
    -
    + //
    + //
    + // + //
    + //
    + // + //
    + //
    -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -
    -
    + //
    + //
    + // + //
    + //
    + // + //
    + //
    + //
    + //
    + //
    + //
    + //
    -
    -
    - -
    -
    - -
    -
    + //
    + //
    + // + //
    + //
    + // + //
    + //
    -
    -
    - -
    -
    - -
    -
    + //
    + //
    + // + //
    + //
    + // + //
    + //
    -
    -
    - -
    -
    - -
    -
    + //
    + //
    + // + //
    + //
    + // + //
    + //
    -
    -
    - -
    -
    - -
    -
    + //
    + //
    + // + //
    + //
    + // + //
    + //
    -
    -
    - -
    -
    - -
    -
    + //
    + //
    + // + //
    + //
    + // + //
    + //
    -
    + //
    - ` + // ` - } else if (policy_type == 6) { + // } else if (policy_type == 6) { - termsHTML = ` + // termsHTML = ` -
    + //
    -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -
    -
    + //
    + //
    + // + //
    + //
    + // + //
    + //
    + // + //
    + //
    + //
    + //
    + //
    + //
    + //
    -
    + //
    -
    -
    - -
    -
    - -
    -
    + //
    + //
    + // + //
    + //
    + // + //
    + //
    -
    -
    - -
    -
    - -
    -
    + //
    + //
    + // + //
    + //
    + // + //
    + //
    -
    -
    - -
    -
    - -
    -
    + //
    + //
    + // + //
    + //
    + // + //
    + //
    -
    -
    - -
    -
    - -
    -
    + //
    + //
    + // + //
    + //
    + // + //
    + //
    -
    -
    - -
    -
    - -
    -
    + //
    + //
    + // + //
    + //
    + // + //
    + //
    -
    -
    - -
    -
    - -
    -
    + //
    + //
    + // + //
    + //
    + // + //
    + //
    -
    + //
    - ` - } + // ` + // } $('#append_html_for_other_policy_terms').append(termsHTML); } @@ -699,4 +755,13 @@ function appendOtherSIAddMore(data = null) { addMoreContainer.insertAdjacentHTML('beforeend', html); } + +function beautifyString(str) { + return str + .split('_') // Split the string by underscores + .map(word => + word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() // Capitalize each word + ) + .join(' '); // Join with spaces instead of underscores +} \ No newline at end of file diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index 68ae324d..04f29286 100755 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -1,75 +1,75 @@ @@ -158,7 +158,7 @@ label {
    @@ -326,10 +326,10 @@ label {
    - +
    - +
    @@ -405,10 +405,10 @@ label { id="9monthwaitingperiodwaived_display" class="unchecked" checked>
    - +
    - +
    @@ -418,7 +418,7 @@ label { id="maternitycoverage_display" class="unchecked" checked>
    - +
    @@ -431,7 +431,7 @@ label { id="twindelivery_display" class="unchecked" checked>
    - +
    @@ -457,7 +457,7 @@ label { id="preandpostnatal_display" class="unchecked" checked>
    - +
    @@ -483,7 +483,7 @@ label { id="babyday1cover_display" class="unchecked" checked>
    - +
    @@ -496,7 +496,7 @@ label { id="coverfromthedateofjoining_display" class="unchecked" checked>
    - +
    - +
    - +
    - +
    @@ -564,7 +564,7 @@ label { id="congenitaldiseasesexternal_display" class="unchecked" checked>
    - +
    - +
    @@ -617,7 +617,7 @@ label { id="proportionatedeductionclause_display" class="unchecked" checked>
    - +
    @@ -643,7 +643,7 @@ label { id="ailment_capping_details_display" class="unchecked" checked>
    - +
    @@ -656,7 +656,7 @@ label { id="corporatebuffer_display" class="unchecked" checked>
    - +
    @@ -683,7 +683,7 @@ label { id="ambulancecharges_display" class="unchecked" checked>
    - +
    @@ -696,7 +696,7 @@ label { id="airambulance_display" class="unchecked" checked>
    - +
    @@ -735,7 +735,7 @@ label { id="lasiksurgery_display" class="unchecked" checked>
    - +
    @@ -744,14 +744,14 @@ label {
    - +
    - +
    @@ -761,7 +761,7 @@ label { id="moderntreatmentsasperirdai_display" class="unchecked" checked>
    - +
    - +
    @@ -801,7 +801,7 @@ label { id="days_from_dod_display" class="unchecked" checked>
    - +
    @@ -817,7 +817,7 @@ label {
    - +
    @@ -849,7 +849,7 @@ label {
    - +
    @@ -880,584 +880,191 @@ label { + + + + + + + + + - - - - - - - - - \ No newline at end of file diff --git a/app/Views/policy_gpa_terms.php b/app/Views/policy_gpa_terms.php index 3ad9d2be..0424063f 100755 --- a/app/Views/policy_gpa_terms.php +++ b/app/Views/policy_gpa_terms.php @@ -784,6 +784,7 @@ $('body').on('click', '.btnPolicyMaster', function() { .next()[0]; $(element).css("display", ""); } + disableUnwantedTermsforGPA(jsonObject); Object.keys(jsonObject).forEach(function(key) { @@ -853,6 +854,34 @@ $('body').on('click', '.btnPolicyMaster', function() { \ No newline at end of file diff --git a/app/Views/rfq/blu.php b/app/Views/rfq/blu.php index c1dccbcb..09f7a164 100644 --- a/app/Views/rfq/blu.php +++ b/app/Views/rfq/blu.php @@ -11,11 +11,11 @@
    > - +
    > - +
    diff --git a/app/Views/rfq/bsu.php b/app/Views/rfq/bsu.php index c1dccbcb..09f7a164 100644 --- a/app/Views/rfq/bsu.php +++ b/app/Views/rfq/bsu.php @@ -11,11 +11,11 @@
    > - +
    > - +
    diff --git a/app/Views/rfq/burglary.php b/app/Views/rfq/burglary.php index c1dccbcb..09f7a164 100644 --- a/app/Views/rfq/burglary.php +++ b/app/Views/rfq/burglary.php @@ -11,11 +11,11 @@
    > - +
    > - +
    diff --git a/app/Views/ticket_list.php b/app/Views/ticket_list.php index d3408054..b81836f1 100644 --- a/app/Views/ticket_list.php +++ b/app/Views/ticket_list.php @@ -297,11 +297,12 @@ $(document).ready(function() { function viewTicket(ticket_id){ - $('.loader').fadeIn(); - $('.loader-mask').fadeIn(); + // $('.loader').fadeIn(); + // $('.loader-mask').fadeIn(); + + let url = '' + ticket_id; + window.open(url, '_blank'); - let url = '' + ticket_id - window.location.href = url } diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index 183a1bb1..aa289999 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -295,6 +295,7 @@ " /> +
    @@ -629,6 +630,27 @@ myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel')); // monitorTableChanges(); }); + + $(document).ready(function () { + + console.log("Document ready"); + + let lead_status = ''; + console.log('Lead status retrieved:', lead_status); + + if (lead_status != "won") { + console.log("Lead status is not 'won', setting interval for submitData"); + + setInterval(function () { + console.log("Calling submitData(1) at 20-second interval"); + saveRFQ(true); + }, 20000); + } else { + console.log("Lead status is 'won', submitData will not be called"); + } + }); + + var tableCount = 0; const policies = ; // // console.log('policies', policies); @@ -2473,10 +2495,7 @@ table_type: "new", table_id: `${policyName}_summary_` + locationIndex, table_editable: true, - table_name: "Risk Location " + locationIndex + "- " + - storedData.locations[i].policyRisk['occupancy'] + "- " + - storedData.locations[i].policyRisk['address1'] + " " + - storedData.locations[i].policyRisk['address2'], + table_name: "Risk Location " + locationIndex, table_row_contents: rowContents }); } @@ -2548,17 +2567,17 @@ return null; // If canceled, return null } - function saveRFQ() { + function saveRFQ(isAutoSave = false) { // alert("Function Called"); isSaved = true; // // console.log("save button clicked"); leadJson = tablesToJson(); - // // console.log("json from function ", leadJson); + console.log("json from function ", leadJson); var policyJson = localStorage.getItem("policyData") ?? null; - saveRFQTODB(leadJson, policyJson); + saveRFQTODB(leadJson, policyJson, isAutoSave); } - function saveRFQTODB(tableJSON, policyJson) { + function saveRFQTODB(tableJSON, policyJson,isAutoSave = false) { let submit_type = "RFQ" if(rfq_or_qcr == 2){submit_type = 'QCR'} @@ -2570,9 +2589,20 @@ registration_json: policyJson } + let rfq_primaryKey = $('#rfq_primaryKey').val(); + + if (isAutoSave) { + formData['rfq_primaryKey'] = rfq_primaryKey; + } + var url = ''; - $('.loader').fadeIn(); - $('.loader-mask').fadeIn(); + + if (!isAutoSave) { + + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + } + $.ajax({ url: url, @@ -2583,24 +2613,27 @@ console.log('RFQ NON EB FORM SUBMIT RESPONSE : ', response); if (response.status == true) { - localStorage.removeItem('policyData'); - toastr.success(response.message, "Success"); - // // console.log(rfq_data.length); - $('.actionBtns').show(); - if (rfq_or_qcr == 2) { - $("#openQCR").hide(); + if (!isAutoSave) { + + localStorage.removeItem('policyData'); + + $('.actionBtns').show(); + if (rfq_or_qcr == 2) { + $("#openQCR").hide(); + } } - // window.location.reload(); } else { toastr.error(response.message, "Error"); $('.actionBtns').hide(); } - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - window.location.reload(); + if (!isAutoSave) { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + window.location.reload(); + } }, error: function(xhr, status, error) { $('.loader').fadeOut(); From 4005e951c319ec9e1c7e6ff7815ee3acfbf3dd9c Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 28 May 2025 17:36:50 +0530 Subject: [PATCH 121/169] FIX_LEAD_CALCULATION : RV --- app/Views/leads_form.php | 23 ++++++++++++++++--- .../policy_transaction_inception_form.php | 8 +++---- app/Views/rfq/gmc.php | 6 ++--- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 23209757..92d4435f 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -544,7 +544,11 @@ let increment = this.input.id.split('_').pop(); console.log('Extracted increment:', increment); + let lead_type = $('#lead_type').val(); var policyStartDate = $("#source_policy_start_date"); + if(lead_type == 3){ + policyStartDate = $("#policy_start_date"); + } console.log('Selected Dates:', selectedDates); console.log('policy start date instance', policyStartDate) console.log('Policy Start Date:', policyStartDate.val()); @@ -909,6 +913,10 @@ console.log('Extracted increment:', increment); var policyStartDate = $("#source_policy_start_date"); + if(lead_type == 3){ + policyStartDate = $("#policy_start_date"); + } + console.log('Selected Dates:', selectedDates); console.log('policy start date instance', policyStartDate) console.log('Policy Start Date:', policyStartDate.val()); @@ -1155,8 +1163,11 @@ console.log('calculatePolicyRunDays function called'); console.log('increment', increment); - + let lead_type = $('#lead_type').val(); var policyStartDate = $("#source_policy_start_date"); + if(lead_type == 3){ + policyStartDate = $("#policy_start_date"); + } var policyStartDate = flatpickr.parseDate(policyStartDate.val(), "d/m/Y"); var incurredClaimDate = flatpickr.parseDate($("#incurred_claim_date_" + increment).val(), "d/m/Y"); @@ -1207,8 +1218,14 @@ // Prevent division by zero in incurred claim ratio calculation let premium_as_on_date = Number($('#premium_date_' + increment).val()) || 0; - let incurred_claim_ratio = annualised_claims > 0 ? annualised_claims / premium_as_on_date : 0; - let incurred_claim_ratio_roundoff = Math.round(incurred_claim_ratio); + let incurred_claim_ratio = (annualised_claims > 0 && premium_as_on_date > 0) + ? (annualised_claims / premium_as_on_date) + : 0; + + let incurred_claim_ratio_roundoff = isFinite(incurred_claim_ratio) + ? Math.round(incurred_claim_ratio) + : 0; + console.log('incurred_claim_ratio', incurred_claim_ratio_roundoff); $('#incurred_claims_ratio_' + increment).val(incurred_claim_ratio_roundoff); diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index ad4f430c..93cc234d 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -3854,15 +3854,15 @@ $('#policy_no').change(function(){ if(res.status == true){ $('#ct_type').val(1); - $('#client_policy_id').val(res.data.client_policy_id); + $('#client_policy_id').val(res.data.id); $('#policy_start_date').val(res.data.policy_start_date); $('#policy_end_date').val(res.data.policy_end_date); $('#tpa').val(res.data.tpa_branch_id+'-'+res.data.tpa_id).select2(); }else{ $('#ct_type').val(2); - $('#client_policy_id').val(); - $('#policy_start_date').val(); - $('#policy_end_date').val(); + $('#client_policy_id').val(''); + $('#policy_start_date').val(''); + $('#policy_end_date').val(''); $('#tpa').val('').select2(); console.log(res.message, 'warning'); } diff --git a/app/Views/rfq/gmc.php b/app/Views/rfq/gmc.php index 884428b3..9700a144 100644 --- a/app/Views/rfq/gmc.php +++ b/app/Views/rfq/gmc.php @@ -30,7 +30,7 @@
    Min Age: