931 lines
38 KiB
PHP
Executable File
931 lines
38 KiB
PHP
Executable File
<style>
|
||
.table th,
|
||
.table td {
|
||
padding: 8px;
|
||
}
|
||
|
||
table.dataTable tbody td {
|
||
padding: 4px 4px !important;
|
||
}
|
||
|
||
.btn .btn-secondary .buttons-csv .buttons-html5 .my_class {
|
||
position: relative;
|
||
left: 79px;
|
||
}
|
||
|
||
.visa_status_count_view .card-header {
|
||
/* background-color: #eb7a76; */
|
||
background-color: darkgrey;
|
||
/* padding-bottom: 1px; */
|
||
/* padding-top: 10px; */
|
||
}
|
||
|
||
#tickets-table_filter {
|
||
float: right;
|
||
}
|
||
|
||
.click_hover {
|
||
background: #1aa79c !important;
|
||
color: #fff !important;
|
||
border-radius: 5px;
|
||
box-shadow: 6px 5px 8px 0 #00000036;
|
||
cursor: pointer;
|
||
}
|
||
.click_hover .text-muted{
|
||
color: #fff !important;
|
||
}
|
||
.click_hover span{
|
||
color: #fff !important;
|
||
}
|
||
.card {
|
||
border-radius: 10px;
|
||
}
|
||
</style>
|
||
|
||
<div class="row visa_status_count_view">
|
||
<div class="col-12">
|
||
<div class="card">
|
||
<div class="card-header">
|
||
<div class="row" style="margin-bottom: -22px;">
|
||
<div class="col-3">
|
||
<div id="categoryFilter" style="display: flex;">
|
||
<select class="form-control" id="clients" onchange="populateBranches()">
|
||
<option value="0">Select Client</option>
|
||
<?php foreach ($client_list as $client) { ?>
|
||
<option value="<?= $client['id'] ?>"><?= $client['client_name'] ?></option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="col-3">
|
||
<div id="categoryFilter_11">
|
||
<select name="branch_id" class="form-control" id="branch_id" onchange="populatePolicies()">
|
||
<option value="0">Select Branch</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="col-3">
|
||
<div id="categoryFilter_14">
|
||
<select name="client_policy_id" class="form-control" id="client_policy_id">
|
||
<option value="0">Select Policy</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="col-1">
|
||
<div id="categoryFilter_11">
|
||
<a class="btn btn-primary waves-effect waves-light" onclick="fetchEmpolyeeList(event);" data-toggle="tooltip" data-placement="top" title="Search" id="get-emp-list"><i class="fa fa-search" aria-hidden="true"></i></a>
|
||
</div>
|
||
</div>
|
||
<div class="col-0" style="margin-right: 15px; ">
|
||
<div id="categoryFilter_12">
|
||
<a class="btn btn-primary waves-effect waves-light" onclick="sendManualReminder(this)" data-toggle="tooltip" data-placement="top" title="Send Reminder"><i class="fa fa-bell" aria-hidden="true"></i></a>
|
||
</div>
|
||
</div>
|
||
<div class="col-0">
|
||
<div id="categoryFilter_13">
|
||
<a class="btn btn-primary waves-effect waves-light" onclick="uploadEnrollmentFile(this)" data-toggle="tooltip" data-placement="top" title="Enrollment File Upload"><i class="fas fa-file-upload" ></i></a>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- </div> -->
|
||
|
||
<!-- <div class="row" style="margin-bottom: 44px;"> -->
|
||
<div class="col-1 text-right view-status-btn" style="position: relative;bottom: 7px;">
|
||
<button type="button" class="btn btn-link visa_status_button" onclick="toggleContent()" style="color: #000;" data-toggle="tooltip" data-placement="top" title="View Status Card">
|
||
Status <i id="toggleIcon" class="fas fa-minus"></i>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
<div class="card-body status-option" id="statusContent" style="padding: 1.5rem !important;background-color: darkgrey;">
|
||
<div class="text-center">
|
||
<div class="row" style="/* margin-left: 125px; */margin-bottom: -11px;">
|
||
<div class="col-xl-2 col-md-2">
|
||
<div class="card cardWidth">
|
||
<div class="card-body" id="emp_count_view_click">
|
||
<div class="d-flex justify-content-between" style="justify-content: center !important;">
|
||
<div>
|
||
<h5 class="text-muted font-weight-normal mt-0 text-truncate" title="Emp Count">Emp Count</h5>
|
||
<h3 class="my-2 py-1"><span data-plugin="counterup" id="emp_count_view">0</span></h3>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div><!-- end col -->
|
||
<div class="col-xl-2 col-md-2">
|
||
<div class="card">
|
||
<div class="card-body" id="emp_enrolled_view_click">
|
||
<div class="d-flex justify-content-between" style="justify-content: center !important;">
|
||
<div>
|
||
<h5 class="text-muted font-weight-normal mt-0 text-truncate" title="Enrolled">Enroled</h5>
|
||
<h3 class="my-2 py-1"><span data-plugin="counterup" id="emp_enrolled_view">0</span></h3>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div><!-- end col -->
|
||
<div class="col-xl-2 col-md-2">
|
||
<div class="card">
|
||
<div class="card-body" id="emp_not_enrolled_view_click">
|
||
<div class="d-flex justify-content-between" style="justify-content: center !important;">
|
||
<div>
|
||
<h5 class="text-muted font-weight-normal mt-0 text-truncate" title="Not Enrolled">Not Enroled</h5>
|
||
<h3 class="my-2 py-1"><span data-plugin="counterup" id="emp_not_enrolled_view">0</span></h3>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div><!-- end col -->
|
||
<div class="col-xl-2 col-md-2">
|
||
<div class="card">
|
||
<div class="card-body" id="emp_logged_in_view_click">
|
||
<div class="d-flex justify-content-between" style="justify-content: center !important;">
|
||
<div>
|
||
<h5 class="text-muted font-weight-normal mt-0 text-truncate" title="Logged-In">Logged-In</h5>
|
||
<h3 class="my-2 py-1"><span data-plugin="counterup" id="emp_logged_in_view">0</span></h3>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div><!-- end col -->
|
||
<div class="col-xl-2 col-md-2">
|
||
<div class="card">
|
||
<div class="card-body" id="emp_not_logged_in_view_click">
|
||
<div class="d-flex justify-content-between" style="justify-content: center !important;">
|
||
<div>
|
||
<h5 class="text-muted font-weight-normal mt-0 text-truncate" title="Not Logged-In">Not Logged-In</h5>
|
||
<h3 class="my-2 py-1"><span data-plugin="counterup" id="emp_not_logged_in_view">0</span></h3>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div><!-- end col -->
|
||
<div class="col-xl-2 col-md-2">
|
||
<div class="card">
|
||
<div class="card-body" id="emp_draft_view_click">
|
||
<div class="d-flex justify-content-between" style="justify-content: center !important;">
|
||
<div>
|
||
<h5 class="text-muted font-weight-normal mt-0 text-truncate" title="Not Logged-In">Draft</h5>
|
||
<h3 class="my-2 py-1"><span data-plugin="counterup" id="emp_draft_view">0</span></h3>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div><!-- end col -->
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="row" id="client_list">
|
||
<div class="col-12">
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<table class="table table-hover m-0 table-centered dt-responsive w-100" cellspacing="0" id="tickets-table">
|
||
<thead class="bg-light">
|
||
<tr>
|
||
<th class="font-weight-medium">SNO</th>
|
||
<th class="font-weight-medium">Name</th>
|
||
<th class="font-weight-medium">Emp Code</th>
|
||
<th class="font-weight-medium">Relationship</th>
|
||
<th class="font-weight-medium">Enroled</th>
|
||
<th class="font-weight-medium">Logged-In</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="font-12">
|
||
<!-- Table body -->
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Center modal content -->
|
||
<div class="modal fade" id="upload_enrollment_model" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="false">
|
||
<div class="modal-dialog modal-dialog-centered">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myCenterModalLabel">Upload Enrolment File</h4>
|
||
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<form class="parsley-examples" method="post" id="uploadForm" action="<?php echo base_url().'employee/upload'?>" enctype="multipart/form-data">
|
||
<input type="hidden" id="file_client_id" name="client_id">
|
||
<input type="hidden" id="file_branch_id" name="branch_id">
|
||
<input type="hidden" id="file_upload_actions" name="upload-action-type" value="enrollment">
|
||
<div class="form-group">
|
||
<div class="form-row">
|
||
<div class="form-group col-md-12">
|
||
<label for="policy_id">Client Policy<span class="text-danger">*</span></label>
|
||
<select class="form-control" id="policy_id" name="policy_id" required>
|
||
<option selected >Select Client Policy</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="form-row">
|
||
<div class="form-group col-md-6">
|
||
<label for="file">File<span class="text-danger">*</span></label>
|
||
<input type="file" id="fileInput" name="emplist" required
|
||
accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1">Upload</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
<script>
|
||
|
||
function populateBranches()
|
||
{
|
||
var clientId = document.getElementById('clients').value;
|
||
var branchDropdown = document.getElementById('branch_id');
|
||
|
||
branchDropdown.innerHTML = '<option value="0">Select Branch</option>';
|
||
|
||
if (clientId == 0) {
|
||
return;
|
||
}
|
||
|
||
var branches = <?= json_encode($branch_list) ?>;
|
||
|
||
branches.forEach(branch => {
|
||
if (branch.client_id == clientId) {
|
||
var option = document.createElement('option');
|
||
option.value = branch.id;
|
||
option.textContent = branch.branch_name;
|
||
branchDropdown.appendChild(option);
|
||
}
|
||
});
|
||
}
|
||
|
||
function populatePolicies()
|
||
{
|
||
console.log('populatePolicies function called');
|
||
|
||
var clientId = document.getElementById('clients').value;
|
||
var branchId = document.getElementById('branch_id').value;
|
||
var policyDropdown = document.getElementById('client_policy_id');
|
||
|
||
console.log('clientId', clientId);
|
||
console.log('branchId', branchId);
|
||
console.log('policyDropdown', policyDropdown);
|
||
|
||
policyDropdown.innerHTML = '<option value="0">Select Policy</option>';
|
||
|
||
if (clientId == 0 && branchId == 0) {
|
||
return;
|
||
}
|
||
|
||
var policies = <?= json_encode($policy_list) ?>;
|
||
|
||
console.log('policies', policies);
|
||
|
||
policies.forEach(policy => {
|
||
if (policy.client_id == clientId && policy.client_branch_id == branchId) {
|
||
var option = document.createElement('option');
|
||
option.value = policy.id;
|
||
option.textContent = policy.policy_type + ' - ' + policy.policy_no;
|
||
policyDropdown.appendChild(option);
|
||
}
|
||
});
|
||
}
|
||
|
||
// function filterTable(columnIndex, filterValue)
|
||
// {
|
||
// var table = $('#tickets-table').DataTable();
|
||
|
||
// // Reset the search filter for all columns
|
||
// table.columns().search('').draw();
|
||
|
||
// // Apply the filter to the specified column
|
||
// table.column(columnIndex).search(filterValue).draw();
|
||
// }
|
||
|
||
function fetchEmpolyeeList(event)
|
||
{
|
||
event.preventDefault();
|
||
|
||
var client_id = $('#clients').val();
|
||
var branch_id = $('#branch_id').val();
|
||
var client_policy_id = $('#client_policy_id').val();
|
||
if (client_id == '0' || branch_id == '0' || client_policy_id == '0') {
|
||
Swal.fire({
|
||
title: "warning!",
|
||
text: 'Please select the Client, Client Branch and Client Policy.',
|
||
icon: "warning"
|
||
});
|
||
return false;
|
||
}
|
||
|
||
$.ajax({
|
||
url: '<?php echo base_url(); ?>' + '/employee/empby_client_clientbranch/' + client_id + '/' + branch_id + '/' + client_policy_id,
|
||
method: 'GET',
|
||
headers: {
|
||
"Content-Type": "application/json",
|
||
"X-Requested-With": "XMLHttpRequest"
|
||
},
|
||
beforeSend: function() {
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
},
|
||
success: function(response) {
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
var data = JSON.parse(response);
|
||
console.log(data);
|
||
var table = $('#tickets-table').DataTable();
|
||
table.clear();
|
||
|
||
if (data.length === 0) {
|
||
table.row.add([
|
||
'',
|
||
'',
|
||
'No data available',
|
||
'',
|
||
'',
|
||
''
|
||
]).draw();
|
||
return;
|
||
}
|
||
var enrolled_count = 0;
|
||
var not_enrolled_count = 0;
|
||
var loggedIn_count = 0;
|
||
var not_loggedIn_count = 0;
|
||
var self_count = 0;
|
||
var draft_count = 0;
|
||
|
||
data.forEach(function(employee, index) {
|
||
|
||
if(employee.relationship.toLowerCase() === "self"){
|
||
self_count++
|
||
}
|
||
|
||
if(employee.emp_status === 'enrolled'){
|
||
var enrolled = 'Yes';
|
||
enrolled_count++;
|
||
}else{
|
||
var enrolled = 'No';
|
||
if (employee.relationship.toLowerCase() === "self") {
|
||
not_enrolled_count++;
|
||
}
|
||
}
|
||
|
||
if(employee.relationship.toLowerCase() === "self" && employee.user_type === 'employee'){
|
||
var loggedIn = 'Yes';
|
||
loggedIn_count++;
|
||
}else{
|
||
|
||
if (employee.relationship && employee.relationship.toLowerCase() === "self") {
|
||
var loggedIn = 'No';
|
||
not_loggedIn_count ++;
|
||
}else{
|
||
var loggedIn = '-';
|
||
}
|
||
}
|
||
|
||
if(employee.relationship.toLowerCase() === "self" && enrolled == "No" && loggedIn == "Yes"){
|
||
draft_count++;
|
||
}
|
||
|
||
table.row.add([
|
||
index + 1,
|
||
employee.employee_name,
|
||
employee.emp_code,
|
||
employee.relationship,
|
||
enrolled,
|
||
loggedIn
|
||
]);
|
||
});
|
||
|
||
$('#emp_count_view').html(self_count);
|
||
$('#emp_enrolled_view').html(enrolled_count);
|
||
$('#emp_not_enrolled_view').html(not_enrolled_count);
|
||
$('#emp_logged_in_view').html(loggedIn_count);
|
||
$('#emp_not_logged_in_view').html(not_loggedIn_count);
|
||
$('#emp_draft_view').html(draft_count);
|
||
|
||
table.draw();
|
||
|
||
function getUrlParameter(name) {
|
||
var params = new URLSearchParams(window.location.search);
|
||
return params.get(name);
|
||
}
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
}
|
||
|
||
$(document).ready(function()
|
||
{
|
||
|
||
function getUrlParameter(name) {
|
||
var params = new URLSearchParams(window.location.search);
|
||
return params.get(name);
|
||
}
|
||
|
||
// Check for URL parameters and set form values
|
||
var client_id = getUrlParameter('client_id');
|
||
var branch_id = getUrlParameter('branch_id');
|
||
var type = getUrlParameter('type');
|
||
|
||
if (client_id) {
|
||
$('#clients').val(client_id).trigger('change'); // Set client ID and trigger change event to populate branches
|
||
}
|
||
|
||
if (branch_id) {
|
||
setTimeout(function() { // Ensure branches are populated before setting branch ID
|
||
$('#branch_id').val(branch_id).trigger('change');
|
||
if($('#branch_id').val() != 0){
|
||
$('#get-emp-list').click().trigger();
|
||
}
|
||
}, 500);
|
||
|
||
}
|
||
if (history.pushState) {
|
||
var newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname;
|
||
window.history.pushState({path: newUrl}, '', newUrl);
|
||
}
|
||
|
||
setTimeout(() => {
|
||
// var type = getUrlParameter('type');
|
||
console.log("------------------------");
|
||
console.log(type);
|
||
$('#' + type).click().trigger();
|
||
}, 1000);
|
||
|
||
$('#clients').select2();
|
||
$('#policy_id').select2();
|
||
$('#branch_id').select2();
|
||
$('#client_policy_id').select2();
|
||
var table = $('#tickets-table').DataTable({
|
||
dom: 'fBrtip',
|
||
buttons: [
|
||
{
|
||
extend: 'copy',
|
||
text: '<i class="fa fa-copy"></i>',
|
||
titleAttr: 'Copy',
|
||
filename: 'Enrolment List'
|
||
},
|
||
{
|
||
extend: 'print',
|
||
text: '<i class="fa fa-print"></i>',
|
||
titleAttr: 'Print',
|
||
filename: 'Enrolment List'
|
||
},
|
||
{
|
||
extend: 'pdf',
|
||
text: '<i class="fa fa-file-pdf"></i>',
|
||
titleAttr: 'PDF',
|
||
filename: 'Enrolment List'
|
||
},
|
||
{
|
||
extend: 'csv',
|
||
text: '<i class="fa fa-file-csv"></i>',
|
||
titleAttr: 'CSV',
|
||
filename: 'Enrolment List'
|
||
}
|
||
],
|
||
initComplete: function() {
|
||
// Add custom class to the print button
|
||
$('.buttons-print').addClass('buttons-html5');
|
||
}
|
||
});
|
||
|
||
|
||
// $('#emp_enrolled_view_click').on('click', function() {
|
||
|
||
// console.log($(this).hasClass('click_hover'));
|
||
// if ($(this).hasClass('click_hover')) {
|
||
// // $(this).removeClass('click_hover');
|
||
// $('.click_hover').each(function() {
|
||
// $(this).removeClass('click_hover');
|
||
// });
|
||
// table.columns().search('').draw(); // Clear all filters and show all data
|
||
// }else{
|
||
// $('.click_hover').each(function() {
|
||
// $(this).removeClass('click_hover');
|
||
// });
|
||
// $('#emp_enrolled_view_click').addClass('click_hover');
|
||
// filterTable(4, 'Yes'); // Filter "Enrolled" column (4th column, index 3)
|
||
// }
|
||
// });
|
||
|
||
// $('#emp_not_enrolled_view_click').on('click', function() {
|
||
// if ($(this).hasClass('click_hover')) {
|
||
// // $(this).removeClass('click_hover');
|
||
// $('.click_hover').each(function() {
|
||
// $(this).removeClass('click_hover');
|
||
// });
|
||
// table.columns().search('').draw(); // Clear all filters and show all data
|
||
// }else{
|
||
// $('.click_hover').each(function() {
|
||
// $(this).removeClass('click_hover');
|
||
// });
|
||
// $('#emp_not_enrolled_view_click').addClass('click_hover');
|
||
// filterTable(4, 'No'); // Filter "Enrolled" column (4th column, index 3)
|
||
// }
|
||
// });
|
||
|
||
// $('#emp_logged_in_view_click').on('click', function() {
|
||
// if ($(this).hasClass('click_hover')) {
|
||
// // $(this).removeClass('click_hover');
|
||
// $('.click_hover').each(function() {
|
||
// $(this).removeClass('click_hover');
|
||
// });
|
||
// table.columns().search('').draw(); // Clear all filters and show all data
|
||
// }else{
|
||
// $('.click_hover').each(function() {
|
||
// $(this).removeClass('click_hover');
|
||
// });
|
||
// $('#emp_logged_in_view_click').addClass('click_hover');
|
||
// filterTable(5, 'Yes'); // Filter "Logged-In" column (5th column, index 4)
|
||
// }
|
||
// });
|
||
|
||
// $('#emp_not_logged_in_view_click').on('click', function() {
|
||
// if ($(this).hasClass('click_hover')) {
|
||
// // $(this).removeClass('click_hover');
|
||
// $('.click_hover').each(function() {
|
||
// $(this).removeClass('click_hover');
|
||
// });
|
||
// table.columns().search('').draw(); // Clear all filters and show all data
|
||
// }else{
|
||
// $('.click_hover').each(function() {
|
||
// $(this).removeClass('click_hover');
|
||
// });
|
||
// $('#emp_not_logged_in_view_click').addClass('click_hover');
|
||
// filterTable(5, 'No'); // Filter "Logged-In" column (5th column, index 4)
|
||
// }
|
||
// });
|
||
|
||
// $('#emp_draft_view_click').on('click', function() {
|
||
// var table = $('#tickets-table').DataTable();
|
||
|
||
// if ($(this).hasClass('click_hover')) {
|
||
// // Remove active class and reset filters
|
||
// $('.click_hover').removeClass('click_hover');
|
||
// table.columns().search('').draw(); // Clear all filters
|
||
// } else {
|
||
// // Remove existing active state and set new one
|
||
// $('.click_hover').removeClass('click_hover');
|
||
// $(this).addClass('click_hover');
|
||
|
||
// // Apply both filters simultaneously
|
||
// filterTableMultiple([
|
||
// { column: 5, value: 'Yes' },
|
||
// { column: 4, value: 'No' }
|
||
// ]);
|
||
// }
|
||
// });
|
||
|
||
// $('#emp_count_view_click').on('click', function() {
|
||
// if ($(this).hasClass('click_hover')) {
|
||
// // $(this).removeClass('click_hover');
|
||
// $('.click_hover').each(function() {
|
||
// $(this).removeClass('click_hover');
|
||
// });
|
||
// table.columns().search('').draw(); // Clear all filters and show all data
|
||
// }else{
|
||
// $('.click_hover').each(function() {
|
||
// $(this).removeClass('click_hover');
|
||
// });
|
||
// $('#emp_count_view_click').addClass('click_hover');
|
||
// table.columns().search('').draw(); // Clear all filters and show all data
|
||
// }
|
||
// });
|
||
|
||
// === Attach click handlers ===
|
||
$('#emp_enrolled_view_click').on('click', function() {
|
||
handleFilterClick('emp_enrolled_view_click', [{ column: 4, value: 'Yes' }]);
|
||
});
|
||
|
||
$('#emp_not_enrolled_view_click').on('click', function() {
|
||
handleFilterClick('emp_not_enrolled_view_click', [
|
||
{ column: 3, value: 'Self' },
|
||
{ column: 4, value: 'No' }
|
||
]);
|
||
});
|
||
|
||
$('#emp_logged_in_view_click').on('click', function() {
|
||
handleFilterClick('emp_logged_in_view_click', [{ column: 5, value: 'Yes' }]);
|
||
});
|
||
|
||
$('#emp_not_logged_in_view_click').on('click', function() {
|
||
handleFilterClick('emp_not_logged_in_view_click', [{ column: 5, value: 'No' }]);
|
||
});
|
||
|
||
// 🔹 Attach click handlers
|
||
$('#emp_draft_view_click').on('click', function() {
|
||
handleFilterClick('emp_draft_view_click', [
|
||
{ column: 5, value: 'Yes' }, // Logged-in = Yes
|
||
{ column: 4, value: 'No' } // Enrolled = No
|
||
]);
|
||
});
|
||
|
||
$('#emp_count_view_click').on('click', function() {
|
||
// Just reset all filters — no column filter needed
|
||
handleFilterClick('emp_count_view_click', [{ column: 3, value: 'Self' }]);
|
||
});
|
||
|
||
toggleContent();
|
||
});
|
||
|
||
// Common function to handle DataTable filter toggling
|
||
function handleFilterClick(buttonId, filters = null) {
|
||
var table = $('#tickets-table').DataTable();
|
||
var $button = $('#' + buttonId);
|
||
|
||
if ($button.hasClass('click_hover')) {
|
||
// Remove highlight and clear filters
|
||
$('.click_hover').removeClass('click_hover');
|
||
table.columns().search('').draw();
|
||
} else {
|
||
// Remove existing active state, set new one
|
||
$('.click_hover').removeClass('click_hover');
|
||
$button.addClass('click_hover');
|
||
|
||
// Apply multiple filters (array of {column, value})
|
||
table.columns().search(''); // clear existing filters
|
||
if(filters){
|
||
filters.forEach(f => table.column(f.column).search(f.value));
|
||
}
|
||
table.draw();
|
||
}
|
||
}
|
||
|
||
function toggleContent()
|
||
{
|
||
var content = document.getElementById("statusContent");
|
||
var toggleIcon = document.getElementById("toggleIcon");
|
||
if (content.style.display === "none") {
|
||
content.style.display = "block";
|
||
toggleIcon.classList.remove("fa-plus");
|
||
toggleIcon.classList.add("fa-minus");
|
||
} else {
|
||
content.style.display = "none";
|
||
toggleIcon.classList.remove("fa-minus");
|
||
toggleIcon.classList.add("fa-plus");
|
||
}
|
||
}
|
||
|
||
//----------------------------------------------------------------------------------------------------
|
||
|
||
|
||
function uploadEnrollmentFile(input)
|
||
{
|
||
console.log('uploadEnrollmentFile called');
|
||
|
||
var client_id = $('#clients').val()
|
||
var client_branch_id = $('#branch_id').val()
|
||
|
||
console.log('input', input);
|
||
console.log('client_id', client_id);
|
||
console.log('client_branch_id', client_branch_id);
|
||
|
||
if(client_id == 0 && client_branch_id == 0){
|
||
|
||
Swal.fire({
|
||
title: "warning!",
|
||
text: 'Please select the Client and Client Branch.',
|
||
icon: "warning"
|
||
});
|
||
return false
|
||
}
|
||
|
||
// $('#upload_enrollment_model').modal('show');
|
||
var myModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model'));
|
||
myModal.show();
|
||
|
||
$('#file_client_id').val(client_id);
|
||
$('#file_branch_id').val(client_branch_id);
|
||
|
||
$.ajax({
|
||
url: '<?= base_url("util/get_client_policy_list_for_remainder/") ?>' + client_id + '/' + client_branch_id,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
|
||
console.log('uploadEnrollmentFile policy list', res)
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
if (res.status === false) {
|
||
toastr.error(res.status);
|
||
return;
|
||
}
|
||
|
||
appendpolicy(res.data)
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
function appendpolicy(data)
|
||
{
|
||
|
||
$('#policy_id').empty();
|
||
$('#policy_id').append($('<option>', {
|
||
value: '',
|
||
text: 'Select',
|
||
selected: true
|
||
}));
|
||
|
||
$.each(data, function(index, item) {
|
||
var option = $('<option>', {
|
||
value: item.id,
|
||
text:`${item.policy_name ?? ''} - ${item.policy_no ?? ''}`
|
||
});
|
||
$('#policy_id').append(option);
|
||
});
|
||
|
||
}
|
||
|
||
$(document).ready(function() {
|
||
$("#uploadForm").submit(function(event) {
|
||
event.preventDefault(); // Prevent the default form submission
|
||
|
||
var client_id = $('#clients').val()
|
||
var client_branch_id = $('#branch_id').val()
|
||
|
||
var isValid = $('#uploadForm').parsley().validate();
|
||
if (!isValid) {
|
||
console.log('Form is Empty', 'Warning');
|
||
return;
|
||
}
|
||
|
||
if(client_id == 0 && client_branch_id == 0){
|
||
toastr.warning('Select Client and Client Branch');
|
||
return false;
|
||
}
|
||
|
||
var formData = new FormData($(this)[0]);
|
||
|
||
$.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: {
|
||
"X-Requested-With": "XMLHttpRequest"
|
||
},
|
||
beforeSend: function() {
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
},
|
||
success: function(response) {
|
||
// Request successful, handle response
|
||
console.log('Enrollment list:', response);
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||
toastr.success('File upload success, Data validation is in-progress', 'Success');
|
||
setTimeout(function() {
|
||
window.location.href = '<?= base_url("employee/upload/") ?>';
|
||
}, 600);
|
||
} else if (response.code === 404 && response.dataStatus === false) {
|
||
console.error('No data found', response);
|
||
toastr.error(response.message, 'Error');
|
||
setTimeout(function() {
|
||
window.location.href = '<?= base_url("employee/upload/") ?>';
|
||
}, 600);
|
||
} else {
|
||
console.error('Something went wrong!');
|
||
// toastr.error('Something went wrong! Try later', 'Error');
|
||
setTimeout(function() {
|
||
window.location.href = '<?= base_url("employee/upload/") ?>';
|
||
}, 600);
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
// Request failed, handle error
|
||
console.error("Request failed:", status, error);
|
||
console.error('Response:', xhr.responseText);
|
||
// toastr.error('Something went wrong! Try later', 'Error');
|
||
setTimeout(function() {
|
||
window.location.href = '<?= base_url("employee/upload/") ?>';
|
||
}, 1000);
|
||
},
|
||
complete: function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
});
|
||
});
|
||
|
||
function sendManualReminder(input)
|
||
{
|
||
console.log('sendManualReminder function called');
|
||
|
||
var client_id = $('#clients').val()
|
||
var client_branch_id = $('#branch_id').val()
|
||
var client_policy_id = $('#client_policy_id').val()
|
||
|
||
console.log('input', input);
|
||
console.log('client_id', client_id);
|
||
console.log('client_branch_id', client_branch_id);
|
||
console.log('client_policy_id', client_policy_id);
|
||
|
||
if (client_id == 0) {
|
||
Swal.fire({
|
||
title: "Warning!",
|
||
text: 'Please select the Client.',
|
||
icon: "warning"
|
||
});
|
||
return false;
|
||
}
|
||
|
||
if (client_branch_id == 0) {
|
||
Swal.fire({
|
||
title: "Warning!",
|
||
text: 'Please select the Client Branch.',
|
||
icon: "warning"
|
||
});
|
||
return false;
|
||
}
|
||
|
||
if (client_policy_id == 0) {
|
||
Swal.fire({
|
||
title: "Warning!",
|
||
text: 'Please select the Client Policy.',
|
||
icon: "warning"
|
||
});
|
||
return false;
|
||
}
|
||
|
||
Swal.fire({
|
||
title: "Do you want to send reminder mail?",
|
||
showDenyButton: true,
|
||
showCancelButton: false,
|
||
confirmButtonText: "Yes,Send",
|
||
denyButtonText: "Don't Send"
|
||
}).then((result) => {
|
||
|
||
if (result.isConfirmed) {
|
||
|
||
$.ajax({
|
||
url: '<?= base_url("util/send_manual_reminder/") ?>' + client_id + '/' + client_branch_id + '/' + client_policy_id,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
|
||
console.log('send_manual_reminder', res)
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
if(res.status == false){
|
||
toastr.info(res.message, 'Info');
|
||
}else{
|
||
toastr.success(res.message, 'Success');
|
||
}
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
// Swal.fire("Saved!", "", "success");
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
</script>
|