1101 lines
47 KiB
PHP
1101 lines
47 KiB
PHP
<style>
|
||
|
||
.reload:hover {
|
||
cursor: pointer;
|
||
}
|
||
|
||
.table th,
|
||
.table td {
|
||
padding: 8px;
|
||
}
|
||
|
||
table.dataTable tbody td {
|
||
padding: 4px 4px !important;
|
||
}
|
||
|
||
.addbtnStyle{
|
||
margin-left: 20px !important;
|
||
}
|
||
|
||
.dataTables_filter {
|
||
position: absolute;
|
||
}
|
||
|
||
.dataTables_length label {height: 21px !important;}
|
||
|
||
.readonly-select { background-color: #f3f3f3 !important; cursor: not-allowed; pointer-events: none; }
|
||
|
||
.custom-tooltip {
|
||
position: relative;
|
||
display: inline-block;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.info-icon {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 18px;
|
||
height: 18px;
|
||
background-color: #007bff;
|
||
color: #fff;
|
||
border-radius: 50%;
|
||
font-size: 14px;
|
||
font-style: italic;
|
||
font-weight: bold;
|
||
font-family: Georgia, serif;
|
||
line-height: 1;
|
||
vertical-align: middle;
|
||
}
|
||
|
||
.tooltiptext {
|
||
visibility: hidden;
|
||
opacity: 0;
|
||
position: fixed; /* fixed instead of absolute to escape modal overflow */
|
||
background: #333;
|
||
color: #fff;
|
||
padding: 10px 14px;
|
||
border-radius: 6px;
|
||
white-space: normal; /* allow text wrapping */
|
||
width: 320px; /* fixed width for multiline */
|
||
font-size: 12px;
|
||
font-weight: normal;
|
||
font-style: normal;
|
||
line-height: 1.6;
|
||
z-index: 99999;
|
||
transition: opacity 0.2s ease;
|
||
pointer-events: none;
|
||
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
||
top: 20px !important;
|
||
left: 155px !important;
|
||
}
|
||
|
||
.tooltiptext::after {
|
||
content: "";
|
||
position: absolute;
|
||
top: 100%;
|
||
left: 20px;
|
||
border: 6px solid transparent;
|
||
border-top-color: #333;
|
||
}
|
||
|
||
.custom-tooltip:hover .tooltiptext {
|
||
visibility: visible;
|
||
opacity: 1;
|
||
}
|
||
|
||
</style>
|
||
<script>
|
||
var pageHideMainNavTitle = true;
|
||
var pageTitle = 'Claim Dump Upload';
|
||
</script>
|
||
|
||
<!-- <div class="row">
|
||
<div class="col-xl-12" style="margin-left: 14px;max-width: 98%;">
|
||
<div id="accordion1" class="mb-3">
|
||
<div class="card mb-1">
|
||
<h5 class="m-1">
|
||
<a id="toggleIcon1" class="text-dark float-right" data-toggle="collapse" href="#collapseTwo"
|
||
aria-expanded="true">
|
||
<i id="icon1" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
|
||
</a>
|
||
</h5>
|
||
<div id="collapseTwo" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion1">
|
||
<div class="card-body">
|
||
<form class="parsley-examples" id="claim-upload-form" enctype="multipart/form-data">
|
||
<div class="form-group">
|
||
<div class="form-row" id="file_upload">
|
||
<div class="form-group col-md-4">
|
||
<label>Upload file</label>
|
||
<input type="file" name="claim_dump_list" id="claim_dump_list" accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet" required>
|
||
</div>
|
||
<div class="d-flex align-items-center justify-content-start">
|
||
<div class="form-group col-md-11">
|
||
<div class="col-md-3">
|
||
<button id="claim_form_submit_button" type="submit" class="btn btn-primary waves-effect waves-light justify-content-end">Upload</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div> -->
|
||
|
||
<div class="col-12">
|
||
<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;">Claim Dump Upload</h4>
|
||
</div>
|
||
|
||
</div> -->
|
||
<table data-custom-table-css="table" class="table table-hover m-0 table-centered w-100" cellspacing="0" id="tickets-table">
|
||
<thead class="bg-light">
|
||
<tr>
|
||
<th class="font-weight-medium">S.No </th>
|
||
<th class="font-weight-medium">Client</th>
|
||
<th class="font-weight-medium">Policy</th>
|
||
<th class="font-weight-medium">File name</th>
|
||
<th class="font-weight-medium">User/Time</th>
|
||
<th class="font-weight-medium">Status</th>
|
||
<th class="font-weight-medium">Action</th>
|
||
</tr>
|
||
</thead>
|
||
|
||
<tbody class="font-12">
|
||
<?php
|
||
if (isset($claim_dump_file_data)) {
|
||
foreach ($claim_dump_file_data as $key => $file) {
|
||
?>
|
||
|
||
<tr>
|
||
<td><b><?php echo ($key + 1) ?></b></td>
|
||
<td><?php echo $file['client_name'] ?></td>
|
||
<td><?php echo $file['policy_no'] ?></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 change_date_format($file['created_at'], 'Y-m-d H:i:s', 'd/m/Y h:i A') . ' by <strong>' . $file['user_name'] . '</strong>' ?> </td>
|
||
<td>
|
||
<?php
|
||
$pendingCount = (int) ($file['pending_ticket_count'] ?? 0);
|
||
$hasPendingTickets = !empty($file['tpa_id']) && $pendingCount > 0;
|
||
?>
|
||
<?php if ($file['status'] == "failed") { ?>
|
||
<span style="color : #BD0707 ;"> <?= $file['status'] ?> </span>
|
||
<span class='col-xl-3 col-lg-4 col-sm-6'>
|
||
<a href="#" class='fe-alert-circle' onclick="fetchFileError(<?= $file['file_id'] ?>)"></a>
|
||
</span>
|
||
<?php } else if ($file['status'] == "inprogress" || $file['status'] == "processing") { ?>
|
||
<a data-id="<?= $file['status'] ?>" class="reload" href="#"
|
||
style="color : #938e04ff ;">
|
||
<?= $file['status'] ?>
|
||
</a>
|
||
<?php } else if ($hasPendingTickets) { ?>
|
||
<span style="color:#D97706;" title="<?= $pendingCount ?> dump row(s) not moved to ticket master">
|
||
partial
|
||
</span>
|
||
<div class="text-muted small mt-1"><?= $pendingCount ?> pending ticket(s)</div>
|
||
<?php } else { ?>
|
||
<span style="color : #34A853 ;"> <?= $file['status'] ?> </span>
|
||
<?php } ?>
|
||
</td>
|
||
<td class="text-center table-action-cell">
|
||
<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>
|
||
<div class="dropdown-menu dropdown-menu-right">
|
||
<a target="_blank" class="dropdown-item" href="<?= base_url("util/download_claim_dump_file/") . $file['file_id']; ?>"><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download</a>
|
||
|
||
<?php if ($file['status'] === 'failed') : ?>
|
||
<a href="javascript:void(0);"
|
||
class="dropdown-item"
|
||
onclick="downloadTpaErrorFile(<?= (int) $file['file_id']; ?>)">
|
||
<i class="mdi mdi-file-excel mr-2 text-danger font-18 vertical-middle"></i>
|
||
Download Error File
|
||
</a>
|
||
<?php endif; ?>
|
||
|
||
<?php if ($hasPendingTickets && $file['status'] !== 'processing') : ?>
|
||
<a href="javascript:void(0);"
|
||
class="dropdown-item"
|
||
onclick="viewClaimDumpPendingData(<?= (int) $file['file_id']; ?>)">
|
||
<i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>
|
||
View Data (<?= $pendingCount; ?>)
|
||
</a>
|
||
<a href="javascript:void(0);"
|
||
class="dropdown-item text-warning"
|
||
onclick="reprocessClaimDumpPending(<?= (int) $file['file_id']; ?>, <?= $pendingCount; ?>)">
|
||
<i class="mdi mdi-reload mr-2 text-warning font-18 vertical-middle"></i>
|
||
Process Pending (<?= $pendingCount; ?>)
|
||
</a>
|
||
<?php endif; ?>
|
||
|
||
<?php if (!empty($file['tpa_id']) && $file['status'] !== 'processing') : ?>
|
||
<a href="javascript:void(0);"
|
||
class="dropdown-item text-danger"
|
||
onclick="truncateClaimDumpFile(<?= (int) $file['file_id']; ?>)">
|
||
<i class="mdi mdi-delete-forever mr-2 text-danger font-18 vertical-middle"></i>
|
||
Truncate
|
||
</a>
|
||
<?php endif; ?>
|
||
|
||
<!-- <a data-id="<?php echo $file['file_id'] ?>" data-toggle="modal" data-target="#full-width-modal-emp-list" class="dropdown-item view_emp_list" href="#"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View</a> -->
|
||
</div>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<?php }
|
||
} ?>
|
||
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div><!-- end col -->
|
||
|
||
<!-- Pending dump rows (ticket_id NULL) modal -->
|
||
<div class="modal fade" id="claim-dump-pending-modal" tabindex="-1" role="dialog" aria-labelledby="claim-dump-pending-title" aria-hidden="true" data-backdrop="static">
|
||
<div class="modal-dialog modal-dialog-centered modal-xl" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="claim-dump-pending-title">Pending Dump Rows (ticket_id empty)</h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||
<span aria-hidden="true">×</span>
|
||
</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div id="claim-dump-pending-loading" class="text-center py-4">
|
||
<div class="spinner-border text-primary" role="status"></div>
|
||
</div>
|
||
<div id="claim-dump-pending-content" style="display:none;">
|
||
<p class="mb-2 text-muted" id="claim-dump-pending-summary"></p>
|
||
<div class="table-responsive" style="max-height: 420px; overflow:auto;">
|
||
<table class="table table-sm table-bordered table-hover mb-0" id="claim-dump-pending-table">
|
||
<thead class="thead-light" id="claim-dump-pending-thead"></thead>
|
||
<tbody id="claim-dump-pending-tbody"></tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
<div id="claim-dump-pending-empty" class="text-center text-muted py-4" style="display:none;">
|
||
No pending rows found.
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-light" data-dismiss="modal">Close</button>
|
||
<button type="button" class="btn btn-warning" id="claim-dump-pending-process-btn" style="display:none;">
|
||
Process Pending
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<style>
|
||
#claim-dump-pending-modal {
|
||
z-index: 1060;
|
||
}
|
||
#claim-dump-pending-modal .modal-content {
|
||
background: #fff;
|
||
opacity: 1;
|
||
}
|
||
#claim-dump-pending-modal .modal-body {
|
||
background: #fff;
|
||
}
|
||
</style>
|
||
|
||
<!-- Center modal content -->
|
||
<div class="modal fade" id="cliam-dump-file-err-modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
|
||
<div class="modal-dialog modal-dialog-centered">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myCenterModalLabel">File Rejected Reason</h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div id="modal_body" class="modal-body">
|
||
<div class="spinner-border text-primary" role="status" style="position: relative; left: 200px;"></div>
|
||
</div>
|
||
</div>
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
<!-- Center modal content for upload file-->
|
||
<div class="modal fade" id="claim-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">
|
||
Claim Dump Upload
|
||
<i class="info-icon"
|
||
data-toggle="tooltip"
|
||
data-placement="right"
|
||
data-html="true"
|
||
title="1. If you want to upload a TPA-wise claim dump, select the client and policy, then upload the TPA's Excel file. <br><br> 2. The second option without selecting the client and policy allows you to upload multiple claims. You can download the sample file provided below, fill it in, and upload it. This is for bulk dump upload.">
|
||
i
|
||
</i>
|
||
</h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<form class="parsley-examples" id="claim-upload-form" enctype="multipart/form-data">
|
||
<div class="form-group">
|
||
<div class="form-row">
|
||
<div class="form-group col-md-12">
|
||
<label>Client<span id="tpa_danger" class="text-danger"></span></label>
|
||
<select name="client_id" class="form-control" id="client_id">
|
||
<option value="">Select</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-12">
|
||
<label>Policy <span id="tpa_danger" class="text-danger"></span></label>
|
||
<select name="client_policy_id" class="form-control" id="client_policy_id">
|
||
<option value="">Select</option>
|
||
</select>
|
||
</div>
|
||
<div class="form-group col-md-12">
|
||
<label for="tpa">TPA<span id="tpa_danger" class="text-danger"></span></label>
|
||
<select class="form-control readonly-select" id="tpa_id" name="tpa_id">
|
||
<option value="">Select TPA</option>
|
||
<?php foreach ($tpa_list ?? [] as $value) { ?>
|
||
<option value="<?= $value['id'] ?>"><?= $value['short_name'] ?></option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
<div class="form-group col-md-12">
|
||
<label for="claim_dump_date">Claim Dump Date</label>
|
||
<input type="text" class="form-control" id="claim_dump_date" name="claim_dump_date" placeholder="Select claim dump date" autocomplete="off">
|
||
</div>
|
||
</div>
|
||
<div class="form-row" id="file_upload">
|
||
|
||
<div class="form-group col-md-9">
|
||
<label>Upload file</label>
|
||
[ <a href="<?= base_url("util/download-excel/claim_dump_upload"); ?>" id="download_sample_file" style="font-size: small; color:red !important;">Download sample file</a> ]
|
||
<input type="file" name="claim_dump_list" id="claim_dump_list" accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet" required>
|
||
</div>
|
||
<div class="form-group col-md-3" style="margin-top: 40px;">
|
||
<button id="claim_form_submit_button" type="submit" class="btn btn-primary waves-effect waves-light justify-content-end">Upload</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
<div id="full-width-modal-emp-list" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="fullWidthModalLabel"
|
||
aria-hidden="true">
|
||
<div class="modal-dialog modal-full-width">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="fullWidthModalLabel">View Uploaded File<span
|
||
id="title_header_name"></span></h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body" id="emp_data_success">
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
<script>
|
||
|
||
let policyListByClient = null;
|
||
let client_list = null;
|
||
|
||
$(function () {
|
||
$('[data-toggle="tooltip"]').tooltip();
|
||
});
|
||
|
||
document.querySelectorAll('.custom-tooltip').forEach(function(tooltip) {
|
||
tooltip.addEventListener('mouseenter', function() {
|
||
var icon = this.querySelector('.info-icon');
|
||
var tip = this.querySelector('.tooltiptext');
|
||
var rect = icon.getBoundingClientRect();
|
||
tip.style.left = rect.left + 'px';
|
||
tip.style.top = (rect.top - tip.offsetHeight - 10) + 'px';
|
||
});
|
||
});
|
||
|
||
$(document).ready(function() {
|
||
|
||
getClientAndBranchAndPolicy();
|
||
|
||
$('#client_id').select2();
|
||
$('#client_policy_id').select2();
|
||
flatpickr("#claim_dump_date", {
|
||
dateFormat: "d/m/Y",
|
||
allowInput: false,
|
||
maxDate: "today"
|
||
});
|
||
|
||
// AJAX Form Submit Function
|
||
$('#claim-upload-form').on('submit', function(e) {
|
||
e.preventDefault(); // Prevent default form submission
|
||
|
||
let client_id = $('#client_id').val() ?? null;
|
||
let client_policy_id = $('#client_policy_id').val() ?? null;
|
||
let tpa_id = $('#tpa_id').val() ?? null;
|
||
|
||
if(client_id){
|
||
|
||
if(!client_policy_id){
|
||
toastr.warning('Please select the client policy', 'WARNING');
|
||
return;
|
||
}
|
||
|
||
if(!tpa_id){
|
||
toastr.warning('TPA is required', 'WARNING');
|
||
return;
|
||
}
|
||
}
|
||
|
||
// Get form data
|
||
var formData = new FormData(this);
|
||
var fileInput = $('#claim_dump_list')[0];
|
||
|
||
// Validate file type
|
||
var allowedTypes = [
|
||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||
'application/vnd.ms-excel',
|
||
'application/vnd.oasis.opendocument.spreadsheet'
|
||
];
|
||
|
||
if (!fileInput.files.length) {
|
||
toastr.warning('Please select an Excel file', 'WARNING');
|
||
return false;
|
||
}
|
||
|
||
var selectedFile = fileInput.files[0];
|
||
|
||
if (!allowedTypes.includes(selectedFile.type)) {
|
||
toastr.warning('Please upload a valid Excel file (.xlsx, .xls, .ods)', 'WARNING');
|
||
return false;
|
||
}
|
||
|
||
//form submit url;
|
||
let url = `<?php echo base_url('ticket/claim-upload'); ?>`;
|
||
|
||
// Show loading state
|
||
var submitButton = $('#claim_form_submit_button');
|
||
var originalText = submitButton.text();
|
||
submitButton.prop('disabled', true).text('Uploading...');
|
||
|
||
|
||
// AJAX request
|
||
$.ajax({
|
||
url: url, // Your route URL
|
||
type: 'POST',
|
||
data: formData,
|
||
processData: false, // CRITICAL: Don't process the data
|
||
contentType: false, // CRITICAL: Don't set content-type header
|
||
cache: false,
|
||
success: function(response) {
|
||
|
||
// Handle successful response
|
||
console.log('Upload successful:', response);
|
||
|
||
if (response.status == true) {
|
||
toastr.success(response.message, "Success");
|
||
} else {
|
||
toastr.error(response.message, "Error");
|
||
}
|
||
|
||
// Reset form
|
||
$('#claim-upload-form')[0].reset();
|
||
$('.close').click();
|
||
window.location.reload();
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
// Handle error response
|
||
console.error('Upload failed:', error);
|
||
console.error('Upload failed:', error);
|
||
},
|
||
complete: function() {
|
||
// Reset button state
|
||
submitButton.prop('disabled', false).text(originalText);
|
||
}
|
||
});
|
||
});
|
||
|
||
// File input change event for additional validation
|
||
$('#claim_dump_list').on('change', function() {
|
||
var fileInput = this;
|
||
var file = fileInput.files[0];
|
||
|
||
if (file) {
|
||
// Check file size (optional - set max size as needed, e.g., 10MB)
|
||
var maxSize = 10 * 1024 * 1024; // 10MB in bytes
|
||
if (file.size > maxSize) {
|
||
toastr.warning('File size should not exceed 10MB');
|
||
$(this).val(''); // Clear the input
|
||
return false;
|
||
}
|
||
|
||
// Display selected file name
|
||
var fileName = file.name;
|
||
if ($('#selected-file').length === 0) {
|
||
$('<div id="selected-file" class="mt-2 text-muted"><small>Selected file: <span id="file-name"></span></small></div>')
|
||
.insertAfter('#claim_dump_list');
|
||
}
|
||
$('#file-name').text(fileName);
|
||
}
|
||
});
|
||
|
||
$('body').on('click', '.reload', function() {
|
||
status = this.getAttribute('data-id')
|
||
console.log(status);
|
||
if (status == 'inprogress') {
|
||
window.location.reload(true);
|
||
}
|
||
})
|
||
|
||
$('#client_id').on('change', function(){
|
||
|
||
let client_id = $(this).val();
|
||
|
||
if(policyListByClient != '') {
|
||
console.log(policyListByClient[client_id]);
|
||
let data = policyListByClient[client_id];
|
||
appendPolicies(data);
|
||
}
|
||
})
|
||
|
||
$('#client_policy_id').on('change', function(){
|
||
let tpa_id = $(this).find(':selected').data('tpaid');
|
||
console.log('tpa_id', tpa_id);
|
||
|
||
if(tpa_id){
|
||
$('#tpa_id').val(tpa_id);
|
||
}else{
|
||
$('#tpa_id').val('');
|
||
}
|
||
})
|
||
|
||
});
|
||
|
||
// Datatable document ready
|
||
$(document).ready(function() {
|
||
|
||
var ticketsTable = $('#tickets-table');
|
||
|
||
if (ticketsTable.length) {
|
||
ticketsTable.DataTable({
|
||
scrollX: true,
|
||
// dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
|
||
// "<'row'<'col-sm-12'tr>>" +
|
||
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
|
||
dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
|
||
"<'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: [
|
||
{
|
||
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',
|
||
className: 'buttons-html5 addbtnStyle',
|
||
action: function (e, dt, node, config) {
|
||
openDumpUploadModal();
|
||
}
|
||
}
|
||
],
|
||
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>',
|
||
paginate: {
|
||
previous: '◄',
|
||
next: '►'
|
||
}
|
||
},
|
||
paging: true, // Enable pagination
|
||
pageLength: 10, // Set default number of rows per page (optional)
|
||
});
|
||
|
||
function applyBottomRowDropup() {
|
||
if (!ticketsTable) return;
|
||
const currentRows = ticketsTable.DataTable().rows({ page: 'current' }).nodes().toArray();
|
||
$('#tickets-table tbody tr').removeClass('nh-force-dropup');
|
||
$('#tickets-table tbody tr td.table-action-cell .btn-group.dropdown').removeClass('dropup');
|
||
|
||
const targetCount = Math.min(2, currentRows.length);
|
||
for (let i = 0; i < targetCount; i++) {
|
||
const row = currentRows[currentRows.length - 1 - i];
|
||
if (!row) continue;
|
||
$(row).addClass('nh-force-dropup');
|
||
$(row).find('td.table-action-cell .btn-group.dropdown').addClass('dropup');
|
||
}
|
||
}
|
||
|
||
applyBottomRowDropup();
|
||
ticketsTable.on('draw.dt', applyBottomRowDropup);
|
||
} else {
|
||
console.error("Table not found.");
|
||
}
|
||
});
|
||
|
||
function fetchFileError(file_id) {
|
||
|
||
var url = '<?php echo base_url('util/getClaimDumpFileErrorData/'); ?>';
|
||
let requestData = { file_id: file_id };
|
||
|
||
var myModal = new bootstrap.Modal(document.getElementById('cliam-dump-file-err-modal'));
|
||
myModal.show();
|
||
|
||
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
||
console.log('Data fetched successfully:', response);
|
||
|
||
$('#modal_body').empty();
|
||
if (response.status === true) {
|
||
|
||
var file_error_data = (JSON.parse(response.data));
|
||
var file_error_html = "";
|
||
|
||
for (var key in file_error_data['error_summary']) {
|
||
var err_id = parseInt(key);
|
||
var err_count = file_error_data['error_summary'][key];
|
||
switch (err_id) {
|
||
case 0:
|
||
file_error_html += "<strong>" + file_error_data['error_data'] + "</strong>";
|
||
break;
|
||
case 1:
|
||
file_error_html += "<strong>Mandatory values missing</strong> <span class='badge badge-danger float-right'>" +
|
||
err_count + "</span><br>";
|
||
break;
|
||
case 2:
|
||
file_error_html += "<strong>Values not in expected format</strong> <span class='badge badge-danger float-right'>" +
|
||
err_count + "</span><br>";
|
||
break;
|
||
case 3:
|
||
file_error_html += "<strong>Field contains not allowed values</strong> <span class='badge badge-danger float-right'>" +
|
||
err_count + "</span><br>";
|
||
break;
|
||
case 4:
|
||
file_error_html += "<strong>Rule Conflict</strong> <span class='badge badge-danger float-right'>" +
|
||
err_count + "</span><br>";
|
||
break;
|
||
case 5:
|
||
file_error_html += "<strong>" + (file_error_data['error_data'] || 'Error data not available') + "</strong>";
|
||
break;
|
||
case 6:
|
||
file_error_html += "<strong>" + (file_error_data['error_data'] || 'Error data not available') + "</strong>";
|
||
break;
|
||
case 7:
|
||
file_error_html += "<strong>Claim already exist</strong> <span class='badge badge-danger float-right'>" +
|
||
err_count + "</span><br>";
|
||
break;
|
||
case 8:
|
||
file_error_html += "<strong>Policy not found</strong> <span class='badge badge-warning float-right'>" +
|
||
err_count + "</span><br>";
|
||
break;
|
||
case 9:
|
||
file_error_html += "<strong>Employee not found</strong> <span class='badge badge-danger float-right'>" +
|
||
err_count + "</span><br>";
|
||
break;
|
||
case 10:
|
||
file_error_html += "<strong>ACM not found</strong> <span class='badge badge-danger float-right'>" +
|
||
err_count + "</span><br>";
|
||
break;
|
||
default:
|
||
file_error_html += "<strong>Unknown error type</strong> <span class='badge badge-secondary float-right'>" +
|
||
err_count + "</span><br>";
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
if (err_id != 5 && err_id != 6 && err_id != 0) {
|
||
file_error_html += (file_error_html != "" ?
|
||
"<a href ='<?php echo base_url('util/claim_dump_excel_error/') ?>" + file_id +
|
||
"' target=_blank>click here to more details...</a>" : "");
|
||
}
|
||
|
||
// console.log(file_error_html);
|
||
$('#modal_body').append(file_error_html);
|
||
|
||
} else {
|
||
console.log('Response status was false');
|
||
$('#modal_body').append('<div class="alert alert-warning">No error data available.</div>');
|
||
}
|
||
|
||
}, function(xhr, status, error) {
|
||
console.error('Error fetching data:', error);
|
||
console.error('Status:', status);
|
||
console.error('Response:', xhr.responseText);
|
||
|
||
// Show error message to user
|
||
$('#modal_body').empty().append(
|
||
'<div class="alert alert-danger">Failed to fetch error data. Please try again.</div>'
|
||
);
|
||
});
|
||
|
||
}
|
||
|
||
function downloadTpaErrorFile(file_id) {
|
||
if (!file_id) {
|
||
toastr.error('Invalid file reference for error download', 'Error');
|
||
return;
|
||
}
|
||
|
||
var url = '<?= base_url("util/getTpaClaimDumpErrorData"); ?>/' + file_id;
|
||
|
||
$.ajax({
|
||
url: url,
|
||
type: 'GET',
|
||
xhrFields: { responseType: 'blob' },
|
||
success: function (data, status, xhr) {
|
||
var disposition = xhr.getResponseHeader('Content-Disposition') || '';
|
||
var contentType = xhr.getResponseHeader('Content-Type') || '';
|
||
|
||
// If server sent JSON (error), parse it and show via Toastr
|
||
if (contentType.indexOf('application/json') !== -1) {
|
||
var reader = new FileReader();
|
||
reader.onload = function () {
|
||
try {
|
||
var json = JSON.parse(reader.result);
|
||
var msg = json.message || 'Unable to download error file.';
|
||
toastr.error(msg, 'Error');
|
||
} catch (e) {
|
||
toastr.error('Unable to download error file.', 'Error');
|
||
}
|
||
};
|
||
reader.readAsText(data);
|
||
return;
|
||
}
|
||
|
||
// Otherwise assume it is Excel and trigger a download
|
||
var filename = 'tpa_claim_dump_errors_' + file_id + '.xlsx';
|
||
var match = /filename="?([^"]+)"?/.exec(disposition);
|
||
if (match && match[1]) {
|
||
filename = match[1];
|
||
}
|
||
|
||
var blob = new Blob([data], {
|
||
type: contentType || 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||
});
|
||
var link = document.createElement('a');
|
||
link.href = window.URL.createObjectURL(blob);
|
||
link.download = filename;
|
||
document.body.appendChild(link);
|
||
link.click();
|
||
document.body.removeChild(link);
|
||
|
||
toastr.success('Error file download started', 'Success');
|
||
},
|
||
error: function (xhr) {
|
||
var msg = 'Unable to download error file.';
|
||
try {
|
||
var json = JSON.parse(xhr.responseText);
|
||
if (json.message) {
|
||
msg = json.message;
|
||
}
|
||
} catch (e) {}
|
||
toastr.error(msg, 'Error');
|
||
}
|
||
});
|
||
}
|
||
|
||
function truncateClaimDumpFile(file_id) {
|
||
if (!file_id) {
|
||
toastr.error('Invalid file reference', 'Error');
|
||
return;
|
||
}
|
||
|
||
Swal.fire({
|
||
title: 'Do you want to truncate this?',
|
||
icon: 'warning',
|
||
showCancelButton: true,
|
||
confirmButtonText: 'OK',
|
||
cancelButtonText: 'Cancel',
|
||
}).then(function(result) {
|
||
if (!result.isConfirmed) {
|
||
return;
|
||
}
|
||
|
||
var url = '<?= base_url("util/truncateClaimDumpFile"); ?>';
|
||
sendAjaxRequestForGlobal(url, 'GET', { file_id: file_id }, function(response) {
|
||
if (response && response.status === true) {
|
||
toastr.success(response.message || 'Claim dump truncated', 'Success');
|
||
setTimeout(function() {
|
||
window.location.reload();
|
||
}, 800);
|
||
} else {
|
||
toastr.error((response && response.message) ? response.message : 'Truncate failed', 'Error');
|
||
}
|
||
}, function() {
|
||
toastr.error('Truncate request failed', 'Error');
|
||
});
|
||
});
|
||
}
|
||
|
||
function viewClaimDumpPendingData(file_id) {
|
||
if (!file_id) {
|
||
toastr.error('Invalid file reference', 'Error');
|
||
return;
|
||
}
|
||
|
||
var $loading = $('#claim-dump-pending-loading');
|
||
var $content = $('#claim-dump-pending-content');
|
||
var $empty = $('#claim-dump-pending-empty');
|
||
var $processBtn = $('#claim-dump-pending-process-btn');
|
||
|
||
$('#claim-dump-pending-title').text('Pending Dump Rows');
|
||
$('#claim-dump-pending-summary').text('');
|
||
$('#claim-dump-pending-thead').empty();
|
||
$('#claim-dump-pending-tbody').empty();
|
||
$loading.show();
|
||
$content.hide();
|
||
$empty.hide();
|
||
$processBtn.hide().off('click');
|
||
|
||
var myModal = new bootstrap.Modal(document.getElementById('claim-dump-pending-modal'));
|
||
myModal.show();
|
||
|
||
$.ajax({
|
||
url: '<?= base_url("util/getClaimDumpPendingRows"); ?>',
|
||
type: 'GET',
|
||
dataType: 'json',
|
||
data: { file_id: file_id },
|
||
success: function(response) {
|
||
$loading.hide();
|
||
if (!response || response.status !== true || !response.data) {
|
||
toastr.error((response && response.message) ? response.message : 'Unable to load pending rows', 'Error');
|
||
$empty.show().text((response && response.message) ? response.message : 'Unable to load pending rows');
|
||
return;
|
||
}
|
||
|
||
var data = response.data;
|
||
var rows = data.rows || [];
|
||
var headers = data.headers || [];
|
||
|
||
$('#claim-dump-pending-title').text(
|
||
'Pending Dump Rows — ' + (data.file_name || ('File #' + file_id))
|
||
);
|
||
$('#claim-dump-pending-summary').text(
|
||
rows.length + ' row(s) with ticket_id empty (not moved to ticket master).'
|
||
);
|
||
|
||
if (!rows.length) {
|
||
$empty.show();
|
||
return;
|
||
}
|
||
|
||
var headHtml = '<tr>';
|
||
headHtml += '<th>#</th>';
|
||
headers.forEach(function(h) {
|
||
headHtml += '<th>' + (h.label || h.key) + '</th>';
|
||
});
|
||
headHtml += '</tr>';
|
||
$('#claim-dump-pending-thead').html(headHtml);
|
||
|
||
var bodyHtml = '';
|
||
rows.forEach(function(row, idx) {
|
||
bodyHtml += '<tr>';
|
||
bodyHtml += '<td>' + (idx + 1) + '</td>';
|
||
headers.forEach(function(h) {
|
||
var val = row[h.key];
|
||
if (val === null || typeof val === 'undefined' || val === '') {
|
||
val = '-';
|
||
}
|
||
bodyHtml += '<td>' + $('<div>').text(String(val)).html() + '</td>';
|
||
});
|
||
bodyHtml += '</tr>';
|
||
});
|
||
$('#claim-dump-pending-tbody').html(bodyHtml);
|
||
$content.show();
|
||
|
||
$processBtn.show().on('click', function() {
|
||
myModal.hide();
|
||
reprocessClaimDumpPending(file_id, rows.length);
|
||
});
|
||
},
|
||
error: function() {
|
||
$loading.hide();
|
||
$empty.show().text('Failed to load pending rows');
|
||
toastr.error('Failed to load pending rows', 'Error');
|
||
}
|
||
});
|
||
}
|
||
|
||
function reprocessClaimDumpPending(file_id, pending_count) {
|
||
if (!file_id) {
|
||
toastr.error('Invalid file reference', 'Error');
|
||
return;
|
||
}
|
||
|
||
Swal.fire({
|
||
title: 'Process pending dump rows?',
|
||
text: (pending_count || 0) + ' row(s) have no ticket yet. This will try to create/link tickets again.',
|
||
icon: 'question',
|
||
showCancelButton: true,
|
||
confirmButtonText: 'Process',
|
||
cancelButtonText: 'Cancel',
|
||
}).then(function(result) {
|
||
if (!result.isConfirmed) {
|
||
return;
|
||
}
|
||
|
||
var url = '<?= base_url("util/reprocessClaimDumpPending"); ?>';
|
||
sendAjaxRequestForGlobal(url, 'GET', { file_id: file_id }, function(response) {
|
||
if (response && response.status === true) {
|
||
toastr.success(response.message || 'Pending rows processed', 'Success');
|
||
setTimeout(function() {
|
||
window.location.reload();
|
||
}, 800);
|
||
} else {
|
||
toastr.error((response && response.message) ? response.message : 'Reprocess failed', 'Error');
|
||
}
|
||
}, function() {
|
||
toastr.error('Reprocess request failed', 'Error');
|
||
});
|
||
});
|
||
}
|
||
|
||
$('.close').click(function(){
|
||
$('#modal_body').empty()
|
||
let html = `<div class="spinner-border text-primary" role="status" style="position: relative; left: 200px;"></div>`
|
||
$('#modal_body').append(html);
|
||
});
|
||
|
||
function openDumpUploadModal() {
|
||
|
||
var myModal = new bootstrap.Modal(document.getElementById('claim-file-upload-modal'));
|
||
myModal.show();
|
||
}
|
||
|
||
function getClientAndBranchAndPolicy() {
|
||
$.ajax({
|
||
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
|
||
console.log('getClientAndBranchAndPolicy', res);
|
||
|
||
if (res.status == true) {
|
||
policyListByClient = res.policyListByClient;
|
||
client_list = res.client_data;
|
||
appendClients(res.client_data);
|
||
} else {
|
||
console.log('No data found');
|
||
}
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
}
|
||
});
|
||
}
|
||
|
||
function appendClients(data) {
|
||
|
||
$('#client_id').empty();
|
||
|
||
$('#client_id').append($('<option>', {
|
||
value: '',
|
||
text: 'Select Client'
|
||
}));
|
||
|
||
$.each(data, function(index, item) {
|
||
|
||
if (item.client_policy_count > 0) {
|
||
|
||
var option = $('<option>', {
|
||
value: item.id,
|
||
text: item.client_name
|
||
});
|
||
$('#client_id').append(option);
|
||
}
|
||
|
||
});
|
||
}
|
||
|
||
function appendPolicies(data) {
|
||
|
||
|
||
$('#client_policy_id').empty();
|
||
$('#client_policy_id').append($('<option>', {
|
||
value: '',
|
||
text: 'Select Policy',
|
||
}));
|
||
|
||
$.each(data, function(index, item) {
|
||
|
||
if(item.policy_type_id == 2 || item.policy_type_id == 3 || item.policy_type_id == 4 || item.policy_type_id == 5) {
|
||
|
||
var option = $('<option>', {
|
||
value: item.id,
|
||
text: item.policy_type + '-' + item.policy_no,
|
||
'data-tpaid': item.tpa_id,
|
||
});
|
||
|
||
$('#client_policy_id').append(option);
|
||
|
||
}
|
||
});
|
||
}
|
||
|
||
$('body').on('click', '.view_emp_list', function() {
|
||
|
||
$('#emp_data_success').empty();
|
||
var file_id = $(this).attr('data-id');
|
||
console.log(file_id);
|
||
|
||
var queryParams = {
|
||
file_id: file_id,
|
||
};
|
||
|
||
console.log('queryParams', queryParams)
|
||
const queryString = objectToQueryString(queryParams);
|
||
console.log('queryString', queryString)
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
var uri = '<?= base_url('util/view-success-emp-list') ?>?' + queryString
|
||
console.log(uri)
|
||
|
||
$.ajax({
|
||
url: uri,
|
||
data: {
|
||
file_id: file_id,
|
||
},
|
||
type: "GET",
|
||
dataType: 'json',
|
||
processData: false,
|
||
contentType: false,
|
||
success: function(res) {
|
||
|
||
console.log(res);
|
||
|
||
if (res) {
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 1000);
|
||
}
|
||
|
||
var title = " - ";
|
||
|
||
if (res.file_data) {
|
||
title += (res.file_data.file_name || "") + " - ";
|
||
title += (res.file_data.short_name || "") + " - ";
|
||
title += (res.file_data.policy_name || "") + " - ";
|
||
title += (res.file_data.action || "") + " - ";
|
||
title += (res.file_data.status || "");
|
||
}
|
||
|
||
$('#title_header_name').html(title);
|
||
$('#emp_data_success').html(res.data);
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
toastr.warning('Something went wrong', 'Warning');
|
||
|
||
}, 1000);
|
||
}
|
||
});
|
||
|
||
})
|
||
|
||
</script>
|