nhance/app/Views/client_onboarding.php

939 lines
34 KiB
PHP
Executable File

<style>
body {
.multiselect-native-select {
position: relative;
/* bottom: 32px; */
select {
border: 0 !important;
clip: rect(0 0 0 0) !important;
height: 1px !important;
margin: -1px -1px -1px -3px !important;
overflow: hidden !important;
padding: 0 !important;
position: absolute !important;
width: 1px !important;
left: 50%;
top: 30px;
}
}
.multiselect-container{
width: 100% !important;
}
.multiselect-selected-text{
float: left !important;
}
}
.navtab-bg .nav-link {
margin: 0 5px 10px!important;
}
.readonly-select {
pointer-events: none;
/* background-color: #f0f0f0; */
background-color: #e0e0e0;
color: #666;
}
</style>
<style>
body {
background-color: #f8f9fa;
font-size: 14px;
}
.container-fluid {
padding: 12px;
}
.user-card {
background: white;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(77, 77, 77, 0.3);
margin-bottom: 12px;
overflow: hidden;
transition: all 0.3s ease;
}
.user-card:hover {
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.card-header {
background: #d6d6d6;
color: white;
padding: 12px 18px;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
transition: background 0.3s ease;
}
.card-header:hover {
background: #b4bec5;
}
.user-info h5 {
margin-bottom: 2px;
font-size: 1.1em;
color: #121212;
}
.user-email {
font-size: 0.85em;
opacity: 0.9;
margin: 0;
color:rgb(56, 55, 55);
}
.accordion-icon {
font-size: 1.2em;
transition: transform 0.3s ease;
color: #121212;
}
.accordion-icon.active {
transform: rotate(180deg);
}
.card-content {
max-height: 0;
overflow: hidden;
transition: max-height 0.4s ease;
background: white;
}
.card-content.active {
max-height: 500px;
overflow-y: auto;
}
.content-inner {
padding: 18px;
}
.section {
background: #d6dce1;
border-radius: 6px;
padding: 12px;
border: 1px solid #e9ecef;
margin-bottom: 12px;
transition: all 0.3s ease;
}
.section:hover {
border-color: #667eea;
box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}
.section-title {
font-weight: 600;
margin-bottom: 8px;
color: #121212;
font-size: 0.95em;
display: flex;
align-items: center;
}
.main-checkbox {
margin-right: 8px;
transform: scale(1.1);
cursor: pointer;
}
.checkbox-group {
margin-left: 24px;
transition: all 0.3s ease;
max-height: 225px;
overflow-y: auto;
padding-right: 8px;
overflow-x: hidden;
}
.checkbox-group::-webkit-scrollbar {
width: 4px;
}
.checkbox-group::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 2px;
}
.checkbox-group::-webkit-scrollbar-thumb {
background: #667eea;
border-radius: 2px;
}
.checkbox-group::-webkit-scrollbar-thumb:hover {
background: #5a6fd8;
}
.checkbox-item {
display: flex;
align-items: center;
padding: 4px 8px;
border-radius: 4px;
transition: background 0.2s ease;
/* margin-bottom: 3px; */
margin-bottom: -7px;
}
.checkbox-item:hover {
background: rgba(102, 126, 234, 0.1);
}
.checkbox-item input[type="checkbox"] {
transform: scale(1.05);
cursor: pointer;
margin-right: 6px;
}
.checkbox-item label {
cursor: pointer;
user-select: none;
margin: 0;
font-size: 0.9em;
}
.hidden {
opacity: 0;
max-height: 0 !important;
overflow: hidden;
margin: 0;
padding: 0;
}
.policy-number {
font-family: monospace;
font-size: 0.8em;
color: #6c757d;
}
.submit-container {
background: white;
padding: 18px;
border-radius: 8px;
/* box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); */
margin-top: 20px;
text-align: right;
}
/* .btn-submit {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border: none;
padding: 10px 30px;
font-weight: 600;
border-radius: 25px;
transition: all 0.3s ease;
}
.btn-submit:hover {
background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
transform: translateY(-2px);
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
} */
.output-container {
background: #f8f9fa;
border: 1px solid #dee2e6;
border-radius: 8px;
padding: 15px;
margin-top: 20px;
display: none;
}
.output-table {
font-family: monospace;
font-size: 0.85em;
white-space: pre-wrap;
background: white;
padding: 10px;
border-radius: 4px;
border: 1px solid #dee2e6;
}
</style>
<div class="row" id="client_add">
<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;">Client Onboarding <?php if(isset($client)) {echo ' - ' . $client['client_name']; } ?></h4>
</div>
<div class="col-6" style="text-align: right;">
<a href="<?= base_url("client/list"); ?>"><i class="fas fa-arrow-left" style="font-size: 17px;"></i></a>
</div>
</div>
<br>
<ul class="nav nav-pills navtab-bg">
<li class="nav-item">
<a href="#general-q-tab" data-toggle="tab" aria-expanded="false"
class="nav-link px-3 py-2 active" id="general_tab">
<span class="mr-1"><i class="mdi mdi-contacts"></i></span>
<span class="d-none d-sm-inline-block">General</span>
</a>
</li>
<li class="nav-item">
<a href="#KYC-DOC-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="kyc_tab">
<span class="mr-1"><i class="fa fa-file"></i></span>
<span class="d-none d-sm-inline-block">KYC Docs</span>
</a>
</li>
<li class="nav-item">
<a href="#RM-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="RM_tab">
<span class="mr-1"><i class="mdi mdi-account-switch"></i></span>
<span class="d-none d-sm-inline-block"> Relationship Manager</span>
</a>
</li>
<li class="nav-item">
<a href="#branch-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="branch_tab">
<span class="mr-1"><i class="mdi mdi-source-branch"></i></span>
<span class="d-none d-sm-inline-block">Branch & Contacts</span>
</a>
</li>
<li class="nav-item">
<a href="#notification-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="notification_tab">
<span class="mr-1"><i class="mdi mdi-bell"></i></span>
<span class="d-none d-sm-inline-block">Notifications</span>
</a>
</li>
<li class="nav-item">
<a href="#police-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="policy_tab">
<span class="mr-1"><i class="mdi mdi-book-open-page-variant"></i></span>
<span class="d-none d-sm-inline-block">Policies</span>
</a>
</li>
<li class="nav-item">
<a href="#hr-access-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="hr_access_tab" onclick="appendHrAccessControllHtml(this)">
<span class="mr-1"><i class="mdi mdi-book-open-page-variant"></i></span>
<span class="d-none d-sm-inline-block">HR Access Controll</span>
</a>
</li>
<li class="nav-item">
<a href="#hr-activity-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="hr_activity_tab" onclick="appendHrActivityHistoryHtml(this)">
<span class="mr-1"><i class="mdi mdi-book-open-page-variant"></i></span>
<span class="d-none d-sm-inline-block">HR Activity</span>
</a>
</li>
<!-- <li class="nav-item">
<a href="#api-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="api_tab">
<span class="mdi mdi-api"></span>
<span class="d-none d-sm-inline-block">API</span>
</a>
</li> -->
<!-- <li class="nav-item">
<a href="#others-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="others_tab">
<span class="mr-1"><i class="mdi mdi-tag-text-outline"></i></span>
<span class="d-none d-sm-inline-block">Others</span>
</a>
</li> -->
</ul>
<div class="tab-content">
<div class="tab-pane fade" id="hr-access-tab">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body" id="hr_access_append_area">
</div>
</div>
</div> <!-- end col -->
</div>
</div>
<div class="tab-pane fade" id="hr-activity-tab">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body" id="hr_activity_history_append_area" style="position: relative;bottom: 50px;">
</div>
</div>
</div> <!-- end col -->
</div>
</div>
<?php include("client_api.php"); ?>
<?php // include('client_others_tab.php'); ?>
<?php include('notification.php'); ?>
<?php include('client_basic_info.php'); ?>
<?php include('client_kyc.php'); ?>
<?php include('client_rm.php'); ?>
<?php include('client_branch.php'); ?>
<?php include('client_policy.php'); ?>
</div>
</div>
</div>
</div>
</div>
<script>
let hrAccessControlHtmlAppended = false;
let hrActivityHistoryHtmlAppended = false;
function client_kyc_docs() {
var check_client_id = $('#general_PrimaryKey');
if(check_client_id[0].value == '' || check_client_id[0].value == null || check_client_id[0].value == 0){
$('#btnBranchAdd').hide();
toastr.warning('Please Add the Client!', 'warning',{timeOut: 2000});
}else{
if ($('#btnBranchBack')[0].style.display == 'none') {
$('#btnBranchAdd').show();
}
}
}
function client_relationship_manager() {
var check_client_id = $('#general_PrimaryKey');
if(check_client_id[0].value == '' || check_client_id[0].value == null || check_client_id[0].value == 0){
$('#relation_form').hide();
toastr.warning('Please Add the Client!', 'warning',{timeOut: 2000});
}else{
$('#relation_form').show();
}
}
function client_policies() {
var check_client_id = $('#general_PrimaryKey').val();
if(check_client_id == '' || check_client_id == null || check_client_id == 0){
$('#BtnAdd').hide();
toastr.warning('Please Add the Client!', 'warning',{timeOut: 2000});
}else{
if ($('#btnPolicyBack')[0].style.display == 'none') {
$('#BtnAdd').show();
}
}
}
function client_branch_contact() {
var check_client_id = $('#general_PrimaryKey');
if(check_client_id[0].value == '' || check_client_id[0].value == null || check_client_id[0].value == 0){
$('#btnBranchAdd').hide();
toastr.warning('Please Add the Client!', 'warning',{timeOut: 2000});
}else{
if ($('#btnBranchBack')[0].style.display == 'none') {
$('#btnBranchAdd').show();
}
}
}
function client_notification() {
var check_client_id = $('#general_PrimaryKey');
if(check_client_id[0].value == '' || check_client_id[0].value == null || check_client_id[0].value == 0){
$('#notification-tab').hide();
toastr.warning('Please Add the Client!', 'warning',{timeOut: 2000});
}else{
if ($('#notification-tab')[0].style.display == 'none') {
$('#notification-tab').show();
}
}
}
document.getElementById("kyc_tab").addEventListener("click", function(event) {
event.preventDefault();
client_kyc_docs();
});
document.getElementById("RM_tab").addEventListener("click", function(event) {
event.preventDefault();
client_relationship_manager();
});
document.getElementById("policy_tab").addEventListener("click", function(event) {
event.preventDefault();
client_policies();
});
document.getElementById("branch_tab").addEventListener("click", function(event) {
event.preventDefault();
client_branch_contact();
});
document.getElementById("notification_tab").addEventListener("click", function(event) {
event.preventDefault();
client_notification();
});
//HR Access Controll
function appendHrAccessControllHtml(input){
console.log(input.id);
let client_id = $('#general_PrimaryKey').val();
console.log('client_id ', client_id);
let url = '<?= base_url('util/viewHrAccessData') ?>';
let requestData = {client_id : client_id};
if(hrAccessControlHtmlAppended == false){
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
$('#hr_access_append_area').empty();
$('#hr_access_append_area').append(response.data)
hrAccessControlHtmlAppended = true;
} else {
console.log(response.message, 'WARNING');
hrAccessControlHtmlAppended = false;
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
hrAccessControlHtmlAppended = false;
});
}else{
console.log('Already HTML appended');
}
}
//HR Activity History
function appendHrActivityHistoryHtml(input, submit = false){
console.log(input.id);
let client_id = $('#general_PrimaryKey').val();
let startDate = $('#startDate').val();
let endDate = $('#endDate').val();
console.log('client_id ', client_id);
console.log('startDate ', startDate);
console.log('endDate ', endDate);
if(submit){
hrActivityHistoryHtmlAppended = false;
}
let url = '<?= base_url('user/getUserActivityHistory') ?>';
let requestData = {client_id : client_id, startDate : startDate, endDate : endDate};
if(hrActivityHistoryHtmlAppended == false){
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
$('#hr_activity_history_append_area').empty();
$('#hr_activity_history_append_area').append(response.data)
hrActivityHistoryHtmlAppended = true;
} else {
console.log(response.message, 'WARNING');
hrActivityHistoryHtmlAppended = false;
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
hrActivityHistoryHtmlAppended = false;
});
}else{
console.log('Already HTML appended');
}
}
</script>
<script>
function toggleAccordion(header) {
if (event.target.classList.contains('fa-info-circle') ||
event.target.parentElement.classList.contains('fa-info-circle')) {
getHrActivityHistory();
return; // Do nothing if click was on the info icon
}
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');
otherContent.classList.remove('active');
otherIcon.classList.remove('fa-chevron-up');
otherIcon.classList.add('fa-chevron-down');
}
});
// Toggle current accordion
content.classList.toggle('active');
if (content.classList.contains('active')) {
icon.classList.remove('fa-chevron-down');
icon.classList.add('fa-chevron-up');
} else {
icon.classList.remove('fa-chevron-up');
icon.classList.add('fa-chevron-down');
}
}
function toggleSection(checkbox, sectionId) {
const section = document.getElementById(sectionId);
const checkboxes = section.querySelectorAll('input[type="checkbox"]');
if (checkbox.checked) {
section.classList.remove('hidden');
checkboxes.forEach(cb => {
cb.disabled = false;
});
} else {
section.classList.add('hidden');
checkboxes.forEach(cb => {
cb.checked = false;
cb.disabled = true;
});
}
}
function getCheckedValues(name) {
const checkboxes = document.querySelectorAll(`input[name="${name}"]:checked`);
return Array.from(checkboxes).map(cb => parseInt(cb.value));
}
function getHrActivityHistory()
{
console.log(event.target.dataset.id);//return;
let ids = event.target.dataset.id.split('-');
console.log('ids', ids)
let client_id = $('#general_PrimaryKey').val();
// let url = '<?= base_url('user/getUserActivityHistory?user_id=') ?>' + event.target.dataset.id.split('-')[0] + '&pre_hr_id=' + event.target.dataset.id.split('-')[1];
let url = '<?= base_url('user/getUserActivityHistory') ?>';
console.log(url);
let user_type = "hr";
let requestData = {user_id : ids[1], pre_hr_id : ids[0], user_type : user_type, client_id : client_id};
console.log('requestData', requestData);
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
toastr.success(response.message, 'SUCCESS');
} else {
console.error(response.message, 'WARNING');
}
}, function(xhr, status, error) {
console.error('--- AJAX Error Details ---');
console.error('Status Code:', xhr.status);
console.error('Status Text:', xhr.statusText);
console.error('Response Text:', xhr.responseText);
console.error('XHR Object:', xhr);
console.error('jQuery Status:', status);
console.error('Thrown Error:', error);
});
}
function submitForm(event) {
event.preventDefault();
let client_id = $('#general_PrimaryKey').val();
const formData = new FormData(document.getElementById('insuranceForm'));
const users = [];
// Loop through each .user-card
document.querySelectorAll('.user-card').forEach(card => {
const userId = card.getAttribute('data-user-id'); // e.g., "user1", "user2"
const user = {
pk: formData.get(`${userId}_pk`),
pre_hr_id: formData.get(`${userId}_pre_hr_id`),
post_hr_id: formData.get(`${userId}_post_hr_id`),
post_client_id: formData.get(`${userId}_post_client_id`),
allowed_modules: getCheckedValues(`${userId}_modules`),
allowed_pre_policies: getCheckedValues(`${userId}_pre_policies`),
allowed_active_policies: getCheckedValues(`${userId}_active_policies`),
allowed_cd: getCheckedValues(`${userId}_cd`),
allowed_claims: getCheckedValues(`${userId}_claims`)
};
users.push(user);
});
console.log("users array", users);
const jsonOutput = users.map(user => {
return {
pk: parseInt(user.pk) || 0,
pre_hr_id: user.pre_hr_id || "",
post_hr_id: user.post_hr_id || "",
post_client_id: user.post_client_id || "",
allowed_modules: user.allowed_modules.length ? `[${user.allowed_modules.join(',')}]` : '[]',
allowed_pre_policies: user.allowed_pre_policies.length ? `[${user.allowed_pre_policies.join(',')}]` : '[]',
allowed_active_policies: user.allowed_active_policies.length ? `[${user.allowed_active_policies.join(',')}]` : '[]',
allowed_cd: user.allowed_cd.length ? `[${user.allowed_cd.join(',')}]` : '[]',
allowed_claims: user.allowed_claims.length ? `[${user.allowed_claims.join(',')}]` : '[]'
};
});
const output = JSON.stringify(jsonOutput, null, 1);
// Display the output
const outputElement = document.getElementById('outputTable');
if (outputElement) {
outputElement.textContent = output;
}
// Copy to clipboard
if (navigator.clipboard) {
navigator.clipboard.writeText(output).then(() => {
console.log('Output copied to clipboard');
}).catch(err => {
console.error('Failed to copy to clipboard:', err);
});
}
console.log(output);
let url = '<?= base_url('util/saveHrAccessData') ?>';
let requestData = {json : output, client_id : client_id};
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
$('#hr_access_append_area').empty();
$('#hr_access_append_area').append(response.data)
toastr.success(response.message, 'SUCCESS');
} else {
console.error(response.message, 'WARNING');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
});
}
// Helper function to get checked checkbox values (if not already defined)
function getCheckedValues(namePrefix) {
const checkboxes = document.querySelectorAll(`input[name^="${namePrefix}"]:checked`);
return Array.from(checkboxes).map(cb => cb.value);
}
$(document).on('change', '.select-all', function () {
let $this = $(this);
let type = $this.data('type');
let user = $this.data('user');
let group = $this.data('group');
console.log('--- SELECT-ALL CHANGED ---');
console.log('Type:', type); // all / active / inactive
console.log('User:', user); // user index
console.log('Group:', group); // pre / post
// Step 1: Uncheck other "select-all" checkboxes in the same user/group
$('.select-all[data-user="' + user + '"][data-group="' + group + '"]').not(this).prop('checked', false);
console.log('Unchecked other master checkboxes in same group');
// Step 2: Build full selector
let baseSelector = '.policy-checkbox[data-user="' + user + '"][data-group="' + group + '"]';
let targetSelector = baseSelector;
if (type === 'active') {
targetSelector += '.active';
console.log('Targeting ACTIVE checkboxes only');
} else if (type === 'inactive') {
targetSelector += '.inactive';
console.log('Targeting INACTIVE checkboxes only');
} else {
console.log('Targeting ALL checkboxes');
}
// Step 3: Uncheck all policy checkboxes in that group
$(baseSelector).prop('checked', false);
console.log('Unchecked all checkboxes for user', user, 'group', group);
// Step 4: If this master is checked, apply checking to relevant ones
if ($this.is(':checked')) {
$(targetSelector).prop('checked', true);
console.log('Checked selector:', targetSelector);
} else {
console.log('Master checkbox was unchecked — no checkboxes set');
}
console.log('--- END ---');
});
//----------------------------------------------------------------------------------------------------------------------
// function submitForm(event) {
// event.preventDefault();
// const formData = new FormData(document.getElementById('insuranceForm'));
// const users = [];
// // Process User 1
// const user1 = {
// pk: formData.get('user1_pk'),
// pre_hr_id: formData.get('user1_pre_hr_id'),
// post_hr_id: formData.get('user1_post_hr_id'),
// allowed_modules: getCheckedValues('user1_modules'),
// allowed_pre_policies: getCheckedValues('user1_pre_policies'),
// allowed_active_policies: getCheckedValues('user1_active_policies'),
// allowed_cd: getCheckedValues('user1_cd'),
// allowed_claims: getCheckedValues('user1_claims')
// };
// // Process User 2
// const user2 = {
// pk: formData.get('user2_pk'),
// pre_hr_id: formData.get('user2_pre_hr_id'),
// post_hr_id: formData.get('user2_post_hr_id'),
// allowed_modules: getCheckedValues('user2_modules'),
// allowed_pre_policies: getCheckedValues('user2_pre_policies'),
// allowed_active_policies: getCheckedValues('user2_active_policies'),
// allowed_cd: getCheckedValues('user2_cd'),
// allowed_claims: getCheckedValues('user2_claims')
// };
// users.push(user1, user2);
// // Generate JSON format
// const jsonOutput = users.map(user => {
// const modules = user.allowed_modules.length > 0 ? `[${user.allowed_modules.join(',')}]` : '[]';
// const prePolicies = user.allowed_pre_policies.length > 0 ? `[${user.allowed_pre_policies.join(',')}]` : '[]';
// const activePolicies = user.allowed_active_policies.length > 0 ? `[${user.allowed_active_policies.join(',')}]` : '[]';
// const cdPolicies = user.allowed_cd.length > 0 ? `[${user.allowed_cd.join(',')}]` : '[]';
// const claims = user.allowed_claims.length > 0 ? `[${user.allowed_claims.join(',')}]` : '[]';
// return {
// pk: parseInt(user.pk) || 0,
// pre_hr_id: user.pre_hr_id || "",
// post_hr_id: user.post_hr_id || "",
// allowed_modules: modules,
// allowed_pre_policies: prePolicies,
// allowed_active_policies: activePolicies,
// allowed_cd: cdPolicies,
// allowed_claims: claims
// };
// });
// const output = JSON.stringify(jsonOutput, null, 1);
// // Display the output (you can modify this part based on your needs)
// console.log(output);
// // Optional: Display in a textarea or pre element
// const outputElement = document.getElementById('output');
// if (outputElement) {
// outputElement.textContent = output;
// }
// // Optional: Copy to clipboard
// if (navigator.clipboard) {
// navigator.clipboard.writeText(output).then(() => {
// console.log('Output copied to clipboard');
// }).catch(err => {
// console.error('Failed to copy to clipboard:', err);
// });
// }
// }
//----------------------------------------------------------------------------------------------------------------------
// $(document).on('change', '.select-all', function () {
// let type = $(this).data('type');
// let user = $(this).data('user');
// let group = $(this).data('group');
// let selector = '.policy-checkbox[data-user="' + user + '"][data-group="' + group + '"]';
// if (type === 'active') {
// selector += '.active';
// } else if (type === 'inactive') {
// selector += '.inactive';
// }
// $(selector).prop('checked', this.checked);
// });
//----------------------------------------------------------------------------------------------------------------------
// $(document).on('change', '.post-select-all', function () {
// let $this = $(this);
// let type = $this.data('type');
// let user = $this.data('user');
// let group = $this.data('group');
// console.log('--- POST SELECT-ALL CHANGED ---');
// console.log('Type:', type); // all / active / inactive
// console.log('User:', user); // user index
// console.log('Group:', group); // pre / post
// // Step 1: Uncheck other "select-all" checkboxes in the same user/group
// $('.post-select-all[data-user="' + user + '"][data-group="' + group + '"]').not(this).prop('checked', false);
// console.log('Unchecked other master checkboxes in same group');
// // Step 2: Build selector for post policy checkboxes
// // Note: Post policy checkboxes use name="userX_active_policies" not class="policy-checkbox"
// let baseSelector = 'input[name="user' + user + '_active_policies"][data-user="' + user + '"][data-group="' + group + '"]';
// let targetSelector = baseSelector;
// if (type === 'active-post') {
// // Target checkboxes that have 'active' in their class or are associated with active policies
// targetSelector = baseSelector + ':not(.inactive)';
// console.log('Targeting ACTIVE checkboxes only');
// } else if (type === 'inactive-post') {
// // Target checkboxes that have 'inactive' in their class
// targetSelector = baseSelector + '.inactive';
// console.log('Targeting INACTIVE checkboxes only');
// } else {
// console.log('Targeting ALL checkboxes');
// }
// // Step 3: Uncheck all policy checkboxes in that group first
// $(baseSelector).prop('checked', false);
// console.log('Unchecked all checkboxes for user', user, 'group', group);
// // Step 4: If this master is checked, apply checking to relevant ones
// if ($this.is(':checked')) {
// if (type === 'active') {
// // Check all checkboxes that don't have 'inactive' class
// $(baseSelector).each(function() {
// if (!$(this).hasClass('inactive')) {
// $(this).prop('checked', true);
// }
// });
// } else if (type === 'inactive') {
// // Check all checkboxes that have 'inactive' class
// $(baseSelector + '.inactive').prop('checked', true);
// } else {
// // Check all checkboxes
// $(baseSelector).prop('checked', true);
// }
// console.log('Applied checking based on type:', type);
// } else {
// console.log('Master checkbox was unchecked — no checkboxes set');
// }
// console.log('--- END ---');
// });
</script>