331 lines
13 KiB
PHP
331 lines
13 KiB
PHP
<?php
|
|
$getData = $getData ?? [];
|
|
|
|
if (! function_exists('format_pending_approval_date')) {
|
|
function format_pending_approval_date($date)
|
|
{
|
|
if (empty($date)) {
|
|
return '-';
|
|
}
|
|
|
|
$timestamp = strtotime((string) $date);
|
|
|
|
return $timestamp ? date('d/m/Y', $timestamp) : '-';
|
|
}
|
|
}
|
|
?>
|
|
<style>
|
|
#client_list .card-body {
|
|
padding: 12px 16px 8px;
|
|
}
|
|
|
|
#pending-approvals-table .approval-action-btn {
|
|
width: 28px;
|
|
height: 28px;
|
|
padding: 0;
|
|
line-height: 28px;
|
|
border-radius: 50%;
|
|
}
|
|
|
|
#pending-approvals-table .employee-meta {
|
|
line-height: 1.2;
|
|
}
|
|
|
|
#pending-approvals-table .employee-meta small {
|
|
display: block;
|
|
color: #6c757d;
|
|
font-size: 11px;
|
|
margin-top: 1px;
|
|
}
|
|
|
|
#pending-approvals-table .approval-status-badge {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
min-width: 72px;
|
|
width: 72px;
|
|
height: 22px;
|
|
padding: 0;
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
border-radius: 12px;
|
|
line-height: 1;
|
|
}
|
|
|
|
#pending-approvals-table .approval-reject-info {
|
|
position: relative;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
width: 22px;
|
|
height: 22px;
|
|
margin-left: 6px;
|
|
color: #dc3545;
|
|
cursor: pointer;
|
|
vertical-align: middle;
|
|
font-size: 18px;
|
|
line-height: 1;
|
|
}
|
|
|
|
#pending-approvals-table .approval-reject-info:hover,
|
|
#pending-approvals-table .approval-reject-info:focus {
|
|
color: #00999E;
|
|
outline: none;
|
|
}
|
|
|
|
#pending-approvals-table .approval-reject-tooltip-text {
|
|
visibility: hidden;
|
|
opacity: 0;
|
|
position: absolute;
|
|
bottom: calc(100% + 8px);
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
min-width: 160px;
|
|
max-width: 280px;
|
|
padding: 6px 10px;
|
|
background: #343a40;
|
|
color: #fff;
|
|
font-size: 12px;
|
|
font-weight: 400;
|
|
line-height: 1.4;
|
|
border-radius: 6px;
|
|
white-space: normal;
|
|
word-wrap: break-word;
|
|
z-index: 9999;
|
|
pointer-events: none;
|
|
text-align: left;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
|
transition: opacity 0.15s ease;
|
|
}
|
|
|
|
#pending-approvals-table .approval-reject-tooltip-text::after {
|
|
content: '';
|
|
position: absolute;
|
|
top: 100%;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
border: 6px solid transparent;
|
|
border-top-color: #343a40;
|
|
}
|
|
|
|
#pending-approvals-table .approval-reject-info:hover .approval-reject-tooltip-text,
|
|
#pending-approvals-table .approval-reject-info:focus .approval-reject-tooltip-text {
|
|
visibility: visible;
|
|
opacity: 1;
|
|
}
|
|
|
|
#pending-approvals-table .badge {
|
|
font-size: 11px;
|
|
padding: 3px 8px;
|
|
}
|
|
|
|
#pending-approvals-table tbody td:last-child {
|
|
overflow: visible !important;
|
|
text-overflow: clip;
|
|
position: relative;
|
|
}
|
|
|
|
#pending-approvals-table_wrapper .dataTables_scrollBody,
|
|
#pending-approvals-table_wrapper table.dataTable tbody td:last-child {
|
|
overflow: visible !important;
|
|
}
|
|
|
|
#pending-approvals-table_wrapper .row {
|
|
margin-left: 0;
|
|
margin-right: 0;
|
|
margin-bottom: 6px;
|
|
}
|
|
|
|
#pending-approvals-table_wrapper .row:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
#pending-approvals-table_wrapper .dataTables_filter,
|
|
#pending-approvals-table_wrapper .dt-buttons {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
#pending-approvals-table_wrapper .dataTables_filter label {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
#pending-approvals-table_wrapper .dataTables_info,
|
|
#pending-approvals-table_wrapper .dataTables_length label,
|
|
#pending-approvals-table_wrapper .dataTables_paginate {
|
|
margin-bottom: 0;
|
|
padding-top: 0;
|
|
font-size: 13px;
|
|
}
|
|
|
|
#pending-approvals-table_wrapper .dataTables_length select {
|
|
margin: 0 6px;
|
|
padding: 2px 6px;
|
|
height: auto;
|
|
}
|
|
</style>
|
|
|
|
<div class="row" id="client_list">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table data-custom-table-css="table" class="table table-hover mb-0 nowrap w-100 table-centered m-0" cellspacing="0" id="pending-approvals-table">
|
|
<thead class="bg-light">
|
|
<tr>
|
|
<th class="font-weight-medium">Employee </th>
|
|
<th class="font-weight-medium">Dependent </th>
|
|
<th class="font-weight-medium">Relationship </th>
|
|
<th class="font-weight-medium">Date Of Birth </th>
|
|
<th class="font-weight-medium">Dependent Effective Date </th>
|
|
<th class="font-weight-medium">Policy </th>
|
|
<th class="font-weight-medium">Status </th>
|
|
<th class="font-weight-medium text-center">Action </th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="font-12">
|
|
<?php if (! empty($employees)) {
|
|
foreach ($employees as $employee) {
|
|
$rowStatus = strtolower((string) ($employee['status'] ?? ''));
|
|
?>
|
|
<tr>
|
|
<td class="employee-meta">
|
|
<?= esc($employee['self_name'] ?? '-') ?>
|
|
<small><?= esc($employee['emp_code'] ?? '') ?></small>
|
|
</td>
|
|
<td><?= esc($employee['name'] ?? '') ?></td>
|
|
<td><?= esc($employee['relationship'] ?? '') ?></td>
|
|
<td><?= format_pending_approval_date($employee['dob'] ?? null) ?></td>
|
|
<td><?= format_pending_approval_date($employee['date_coverage'] ?? null) ?></td>
|
|
<td><?= esc($employee['policy_no'] ?? '') ?></td>
|
|
<td>
|
|
<?php
|
|
if ($rowStatus === 'pending_approval') {
|
|
echo '<span class="badge badge-warning approval-status-badge">Pending</span>';
|
|
} elseif ($rowStatus === 'active') {
|
|
echo '<span class="badge badge-success approval-status-badge">Approved</span>';
|
|
} elseif ($rowStatus === 'rejected') {
|
|
echo '<span class="badge badge-danger approval-status-badge">Rejected</span>';
|
|
} else {
|
|
echo esc($employee['status'] ?? '-');
|
|
}
|
|
?>
|
|
</td>
|
|
<td class="text-nowrap text-center">
|
|
<?php
|
|
$rejectReason = trim((string) (
|
|
$employee['reject_reason']
|
|
?? $employee['emp_reject_reason']
|
|
?? $employee['policy_reject_reason']
|
|
?? ''
|
|
));
|
|
?>
|
|
<?php if ($rowStatus === 'pending_approval') { ?>
|
|
<button type="button" class="btn btn-success approval-action-btn mr-1" title="Approve"
|
|
onclick="processPendingDependent('<?= $employee['employee_id'] ?>', '<?= $employee['client_policy_id'] ?>', 'approved')">
|
|
<i class="mdi mdi-check"></i>
|
|
</button>
|
|
<button type="button" class="btn btn-danger approval-action-btn" title="Reject"
|
|
onclick="processPendingDependent('<?= $employee['employee_id'] ?>', '<?= $employee['client_policy_id'] ?>', 'rejected')">
|
|
<i class="mdi mdi-close"></i>
|
|
</button>
|
|
<?php } elseif ($rowStatus === 'rejected') { ?>
|
|
<button type="button" class="btn btn-success approval-action-btn" title="Approve"
|
|
onclick="processPendingDependent('<?= $employee['employee_id'] ?>', '<?= $employee['client_policy_id'] ?>', 'approved')">
|
|
<i class="mdi mdi-check"></i>
|
|
</button>
|
|
<span class="approval-reject-info" tabindex="0" role="button" aria-label="Reject reason">
|
|
<i class="mdi mdi-information-outline"></i>
|
|
<span class="approval-reject-tooltip-text"><?= esc($rejectReason !== '' ? $rejectReason : 'No reject reason provided') ?></span>
|
|
</span>
|
|
<?php } else { ?>
|
|
-
|
|
<?php } ?>
|
|
</td>
|
|
</tr>
|
|
<?php }
|
|
} ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function initPendingApprovalsDataTable() {
|
|
if (!$.fn.DataTable) {
|
|
return;
|
|
}
|
|
|
|
var $table = $('#pending-approvals-table');
|
|
if (!$table.length) {
|
|
return;
|
|
}
|
|
|
|
if ($.fn.DataTable.isDataTable('#pending-approvals-table')) {
|
|
$table.DataTable().destroy();
|
|
}
|
|
|
|
if (typeof nhanceListDataTableBeforeInit === 'function') {
|
|
nhanceListDataTableBeforeInit();
|
|
}
|
|
|
|
var dtOptions = {
|
|
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>>",
|
|
order: [],
|
|
pageLength: 10,
|
|
lengthMenu: [[10, 25, 50, 100], [10, 25, 50, 100]],
|
|
buttons: [
|
|
{
|
|
extend: 'excel',
|
|
text: '<i class="mdi mdi-file-excel"></i><span class="btn-custom"> EXCEL </span>',
|
|
className: 'btn app-btn-secondary',
|
|
title: 'Approvals',
|
|
sheetName: 'Approvals',
|
|
exportOptions: {
|
|
columns: [0, 1, 2, 3, 4, 5, 6],
|
|
format: {
|
|
body: function (data, row, column, node) {
|
|
var $node = $(node);
|
|
if (column === 0) {
|
|
var name = $node.clone().children().remove().end().text().trim();
|
|
var code = $node.find('small').text().trim();
|
|
return code ? (name + ' (' + code + ')') : name;
|
|
}
|
|
return $node.text().replace(/\s+/g, ' ').trim();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
],
|
|
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>
|
|
</div>`,
|
|
searchPlaceholder: "Search",
|
|
emptyTable: '<div class="text-center text-muted">No approval records found</div>'
|
|
}
|
|
};
|
|
|
|
var pendingApprovalsTable = typeof nhanceMergeListDataTableOptions === 'function'
|
|
? $table.DataTable(nhanceMergeListDataTableOptions(dtOptions))
|
|
: $table.DataTable(dtOptions);
|
|
|
|
if (typeof nhanceListDataTableAfterInit === 'function') {
|
|
nhanceListDataTableAfterInit();
|
|
}
|
|
|
|
if (typeof nhanceListDataTableBindAdjust === 'function') {
|
|
nhanceListDataTableBindAdjust(pendingApprovalsTable);
|
|
}
|
|
}
|
|
|
|
initPendingApprovalsDataTable();
|
|
</script>
|