462 lines
26 KiB
PHP
462 lines
26 KiB
PHP
<style>
|
|
/* UI improvements for module cards - all 5 in one row on large screens */
|
|
.module-cards-row .section {
|
|
min-height: 60px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
padding: 0.5rem 0;
|
|
}
|
|
.module-cards-row .section-title {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
min-height: 40px;
|
|
cursor: default;
|
|
margin-left: 25px;
|
|
}
|
|
.module-cards-row .section-title input[type="checkbox"] {
|
|
cursor: pointer;
|
|
flex-shrink: 0;
|
|
}
|
|
.module-cards-row .section-title .mdi {
|
|
margin-bottom: 0;
|
|
color: #555;
|
|
}
|
|
/* Fallback: ensure 5 equal columns on large screens if row-cols not supported */
|
|
@media (min-width: 992px) {
|
|
.module-cards-row > .col {
|
|
flex: 0 0 20%;
|
|
max-width: 20%;
|
|
}
|
|
}
|
|
|
|
/* Checkbox alignment - vertically center with labels */
|
|
.checkbox-item {
|
|
display: flex !important;
|
|
align-items: center !important;
|
|
gap: 0.5rem;
|
|
min-height: 1.5rem;
|
|
}
|
|
.checkbox-item input[type="checkbox"] {
|
|
margin: 0 !important;
|
|
flex-shrink: 0;
|
|
vertical-align: middle;
|
|
}
|
|
.checkbox-item label {
|
|
margin: 0 !important;
|
|
flex: 1;
|
|
cursor: pointer;
|
|
line-height: 1.4;
|
|
}
|
|
|
|
.checkbox-group {
|
|
margin-left: 8px !important;
|
|
}
|
|
|
|
<?php foreach ($hr_access_data ?? [] as $key => $value) {
|
|
$key = $key + 1;
|
|
?>
|
|
|
|
|
|
#user<?php echo "$key"; ?>-active {
|
|
margin: 0;
|
|
}
|
|
|
|
#user<?= $key ?>-active .checkbox-item {
|
|
padding-left: 0;
|
|
}
|
|
|
|
#user<?= $key ?>-active label {
|
|
font-size: 11px !important;
|
|
height: auto !important;
|
|
}
|
|
|
|
#user<?php echo "$key"; ?>-pre {
|
|
margin: 0;
|
|
}
|
|
|
|
#user<?= $key ?>-pre .checkbox-item {
|
|
padding-left: 0;
|
|
}
|
|
|
|
#user<?= $key ?>-pre label {
|
|
font-size: 11px !important;
|
|
height: auto !important;
|
|
}
|
|
|
|
#user<?php echo "$key"; ?>-gmc2 {
|
|
margin: 0;
|
|
}
|
|
|
|
#user<?= $key ?>-gmc2 .checkbox-item {
|
|
padding-left: 0;
|
|
}
|
|
|
|
#user<?= $key ?>-gmc2 label {
|
|
font-size: 11px !important;
|
|
height: auto !important;
|
|
}
|
|
|
|
#user<?php echo "$key"; ?>-cd {
|
|
margin: 0;
|
|
}
|
|
|
|
#user<?= $key ?>-cd .checkbox-item {
|
|
padding-left: 0;
|
|
}
|
|
|
|
#user<?= $key ?>-cd label {
|
|
font-size: 11px !important;
|
|
height: auto !important;
|
|
}
|
|
|
|
|
|
<?php } ?>
|
|
</style>
|
|
|
|
<div class="container-fluid-min">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
|
|
<?php if (isset($hr_access_data) && !empty($hr_access_data)) {
|
|
$listed_pre = [];
|
|
$listed_post = [];
|
|
?>
|
|
<form id="insuranceForm" onsubmit="submitForm(event)">
|
|
|
|
<?php foreach ($hr_access_data as $key => $value) {
|
|
$key = $key + 1;
|
|
|
|
// Calculate data counts per user for toggling rules
|
|
// Cast to int — DB drivers may return branch ids as string or int
|
|
$prePolicyCount = 0;
|
|
if (!empty($pre_policy_data)) {
|
|
foreach ($pre_policy_data as $p) {
|
|
if (!empty($value['pre_hr_id']) && (int) $value['pre_branch_id'] === (int) $p['branch_id']) {
|
|
$prePolicyCount++;
|
|
}
|
|
}
|
|
}
|
|
|
|
$postPolicyCount = 0;
|
|
if (!empty($post_policy_data)) {
|
|
foreach ($post_policy_data as $p) {
|
|
if (!empty($value['post_hr_id']) && (int) $value['post_branch_id'] === (int) $p['branch_id']) {
|
|
$postPolicyCount++;
|
|
}
|
|
}
|
|
}
|
|
|
|
$cdCount = !empty($post_cd_data) ? count($post_cd_data) : 0;
|
|
?>
|
|
|
|
<!-- User 1 Card -->
|
|
<div class="user-card" data-user-id="<?= 'user' . $key ?>">
|
|
<!-- Hidden form elements for User 1 -->
|
|
<input type="hidden" name="<?= 'user' . $key ?>_pk" value="<?= $value['hr_access_table_pk'] ?>">
|
|
<input type="hidden" name="<?= 'user' . $key ?>_pre_hr_id" value="<?= $value['pre_hr_id'] ?>">
|
|
<input type="hidden" name="<?= 'user' . $key ?>_post_hr_id" value="<?= $value['post_hr_id'] ?>">
|
|
<input type="hidden" name="<?= 'user' . $key ?>_post_client_id" value="<?= $value['post_client_id'] ?>">
|
|
<input type="hidden" name="<?= 'user' . $key ?>_pre_branch_id" value="<?= $value['pre_branch_id'] ?>">
|
|
<input type="hidden" name="<?= 'user' . $key ?>_post_branch_id" value="<?= $value['post_branch_id'] ?>">
|
|
<input type="hidden" name="<?= 'user' . $key ?>_pre_client_id" value="<?= $value['pre_client_id'] ?>">
|
|
|
|
<div class="card-header" onclick="toggleAccordion(this)" style="background-color: #F5FFFF;">
|
|
<div class="user-info">
|
|
<h5 class="mb-0"> Name -<?= $value['hr_name'] ?>
|
|
<!-- <i class="mdi mdi-information-outline" aria-hidden="true" data-id="<?= (!empty($value['pre_hr_id']) ? $value['pre_hr_id'] : 0) . '-' . (!empty($value['post_hr_id']) ? $value['post_hr_id'] : 0) ?>"></i> -->
|
|
</h5>
|
|
<p style="color: black;"> <b>branch - <?= $value['post_branch_name']?></b></p>
|
|
<p class="user-email"> Mail - <?= $value['hr_mail'] ?></p>
|
|
</div>
|
|
<div class="accordion-icon">
|
|
<i class="mdi mdi-chevron-down"></i>
|
|
</div>
|
|
</div>
|
|
<div class="card-content">
|
|
<div class="content-inner" style="background-color: #F5FFFF;">
|
|
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-5 module-cards-row">
|
|
<div class="col">
|
|
<div class="section">
|
|
<div class="section-title">
|
|
<input type="checkbox" class="main-checkbox"
|
|
onchange="toggleSection(this, '<?= 'user' . $key ?>-pre', <?= $prePolicyCount ?>)" name="<?= 'user' . $key ?>_modules"
|
|
value="1" <?php if (in_array(1, $value['allowed_pre_modules'] ?? [])) {
|
|
echo 'checked';
|
|
} ?>>
|
|
<i class="mdi mdi-account-plus mr-2"></i>Pre enrollment
|
|
</div>
|
|
|
|
<div class="<?= in_array(1, $value['allowed_pre_modules'] ?? []) ? 'checkbox-group' : 'checkbox-group hidden' ?>" id="<?= 'user' . $key ?>-pre">
|
|
|
|
<!-- Select All -->
|
|
<div class="checkbox-item">
|
|
<input type="checkbox" class="select-all" data-type="all" data-user="<?= $key ?>" data-group="pre">
|
|
<label>Select all</label>
|
|
</div>
|
|
|
|
<!-- Select All Active -->
|
|
<div class="checkbox-item">
|
|
<input type="checkbox" class="select-all" data-type="active" data-user="<?= $key ?>" data-group="pre">
|
|
<label>Select all Active policies</label>
|
|
</div>
|
|
|
|
<!-- Select All Inactive -->
|
|
<div class="checkbox-item">
|
|
<input type="checkbox" class="select-all" data-type="inactive" data-user="<?= $key ?>" data-group="pre">
|
|
<label>Select all In-Active policies</label>
|
|
</div>
|
|
|
|
<?php foreach ($pre_policy_data ?? [] as $key1 => $policies) {
|
|
$statusText = $policies['policy_status'] == 1 ? 'Active' : 'In-Active';
|
|
$statusClass = $policies['policy_status'] == 1 ? 'active' : 'inactive';
|
|
// if (
|
|
// in_array($policies['branch_id'].'-'.$policies['policy_no'], $listed_pre)
|
|
// &&
|
|
// $value['pre_branch_id'] != $policies['branch_id']
|
|
// ) {
|
|
// continue;
|
|
// } else {
|
|
// $listed_pre[] = $policies['branch_id'].'-'.$policies['policy_no'];
|
|
// }
|
|
|
|
if (empty($value['pre_hr_id']) || (int) $value['pre_branch_id'] !== (int) $policies['branch_id']) {
|
|
continue;
|
|
}
|
|
?>
|
|
<div class="checkbox-item">
|
|
<input type="checkbox" class="policy-checkbox <?= $statusClass ?>" name="<?= 'user' . $key ?>_pre_policies" data-user="<?= $key ?>" data-group="pre" value="<?= $policies['client_policy_id'] ?>"
|
|
<?= in_array($policies['client_policy_id'], $value['allowed_pre_policies'] ?? []) ? 'checked' : '' ?>>
|
|
<label style="<?php if ($policies['policy_status'] == 0) {
|
|
echo 'color:#ff5757';
|
|
} ?>"><?= $policies['policy_type'] . ' - ' . $policies['policy_no'] ?></label>
|
|
</div>
|
|
<?php } ?>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col">
|
|
<div class="section">
|
|
<div class="section-title">
|
|
<input type="checkbox" class="main-checkbox"
|
|
onchange="toggleSection(this, '<?= 'user' . $key ?>-active', <?= $postPolicyCount ?>)" name="<?= 'user' . $key ?>_modules"
|
|
value="2" <?php if (in_array(2, $value['allowed_post_modules'])) {
|
|
echo 'checked';
|
|
} ?>>
|
|
<i class="mdi mdi-check-circle mr-2"></i>Active policies
|
|
</div>
|
|
<div class="<?php if (in_array(2, $value['allowed_post_modules'])) {
|
|
echo 'checkbox-group';
|
|
} else {
|
|
echo 'checkbox-group hidden';
|
|
} ?>" id="<?= 'user' . $key ?>-active">
|
|
|
|
|
|
<!-- Select All -->
|
|
<div class="checkbox-item">
|
|
<input type="checkbox" class="select-all" data-type="all" data-user="<?= $key ?>" data-group="post">
|
|
<label>Select all</label>
|
|
</div>
|
|
|
|
<!-- Select All Active -->
|
|
<div class="checkbox-item">
|
|
<input type="checkbox" class="select-all" data-type="active" data-user="<?= $key ?>" data-group="post">
|
|
<label>Select all Active policies</label>
|
|
</div>
|
|
|
|
<!-- Select All Inactive -->
|
|
<div class="checkbox-item">
|
|
<input type="checkbox" class="select-all" data-type="inactive" data-user="<?= $key ?>" data-group="post">
|
|
<label>Select all In-Active policies</label>
|
|
</div>
|
|
|
|
<?php foreach ($post_policy_data ?? [] as $key2 => $policies) {
|
|
$statusText = $policies['policy_status'] == 1 ? 'Active' : 'In-Active';
|
|
$statusClass = $policies['policy_status'] == 1 ? 'active' : 'inactive';
|
|
// if(
|
|
// in_array($policies['branch_id'].'-'.$policies['policy_no'] , $listed_post)
|
|
// &&
|
|
// $value['post_branch_id'] != $policies['branch_id']
|
|
// )
|
|
// {
|
|
// continue;
|
|
// }
|
|
// else
|
|
// {
|
|
// $listed_post[] = $policies['branch_id'].'-'.$policies['policy_no'];
|
|
// }
|
|
|
|
if (empty($value['post_hr_id']) || (int) $value['post_branch_id'] !== (int) $policies['branch_id']) {
|
|
continue;
|
|
}
|
|
|
|
?>
|
|
<div class="checkbox-item">
|
|
<input type="checkbox" class="policy-checkbox <?= $statusClass ?>" id="<?= 'user' . $key ?>-gmc2" name="<?= 'user' . $key ?>_active_policies" data-user="<?= $key ?>" data-group="post"
|
|
value="<?= $policies['client_policy_id'] ?>" <?php if (in_array($policies['client_policy_id'], $value['allowed_active_policies'])) {
|
|
echo 'checked';
|
|
} ?>>
|
|
|
|
<label for="<?= 'user' . $key ?>-gmc2" style="<?php if ($policies['policy_status'] == 0) {
|
|
echo 'color:#ff5757';
|
|
} ?>">
|
|
<?= $policies['policy_type'] . ' - ' . $policies['policy_no'] ?>
|
|
</label>
|
|
</div>
|
|
<?php } ?>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col">
|
|
<div class="section">
|
|
<div class="section-title">
|
|
<input type="checkbox" class="main-checkbox"
|
|
onchange="toggleSection(this, '<?= 'user' . $key ?>-cd', <?= $cdCount ?>)" name="<?= 'user' . $key ?>_modules" value="3" <?php if (in_array(3, $value['allowed_post_modules'])) {
|
|
echo 'checked';
|
|
} ?>>
|
|
<i class="mdi mdi-file mr-2"></i>CD statement
|
|
</div>
|
|
|
|
<div class="<?php if (in_array(3, $value['allowed_post_modules'])) {
|
|
echo 'checkbox-group';
|
|
} else {
|
|
echo 'checkbox-group hidden';
|
|
} ?>" id="<?= 'user' . $key ?>-cd">
|
|
|
|
<!-- Select All -->
|
|
<div class="checkbox-item">
|
|
<input type="checkbox" class="select-all" data-type="all" data-user="<?= $key ?>" data-group="cd">
|
|
<label>Select all</label>
|
|
</div>
|
|
|
|
<?php foreach ($post_cd_data ?? [] as $key3 => $cd) { ?>
|
|
<div class="checkbox-item">
|
|
<input type="checkbox" class="policy-checkbox" data-user="<?= $key ?>" data-group="cd" id="<?= 'user' . $key ?>-icici1" name="<?= 'user' . $key ?>_cd" value="<?= $cd['cd_master_pk'] ?>" <?php if (in_array($cd['cd_master_pk'], $value['allowed_cd'])) {
|
|
echo 'checked';
|
|
} ?>>
|
|
<label for="<?= 'user' . $key ?>-icici1"><?= $cd['insurer_short_name'] ?> - <span class="policy-number"><?= $cd['cd_account_no'] ?></span></label>
|
|
</div>
|
|
<?php } ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col">
|
|
<div class="section">
|
|
<div class="section-title">
|
|
<input type="checkbox" class="main-checkbox" name="<?= 'user' . $key ?>_modules" value="4" <?php if (in_array(4, $value['allowed_post_modules'])) {
|
|
echo 'checked';
|
|
} ?>>
|
|
<i class="mdi mdi-clipboard-text mr-2"></i>Claims
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col">
|
|
<div class="section">
|
|
<div class="section-title">
|
|
<input type="checkbox" class="main-checkbox" name="<?= 'user' . $key ?>_modules" value="5" <?php if (in_array(5, $value['allowed_post_modules'] ?? [])) {
|
|
echo 'checked';
|
|
} ?>>
|
|
<i class="mdi mdi-chart-line mr-2"></i>Insights
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php } ?>
|
|
|
|
<!-- Submit Section -->
|
|
<div class="submit-container">
|
|
<button type="submit" class="btn btn-primary btn-submit">
|
|
Submit Form
|
|
</button>
|
|
</div>
|
|
</form>
|
|
|
|
<?php } else { ?>
|
|
<div class="submit-container">
|
|
<p align="center"> <b>There is no HR data</b></p>
|
|
</div>
|
|
<?php } ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
|
|
function toggleAccordion(header) {
|
|
const card = header.parentElement;
|
|
const content = card.querySelector('.card-content');
|
|
const icon = header.querySelector('.accordion-icon i');
|
|
|
|
// Close all other accordions
|
|
document.querySelectorAll('.user-card').forEach(otherCard => {
|
|
if (otherCard !== card) {
|
|
const otherContent = otherCard.querySelector('.card-content');
|
|
const otherIcon = otherCard.querySelector('.accordion-icon i');
|
|
if (otherContent && otherIcon) {
|
|
otherContent.classList.remove('active');
|
|
otherIcon.setAttribute('class', 'mdi mdi-chevron-down');
|
|
}
|
|
}
|
|
});
|
|
|
|
// Toggle current accordion
|
|
if (content && icon) {
|
|
content.classList.toggle('active');
|
|
if (content.classList.contains('active')) {
|
|
icon.setAttribute('class', 'mdi mdi-chevron-up');
|
|
} else {
|
|
icon.setAttribute('class', 'mdi mdi-chevron-down');
|
|
}
|
|
}
|
|
}
|
|
|
|
function toggleSection(checkbox, sectionId, dataCount) {
|
|
const section = document.getElementById(sectionId);
|
|
const checkboxes = section.querySelectorAll('input[type="checkbox"]');
|
|
|
|
// If checkbox is being unchecked, always allow without any restriction
|
|
if (!checkbox.checked) {
|
|
section.classList.add('hidden');
|
|
checkboxes.forEach(cb => {
|
|
cb.checked = false;
|
|
cb.disabled = true;
|
|
});
|
|
return;
|
|
}
|
|
|
|
// From here, checkbox is being checked
|
|
// If there is no data, show warning and revert the checkbox state
|
|
if (!dataCount || dataCount === 0) {
|
|
checkbox.checked = false;
|
|
if (typeof toastr !== 'undefined' && toastr.warning) {
|
|
toastr.warning('No data available for this section.', 'Warning');
|
|
} else {
|
|
alert('No data available for this section.');
|
|
}
|
|
return;
|
|
}
|
|
|
|
// Data is available and checkbox is being checked - show section and enable inner checkboxes
|
|
section.classList.remove('hidden');
|
|
checkboxes.forEach(cb => {
|
|
cb.disabled = false;
|
|
});
|
|
}
|
|
|
|
function getCheckedValues(name) {
|
|
const checkboxes = document.querySelectorAll(`input[name="${name}"]:checked`);
|
|
return Array.from(checkboxes).map(cb => cb.value);
|
|
}
|
|
|
|
</script>
|