nhance/app/Views/batch_list.php

806 lines
35 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<style>
.table-responsive {
overflow-x: auto;
}
.reload:hover {
cursor: pointer;
}
.truncate {
max-width: 80px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.dataTables_length label {
height: 21px !important;
}
/* TPA variation modal layout */
#tpa_variation_modal .modal-dialog {
max-width: 95%;
}
#tpa_variation_modal .modal-content {
max-height: 90vh;
}
#tpa_variation_modal .modal-body {
max-height: calc(85vh - 50px);
overflow-y: auto;
direction: ltr;
}
#tpa_variation_modal .table-responsive {
overflow-x: auto;
}
#tpa_variation_modal table {
white-space: nowrap;
font-size: 11px;
}
#tpa_variation_modal table thead th,
#tpa_variation_modal table tbody td {
padding: 2px 6px;
line-height: 1.1;
}
/* Tabs spacing & styling */
#tpa_variation_modal .nav-tabs {
border-bottom: 1px solid #dee2e6;
margin-bottom: 12px;
gap: 6px;
}
#tpa_variation_modal .nav-tabs .nav-item {
margin-right: 6px;
}
#tpa_variation_modal .nav-tabs .nav-link {
padding: 6px 14px;
border-radius: 4px 4px 0 0;
}
#tpa_variation_modal .nav-tabs .nav-link.active {
background-color: #f8f9fa;
border-color: #dee2e6 #dee2e6 transparent;
}
/* Modal footer buttons size */
#tpa_variation_modal .modal-footer .btn {
padding: 4px 12px;
font-size: 12px;
}
</style>
<div class="col-12" id="second_page">
<div class="card">
<div class="card-body">
<div class="row" style="padding-bottom: 10px;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">Batch List</h4>
</div>
</div>
<div class="table-responsive">
<table data-custom-table-css="table" id="datatable-buttons" class="table table-hover m-0 table-centered dt-responsive w-100">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No&nbsp;</th>
<th class="font-weight-medium">Batch Code&nbsp;</th>
<th class="font-weight-medium">File Name&nbsp;</th>
<th class="font-weight-medium">Client&nbsp;</th>
<th class="font-weight-medium">Client Branch&nbsp;</th>
<th class="font-weight-medium">Client Policy&nbsp;</th>
<th class="font-weight-medium">Event Type&nbsp;</th>
<th class="font-weight-medium">Insurer/ TPA&nbsp;</th>
<th class="font-weight-medium">Action&nbsp;</th>
<th class="font-weight-medium">Count&nbsp;</th>
<th class="font-weight-medium">()Amount&nbsp;</th>
<th class="font-weight-medium">User/Time&nbsp;</th>
<th class="font-weight-medium">Status&nbsp;</th>
<th class="font-weight-medium">Action&nbsp;</th>
</tr>
</thead>
<tbody class="font-12">
<?php
if (isset($batch_list)) {
foreach ($batch_list as $key => $file) {
?>
<tr>
<td class="text-center"><b><?php echo ($key + 1) ?></b></td>
<td><?php echo $file['batch_code'] ?></td>
<td style="overflow: hidden;" class="reload truncate" data-toggle="tooltip" data-placement="top" title="<?php echo $file['file_name'] ?>">
<?php echo $file['file_name']?>
</td>
<td><?php echo $file['client_short_name'] ?></td>
<td><?php echo $file['branch_name'] ?></td>
<!-- <td><?php echo isset($file['policy_name']) ? $file['policy_name'] : '' ?> - <?php echo isset($file['policy_no']) ? $file['policy_no'] : '' ?> - <?php echo isset($file['policy_type']) ? $file['policy_type'] : '' ?></td> -->
<td><?php echo isset($file['policy_type']) ? $file['policy_type'] : '' ?> - <?php echo isset($file['policy_no']) ? $file['policy_no'] : '' ?></td>
<td><?php echo $file['event_type'] ?></td>
<td><?php echo $insurer_or_tpa[$file['insurer_or_tpa']] ?></td>
<td><?php echo $import_or_export[$file['actions']] ?? ucfirst($file['actions']) ?></td>
<td><?php echo $file['count'] == null ? '-' : $file['count'] ?></td>
<td><?php echo format_indian_number($file['amount'])?></td>
<td class="reload">
<?php echo change_date_format($file['created_at'],'Y-m-d H:i:s', 'd M Y h:i a') ?> by <?php echo get_username($file['created_by']) ?>
</td>
<td>
<?php if ($file['status'] == 'failed') { ?>
<?php echo $file['status']; ?>
<a href="<?= base_url('/util/export-import-error-list/') . $file['id'] ?>"
class="fe-alert-circle" style="color: #000;" aria-hidden="true" target="_blank"
data-toggle="tooltip" data-placement="top" title="Click to show the error"></a>
&nbsp;
<?php } else if ($file['status'] == 'partially success') { ?>
<?php echo $file['status']; ?>
<?php if ($file['error_data'] != 0) { ?>
<a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
data-placement="top" title="<?= $file['error_data'] ?>"></a>
&nbsp;
<?php } ?>
<?php } else if ($file['status'] == 'in-progress-partially') { ?>
<?php echo $file['status']; ?>
<?php if (!is_json_string($file['error_data'])) { ?>
<a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
data-placement="top" title="<?= $file['error_data'] ?>"></a>
&nbsp;
<?php } ?>
<?php } else if ($file['status'] == 'failed-1') { ?>
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
data-placement="top"
title="<?= $file['event_type'] == 'inception' ? 'The list of employees provided has already been updated with the TPA ID.' : 'The list of employees provided has already been updated with the ENDORSEMENT ID.' ?> "></a>
<?php } else if ($file['status'] == 'failed-2') { ?>
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
data-placement="top"
title="<?= $file['event_type'] == 'inception' ? 'The list of employees provided has already been updated with the UHID.' : 'The list of employees provided has already been updated with the ENDORSEMENT ID.' ?>"></a>
<?php } else if ($file['status'] == 'failed-3') { ?>
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
data-placement="top"
title="The Excel record count exceeds the DB record count."></a>
<?php } else if ($file['status'] == 'failed-4') { ?>
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
data-placement="top" title="Physical File Not Found."></a>
<?php } else if ($file['status'] == 'failed-5') { ?>
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
data-placement="top" title="Wrong File Uploaded"></a>
<?php } else if ($file['status'] == 'failed-6') { ?>
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
data-placement="top" title="There is no data to update"></a>
<?php } else if ($file['status'] == 'failed-7') { ?>
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
data-placement="top" title="<?= $file['error_data'] ?>"></a>
<?php } else if ($file['status'] == 'failed-8') { ?>
failed
<?php } else { ?>
<?php echo $file['status']; ?>
<?php } ?>
</td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm"
data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<?php if($file['actions'] != 'export') { ?>
<div class="dropdown-menu dropdown-menu-right">
<?php if (str_starts_with($file['status'], 'failed')) { ?>
<a href="#"
data-id="<?= $file['id'] ?>"
data-client_id="<?= $file['client_id'] ?>"
data-client_policy_id="<?= $file['client_policy_id'] ?>"
data-insurer_or_tpa="<?= $file['insurer_or_tpa'] ?>"
data-event_type="<?= $file['event_type'] ?>"
data-actions="<?= $file['actions'] ?>"
data-client_branch_id="<?= $file['client_branch_id'] ?>"
data-issue_date="<?= $file['policy_issue_date'] ?>"
onclick="getBatchFileData(this)" class="dropdown-item upload_button" ><i class="mdi mdi-upload mr-2 text-muted font-18 vertical-middle"></i>Re-Upload</a>
<?php } ?>
<?php if ($file['actions'] == "import") { ?>
<a href="<?= base_url('/util/download_import_file/') . $file['id'] ?>" class="dropdown-item" style="color: #000;" aria-hidden="true" target="_blank" ><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download</a>
<?php } ?>
<?php if ($file['actions'] == "fetch" && $file['status'] == 'partially success') { ?>
<a href="<?= base_url('employee/getTPADataVariationReport/') . $file['id'] ?>" class="dropdown-item" style="color: #000;" aria-hidden="true" target="_blank" ><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download TPA Variation report</a>
<a href="#" class="dropdown-item" style="color: #000;" aria-hidden="true" onclick="getTPADataVariationReport(<?= $file['id'] ?>)"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View TPA Variation report</a>
<?php } ?>
</div>
<?php } ?>
</div>
</td>
</tr>
<?php }
} ?>
</tbody>
</table>
<div>
</div>
</div>
</div><!-- end col -->
</div>
</div>
<!-- Center modal content for reupload file-->
<div class="modal fade" id="batch_file_upload_modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myCenterModalLabel">Re-Upload the file</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<form class="parsley-examples" id="re_upload_import_export_excel_form" action="<?php echo base_url() . 'util/import-export' ?>" method="post" enctype="multipart/form-data">
<input type="hidden" id="batch_file_client_id" name="client_id">
<input type="hidden" id="batch_file_policy_id" name="client_policy_id">
<input type="hidden" id="batch_file_branch_id" name="client_branch_id">
<input type="hidden" id="batch_file_insurer_or_tpa" name="insurer_or_tpa">
<input type="hidden" id="batch_file_action_type" name="action_type">
<input type="hidden" id="batch_file_event_type" name="event_type">
<input type="hidden" id="batch_file_issue_date" name="policy_issue_date">
<input type="file" id="import_file_data" name="import_file_data" required
accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet">
<button type="submit" class="btn btn-primary">Upload</button>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- TPA Data Variation Modal -->
<div class="modal fade" id="tpa_variation_modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-xl modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">TPA Data Variation Report</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<ul class="nav nav-tabs" id="tpaVariationTabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="not-in-nhance-tab" data-toggle="tab" href="#not_in_nhance_tab" role="tab" aria-controls="not_in_nhance_tab" aria-selected="true">Not in Nhance</a>
</li>
<li class="nav-item">
<a class="nav-link" id="not-in-tpa-tab" data-toggle="tab" href="#not_in_tpa_tab" role="tab" aria-controls="not_in_tpa_tab" aria-selected="false">Not in TPA</a>
</li>
<li class="nav-item">
<a class="nav-link" id="need-to-review-tab" data-toggle="tab" href="#need_to_review_tab" role="tab" aria-controls="need_to_review_tab" aria-selected="false">Need to Review</a>
</li>
</ul>
<div class="tab-content pt-3" id="tpaVariationTabContent">
<div class="tab-pane fade show active" id="not_in_nhance_tab" role="tabpanel" aria-labelledby="not-in-nhance-tab">
<div class="table-responsive">
<table class="table table-bordered table-sm" id="not_in_nhance_table">
<thead></thead>
<tbody></tbody>
</table>
</div>
</div>
<div class="tab-pane fade" id="not_in_tpa_tab" role="tabpanel" aria-labelledby="not-in-tpa-tab">
<div class="table-responsive">
<table class="table table-bordered table-sm" id="not_in_tpa_table">
<thead></thead>
<tbody></tbody>
</table>
</div>
</div>
<div class="tab-pane fade" id="need_to_review_tab" role="tabpanel" aria-labelledby="need-to-review-tab">
<div class="table-responsive">
<table class="table table-bordered table-sm" id="need_to_review_table">
<thead></thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">Close</button>
<button type="button" id="tpaProceedButton" class="btn btn-primary btn-sm" onclick="handleTPAProceed()">Proceed</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
let currentTPAVariationFileId = null;
const tpaVariationColumns = {
not_in_nhance: [
{ key: 'emp_code', label: 'Employee Code' },
{ key: 'name', label: 'Employee Name' },
{ key: 'relation', label: 'Relation' },
{ key: 'dob', label: 'Date of Birth' },
{ key: 'gender', label: 'Gender' },
{ key: 'age', label: 'Age' },
{ key: 'tpa_id', label: 'TPA Member ID' },
],
not_in_tpa: [
{ key: 'emp_code', label: 'Employee Code' },
{ key: 'name', label: 'Employee Name' },
{ key: 'relationship', label: 'Relation' },
{ key: 'dob', label: 'Date of Birth' },
{ key: 'gender', label: 'Gender' },
{ key: 'mobile', label: 'Mobile No' },
{ key: 'email_corporate', label: 'Corporate Email' },
{ key: 'policy_no', label: 'Policy No' },
{ key: 'tpa_name', label: 'TPA Name' },
{ key: 'change_event', label: 'Change Event' },
],
need_to_review: [
// DB side
{ key: 'emp_code', label: 'Employee Code' },
{ key: 'name', label: 'Employee Name' },
{ key: 'relationship', label: 'Relation' },
{ key: 'dob', label: 'Date of Birth' },
{ key: 'gender', label: 'Gender' },
{ key: 'policy_no', label: 'Policy No' },
{ key: 'uhid', label: 'UHID' },
{ key: 'change_event', label: 'Change Event' },
// TPA side
{ key: 'tpa_emp_code', label: 'TPA Employee Code' },
{ key: 'tpa_name', label: 'TPA Name' },
{ key: 'tpa_relation', label: 'TPA Relation' },
{ key: 'tpa_dob', label: 'TPA Date of Birth' },
{ key: 'tpa_gender', label: 'TPA Gender' },
{ key: 'tpa_tpa_id', label: 'TPA Member ID' },
{ key: 'tpa_age', label: 'TPA Age' },
// Mismatch info
{ key: 'mismatch_fields', label: 'Mismatch Fields' },
],
};
function renderVariationTable(tableSelector, rows, columns) {
const $table = $(tableSelector);
const $thead = $table.find('thead');
const $tbody = $table.find('tbody');
$thead.empty();
$tbody.empty();
const headerRow = $('<tr></tr>');
columns.forEach(col => {
headerRow.append($('<th></th>').text(col.label));
});
$thead.append(headerRow);
if (!rows || !rows.length) {
const emptyRow = $('<tr></tr>');
columns.forEach((col, index) => {
const td = $('<td></td>');
if (index === 0) {
td.addClass('text-center text-muted').text('No data found');
}
emptyRow.append(td);
});
$tbody.append(emptyRow);
return;
}
rows.forEach(row => {
const tr = $('<tr></tr>');
columns.forEach(col => {
let value = row[col.key];
if (value === null || value === undefined) {
value = '';
}
tr.append($('<td></td>').text(value));
});
$tbody.append(tr);
});
}
function populateTPAVariationModal(data) {
const notInNhance = data.not_in_nhance || [];
const notInTpa = data.not_in_tpa || [];
const reviewData = (data.mismatch_data || []).map(row => {
let mismatchFields = '';
const match = row.match || {};
const notMatching = match.not_matching || [];
if (Array.isArray(notMatching) && notMatching.length) {
mismatchFields = notMatching.join(', ');
} else if (match.status && match.status !== 'matched') {
mismatchFields = match.status;
}
const tpaRecord = match.tpa_record || {};
return Object.assign({}, row, {
mismatch_fields: mismatchFields,
tpa_emp_code: tpaRecord.emp_code || '',
tpa_name: tpaRecord.name || '',
tpa_relation: tpaRecord.relation || '',
tpa_dob: tpaRecord.dob || '',
tpa_gender: tpaRecord.gender || '',
tpa_tpa_id: tpaRecord.tpa_id || '',
tpa_age: tpaRecord.age || '',
});
});
destroyVariationDataTable('#not_in_nhance_table');
destroyVariationDataTable('#not_in_tpa_table');
destroyVariationDataTable('#need_to_review_table');
renderVariationTable('#not_in_nhance_table', notInNhance, tpaVariationColumns.not_in_nhance);
renderVariationTable('#not_in_tpa_table', notInTpa, tpaVariationColumns.not_in_tpa);
renderVariationTable('#need_to_review_table', reviewData, tpaVariationColumns.need_to_review);
initVariationDataTable('#not_in_nhance_table');
initVariationDataTable('#not_in_tpa_table');
initVariationDataTable('#need_to_review_table');
}
function showTPAVariationModal() {
const modalElement = document.getElementById('tpa_variation_modal');
if (!modalElement) {
return;
}
const modal = new bootstrap.Modal(modalElement);
modal.show();
// Ensure proceed button reflects the currently active tab when modal opens
const $activeTab = $('#tpaVariationTabs .nav-link.active');
updateTPAProceedButton($activeTab.attr('id'));
}
function initVariationDataTable(tableSelector) {
const $table = $(tableSelector);
$table.DataTable({
pageLength: 20,
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
searching: true,
paging: true,
ordering: false,
info: true,
autoWidth: false
});
}
function destroyVariationDataTable(tableSelector) {
const $table = $(tableSelector);
if ($.fn.DataTable.isDataTable($table)) {
$table.DataTable().clear().destroy();
}
}
function updateTPAProceedButton(activeId) {
const $button = $('#tpaProceedButton');
if (!$button.length) {
return;
}
// Default: visible
$button.removeClass('d-none');
if (activeId === 'not-in-nhance-tab') {
$button.text('Proceed - Not in Nhance');
} else if (activeId === 'need-to-review-tab') {
$button.text('Proceed - Need to Review');
} else if (activeId === 'not-in-tpa-tab') {
// Hide button for "Not in TPA" section
$button.addClass('d-none');
} else {
$button.text('Proceed');
}
}
$(document).ready(function() {
// Update proceed button label/visibility on tab change
$('#tpaVariationTabs a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
const activeId = $(e.target).attr('id');
updateTPAProceedButton(activeId);
});
$('#datatable-buttons').DataTable({
// dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
// buttons: [{
// extend: 'csv',
// text: 'CSV',
// title: 'Batch List',
// className: 'my_class',
// }],
// initComplete: function(settings, json) {
// $('.my_class').css({
// position: "relative",
// left: "50px"
// });
// },
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
className: 'btn app-btn-secondary ',
buttons: [
{
extend: 'csv',
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
title: 'Batch List',
className: 'app-btn-primary ',
}
]
}
],
language: {
search: `
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
</div>`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
paging: true
});
});
// Function to format a number in Indian Rupees format
function formatNumberInIndianRupees(number) {
const maxLength = 16;
let value = number.toString().replace(/\D/g, ''); // Remove non-numeric characters
// Limit the number of digits
value = value.slice(0, maxLength);
// Format the number with commas using Indian numbering system
const formattedNumber = Number(value).toLocaleString('en-IN');
return formattedNumber;
}
// Function to format numbers based on a class
function formatNumbersByClass(className) {
const elements = document.querySelectorAll(`.${className}`);
console.log('element', elements)
elements.forEach(element => {
const number = parseFloat(element.innerText.replace(/,/g, ''));
console.log('number', number)
if (!isNaN(number)) {
console.log(formatNumberInIndianRupees(number))
element.innerText = formatNumberInIndianRupees(number);
}
});
}
// Format numbers when the DOM content is loaded
document.addEventListener("DOMContentLoaded", function() {
setTimeout(() => {
formatNumbersByClass('indian-number');
}, 500);
});
function getBatchFileData(input){
let client_id = $(input).data('client_id')
let client_policy_id = $(input).data('client_policy_id')
let client_branch_id = $(input).data('client_branch_id')
let insurer_or_tpa = $(input).data('insurer_or_tpa')
let event_type = $(input).data('event_type')
let actions = $(input).data('actions')
let issue_date = $(input).data('issue_date')
console.log('client_id', client_id);
console.log('client_policy_id', client_policy_id);
console.log('client_branch_id', client_branch_id);
console.log('insurer_or_tpa', insurer_or_tpa);
console.log('event_type', event_type);
console.log('actions', actions);
console.log('issue_date', issue_date);
$('#batch_file_client_id').val(client_id);
$('#batch_file_policy_id').val(client_policy_id);
$('#batch_file_branch_id').val(client_branch_id);
$('#batch_file_insurer_or_tpa').val(insurer_or_tpa);
$('#batch_file_action_type').val(actions);
$('#batch_file_event_type').val(event_type);
$('#batch_file_issue_date').val(issue_date);
var myModal = new bootstrap.Modal(document.getElementById('batch_file_upload_modal'));
myModal.show();
// $('.loader').fadeIn();
// $('.loader-mask').fadeIn();
// console.log('file_id', file_id);
// let url = '<?= base_url('util/getBatchFileData') ?>';
// // Data to send in the AJAX request
// let requestData = {
// file_id: file_id,
// };
// // Send AJAX request
// sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
// console.log('Data fetched successfully:', response);
// console.log('Data fetched successfully:', response.batch_file_data);
// console.log('response.batch_file_data.client_branch_id:', response.batch_file_data.client_branch_id);
// if (response.status == true) {
// } else {
// toastr.warning(response.message || 'Unable to fetch data', 'WARNING');
// }
// $('.loader').fadeOut();
// $('.loader-mask').delay(350).fadeOut('slow');
// }, function(xhr, status, error) {
// console.error('Error fetching data:', error);
// console.error(xhr.responseText);
// toastr.error('An error occurred while checking the SI amount.', 'ERROR');
// $('.loader').fadeOut();
// $('.loader-mask').delay(350).fadeOut('slow');
// // addRow();
// });
}
function getTPADataVariationReport(file_id) {
currentTPAVariationFileId = file_id;
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
let url = '<?= base_url('employee/getTPADataVariationReportView') ?>/' + file_id;
sendAjaxRequestForGlobal(url, 'GET', {}, function (response) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (response && response.status && response.data) {
populateTPAVariationModal(response.data);
showTPAVariationModal();
} else {
toastr.warning((response && response.message) || 'No data found for variation report.', 'WARNING');
}
}, function (xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.error('Error fetching TPA variation data:', error);
toastr.error('An error occurred while fetching the variation report.', 'ERROR');
});
}
function proceedTPADataVariationNextStep(tabKey) {
if (!currentTPAVariationFileId) {
toastr.warning('Unable to identify the selected file.', 'WARNING');
return;
}
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
const url = '<?= base_url('employee/proceedTPADataVariationNextStep') ?>/' + currentTPAVariationFileId + '?tab=' + encodeURIComponent(tabKey);
sendAjaxRequestForGlobal(url, 'GET', {}, function (response) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (response && response.status) {
toastr.success(response.message || 'Proceed to next step initiated successfully.', 'SUCCESS');
} else {
toastr.warning(response.message || 'Unable to proceed to next step.', 'WARNING');
}
window.location.reload();
}, function (xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.error('An error occurred while proceeding to the next step.', 'ERROR');
console.error(error);
});
}
function proceedNotInNhance() {
proceedTPADataVariationNextStep('not_in_nhance');
}
function proceedNotInTPA() {
proceedTPADataVariationNextStep('not_in_tpa');
}
function proceedNeedToReview() {
proceedTPADataVariationNextStep('need_to_review');
}
function handleTPAProceed() {
const $activeTab = $('#tpaVariationTabs .nav-link.active');
const activeId = $activeTab.attr('id');
if (!activeId) {
toastr.warning('No active tab selected.', 'WARNING');
return;
}
const tabLabel = ($activeTab.text() || '').trim() || 'this tab';
confirmActionSweertAlert(
"Are you sure you want to proceed with the data in this tab?",
"Yes, Proceed",
"Cancel",
"warning"
).then(function(isConfirmed) {
if (!isConfirmed) {
return;
}
if (activeId === 'not-in-nhance-tab') {
proceedNotInNhance();
} else if (activeId === 'not-in-tpa-tab') {
proceedNotInTPA();
} else if (activeId === 'need-to-review-tab') {
proceedNeedToReview();
} else {
toastr.warning('Unknown tab selected.', 'WARNING');
}
});
}
</script>