350 lines
16 KiB
PHP
Executable File
350 lines
16 KiB
PHP
Executable File
<style>
|
||
.table-responsive {
|
||
overflow-x: auto;
|
||
}
|
||
|
||
.reload:hover {
|
||
cursor: pointer;
|
||
}
|
||
|
||
.truncate {
|
||
max-width: 80px;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
</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">SNO</th>
|
||
<th class="font-weight-medium">Batch Code</th>
|
||
<th class="font-weight-medium">File Name</th>
|
||
<th class="font-weight-medium">Client</th>
|
||
<th class="font-weight-medium">Client Branch</th>
|
||
<th class="font-weight-medium">Client Policy</th>
|
||
<th class="font-weight-medium">Event Type</th>
|
||
<th class="font-weight-medium">Insurer/ TPA</th>
|
||
<th class="font-weight-medium">Action</th>
|
||
<th class="font-weight-medium">Count</th>
|
||
<th class="font-weight-medium">(₹)Amount</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($batch_list)) {
|
||
foreach ($batch_list as $key => $file) {
|
||
?>
|
||
|
||
<tr>
|
||
<td><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']] ?></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>
|
||
|
||
|
||
<?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>
|
||
|
||
|
||
<?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>
|
||
|
||
|
||
<?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 { ?>
|
||
|
||
<?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>
|
||
|
||
<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'] ?>"
|
||
|
||
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 } ?>
|
||
|
||
</div>
|
||
</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="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 -->
|
||
|
||
|
||
<script>
|
||
$(document).ready(function() {
|
||
|
||
$('#datatable-buttons').DataTable({
|
||
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'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"
|
||
});
|
||
},
|
||
language: {
|
||
search: "_INPUT_",
|
||
searchPlaceholder: "Search..."
|
||
},
|
||
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')
|
||
|
||
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);
|
||
|
||
$('#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);
|
||
|
||
|
||
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();
|
||
// });
|
||
}
|
||
|
||
|
||
</script>
|