From 8c1ae38108a7f37d0878c93d7f2d8970019d4fba Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 22 Dec 2025 09:34:07 +0530 Subject: [PATCH 01/15] CHANGE_OLD_QUERY_ISSUE_MONTH --- app/Models/PolicyTransactionModel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php index 05a734c1..509dbd30 100644 --- a/app/Models/PolicyTransactionModel.php +++ b/app/Models/PolicyTransactionModel.php @@ -616,9 +616,9 @@ policy_transaction.*, DATE_FORMAT(policy_transaction.policy_issue_date, '%d %b %Y') AS policy_issue_date, DATE_FORMAT( - IF(policy_transaction.month IS NULL, + IF(pt_co_share_details.pt_policy_issue_date IS NULL, policy_transaction.policy_issue_date, - policy_transaction.month), + pt_co_share_details.pt_policy_issue_date), '%b %Y') AS policy_issue_month, CASE WHEN clients.client_type = 1 THEN 'Group' From 052cf9df97faeb9e7f9916004959003a4f48a1cf Mon Sep 17 00:00:00 2001 From: velz Date: Mon, 22 Dec 2025 18:28:04 +0530 Subject: [PATCH 02/15] FEAT_TPA_VARIATION_REPORT --- app/Config/Routes.php | 1 + app/Controllers/EmployeeController.php | 386 ++++++++++++++++++++ app/Controllers/MediAssistApiController.php | 5 +- app/Models/EmployeePolicyModel.php | 55 +++ app/Views/batch_list.php | 6 + app/Views/insurer_or_tpa_data.php | 5 + 6 files changed, 457 insertions(+), 1 deletion(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 4764e7e1..360c6b8c 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -213,6 +213,7 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) { $routes->post('get_emp_history','EmployeeController::getEmpHistory'); $routes->get("retail-endorsement-list", "EmployeeController::retailendorsementlist"); $routes->post("retail-endorsement-save", "EmployeeController::retailendorsementsave"); + $routes->get("getTPADataVariationReport/(:num)", "EmployeeController::getTPADataVariationReport/$1"); }); diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index dc72314e..32217c91 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -28,6 +28,7 @@ use App\Models\PolicyPremium2Model; use App\Models\AuditHistoryModel; use App\Models\UserModel; use App\Models\PartnerEndorsementRequestModel; +use App\Models\TpaApiDataModel; use App\Controllers\Jobs; @@ -42,6 +43,8 @@ use CodeIgniter\API\ResponseTrait; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use PhpOffice\PhpSpreadsheet\Cell\Coordinate; +use PhpOffice\PhpSpreadsheet\Style\Fill; use Dompdf\Dompdf; use Dompdf\Options; @@ -3579,5 +3582,388 @@ class EmployeeController extends AdminController } } + public function getTPADataVariationReport($file_id) + { + $file_info = $this->batchFileModel->where('id', $file_id)->find(); + $client_id = $file_info[0]['client_id']; + $client_policy_id = $file_info[0]['client_policy_id']; + $TpaApiDataModel = new TpaApiDataModel(); + $emp_data_wo_tpa_id = $this->employeePolicyModel->getTPADataVariationReport($client_id, $client_policy_id, $file_id); + + + //loop emp data with TPA data for matches + foreach ($emp_data_wo_tpa_id as $db_key => $db_row) + { + //get TPA API data from table for current DB ep code + $tpa_temp_data = $TpaApiDataModel->select('*') + ->where('emp_code', $db_row['emp_code']) + ->where('file_id', $file_id) + ->where('is_active', 1) + ->findAll(); + $match= $this->reconcileDbWithTpa($db_row,$tpa_temp_data); + $emp_data_wo_tpa_id[$db_key]['match'] = $match; + } + + // d($emp_data_wo_tpa_id); + + // die(); + //not_in_tpa + $tpa_emp_codes = $TpaApiDataModel->select('emp_code') + ->where('file_id', $file_id) + ->where('is_active', 1) + ->groupBy('emp_code') + ->findAll(); + $tpa_emp_codes = array_column($tpa_emp_codes, 'emp_code'); + + $not_in_tpa = $this->employeePolicyModel->getTPADataVariationReport($client_id, $client_policy_id, $file_id,$tpa_emp_codes); + // d($not_in_tpa);die(); + + // not_in_nhance + $master_emp_codes = $this->employeePolicyModel->getTPADataVariationReport($client_id, $client_policy_id, $file_id,[],true); + $master_emp_codes = array_column($master_emp_codes, 'emp_code'); + + $not_in_nhance = $TpaApiDataModel->select('*') + ->where('is_active',1) + ->where('file_id',$file_id) + ->whereNotIn('emp_code',$master_emp_codes) + ->findAll(); + // d($not_in_nhance);die(); + + if( !empty($not_in_tpa) || !empty($not_in_nhance) || !empty($emp_data_wo_tpa_id) ) + { + $this->exportVariationReportExcel($not_in_tpa,$not_in_nhance,$emp_data_wo_tpa_id); + } + else + { + return false; + } + // $this->exportVariationReportExcel([],[],[]); + + + } + + + // not in use once all functionality workes well in this funciton then remvoe this function + function compareDbWithTpa(array $db, array $tpaRows): array + { + $partialMatches = []; + + // Normalize helper + $normalizeName = function ($name) { + return strtolower( + preg_replace('/[.\s_]+/', '', trim($name)) + ); + }; + + foreach ($tpaRows as $tpa) { + + // 0️⃣ emp_code must match + if (($db['emp_code'] ?? '') !== ($tpa['emp_code'] ?? '')) { + continue; + } + + $relationMatch = strtolower($db['relation'] ?? '') === strtolower($tpa['relation'] ?? ''); + $genderMatch = strtoupper($db['gender'] ?? '') === strtoupper($tpa['gender'] ?? ''); + $dobMatch = ($db['dob'] ?? '') === ($tpa['dob'] ?? ''); + + $nameMatch = $normalizeName($db['name'] ?? '') === + $normalizeName($tpa['name'] ?? ''); + + // ✅ FULL MATCH + if ($nameMatch && $relationMatch && $genderMatch && $dobMatch) { + return [ + 'match' => 'full_match', + 'record'=> $tpa + ]; + } + + // ⚠️ PARTIAL MATCH + if ($relationMatch || $genderMatch || $dobMatch) { + $partialMatches[] = [ + 'record' => $tpa, + 'matched_on' => [ + 'relation' => $relationMatch, + 'gender' => $genderMatch, + 'dob' => $dobMatch + ] + ]; + } + } + + // If no full match but partial exists + if (!empty($partialMatches)) { + return [ + 'match' => 'partial_match', + 'candidates' => $partialMatches + ]; + } + + // Nothing matched + return [ + 'match' => 'no_match' + ]; + } + + + function reconcileDbWithTpa(array $db, array $tpaRows): array + { + // Name normalization + $normalizeName = function ($name) { + return strtolower( + preg_replace('/[.\s_]+/', '', trim($name)) + ); + }; + + foreach ($tpaRows as $tpa) { + + // 1️⃣ emp_code + relation must match + if ( + // ($db['emp_code'] ?? '') !== ($tpa['emp_code'] ?? '') || + strtolower($db['relationship']) !== strtolower($tpa['relation']) + ) { + continue; + } + + // 2️⃣ Field comparison + $diff = []; + + if ( + ($db['name'] ?? '') !== + ($tpa['name'] ?? '') + ) { + $diff[] = 'name'; + } + + if (($db['dob'] ?? '') !== ($tpa['dob'] ?? '')) { + $diff[] = 'dob'; + } + + if ( + strtoupper($db['gender'] ?? '') !== + strtoupper($tpa['gender'] ?? '') + ) { + $diff[] = 'gender'; + } + + // 3️⃣ Match found + return [ + 'status' => 'matched', + 'tpa_record' => $tpa, + 'not_matching' => $diff // empty = perfect match + ]; + } + + // 4️⃣ No match found + return [ + 'status' => 'no_match' + ]; + } + + + function exportVariationReportExcel( + array $notInTPA, + array $notInNhance, + array $reviewNeeded, + string $filename = 'employee_review.xlsx' +) { + + function setCell($sheet, int $col, int $row, $value) +{ + $cell = Coordinate::stringFromColumnIndex($col) . $row; + $sheet->setCellValue($cell, $value); +} + +$EXPORT_COLUMNS = [ + + // Sheet 1 — Not in TPA + 'not_in_tpa' => [ + 'emp_code' => 'Employee Code', + 'name' => 'Employee Name', + 'relationship' => 'Relation', + 'dob' => 'Date of Birth', + 'gender' => 'Gender', + 'mobile' => 'Mobile No', + 'email_corporate' => 'Corporate Email', + 'policy_no' => 'Policy No', + 'tpa_name' => 'TPA Name', + 'change_event' => 'Change Event', + ], + + // Sheet 2 — Not in Nhance + 'not_in_nhance' => [ + 'emp_code' => 'Employee Code', + 'name' => 'Employee Name', + 'relation' => 'Relation', + 'dob' => 'Date of Birth', + 'gender' => 'Gender', + 'age' => 'Age', + 'tpa_id' => 'TPA Member ID', + ], + + // Sheet 3 — Review Needed (DB side) + 'review_main' => [ + 'emp_code' => 'Employee Code', + 'name' => 'Employee Name', + 'relationship' => 'Relation', + 'dob' => 'Date of Birth', + 'gender' => 'Gender', + 'policy_no' => 'Policy No', + 'uhid' => 'UHID', + 'change_event' => 'Change event' + ], + + // Sheet 3 — Review Needed (TPA side) + 'review_tpa' => [ + 'emp_code' => 'TPA Employee Code', + 'name' => 'TPA Name', + 'relation' => 'TPA Relation', + 'dob' => 'TPA DOB', + 'gender' => 'TPA Gender', + 'tpa_id' => 'TPA Member ID', + 'age' => 'TPA Age', + ], +]; + + + $spreadsheet = new Spreadsheet(); + + /* ========================================================= + * SHEET 1 — NOT IN TPA + * ========================================================= */ + $sheet1 = $spreadsheet->getActiveSheet(); + $sheet1->setTitle('Not in TPA'); + + $cols = $EXPORT_COLUMNS['not_in_tpa']; + + $colNo = 1; + foreach ($cols as $label) { + setCell($sheet1, $colNo++, 1, $label); + } + + $rowNo = 2; + foreach ($notInTPA as $row) { + $colNo = 1; + foreach ($cols as $key => $label) { + setCell($sheet1, $colNo++, $rowNo, $row[$key] ?? ''); + } + $rowNo++; + } + + foreach (range(1, count($cols)) as $c) { + $sheet1->getColumnDimension(Coordinate::stringFromColumnIndex($c))->setAutoSize(true); + } + + /* ========================================================= + * SHEET 2 — NOT IN NHANCE + * ========================================================= */ + $sheet2 = $spreadsheet->createSheet(); + $sheet2->setTitle('Not in Nhance'); + + $cols = $EXPORT_COLUMNS['not_in_nhance']; + + $colNo = 1; + foreach ($cols as $label) { + setCell($sheet2, $colNo++, 1, $label); + } + + $rowNo = 2; + foreach ($notInNhance as $row) { + $colNo = 1; + foreach ($cols as $key => $label) { + setCell($sheet2, $colNo++, $rowNo, $row[$key] ?? ''); + } + $rowNo++; + } + + foreach (range(1, count($cols)) as $c) { + $sheet2->getColumnDimension(Coordinate::stringFromColumnIndex($c))->setAutoSize(true); + } + + /* ========================================================= + * SHEET 3 — REVIEW NEEDED + * ========================================================= */ + $sheet3 = $spreadsheet->createSheet(); + $sheet3->setTitle('Review Needed'); + + $mainCols = $EXPORT_COLUMNS['review_main']; + $tpaCols = $EXPORT_COLUMNS['review_tpa']; + + // headers + $colNo = 1; + foreach ($mainCols as $label) { + setCell($sheet3, $colNo++, 1, $label); + } + foreach ($tpaCols as $label) { + setCell($sheet3, $colNo++, 1, $label); + } + + // rows + $rowNo = 2; + foreach ($reviewNeeded as $row) { + + // main (DB) + $colNo = 1; + foreach ($mainCols as $key => $label) { + setCell($sheet3, $colNo++, $rowNo, $row[$key] ?? ''); + } + + $tpaData = []; + $notMatching = []; + + if (($row['match']['status'] ?? '') === 'matched') { + $tpaData = $row['match']['tpa_record'] ?? []; + $notMatching = $row['match']['not_matching'] ?? []; + } + + // TPA + foreach ($tpaCols as $key => $label) { + setCell($sheet3, $colNo++, $rowNo, $tpaData[$key] ?? ''); + } + + // highlight mismatches + foreach ($notMatching as $field) { + + if (isset($mainCols[$field])) { + $idx = array_keys($mainCols); + $pos = array_search($field, $idx); + $cell = Coordinate::stringFromColumnIndex($pos + 1) . $rowNo; + $sheet3->getStyle($cell)->getFill() + ->setFillType(Fill::FILL_SOLID) + ->getStartColor()->setARGB('FFFFFF00'); + } + + if (isset($tpaCols[$field])) { + $idx = array_keys($tpaCols); + $pos = array_search($field, $idx); + $cell = Coordinate::stringFromColumnIndex(count($mainCols) + $pos + 1) . $rowNo; + $sheet3->getStyle($cell)->getFill() + ->setFillType(Fill::FILL_SOLID) + ->getStartColor()->setARGB('FFFFFF00'); + } + } + + $rowNo++; + } + + foreach (range(1, count($mainCols) + count($tpaCols)) as $c) { + $sheet3->getColumnDimension(Coordinate::stringFromColumnIndex($c))->setAutoSize(true); + } + + /* ========================================================= + * OUTPUT + * ========================================================= */ + $writer = new Xlsx($spreadsheet); + + if (ob_get_length()) ob_end_clean(); + + header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); + header('Content-Disposition: attachment; filename="' . $filename . '"'); + header('Cache-Control: max-age=0'); + + $writer->save('php://output'); + exit; +} + + } diff --git a/app/Controllers/MediAssistApiController.php b/app/Controllers/MediAssistApiController.php index ba21f694..476cf2f7 100644 --- a/app/Controllers/MediAssistApiController.php +++ b/app/Controllers/MediAssistApiController.php @@ -351,6 +351,7 @@ class MediAssistApiController extends BaseController // now update DB + $batch_file_success = 'success'; $updated = 0; $employee_policy_ids = []; foreach ($employeePolicyData as $policy_data) { @@ -401,6 +402,7 @@ class MediAssistApiController extends BaseController 'gender' => $policy_data['gender'] ?? null, 'dob' => $policy_data['dob'] ?? null, ]; + $batch_file_success = 'partially success'; log_message( 'error', @@ -421,7 +423,8 @@ class MediAssistApiController extends BaseController // update file table status after the tpa id successfully updated if (isset($requestData['file_id']) && !empty($requestData['file_id'])) { $file_model = new BatchFileModel(); - $file_model->where('id', $requestData['file_id'])->set('status', 'success')->update(); + + $file_model->where('id', $requestData['file_id'])->set('status', $batch_file_success)->update(); log_message('error', "Files table status updated for the file id : {$requestData['file_id']}"); } else { log_message('error', "Failed to update file table status."); diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 16d4a815..0e86d94a 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -2139,5 +2139,60 @@ class EmployeePolicyModel extends Model return $data; } + public function getTPADataVariationReport($client_id, $client_policy_id, $file_id,$emp_codes = [],$all = false) + { + $result = $this->select([ + 'employee_polices.*', + 'tpam.name as tpa_name', + 'tpam.short_name as tpa_short_name', + 'emp.relationship', + 'emp.relationship_code', + 'emp.change_event', + 'emp.emp_code', + 'emp.name', + 'emp.email_corporate', + 'emp.dob', + 'emp.gender', + 'emp.emp_status', + 'emp.is_active as emp_is_active', + 'emp.mobile as mobile', + 'emp.doj', + 'emp.basic_pay', + 'emp.band as grade', + 'cp.policy_no', + 'cp.policy_type_id', + + ]) + ->join('employees emp', 'employee_polices.employee_id = emp.id') + ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') + ->join('tpa tpam', 'cp.tpa_id = tpam.id', 'left') //tpam - tpa master + // ->orderBy('emp.emp_code', 'ASC') + // ->orderBy('employee_polices.employee_id', 'ASC'); + ->where('employee_polices.status', 'active') + ->where('employee_polices.is_active', 1) + ->where('emp.is_active', 1) + ->where('employee_polices.status !=', 'inactive') + ->where('cp.id', $client_policy_id) + ->where('employee_polices.client_policy_id', $client_policy_id) + ->where('emp.client_id', $client_id); + + if(count($emp_codes) == 0 && $all == false) + { + $result->where('employee_polices.tpa_id IS NULL'); + } + else if(count($emp_codes) > 0 && $all == false) + { + $result->whereNotIn('emp.emp_code',$emp_codes); + } + else if(count($emp_codes) == 0 && $all == true) + { + $result->groupBy('emp.emp_code'); + } + + return $result->findAll(); + // print_r($result); + // return $result; + } + } \ No newline at end of file diff --git a/app/Views/batch_list.php b/app/Views/batch_list.php index 123950fb..aa2aa0da 100755 --- a/app/Views/batch_list.php +++ b/app/Views/batch_list.php @@ -176,6 +176,12 @@ + + + + + + diff --git a/app/Views/insurer_or_tpa_data.php b/app/Views/insurer_or_tpa_data.php index 60efbcb4..70296812 100755 --- a/app/Views/insurer_or_tpa_data.php +++ b/app/Views/insurer_or_tpa_data.php @@ -813,6 +813,11 @@ } function fetchTpaIdFromTpa(){ + let user_confirm = confirm('Are you sure you want to initiate the TPA fetch? This may take a while.'); + if(!user_confirm) + { + return false; + } let event = $('#event_type').val(); let client_id = $('#client').val(); From 0c85b8ec728764d8ac41fb08273eb26497ef46f4 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 23 Dec 2025 12:42:11 +0530 Subject: [PATCH 03/15] BDS_CHANGE_NEW --- .../PolicyTransactionController.php | 6 + .../policy_transaction_endorsement_form.php | 12 +- .../policy_transaction_inception_form.php | 140 ++++++++++++++---- app/Views/report_bds.php | 7 +- 4 files changed, 131 insertions(+), 34 deletions(-) diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 385a4bff..2fdfe255 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -732,6 +732,11 @@ // dd($data); + //Fetch POS + $data['pos_data'] = db_connect()->table('partner_pos') + ->where('is_active', 1) + ->get() + ->getResultArray(); // Load view $this->loadLayout('policy_transaction_inception_list', $data); @@ -2382,6 +2387,7 @@ 'service_person_branch_id' => $issue_type['service_person_branch_id'] ?? null, 'agent_id' => $issue_type['agent_id'] ?? null, 'agent_code' => $issue_type['agent_code'] ?? null, + 'pos_id' => $issue_type['pos_id'] ?? null, ]; $data['client_branch_id'] = $client_branch_id; diff --git a/app/Views/policy_transaction_endorsement_form.php b/app/Views/policy_transaction_endorsement_form.php index 98f20c0b..2d6a5bd8 100644 --- a/app/Views/policy_transaction_endorsement_form.php +++ b/app/Views/policy_transaction_endorsement_form.php @@ -447,7 +447,7 @@ Co-Share % - Non Commissional
Premium Amount + Non-Commissionable
Premium Amount Base Premium @@ -1580,6 +1580,16 @@ let terrisom_premium = ($('#bro_payable_by').val() == 1) ? tep : cotep; let tpTotal = base_premium + third_part_premium + terrisom_premium; + if($('#bro_payable_by').val() == 2){ + + if($('#co_share_type_' + input).val() == 1){ + base_premium = bp; + third_part_premium = tp; + terrisom_premium = tep; + tpTotal = base_premium + third_part_premium + terrisom_premium; + } + } + // Co-premium defaults if ($('#cop_yes').val() == 0) { if (!rawVal('co_premium')) $('#co_premium_' + input).val(bp); diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index 9fb5cbfe..6a0cb78c 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -790,7 +790,7 @@ --> -
+
-
+ + +
+ +
@@ -912,6 +921,20 @@
+
+ + +
+ @@ -977,7 +1000,7 @@ Co-Share % - Non Commissional
Premium Amount + Non-Commissionable
Premium Amount Base Premium @@ -1594,6 +1617,7 @@ $('#owner').select2(); $('#owner_branch').select2(); $('#vehicle_no').select2(); + $('#pos_id').select2(); var today = new Date(); var dob = flatpickr("#dob", { @@ -1671,7 +1695,7 @@ $('#table_tr_34').show(); $('#table_tr_37').show(); - $("select[name='cd_ac_no_for_child[]']").attr('required', 'required'); + // $("select[name='cd_ac_no_for_child[]']").attr('required', 'required'); }else{ @@ -1680,7 +1704,7 @@ $('#table_tr_34').hide(); $('#table_tr_37').hide(); - $("select[name='cd_ac_no_for_child[]']").removeAttr("required"); + // $("select[name='cd_ac_no_for_child[]']").removeAttr("required"); } @@ -2010,7 +2034,7 @@ $('#table_tr_34').hide(); $('#table_tr_37').hide(); - $("select[name='cd_ac_no_for_child[]']").removeAttr("required"); + // $("select[name='cd_ac_no_for_child[]']").removeAttr("required"); }else{ @@ -2018,7 +2042,7 @@ $('#table_tr_34').show(); $('#table_tr_37').show(); - $("select[name='cd_ac_no_for_child[]']").attr('required', 'required'); + // $("select[name='cd_ac_no_for_child[]']").attr('required', 'required'); } if(value == 8){ @@ -2049,6 +2073,8 @@ let val = $(this).val(); let uniqueid = $(this).data('id'); let insurer = $('#follow_insurer_id_'+uniqueid).val() + let policy_type_id = $('#policy_type_id').val(); + let client_type = $('#client_type').val(); var client_id = $('#client_id').val() var insurer_id = $('#follow_insurer_id_'+uniqueid).find('option:selected').attr('data-id'); @@ -2099,6 +2125,27 @@ $('[id^="cd_current_balance_"]').show(); } + if(policy_type_id > 7 || client_type == 1){ + $('[name="cd_ac_no_for_child[]"]').removeAttr('onchange'); + $('#cd_ac_no_' + uniqueid).attr('onchange', 'addCDAccountNumber(this); restrictCDACNO(this);'); + + if ($(this).is(':checked')) { + + $('[name="cd_ac_no_for_child[]"]').each(function () { + $(this).prop('required', false).parsley().reset(); + }); + + $('#cd_ac_no_' + uniqueid).prop('required', true).parsley().reset(); + + } else { + + $('[name="cd_ac_no_for_child[]"]').each(function () { + $(this).prop('required', false).parsley().reset(); + }); + } + + } + }); $(document).on('change', 'select[name="relationship[]"]', function() { @@ -2141,6 +2188,7 @@ $(document).on('change', '[name="follow_insurer_id[]"]', function() { + let currentSelect = $(this); let insurer = $(this).val(); let unique_id = $(this).data('count'); let client_id = $('#client_id').val(); @@ -2154,8 +2202,24 @@ $('#insurer_id').val(insurer) if (!policy_type_id || !client_id) { - $(this).val('').select2(); + $(this).val('').select2(); toastr.warning(!policy_type_id ? 'Please select the Policy Type' : 'Please select the Client', 'WARNING'); + return false; + } + + let isDuplicate = false; + + $('[name="follow_insurer_id[]"]').not(currentSelect).each(function () { + if ($(this).val() === insurer) { + isDuplicate = true; + return false; // break loop + } + }); + + if (isDuplicate) { + $(this).val('').select2(); + toastr.warning('Do not select the same insurer and branch again'); + return false; } }); @@ -2352,8 +2416,7 @@ $('#serviced_by').val(res.data.serviced_by ?? '').change(); $('#base_cd_amount').val(res.data.base_cd_amount); $('#issuer_branch').val(res.data.issuer_branch); - console.log('res.data.base_cd_amount', res.data.base_cd_amount); - console.log('res.data.issuer_branch', res.data.issuer_branch); + $('#pos_id').val(res.data.pos_id ?? '').change(); // Additional form handling logic @@ -2417,11 +2480,12 @@ } // Handle brokerage pay by - if (res.data.bro_payable_by == 1) { - $('#bro_payable_by').prop('checked', true); - } else { - $('#bro_payable_by').prop('checked', false); - } + // if (res.data.bro_payable_by == 1) { + // $('#bro_payable_by').prop('checked', true); + // } else { + // $('#bro_payable_by').prop('checked', false); + // } + $('#bro_payable_by').val(res.data.bro_payable_by); // Policy transaction status handling if (res.data.status == "completed") { @@ -2457,7 +2521,7 @@ $('#client_branch_id').prop('required', false); $('#table_tr_34').hide(); $('#table_tr_37').hide(); - $("select[name='cd_ac_no_for_child[]']").removeAttr("required"); + // $("select[name='cd_ac_no_for_child[]']").removeAttr("required"); } else { $('#policyholdernamediv').hide(); @@ -2465,7 +2529,7 @@ $('#client_branch_id').prop('required', true); $('#table_tr_34').show(); $('#table_tr_37').show(); - $("select[name='cd_ac_no_for_child[]']").attr('required', 'required'); + // $("select[name='cd_ac_no_for_child[]']").attr('required', 'required'); } //Vehicle File Upload Tab Hide And show @@ -2711,7 +2775,8 @@ let terrisom_premium = cotep; let tpTotal = cop + cotp + cotep; - if($('#bro_payable_by').is(':checked')){ + // if($('#bro_payable_by').is(':checked')){ + if($('#bro_payable_by').val() == 1){ tpTotal = bp + tp + tep; @@ -2719,6 +2784,19 @@ third_part_premium = tp; terrisom_premium = tep; + }else if($('#bro_payable_by').val() == 2){ + + console.log("$('#bro_payable_by').val()", $('#bro_payable_by').val()); + console.log("$('#co_share_type_' + input).is(':checked')", $('co_share_type_' + input).is(':checked')) + + if($('#co_share_type_' + input).is(':checked')){ + + tpTotal = bp + tp + tep; + + base_premium = bp; + third_part_premium = tp; + terrisom_premium = tep; + } } if (!$('#cop_yes').is(':checked')) { @@ -2812,7 +2890,7 @@ let policy_type_id = $('#policy_type_id').val(); if(policy_type_id > 7 && name == "base_premium[]"){ - checkCDAmountForBasePremium(input); + // checkCDAmountForBasePremium(input); }else{ console.log("First Skip the Ajax Call these are group policies"); } @@ -3372,7 +3450,6 @@ $('input[name="co_ter_premium[]"]').addClass('readonly-select'); $('#co_ter_premium_' + value).removeClass('readonly-select'); - $('[name="cd_ac_no_for_child[]"]').hide(); $('[id^="cd_current_balance_"]').hide(); @@ -3382,7 +3459,6 @@ // $('input[name="cd_ac_no_for_child[]"]').addClass('readonly-select'); // $('#cd_ac_no_' + value).removeClass('readonly-select'); - } } }); @@ -4386,11 +4462,11 @@ if(policy_type_id == 1 || policy_type_id == 2 || policy_type_id == 3 || policy_type_id == 4 || policy_type_id == 5 || policy_type_id == 6 || policy_type_id == 7){ $('#table_tr_34').hide(); $('#table_tr_37').hide(); - $("select[name='cd_ac_no_for_child[]']").removeAttr("required"); + // $("select[name='cd_ac_no_for_child[]']").removeAttr("required"); }else{ $('#table_tr_34').show(); $('#table_tr_37').show(); - $("select[name='cd_ac_no_for_child[]']").attr('required', 'required'); + // $("select[name='cd_ac_no_for_child[]']").attr('required', 'required'); } } @@ -4468,13 +4544,13 @@ $('#owner_branch').prop('required', false); $('#table_tr_34').hide(); $('#table_tr_37').hide(); - $("select[name='cd_ac_no_for_child[]']").removeAttr("required"); + // $("select[name='cd_ac_no_for_child[]']").removeAttr("required"); } else { $('.ownerbranchdiv').show(); $('#owner_branch').prop('required', true); $('#table_tr_34').show(); $('#table_tr_37').show(); - $("select[name='cd_ac_no_for_child[]']").attr('required', 'required'); + // $("select[name='cd_ac_no_for_child[]']").attr('required', 'required'); } // console.log('selected Owner type', selectedClientType); @@ -4767,7 +4843,7 @@ newCell = ``; break; case 8: // Base Premium - newCell = ``; + newCell = ``; break; case 9: // TP Premium newCell = ``; @@ -4912,7 +4988,7 @@ newCell = ``; break; case 8: // Base Premium - newCell = ``; + newCell = ``; break; case 9: // TP Premium newCell = ``; @@ -5458,10 +5534,12 @@ }); if(index != 0){ - if(data.co_share_type != 0 && data.co_share_type != 1){ - let co_share_index = index + 1; - select_leader_disable_premium_amt_in_edit(co_share_index); - } + // if(data.co_share_type != 0 && data.co_share_type != 1){ + // let co_share_index = index + 1; + // select_leader_disable_premium_amt_in_edit(co_share_index); + // } + select_leader_disable_premium_amt_in_edit(); + } }); diff --git a/app/Views/report_bds.php b/app/Views/report_bds.php index 23636b9b..40283cfa 100644 --- a/app/Views/report_bds.php +++ b/app/Views/report_bds.php @@ -685,13 +685,16 @@ $(document).ready(function() { var totalRewards = getTotal(24); var totalIrda = getTotal(25); var totalBilled = getTotal(26); - var totalRevenue = parseFloat(totalIrda) + parseFloat(totalRewards); var totalUnbilled = getTotal(27); + var totalIrdaAmt = parseFloat(totalBilled) - parseFloat(totalRewards); + var totalRevenue = parseFloat(totalIrdaAmt) + parseFloat(totalRewards); + // Update the totals section above the table $('#total_premium').text(totalPremium.toFixed(2)); $('#total_rewards').text(totalRewards.toFixed(2)); - $('#total_irda').text(totalIrda.toFixed(2)); + // $('#total_irda').text(totalIrda.toFixed(2)); + $('#total_irda').text(totalIrdaAmt.toFixed(2)); $('#total_revenue').text(totalRevenue.toFixed(2)); // $('#total_revenue').text(totalIrda.toFixed(2)); $('#total_billed').text(totalBilled.toFixed(2)); From 64ac479c30c8013786811b232fe4c8711110ed41 Mon Sep 17 00:00:00 2001 From: "sanjeev.p" Date: Tue, 23 Dec 2025 16:30:05 +0530 Subject: [PATCH 04/15] FIX_Velmurugan told me to add postDB[encrypt] in DataBase.php config Folder And View Member Client dropdown fixes and Dashbaord SSession Enrollment_data removed --- app/Config/Database.php | 4 + app/Controllers/DashboardController.php | 2 +- app/Views/employee_list.php | 249 ++++++++++++++---------- app/Views/insurer_or_tpa_data.php | 2 +- 4 files changed, 153 insertions(+), 104 deletions(-) diff --git a/app/Config/Database.php b/app/Config/Database.php index dcc1c2dd..c0f91c65 100755 --- a/app/Config/Database.php +++ b/app/Config/Database.php @@ -134,6 +134,10 @@ class Database extends Config 'ssl_ca' => ROOTPATH . 'ca.pem', 'ssl_verify' => true, ]; + $this->preDB['encrypt'] = [ + 'ssl_ca' => ROOTPATH . 'ca.pem', + 'ssl_verify' => true, + ]; } } diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index 8958c26d..50a9e4c1 100755 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -238,7 +238,7 @@ class DashboardController extends AdminController $data['client_branch_emp_list'] = $results; $session = \Config\Services::session(); - $session->set('enrollment_data', json_encode($data)); + // $session->set('enrollment_data', json_encode($data)); $data['pendingActionsData'] = $pendingActionsData; $data['businessTeamCount'] = count($businessTeamData) ?? 0; diff --git a/app/Views/employee_list.php b/app/Views/employee_list.php index 45ad39a0..6f6d74dc 100755 --- a/app/Views/employee_list.php +++ b/app/Views/employee_list.php @@ -355,11 +355,54 @@ // } }); + + 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 branch_policy = ''; + var policy_list_by_client = ''; + + $(document).ready(function() { + getClientAndBranchAndPolicy(); + }) + + //featch client and branch and policy + function getClientAndBranchAndPolicy() { + $.ajax({ + url: '', + type: "GET", + dataType: 'json', + success: function(res) { + + console.log('getClientAndBranchAndPolicy', res); + if (res.status == true) { + + client_list = res.client_data; + branch_list = res.branch_data; + policy_list = res.policy_data; + policy_list_by_client = res.policyListByClient; + + appendClients(client_list); + // appendBranch(branch_list); + // appendPolicies(policy_list); + + } else { + console.log('No data found'); + } + + }, + error: function(xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + } + }); + } + // Declare a global variable to store API response data - var clientPolicies = []; - var clientPoliciesWithBranch = { - policies: [] - }; + // var clientPolicies = []; + // var clientPoliciesWithBranch = { + // policies: [] + // }; var client_id = ''; var client_branch_id = ''; @@ -376,91 +419,91 @@ }); - $(document).ready(function() { - console.log("document loaded"); - //fetchClientPolicies(); - }); + // $(document).ready(function() { + // console.log("document loaded"); + // //fetchClientPolicies(); + // }); - $(window).on("load", function() { - console.log("window loaded"); - fetchClientPolicies(); - }); + // $(window).on("load", function() { + // console.log("window loaded"); + // fetchClientPolicies(); + // }); - function fetchClientPolicies() { - $('#loader').show(); - var apiURL = '' + 'util/clients-with-policies'; - console.log('fetchClientPolicies'); - // console.log(apiURL); - $.ajax({ - url: apiURL, - method: 'GET', - headers: { - "Content-Type": "application/json", - "X-Requested-With": "XMLHttpRequest" - }, - success: function(response) { - // console.log(response.code); - // console.log(response.dataStatus); - // console.log(response.data); - if (response.code === 200 && response.dataStatus === true && response.data !== "") { - try { - clientPolicies = (response.data); + // function fetchClientPolicies() { + // $('#loader').show(); + // var apiURL = '' + 'util/clients-with-policies'; + // console.log('fetchClientPolicies'); + // // console.log(apiURL); + // $.ajax({ + // url: apiURL, + // method: 'GET', + // headers: { + // "Content-Type": "application/json", + // "X-Requested-With": "XMLHttpRequest" + // }, + // success: function(response) { + // // console.log(response.code); + // // console.log(response.dataStatus); + // // console.log(response.data); + // if (response.code === 200 && response.dataStatus === true && response.data !== "") { + // try { + // clientPolicies = (response.data); - response.data.forEach(policy => { - // console.log('policies', policy.policies); - policy.policies.forEach(p => { - clientPoliciesWithBranch.policies.push(p); - }); - }); + // response.data.forEach(policy => { + // // console.log('policies', policy.policies); + // policy.policies.forEach(p => { + // clientPoliciesWithBranch.policies.push(p); + // }); + // }); - // console.log('1',clientPolicies); - appendClients(clientPolicies); + // // console.log('1',clientPolicies); + // appendClients(clientPolicies); - //this function for reselect the policy - setTimeout(function() { - if (client_id != 0) { - var foundPolicies = clientPolicies.find(function(item) { - // console.log(typeof item.id) - return item.id == client_id; - }); - appendBranch(foundPolicies.branchs); - } - }, 500); + // //this function for reselect the policy + // setTimeout(function() { + // if (client_id != 0) { + // var foundPolicies = clientPolicies.find(function(item) { + // // console.log(typeof item.id) + // return item.id == client_id; + // }); + // appendBranch(foundPolicies.branchs); + // } + // }, 500); - setTimeout(function() { - if (client_branch_id != 0) { + // setTimeout(function() { + // if (client_branch_id != 0) { - var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) { - // console.log('item', item); - return item.branch_id === client_branch_id; - }); + // var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) { + // // console.log('item', item); + // return item.branch_id === client_branch_id; + // }); - if (foundPolicies) { - // console.log('foundPolicies', foundPolicies); - appendPolicies(foundPolicies); - } else { - console.log('No policies found for the selected client'); - } - } - }, 500); - //end + // if (foundPolicies) { + // // console.log('foundPolicies', foundPolicies); + // appendPolicies(foundPolicies); + // } else { + // console.log('No policies found for the selected client'); + // } + // } + // }, 500); + // //end - } catch (error) { - console.error('Error parsing API response data:', error); - } - } else if (response.code === 404 && response.dataStatus === false) { - console.error('no data found', response); - } else { - console.error('Something went wrong!'); - } - }, - error: function(xhr, status, error) { - console.error('Error fetching data from API:', error); - } - }); + // } catch (error) { + // console.error('Error parsing API response data:', error); + // } + // } else if (response.code === 404 && response.dataStatus === false) { + // console.error('no data found', response); + // } else { + // console.error('Something went wrong!'); + // } + // }, + // error: function(xhr, status, error) { + // console.error('Error fetching data from API:', error); + // } + // }); - $('#loader').hide(); - } + // $('#loader').hide(); + // } function appendClients(data) { var clientID = ; @@ -507,8 +550,9 @@ // console.log(PolicyID) $.each(data, function(index, item) { var option = $('