680 lines
29 KiB
PHP
Executable File
680 lines
29 KiB
PHP
Executable File
<?php
|
||
helper('datatable_view');
|
||
$fl_header_labels = [
|
||
'S.No', 'File name', 'Client', 'Client Branch', 'Policy',
|
||
'Event', 'User/Time', 'Status', 'Action',
|
||
];
|
||
$fl_col_count = count($fl_header_labels);
|
||
$fl_col_max_len = array_fill(0, $fl_col_count, 0);
|
||
for ($i = 0; $i < $fl_col_count; $i++) {
|
||
$fl_col_max_len[$i] = mb_strlen($fl_header_labels[$i]);
|
||
}
|
||
$fileList = $fileList ?? [];
|
||
if (!empty($fileList) && is_array($fileList)) {
|
||
foreach ($fileList as $key => $file) {
|
||
$fl_col_max_len[0] = max($fl_col_max_len[0], mb_strlen((string) ($key + 1)));
|
||
$fl_col_max_len[1] = max($fl_col_max_len[1], mb_strlen((string) ($file['file_name'] ?? '')));
|
||
$fl_col_max_len[2] = max($fl_col_max_len[2], mb_strlen((string) ($file['short_name'] ?? '')));
|
||
$fl_col_max_len[3] = max($fl_col_max_len[3], mb_strlen((string) ($file['branch_name'] ?? '')));
|
||
$policy_display = trim(
|
||
(isset($file['policy_type']) ? $file['policy_type'] : '')
|
||
. ' - '
|
||
. (isset($file['policy_no']) ? $file['policy_no'] : '')
|
||
);
|
||
$fl_col_max_len[4] = max($fl_col_max_len[4], mb_strlen($policy_display));
|
||
$fl_col_max_len[5] = max($fl_col_max_len[5], mb_strlen((string) ($file['action'] ?? '')));
|
||
$userTime = change_date_format($file['created_at'] ?? '', 'Y-m-d H:i:s', 'd M Y h:i a')
|
||
. ' by '
|
||
. ($file['first_name'] ?? '');
|
||
$fl_col_max_len[6] = max($fl_col_max_len[6], mb_strlen($userTime));
|
||
$st = (string) ($file['status'] ?? '');
|
||
$fl_col_max_len[7] = max($fl_col_max_len[7], mb_strlen($st));
|
||
if ($st === 'inprogress' || $st === 'success') {
|
||
$fl_col_max_len[7] = max($fl_col_max_len[7], 12);
|
||
}
|
||
$fl_col_max_len[8] = max($fl_col_max_len[8], 4);
|
||
}
|
||
}
|
||
$fl_col_min_px = [48, 100, 72, 80, 120, 88, 160, 96, 72];
|
||
$fl_col_max_px = [64, 320, 180, 180, 360, 160, 320, 200, 88];
|
||
$fl_col_width_px = nhance_dt_column_widths_px($fl_header_labels, $fl_col_max_len, $fl_col_min_px, $fl_col_max_px);
|
||
?>
|
||
<style>
|
||
.modal-full-width {
|
||
width: 95% !important;
|
||
max-width: none;
|
||
}
|
||
|
||
.reload:hover {
|
||
cursor: pointer;
|
||
}
|
||
|
||
.column-header { margin-right: 10px; /* Adjust this value as needed */ }
|
||
|
||
/* Compact table + buttons (NHance) */
|
||
#file-list-table tbody td {
|
||
padding: 6px 12px !important;
|
||
font-size: 13px;
|
||
line-height: 1.25;
|
||
}
|
||
#file-list-table_wrapper .dataTables_scrollHead table thead th,
|
||
#file-list-table thead th {
|
||
padding: 6px 2.35rem 6px 12px !important;
|
||
font-size: 13px;
|
||
line-height: 1.25;
|
||
}
|
||
|
||
#file-list-table .font-12 {
|
||
font-size: 12px;
|
||
}
|
||
|
||
/* Action dropdown toggle in rows */
|
||
#file-list-table .dropdown-toggle.btn-sm {
|
||
padding: 4px 9px !important;
|
||
font-size: 13px;
|
||
line-height: 1.2;
|
||
}
|
||
|
||
/* DataTables toolbar buttons (Export/Filter/Clear Filter) */
|
||
#file-list-table_wrapper .dt-buttons .btn {
|
||
padding: 6px 13px !important;
|
||
font-size: 13px;
|
||
}
|
||
|
||
#file-list-table_wrapper .dt-buttons .btn .btn-custom {
|
||
font-size: 13px;
|
||
}
|
||
|
||
#file-list-table{
|
||
width: 100% !important;
|
||
}
|
||
|
||
#file-list-table thead th{
|
||
white-space: nowrap;
|
||
vertical-align: middle;
|
||
}
|
||
|
||
#file-list-table_wrapper .datatable-search-wrapper{
|
||
width: auto !important;
|
||
}
|
||
|
||
#file-list-table_wrapper .dataTables_filter input{
|
||
padding-right: 34px !important;
|
||
width: 220px !important;
|
||
}
|
||
|
||
#file-list-table_wrapper .row.align-items-center{
|
||
flex-wrap: nowrap;
|
||
}
|
||
|
||
#file-list-table_wrapper .dataTables_info,
|
||
#file-list-table_wrapper .dataTables_length,
|
||
#file-list-table_wrapper .dataTables_paginate{
|
||
white-space: nowrap;
|
||
}
|
||
|
||
#file-list-table_wrapper .datatable-search-icon,
|
||
#file-list-table_wrapper .datatable-clear-icon{
|
||
right: 11px !important;
|
||
}
|
||
#file-list-page .card-body > .table-responsive {
|
||
overflow-x: auto !important;
|
||
-webkit-overflow-scrolling: touch;
|
||
max-width: 100%;
|
||
}
|
||
|
||
</style>
|
||
<style>
|
||
<?php for ($i = 0; $i < $fl_col_count; $i++) : ?>
|
||
#file-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
|
||
#file-list-table thead th:nth-child(<?= $i + 1 ?>) {
|
||
min-width: <?= (int) $fl_col_width_px[$i] ?>px;
|
||
width: <?= (int) $fl_col_width_px[$i] ?>px;
|
||
box-sizing: border-box;
|
||
vertical-align: middle;
|
||
overflow: visible !important;
|
||
}
|
||
#file-list-table tbody td:nth-child(<?= $i + 1 ?>) {
|
||
width: <?= (int) $fl_col_width_px[$i] ?>px;
|
||
max-width: <?= (int) $fl_col_width_px[$i] ?>px;
|
||
min-width: <?= (int) $fl_col_width_px[$i] ?>px;
|
||
box-sizing: border-box;
|
||
vertical-align: middle;
|
||
}
|
||
<?php endfor; ?>
|
||
#file-list-table tbody td:nth-child(1),
|
||
#file-list-table tbody td:nth-child(2),
|
||
#file-list-table tbody td:nth-child(3),
|
||
#file-list-table tbody td:nth-child(4),
|
||
#file-list-table tbody td:nth-child(5),
|
||
#file-list-table tbody td:nth-child(6),
|
||
#file-list-table tbody td:nth-child(7),
|
||
#file-list-table tbody td:nth-child(8) {
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
#file-list-table tbody td:nth-child(9) {
|
||
overflow: visible;
|
||
text-overflow: clip;
|
||
}
|
||
</style>
|
||
|
||
<div class="col-12" id="file-list-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;">Files</h4>
|
||
</div>
|
||
|
||
</div>
|
||
<div class="table-responsive">
|
||
<table data-custom-table-css="table" class="table mb-0 nowrap w-100 table-centered" cellspacing="0" id="file-list-table">
|
||
<thead class="bg-light">
|
||
<tr>
|
||
<th class="font-weight-medium"><div class="column-header">S.No</div></th>
|
||
<th class="font-weight-medium"><div class="column-header">File name</div></th>
|
||
<th class="font-weight-medium"><div class="column-header">Client</div></th>
|
||
<th class="font-weight-medium"><div class="column-header">Client Branch</div></th>
|
||
<th class="font-weight-medium"><div class="column-header">Policy</div></th>
|
||
<th class="font-weight-medium"><div class="column-header">Event</div></th>
|
||
<th class="font-weight-medium"><div class="column-header">User/Time</div></th>
|
||
<th class="font-weight-medium"><div class="column-header">Status</div></th>
|
||
<th class="font-weight-medium"><div class="column-header">Action</div></th>
|
||
</tr>
|
||
</thead>
|
||
|
||
<tbody class="font-12">
|
||
<?php
|
||
if (isset($fileList)) {
|
||
foreach ($fileList as $key => $file) { //print_r((json_decode($file['reason'])));
|
||
// $reason = json_decode(($file['reason']));
|
||
// $reason = "{'date':'value data kbckl kcn/aksl'}";
|
||
// echo $reason;
|
||
?>
|
||
|
||
<tr>
|
||
<td><b><?php echo ($key + 1) ?></b></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['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['action'] ?></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['first_name'] . '</strong>' ?>
|
||
</td>
|
||
<td>
|
||
<?php
|
||
if ($file['status'] == 'failed') {
|
||
echo $file['status'] . " <span class='col-xl-3 col-lg-4 col-sm-6'> <i class='fe-alert-circle' data-toggle='modal' data-target='#file-err-modal' data-err=" . $file['id'] . "></i></span>";
|
||
} else if ($file['status'] == 'inprogress') {
|
||
|
||
if ($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addtion') {
|
||
|
||
$tool_tip_text = "Live(s) : {$file['employee_count']}" . " | Total premium : ₹ " . format_indian_number($file['total'], 2, ',') . " | Click to reload";
|
||
echo '<a data-toggle="tooltip" data-placement="top" data-id="' . $file['status'] . '" class="reload" title="' . $tool_tip_text . '" href="#">' . $file['status'] . '</a>';
|
||
}else{
|
||
|
||
echo '<a data-id="' . $file['status'] . '" class="reload" href="#">' . $file['status'] . '</a>';
|
||
}
|
||
} else if ($file['status'] == 'success') {
|
||
|
||
if ($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addtion') {
|
||
$tool_tip_text = "Live(s) : {$file['employee_count']}" . " | Total premium : ₹ " . format_indian_number($file['total'], 2, ',');
|
||
// $tool_tip_text = "dssd";
|
||
// Total Amount : $file['total']";
|
||
echo '<span data-toggle="tooltip" data-placement="top" data-id="' . $file['status'] . '" title=" ' . $tool_tip_text . ' ">' . $file['status'] . '</span>';
|
||
}else{
|
||
echo '<span data-id="' . $file['status'] . '" >' . $file['status'] . '</span>';
|
||
}
|
||
}else{
|
||
|
||
echo '<span data-id="' . $file['status'] . '" >' . $file['status'] . '</span>';
|
||
}
|
||
?>
|
||
</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 ($file['status'] == 'failed') { ?>
|
||
<a data-id="<?= htmlspecialchars(json_encode(['client_id' => $file['client_id'], 'client_policy_id' => $file['client_policy_id'], 'client_branch_id' => $file['client_branch_id'], 'action' => $file['action']])) ?>" data-toggle="modal" data-target="#file-upload-modal" class="dropdown-item upload_button" href="#"><i class="mdi mdi-upload mr-2 text-muted font-18 vertical-middle"></i>Re-Upload</a>
|
||
<?php } ?>
|
||
|
||
<a class="dropdown-item" href="<?= base_url("util/download-file-list/") . $file['id']; ?>"><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download</a>
|
||
<a data-id="<?php echo $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>
|
||
|
||
<?php if ($file['status'] == 'success') { ?>
|
||
<a data-id="<?php echo $file['id'] ?>" class="dropdown-item truncate2" href="#"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Truncate</a>
|
||
<?php } ?>
|
||
|
||
</div>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<?php }
|
||
} ?>
|
||
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div><!-- end col -->
|
||
|
||
|
||
<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">Upload Employee List <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 class="modal-footer">
|
||
<button type="button" class="btn btn-primary">Save changes</button>
|
||
</div> -->
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
|
||
<!-- Center modal content for reupload file-->
|
||
<div class="modal fade" id="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">ReUpload 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="uploadForm" action="<?php echo base_url() . 'employee/upload' ?>"
|
||
method="post"
|
||
enctype="multipart/form-data">
|
||
<input type="hidden" id="file_client_id" name="client_id">
|
||
<input type="hidden" id="file_policy_id" name="policy_id">
|
||
<input type="hidden" id="file_branch_id" name="branch_id">
|
||
<input type="hidden" id="file_upload_actions" name="upload-action-type">
|
||
<input type="file" id="fileInput" name="emplist" required
|
||
accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet">
|
||
<small class="text-muted d-block">Allowed: XLS, XLSX. Size : 25MB</small>
|
||
<button type="submit" class="btn btn-primary">Upload</button>
|
||
</form>
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
|
||
<script>
|
||
|
||
$('body').on('click', '.view_emp_list', function() {
|
||
|
||
console.log('file_id', 'file_id');
|
||
$('#emp_data_success').empty();
|
||
$('#title').html(' ');
|
||
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);
|
||
}
|
||
});
|
||
|
||
})
|
||
|
||
$('body').on('click', '.upload_button', function() {
|
||
|
||
$('#uploadForm')[0].reset();
|
||
console.log('file_id');
|
||
var fileId = JSON.parse(this.getAttribute('data-id'));
|
||
console.log(fileId); // Use fileId as needed
|
||
$('#file_client_id').val(fileId.client_id)
|
||
$('#file_policy_id').val(fileId.client_policy_id)
|
||
$('#file_branch_id').val(fileId.client_branch_id)
|
||
$('#file_upload_actions').val(fileId.action)
|
||
})
|
||
|
||
$('body').on('click', '.truncate2', function(event) {
|
||
|
||
event.preventDefault();
|
||
// console.log(event);
|
||
var fileId = JSON.parse(this.getAttribute('data-id'));
|
||
console.log('Truncate File ID' + fileId);
|
||
|
||
Swal.fire({
|
||
title: "Do you want to truncate data from uploaded file?",
|
||
showCancelButton: true,
|
||
confirmButtonText: "Delete",
|
||
confirmButtonColor: "#ff3333",
|
||
}).then((result) => {
|
||
|
||
console.log(result);
|
||
|
||
if (result.isConfirmed) {
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
var apiURL = '<?php echo base_url(); ?>employee/truncate/' + fileId;
|
||
// console.log('Truncate API URL : ', apiURL);
|
||
|
||
$.ajax({
|
||
url: apiURL,
|
||
method: 'GET',
|
||
headers: {
|
||
"X-Requested-With": "XMLHttpRequest"
|
||
},
|
||
success: function(response) {
|
||
|
||
// console.log('Truncate Response', response)
|
||
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 1000);
|
||
|
||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||
Swal.fire({
|
||
title: "Deleted!",
|
||
icon: "success"
|
||
});
|
||
} else if (response.code === 404 && response.dataStatus === false) {
|
||
console.error('No data found', response);
|
||
handleNoDataFound(response, fileId);
|
||
} else {
|
||
Swal.fire({
|
||
title: "Failed!",
|
||
text: 'Something went wrong! Try later',
|
||
icon: "error"
|
||
});
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 1000);
|
||
|
||
console.error('Error fetching data from API:', error);
|
||
toastr.error('Something went wrong! Try later', 'Error');
|
||
}
|
||
});
|
||
}
|
||
|
||
});
|
||
})
|
||
|
||
function handleNoDataFound(response, fileId) {
|
||
if (response.role == 1 || response.role == 5) {
|
||
Swal.fire({
|
||
title: response.message,
|
||
showCancelButton: true,
|
||
confirmButtonText: "Delete",
|
||
confirmButtonColor: "#ff3333",
|
||
}).then((result) => {
|
||
|
||
console.log(result);
|
||
if (result.isConfirmed) {
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
var apiURL = '<?php echo base_url(); ?>employee/truncate/' + fileId + '/' + <?= get_role_id(); ?>;
|
||
|
||
$.ajax({
|
||
url: apiURL,
|
||
method: 'GET',
|
||
headers: {
|
||
"X-Requested-With": "XMLHttpRequest"
|
||
},
|
||
success: function(response) {
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 1000);
|
||
|
||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||
Swal.fire({
|
||
title: "Deleted!",
|
||
icon: "success"
|
||
});
|
||
} else if (response.code === 404 && response.dataStatus === false) {
|
||
console.error('No data found', response);
|
||
Swal.fire({
|
||
title: "Failed!",
|
||
text: response.message,
|
||
icon: "error"
|
||
});
|
||
} else {
|
||
Swal.fire({
|
||
title: "Failed!",
|
||
text: 'Something went wrong! Try later',
|
||
icon: "error"
|
||
});
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 1000);
|
||
|
||
console.error('Error fetching data from API:', error);
|
||
console.error('Something went wrong! Try later', 'Error');
|
||
}
|
||
});
|
||
}
|
||
});
|
||
} else {
|
||
Swal.fire({
|
||
title: "Failed!",
|
||
text: response.message,
|
||
icon: "error"
|
||
});
|
||
}
|
||
}
|
||
|
||
$('#uploadForm').submit(function(event) {
|
||
|
||
event.preventDefault();
|
||
|
||
var isValid = $('#uploadForm').parsley().validate();
|
||
if (!isValid) {
|
||
console.log('Form is Empty', 'Warning');
|
||
return false;
|
||
}
|
||
|
||
// Create FormData object
|
||
var formData = new FormData($(this)[0]);
|
||
for (var pair of formData.entries()) {
|
||
console.log(pair[0] + ', ' + pair[1]);
|
||
}
|
||
|
||
// return false;
|
||
$.ajax({
|
||
url: $(this).attr("action"),
|
||
type: "POST",
|
||
data: formData,
|
||
processData: false, // Prevent jQuery from automatically processing the data
|
||
contentType: false, // Let jQuery handle the content type
|
||
headers: {
|
||
// "Content-Type":"multipart/form-data",
|
||
"X-Requested-With": "XMLHttpRequest"
|
||
},
|
||
success: function(response) {
|
||
|
||
console.log(response);
|
||
$('#uploadForm')[0].reset();
|
||
|
||
if (response.code === 200 && response.dataStatus === true && response
|
||
.data !== "") {
|
||
toastr.success(
|
||
'File upload successs, Data validation is in-progress',
|
||
'Success');
|
||
$('.close').click()
|
||
window.location.reload(true);
|
||
} else if (response.code === 404 && response.dataStatus === false) {
|
||
console.error('no data found', response);
|
||
// alert(response.message);
|
||
toastr.error(response.message, 'Failed');
|
||
window.location.reload(true);
|
||
} else {
|
||
console.error('Something went wrong!');
|
||
// alert('Something went wrong! Try later');
|
||
toastr.error('Something went wrong! Try later', 'Error');
|
||
window.location.reload(true);
|
||
}
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
// Request failed, handle error
|
||
console.error("Request failed:", status, error);
|
||
toastr.error('Something went wrong! Try later', 'Error');
|
||
$('#uploadForm')[0].reset();
|
||
window.location.reload(true);
|
||
}
|
||
});
|
||
|
||
return false;
|
||
})
|
||
|
||
$('body').on('click', '.reload', function() {
|
||
|
||
console.log('status');
|
||
status = this.getAttribute('data-id')
|
||
console.log(status);
|
||
if (status == 'inprogress') {
|
||
window.location.reload(true);
|
||
}
|
||
})
|
||
|
||
$(document).ready(function() {
|
||
|
||
nhanceListDataTableBeforeInit();
|
||
var nhFileListTable = $('#file-list-table').DataTable(nhanceMergeListDataTableOptions({
|
||
|
||
dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'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 mr-2',
|
||
buttons: [
|
||
{
|
||
extend: 'csv',
|
||
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
|
||
title: 'Employee-Upload-List',
|
||
className: 'app-btn-primary ',
|
||
exportOptions: {
|
||
columns: ':not(:last-child)'
|
||
},
|
||
}
|
||
]
|
||
},
|
||
{
|
||
text: '<i class="mdi mdi-filter" ></i><span class=" btn-custom"> Filter </span>',
|
||
className: 'btn app-btn-primary mr-2',
|
||
action: function(e, dt, node, config) {
|
||
openPolicyFilterNav(1);
|
||
}
|
||
},
|
||
{
|
||
text: '<i class="mdi mdi-filter-remove"></i><span class="btn-custom"> Clear Filter </span>',
|
||
className: 'btn app-btn-info mr-2 hide-clear-filter',
|
||
action: function(e, dt, node, config) {
|
||
clearFilterData();
|
||
}
|
||
}
|
||
],
|
||
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,
|
||
columnDefs: [
|
||
<?php for ($i = 0; $i < $fl_col_count; $i++) : ?>
|
||
{ targets: <?= $i ?>, width: '<?= (int) $fl_col_width_px[$i] ?>px' },
|
||
<?php endfor; ?>
|
||
],
|
||
}));
|
||
nhanceListDataTableAfterInit();
|
||
nhanceListDataTableBindAdjust(nhFileListTable);
|
||
|
||
});
|
||
|
||
</script>
|