579 lines
25 KiB
PHP
579 lines
25 KiB
PHP
<style>
|
||
.table th,
|
||
.table td {
|
||
padding: 8px;
|
||
}
|
||
table.dataTable tbody td {
|
||
padding: 4px 4px !important;
|
||
}
|
||
.select2-container .select2-selection--multiple .select2-selection__choice {
|
||
padding: 5px 7px 5px 0 !important;
|
||
color: #000000;
|
||
}
|
||
.dataTables_length label {height: 21px !important;}
|
||
#hr_tickets_table {
|
||
width: 100% !important;
|
||
}
|
||
#hr_tickets_table thead th {
|
||
white-space: nowrap;
|
||
vertical-align: middle;
|
||
}
|
||
#hr_tickets_table_wrapper .dataTables_filter {
|
||
margin-bottom: 12px;
|
||
}
|
||
#hr_tickets_table_wrapper .datatable-search-wrapper {
|
||
width: auto !important;
|
||
}
|
||
#hr_tickets_table_wrapper .dataTables_filter input {
|
||
width: 220px !important;
|
||
background: #F0F0F0;
|
||
border: none;
|
||
border-radius: 8px;
|
||
padding-right: 34px !important;
|
||
}
|
||
#hr_tickets_table_wrapper .datatable-search-icon,
|
||
#hr_tickets_table_wrapper .datatable-clear-icon {
|
||
right: 11px !important;
|
||
}
|
||
#hr_tickets_table_wrapper .dt-buttons {
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
align-items: center;
|
||
}
|
||
#hr_tickets_table_wrapper .dt-buttons .app-btn-secondary,
|
||
#hr_tickets_table_wrapper .dt-buttons .btn-secondary {
|
||
border-radius: 10px;
|
||
}
|
||
#hr_tickets_table_wrapper .dataTables_scrollHeadInner,
|
||
#hr_tickets_table_wrapper .dataTables_scrollHeadInner table,
|
||
#hr_tickets_table_wrapper .dataTables_scrollBody table {
|
||
width: 100% !important;
|
||
}
|
||
#hr_tickets_table tbody tr:hover {
|
||
background-color: #e0e0e0;
|
||
}
|
||
|
||
</style>
|
||
|
||
<div class="tab-pane fade" id="HR-DOC-tab">
|
||
<div class="row">
|
||
<div class="col-xl-12">
|
||
<div id="accordion" class="mb-3">
|
||
<div class="card mb-1">
|
||
|
||
<h4 class="m-1">
|
||
<span>Filters</span>
|
||
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne" aria-expanded="true">
|
||
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
|
||
</a>
|
||
</h4>
|
||
|
||
<!-- <h5 class="m-1">
|
||
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne" aria-expanded="true">
|
||
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
|
||
</a>
|
||
</h5>
|
||
<label id="filterAccordion" class="m-1 d-flex justify-content-between align-items-center">
|
||
<span class="font-color-black">Filters</span>
|
||
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne" aria-expanded="true">
|
||
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
|
||
</a>
|
||
</label> -->
|
||
|
||
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
|
||
<div class="card-body">
|
||
<!-- <div class="text-center"> -->
|
||
<form class="parsley-examples" id="hr_file_upload_search" >
|
||
<input type="hidden" name="<?= csrf_token() ?>" value="<?= csrf_hash() ?>" id="csrf_token">
|
||
<input type="hidden" name="hr_file_type" value="CRM">
|
||
|
||
<div class="form-group">
|
||
<div class="form-row">
|
||
<div class="form-group col-md-4">
|
||
<label>Client</label> <br />
|
||
<select name="client_id" class="form-control" id="client2" >
|
||
<option value="">Select</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-4">
|
||
<label>Branch</label> <br />
|
||
<select name="client_branch_id" class="form-control" id="client_branch_id2" >
|
||
<option value="0">Select</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-4">
|
||
<label>Policy</label> <br />
|
||
<select name="policy_id" class="form-control" id="policy2" >
|
||
<option value="">Select</option>
|
||
</select>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div class="form-row">
|
||
|
||
<div class="form-group col-md-4">
|
||
<label>Event<span class="text-danger">*</span></label> <br />
|
||
<select name="file_action" class="form-control" id="event_type" required>
|
||
<option value="">Select</option>
|
||
<?php
|
||
if (isset($events) && count($events)) {
|
||
foreach ($events as $key => $action) {
|
||
if($key != "inception"){
|
||
echo "<option value='$key'" . ($key == "si_enhancement" ? " class='si-enhancement-option'" : "") . ">$action</option>";
|
||
}
|
||
}
|
||
}
|
||
?>
|
||
</select>
|
||
</div>
|
||
|
||
|
||
|
||
</div>
|
||
|
||
|
||
|
||
<div class="form-row" id="">
|
||
<div class="d-flex align-items-center justify-content-start" style="margin-top: 18px;">
|
||
<div class="form-group col-md-3">
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light justify-content-end">Search</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- end page title -->
|
||
<div class="row" id="hr_file_list">
|
||
<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;">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="hr_tickets_table">
|
||
<thead class="bg-light">
|
||
<tr>
|
||
<th class="font-weight-medium">S.No </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">Policy </th>
|
||
<th class="font-weight-medium">Event </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($HRfileList)) { foreach ($fileList as $key => $file) { ?>
|
||
|
||
<tr>
|
||
<td><b><?php echo ($key + 1) ?></b></td>
|
||
<td 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 $file['policy_no'] ?></td>
|
||
<td><?php echo $file['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 echo $file['status']; ?> </td>
|
||
<td> </td>
|
||
</tr>
|
||
<?php }
|
||
} ?>
|
||
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div><!-- end col -->
|
||
|
||
</div>
|
||
<!-- end row -->
|
||
</div>
|
||
|
||
<!-- Center modal content for reupload file-->
|
||
<div class="modal fade" id="hr-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">Endorsement Upload</h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<form class="parsley-examples" id="hrUploadForm" enctype="multipart/form-data">
|
||
<input type="hidden" id="hr_file_client_id" name="client_id">
|
||
<input type="hidden" id="hr_file_policy_id" name="policy_id">
|
||
<input type="hidden" id="hr_file_branch_id" name="branch_id">
|
||
<input type="hidden" id="hr_file_hr_file_id" name="hr_file_id">
|
||
<input type="hidden" id="hr_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>
|
||
|
||
$(document).ready(function(){
|
||
|
||
//client change to get the Client Branch
|
||
$('#client2').change(function(){
|
||
let client_id = $(this).val();
|
||
console.log('client_id', client_id);
|
||
|
||
if(branch_list != '') {
|
||
// console.log(branch_list[client_id]);
|
||
let data = branch_list[client_id];
|
||
appendBranch3(data);
|
||
}
|
||
})
|
||
|
||
//change the client branch than change the client policy
|
||
$('#client_branch_id2').change(function(){
|
||
|
||
let branch_id = $(this).val();
|
||
console.log("branch_id", branch_id);
|
||
|
||
if(policy_list != '' && branch_id != '') {
|
||
let data = policy_list[branch_id];
|
||
appendPolicy3(data);
|
||
}
|
||
});
|
||
})
|
||
|
||
$(document).ready(function() {
|
||
// Initialize select2
|
||
$("#client2").select2();
|
||
$("#policy2").select2();
|
||
$("#client_branch_id2").select2();
|
||
|
||
// Form submit event
|
||
$("#hr_file_upload_search").on("submit", function (e) {
|
||
|
||
e.preventDefault(); // stop normal form submit
|
||
|
||
let formData = $(this).serialize(); // serialize form with csrf
|
||
var baseurl = `<?= base_url() ?>`;
|
||
$.ajax({
|
||
url: "<?= base_url('hrFileList') ?>",
|
||
type: "POST",
|
||
data: formData,
|
||
dataType: "json",
|
||
beforeSend: function () {
|
||
// optional loader
|
||
$("#hr_tickets_table tbody").html(
|
||
"<tr><td colspan='9' class='text-center'>Loading...</td></tr>"
|
||
);
|
||
},
|
||
success: function (res) {
|
||
let tbody = "";
|
||
|
||
if (res.status === "success" && res.data.length > 0) {
|
||
$.each(res.data, function (index, file) {
|
||
tbody += `
|
||
<tr>
|
||
<td><b>${index + 1}</b></td>
|
||
<td id="${file.id}" class="reload truncate" title="${file.file_name}">${file.file_name}</td>
|
||
<td>${file.short_name ?? ""}</td>
|
||
<td>${file.branch_name ?? ""}</td>
|
||
<td>${file.policy_no ?? ""}</td>
|
||
<td>${formatTextToCamelCase(file.file_action) ?? ""}</td>
|
||
<td>${file.created_at} by <strong>${file.first_name ?? ""}</strong></td>
|
||
<td>${file.status}</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">
|
||
<a href="${baseurl}/hrFileDownload?id=${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>
|
||
<a class="dropdown-item" onclick="uploadEndorsementFile(${file.client_id}, ${file.client_branch_id}, ${file.policy_id}, ${file.id}, '${file.file_action}')" style="color: #000;" aria-hidden="true"><i class="mdi mdi-upload mr-2 text-muted font-18 vertical-middle"></i>Initiate Endorsement</a>
|
||
</div>
|
||
</div>
|
||
|
||
</td>
|
||
</tr>
|
||
`;
|
||
});
|
||
} else {
|
||
tbody = `<tr><td colspan="9" class="text-center">No records found</td></tr>`;
|
||
}
|
||
|
||
if (window.hrFileTableInstance) {
|
||
window.hrFileTableInstance.clear();
|
||
$("#hr_tickets_table tbody").html(tbody);
|
||
window.hrFileTableInstance.rows.add($("#hr_tickets_table tbody tr")).draw();
|
||
window.hrFileTableInstance.columns.adjust().draw(false);
|
||
} else {
|
||
$("#hr_tickets_table tbody").html(tbody);
|
||
}
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.error("Error:", error);
|
||
const errorRow = `<tr><td colspan="9" class="text-center text-danger">Something went wrong</td></tr>`;
|
||
if (window.hrFileTableInstance) {
|
||
window.hrFileTableInstance.clear();
|
||
$("#hr_tickets_table tbody").html(errorRow);
|
||
window.hrFileTableInstance.rows.add($("#hr_tickets_table tbody tr")).draw();
|
||
window.hrFileTableInstance.columns.adjust().draw(false);
|
||
} else {
|
||
$("#hr_tickets_table tbody").html(errorRow);
|
||
}
|
||
},
|
||
});
|
||
});
|
||
});
|
||
|
||
// ------------ Append Functions are Below ----------------------------------------------------------------------------------
|
||
|
||
function appendClients3(data)
|
||
{
|
||
$('#client2').empty();
|
||
|
||
$('#client2').append($('<option>', {
|
||
value: '',
|
||
text: 'Select Client'
|
||
}));
|
||
|
||
$.each(data, function(index, item) {
|
||
|
||
let client_show_name = item.client_name;
|
||
if (item.client_type == 2) {
|
||
client_show_name = item.client_name + (item.dob ? ('- (' + item.dob + ' )' ) : '') + (item.pan ? ('- ' + item.pan ) : '');
|
||
// console.log(client_show_name);
|
||
}
|
||
|
||
var option = $('<option>', {
|
||
value: item.id,
|
||
text: client_show_name,
|
||
'data-cn': item.client_name,
|
||
'data-ct': item.client_type,
|
||
});
|
||
|
||
$('#client2').append(option);
|
||
});
|
||
}
|
||
|
||
function appendBranch3(data)
|
||
{
|
||
|
||
$('#client_branch_id2').empty();
|
||
$('#client_branch_id2').append($('<option>', {
|
||
value: '',
|
||
text: 'Select Branch'
|
||
}));
|
||
|
||
$.each(data, function(index, item) {
|
||
|
||
var option = $('<option>', {
|
||
value: item.id,
|
||
text: item.branch_name
|
||
});
|
||
$('#client_branch_id2').append(option);
|
||
});
|
||
}
|
||
|
||
function appendPolicy3(data)
|
||
{
|
||
$('#policy2').empty();
|
||
$('#policy2').append($('<option>', {
|
||
value: '',
|
||
text: 'Select Policy',
|
||
}));
|
||
|
||
$.each(data, function(index, item) {
|
||
var option = $('<option>', {
|
||
value: item.id,
|
||
text: item.policy_type + '-' + item.policy_no,
|
||
});
|
||
$('#policy2').append(option);
|
||
});
|
||
}
|
||
|
||
// ----------------------------------------------------------------------------------------------
|
||
|
||
// for datatable
|
||
window.hrFileTableInstance = window.hrFileTableInstance || null;
|
||
function fixHrUploadTableHeaderWidth() {
|
||
const $wrapper = $('#hr_tickets_table_wrapper');
|
||
if (!$wrapper.length) {
|
||
return;
|
||
}
|
||
$wrapper.find('.dataTables_scrollHeadInner, .dataTables_scrollHeadInner table, .dataTables_scrollBody table')
|
||
.css('width', '100%');
|
||
|
||
if (window.hrFileTableInstance) {
|
||
window.hrFileTableInstance.columns.adjust().draw(false);
|
||
}
|
||
}
|
||
|
||
$(document).ready(function() {
|
||
if (window.hrFileTableInstance) {
|
||
return;
|
||
}
|
||
window.hrFileTableInstance = $('#hr_tickets_table').DataTable({
|
||
scrollX: false,
|
||
autoWidth: false,
|
||
// 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>>",
|
||
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: 'Employee-Upload-List',
|
||
className: 'app-btn-primary ',
|
||
exportOptions: {
|
||
columns: ':not(:last-child)'
|
||
},
|
||
}
|
||
]
|
||
}
|
||
],
|
||
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,
|
||
ordering: false,
|
||
});
|
||
$('.dataTables_filter input').css({
|
||
'background': '#F0F0F0',
|
||
'border': 'none',
|
||
'border-radius': '8px',
|
||
'padding-right': '34px'
|
||
});
|
||
|
||
setTimeout(fixHrUploadTableHeaderWidth, 0);
|
||
});
|
||
|
||
$(document).on('shown.bs.tab shown.bs.collapse shown.bs.modal', function() {
|
||
setTimeout(fixHrUploadTableHeaderWidth, 50);
|
||
});
|
||
|
||
//for initialize the file upload for the files table
|
||
function uploadEndorsementFile(client_id, branch_id, policy_id, file_id, event){
|
||
|
||
console.log(client_id, branch_id, policy_id, file_id, event);
|
||
|
||
$('#hr_file_client_id').val(client_id);
|
||
$('#hr_file_branch_id').val(branch_id);
|
||
$('#hr_file_policy_id').val(policy_id);
|
||
$('#hr_file_upload_actions').val(event);
|
||
$('#hr_file_hr_file_id').val(file_id);
|
||
|
||
var myModal = new bootstrap.Modal(document.getElementById('hr-file-upload-modal'));
|
||
myModal.show();
|
||
}
|
||
|
||
//hr file upload reupload to the files table
|
||
$('#hrUploadForm').submit(function(e) {
|
||
|
||
e.preventDefault();
|
||
|
||
var isValid = $('#hrUploadForm').parsley().validate();
|
||
if (!isValid) {
|
||
console.log('Form is Empty', 'Warning');
|
||
return;
|
||
}
|
||
|
||
// 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: `<?= base_url('employee/upload') ?>`,
|
||
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);
|
||
$('#hrUploadForm')[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);
|
||
}
|
||
|
||
$('.close').click();
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
// Request failed, handle error
|
||
console.error("Request failed:", status, error);
|
||
toastr.error('Something went wrong! Try later', 'Error');
|
||
$('#hrUploadForm')[0].reset();
|
||
$('.close').click();
|
||
window.location.reload(true);
|
||
}
|
||
});
|
||
})
|
||
|
||
</script>
|