507 lines
23 KiB
PHP
Executable File
507 lines
23 KiB
PHP
Executable File
<style>
|
||
.badge2 {
|
||
box-shadow: none;
|
||
}
|
||
|
||
.badge2-secondary2 {
|
||
color: #fff;
|
||
background-color: #187607;
|
||
}
|
||
|
||
.badge2 {
|
||
display: inline-block;
|
||
padding: .25em .4em;
|
||
font-size: 75%;
|
||
font-weight: 700;
|
||
line-height: 1;
|
||
text-align: center;
|
||
white-space: nowrap;
|
||
vertical-align: baseline;
|
||
border-radius: .25rem;
|
||
transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
|
||
}
|
||
|
||
.table-responsive {
|
||
overflow-x: auto;
|
||
}
|
||
|
||
.word-wrap {
|
||
word-wrap: break-word;
|
||
white-space: normal;
|
||
}
|
||
|
||
.dataTables_filter{
|
||
position: absolute;
|
||
}
|
||
|
||
.right-align-input {
|
||
text-align: right;
|
||
}
|
||
|
||
</style>
|
||
|
||
<?php $pro_rata_total = 0; $gst_total = 0 ?>
|
||
|
||
<div class="row" id="client_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;">Employees</h4>
|
||
</div>
|
||
</div>
|
||
<table class="table table-striped mb-0 nowrap" cellspacing="0" id="tickets-table">
|
||
<thead class="bg-light">
|
||
<tr>
|
||
<th class="font-weight-medium">SNO</th>
|
||
|
||
<?php if (isset($getData)) {
|
||
if ($getData['client_id'] == '0' && $getData['policy_id'] == '0' && $getData['branch_id'] == '0' && ($getData['emp_code'] != "" || $getData['emp_name'] != "" || $getData['status'] != "")) { ?>
|
||
<th class="font-weight-medium">Client/Branch</th>
|
||
<?php }
|
||
if ($getData['client_id'] != '0' && $getData['branch_id'] == '0') { ?>
|
||
<th class="font-weight-medium">Branch</th>
|
||
<?php } } ?>
|
||
|
||
<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">Gender</th>
|
||
<th class="font-weight-medium">Date of Birth</th>
|
||
<th class="font-weight-medium">Policy name</th>
|
||
<th class="font-weight-medium">Insurer name</th>
|
||
<th class="font-weight-medium">TPA ID</th>
|
||
<th class="font-weight-medium">Risk ID</th>
|
||
<th class="font-weight-medium">Policy status</th>
|
||
<th class="font-weight-medium">(₹)Sum Insured</th>
|
||
<th class="font-weight-medium">(₹)Premium</th>
|
||
<th class="font-weight-medium" id="rata_premium" data-toggle="tooltip" data-placement="top">(₹)Pro Rata <br> Premium</th>
|
||
<th class="font-weight-medium" id="gst" data-toggle="tooltip" data-placement="top">(₹)GST</th>
|
||
<th class="font-weight-medium" > Action </th>
|
||
</tr>
|
||
</thead>
|
||
|
||
<tbody class="font-12">
|
||
<?php
|
||
if (isset($employees)) {
|
||
$pro_rata_total = 0;
|
||
$gst_total = 0;
|
||
foreach ($employees as $key => $employee) { ?>
|
||
<tr>
|
||
<td><b><?php echo ($key + 1); ?></b></td>
|
||
|
||
<?php if (isset($getData)) {
|
||
if ($getData['client_id'] == '0' && $getData['policy_id'] == '0' && $getData['branch_id'] == '0' && ($getData['emp_code'] != "" || $getData['emp_name'] != "" || $getData['status'] != "")) { ?>
|
||
<td><?php echo $employee['client_short_name'] . ' - ' . $employee['client_branch_name']; ?></td>
|
||
<?php }
|
||
if ($getData['client_id'] != '0' && $getData['branch_id'] == '0') { ?>
|
||
<td><?php echo $employee['client_branch_name']; ?></td>
|
||
<?php } } ?>
|
||
|
||
<td><?php echo $employee['name']; ?></td>
|
||
<td><?php echo $employee['emp_code']; ?></td>
|
||
<td><?php echo $employee['relationship']; ?></td>
|
||
<td><?php echo $employee['gender']; ?></td>
|
||
<td><?php echo date('d/m/Y', strtotime($employee['dob'])); ?></td>
|
||
<td><?php echo isset($employee['policy_type']) ? $employee['policy_type'] : ''; ?> - <?php echo isset($employee['policy_no']) ? $employee['policy_no'] : ''; ?></td>
|
||
<td><?php echo $employee['insurer_short_name']; ?></td>
|
||
<td><?php echo $employee['tpa_id']; ?></td>
|
||
<td><?php echo $employee['uhid']; ?></td>
|
||
<td>
|
||
<?php
|
||
switch ($employee['status']) {
|
||
case 'draft':
|
||
echo '<span class="badge badge-secondary">' . $employee['status'] . '</span>';
|
||
break;
|
||
case 'active':
|
||
echo '<span class="badge badge-success">' . $employee['status'] . '</span>';
|
||
break;
|
||
case 'inactive':
|
||
echo '<span class="badge badge-warning">' . $employee['status'] . '</span>';
|
||
break;
|
||
case 'expired':
|
||
echo '<span class="badge badge-danger">' . $employee['status'] . '</span>';
|
||
break;
|
||
case 'enrolled':
|
||
echo '<span class="badge2 badge2-secondary2">' . $employee['status'] . '</span>';
|
||
break;
|
||
default:
|
||
echo $employee['status'];
|
||
break;
|
||
}
|
||
?>
|
||
</td>
|
||
<td><?php echo format_indian_number($employee['basic_cover_si']); ?></td>
|
||
<td><?php echo format_indian_number($employee['premium']); ?></td>
|
||
<td><?php $pro_rata_total += $employee['rata_premimum']; echo format_indian_number($employee['rata_premimum']); ?></td>
|
||
<td><?php $gst_total += $employee['gst']; echo format_indian_number($employee['gst']); ?></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(in_array($employee['emp_status'], ['draft', 'enrolled', 'active']) && in_array($employee['status'], ['draft', 'enrolled', 'active'])) { ?>
|
||
<a class="dropdown-item" onclick="get_emp_master_data_for_update(this, '<?= $employee['employee_id'];?>')" ><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||
<?php } ?>
|
||
|
||
<?php if(in_array($employee['policy_type_id'], [2,3,4,5]) && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
|
||
<a href="<?= base_url('download-e-card/'). $employee['rand_string'] ?>" class="dropdown-item" target="_blank"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View E-Card</a>
|
||
<?php } ?>
|
||
|
||
<?php if(in_array($employee['policy_type_id'], [2,3,4,5]) && $employee['email_corporate'] != '' && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
|
||
<a class="dropdown-item" onclick="send_mail_for_individual_employee_ecard('<?= $employee['id'];?>')" ><i class="mdi mdi-email-alert mr-2 text-muted font-18 vertical-middle"></i>Send E-Card Mail</a>
|
||
<?php } ?>
|
||
|
||
</div>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<?php } } ?>
|
||
</tbody>
|
||
|
||
<tfoot>
|
||
<tr>
|
||
<th></th>
|
||
<?php if (isset($getData)) {
|
||
if ($getData['client_id'] == '0' && $getData['policy_id'] == '0' && $getData['branch_id'] == '0' && ($getData['emp_code'] != "" || $getData['emp_name'] != "" || $getData['status'] != "")) { ?>
|
||
<th></th>
|
||
<?php }
|
||
if ($getData['client_id'] != '0' && $getData['branch_id'] == '0') { ?>
|
||
<th></th>
|
||
<?php } } ?>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th>Total</th>
|
||
<th><?php echo format_indian_number($pro_rata_total); ?></th>
|
||
<th><?php echo format_indian_number($gst_total); ?></th>
|
||
<th></th>
|
||
</tr>
|
||
</tfoot>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div><!-- end col -->
|
||
</div>
|
||
|
||
<!-- modal content -->
|
||
|
||
<div id="emp_modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
|
||
<div class="modal-dialog">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title">Edit Employee</h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
|
||
<div class="modal-body p-4">
|
||
<form role="form" class="parsley-examples" id="empForm" onsubmit="update_emp_master_data_submit_function(event, this)" enctype="multipart/form-data">
|
||
|
||
<input type="hidden" name="employee_primary_id" id="employee_primary_id"/>
|
||
|
||
<div class="form-group">
|
||
<div class="form-row">
|
||
<div class="form-group col-md-4">
|
||
<label for="emp_code">Employee Code<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="emp_code_for_edit" placeholder="Enter Code" readonly>
|
||
</div>
|
||
|
||
<div class="form-group col-md-8">
|
||
<label for="name">Name<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" name="name" id="name" placeholder="Ente Name">
|
||
</div>
|
||
</div>
|
||
<div class="form-row">
|
||
|
||
<div class="form-group col-md-6">
|
||
<label for="gender">Gender <span class="text-danger">*</span></label>
|
||
<select class="form-control" id="gender" name="gender" required disabled>
|
||
<option value="">Select Gender</option>
|
||
<option value="M">Male</option>
|
||
<option value="F">Female</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-6">
|
||
<label for="dob">Date of Birth<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="dob" placeholder="Enter DOB" name="dob" required>
|
||
</div>
|
||
|
||
<div class="form-group col-md-12">
|
||
<label for="email">Email<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="email_corporate" placeholder="Enter Email" name="email_corporate" data-parsley-trigger="change" data-parsley-type="email" required>
|
||
</div>
|
||
|
||
<div class="form-group col-md-12">
|
||
<label for="mobile">Mobile Number<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="mobile" placeholder="Enter Mobile Number" name="mobile" onkeypress = "return onlyNumbers(event)" maxlength="10" minlength="10" required>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group text-right m-b-0">
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit">Submit</button>
|
||
</div>
|
||
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div><!-- /.modal -->
|
||
|
||
<script>
|
||
|
||
$(document).ready(function(){
|
||
|
||
var dob = flatpickr("#dob", {
|
||
dateFormat: "d/M/Y",
|
||
allowInput: false
|
||
});
|
||
})
|
||
|
||
$(document).ready(function() {
|
||
var ticketsTable = $('#tickets-table');
|
||
|
||
if (ticketsTable.length) {
|
||
ticketsTable.DataTable({
|
||
scrollX: true,
|
||
dom: "<'row'<'col-sm-6'f><'col-sm-6 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
|
||
buttons: [{
|
||
extend: 'csv',
|
||
text: 'CSV',
|
||
title: 'Member-List',
|
||
},{
|
||
extend: 'excel',
|
||
text: 'Excel',
|
||
title: 'Member-List',
|
||
}],
|
||
language: {
|
||
search: "_INPUT_",
|
||
searchPlaceholder: "Search..."
|
||
},
|
||
paging: true, // Enable pagination
|
||
pageLength: 25 // Set default number of rows per page (optional)
|
||
});
|
||
} else {
|
||
console.error("Table not found.");
|
||
}
|
||
});
|
||
|
||
function get_emp_master_data_for_update(input, id){
|
||
|
||
get_emp_master_data_for_update_ajax(id)
|
||
|
||
}
|
||
|
||
function get_emp_master_data_for_update_ajax(id){
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
$.ajax({
|
||
url: '<?php echo base_url('util/get_emp_master_data_for_update/');?>'+id,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function (res) {
|
||
|
||
console.log('get_emp_master_data_for_update response', res)
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
let data = res.data
|
||
|
||
if(res.status == true){
|
||
|
||
if(data.relationship == 'Self'){
|
||
$('#gender').prop('disabled', false)
|
||
}else{
|
||
$('#gender').prop('disabled', true)
|
||
}
|
||
|
||
$('#employee_primary_id').val(data.id);
|
||
$('#emp_code_for_edit').val(data.emp_code);
|
||
$('#name').val(data.name);
|
||
$('#gender').val(data.gender);
|
||
$('#dob').val(data.formatted_dob);
|
||
$('#email_corporate').val(data.email_corporate);
|
||
$('#mobile').val(data.mobile);
|
||
|
||
if(data.emp_status == "active"){
|
||
$('#name').prop('disabled', true);
|
||
$('#gender').prop('disabled', true);
|
||
$('#dob').prop('disabled', true);
|
||
}else{
|
||
$('#name').prop('disabled', false);
|
||
$('#gender').prop('disabled', false);
|
||
$('#dob').prop('disabled', false);
|
||
}
|
||
|
||
var myModal = new bootstrap.Modal(document.getElementById('emp_modal'));
|
||
myModal.show();
|
||
|
||
}else{
|
||
$('#employee_primary_id').val('');
|
||
$('#emp_code_for_edit').val('');
|
||
$('#name').val('');
|
||
$('#gender').val('');
|
||
$('#dob').val('');
|
||
$('#email_corporate').val('');
|
||
$('#mobile').val('');
|
||
|
||
$('#name').prop('disabled', false);
|
||
$('#gender').prop('disabled', false);
|
||
$('#dob').prop('disabled', false);
|
||
|
||
toastr.warning(res.message, 'WARNING');
|
||
}
|
||
},
|
||
error: function (xhr, status, error) {
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
}
|
||
});
|
||
}
|
||
|
||
function update_emp_master_data_submit_function(event, form){
|
||
|
||
event.preventDefault(); // Prevent the default form submission
|
||
|
||
var isValid = $(form).parsley().validate();
|
||
if (!isValid) {
|
||
console.log('Form is Empty', 'Warning');
|
||
return ;
|
||
}
|
||
|
||
const formData = new FormData(form);
|
||
|
||
const submitButton = form.querySelector('button[type="submit"]');
|
||
submitButton.disabled = true;
|
||
submitButton.innerText = 'Updating...';
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
// AJAX request to update the individual employee
|
||
$.ajax({
|
||
url: '<?= base_url('/util/update_emp_data') ?>',
|
||
type: 'POST',
|
||
data: formData,
|
||
processData: false,
|
||
contentType: false,
|
||
success: function(response) {
|
||
|
||
console.log(response)
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
if(response.status == true){
|
||
toastr.success(response.message, 'SUCCESS');
|
||
|
||
$('.close').click();
|
||
|
||
$('#employee_primary_id').val('');
|
||
$('#emp_code_for_edit').val('');
|
||
$('#name').val('');
|
||
$('#gender').val('');
|
||
$('#dob').val('');
|
||
$('#email_corporate').val('');
|
||
$('#mobile').val('');
|
||
|
||
window.location.reload();
|
||
|
||
}else{
|
||
toastr.error(response.message, 'ERROR');
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
// Handle error
|
||
console.error('Upload error occurred:');
|
||
console.error('Status: ', status); // Status of the request
|
||
console.error('Error: ', error); // Specific error message
|
||
console.error('XHR Object: ', xhr); // Full XHR object with response details
|
||
|
||
// Optionally log server response, if available
|
||
if (xhr.responseText) {
|
||
console.error('Response Text: ', xhr.responseText);
|
||
}
|
||
|
||
toastr.warning('Error uploading file', 'WARNING');
|
||
console.error('Upload error:', error);
|
||
},
|
||
complete: function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
// Re-enable the submit button and reset its text
|
||
submitButton.disabled = false;
|
||
submitButton.innerText = 'Submit';
|
||
}
|
||
});
|
||
}
|
||
|
||
function send_mail_for_individual_employee_ecard(id){
|
||
|
||
Swal.fire({
|
||
title: "Do you want to send Ecard Mail?",
|
||
showDenyButton: true,
|
||
showCancelButton: false,
|
||
confirmButtonText: "Yes,Send",
|
||
denyButtonText: "Don't Send"
|
||
}).then((result) => {
|
||
|
||
if (result.isConfirmed) {
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
$.ajax({
|
||
|
||
url: '<?php echo base_url('util/send_mail_for_individual_employee_ecard/');?>'+id,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function (res) {
|
||
|
||
console.log('send_mail_for_individual_employee_ecard response', res)
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
if(res.status == true){
|
||
toastr.success(res.message, 'SUCCESS');
|
||
}else{
|
||
toastr.error(res.message, 'ERROR');
|
||
}
|
||
},
|
||
error: function (xhr, status, error) {
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
}
|
||
});
|
||
}
|
||
});
|
||
}
|
||
|
||
</script>
|