FIX_LIVE_ISSUE_5

This commit is contained in:
VENKATESHWARAN 2026-03-18 10:04:16 +05:30
parent 948bde3e0b
commit 8268515ca7
2 changed files with 141 additions and 55 deletions

View File

@ -647,57 +647,58 @@
</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');
// 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');
otherIcon.setAttribute('class', 'mdi mdi-chevron-down');
// // 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');
// otherIcon.setAttribute('class', 'mdi mdi-chevron-down');
}
});
// }
// });
// Toggle current accordion
content.classList.toggle('active');
if (content.classList.contains('active')) {
icon.classList.setAttribute('class', 'mdi mdi-chevron-up');
} else {
icon.classList.setAttribute('class', 'mdi mdi-chevron-down');
}
}
// // Toggle current accordion
// content.classList.toggle('active');
// if (content.classList.contains('active')) {
// icon.classList.setAttribute('class', 'mdi mdi-chevron-up');
// } else {
// icon.classList.setAttribute('class', 'mdi mdi-chevron-down');
// }
// }
function toggleSection(checkbox, sectionId) {
const section = document.getElementById(sectionId);
const checkboxes = section.querySelectorAll('input[type="checkbox"]');
// 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;
});
}
}
// 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 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;
@ -827,12 +828,6 @@
}
// 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');

View File

@ -126,6 +126,27 @@
<?php foreach ($hr_access_data as $key => $value) {
$key = $key + 1;
// Calculate data counts per user for toggling rules
$prePolicyCount = 0;
if (!empty($pre_policy_data)) {
foreach ($pre_policy_data as $p) {
if (!empty($value['pre_hr_id']) && $value['pre_branch_id'] === $p['branch_id']) {
$prePolicyCount++;
}
}
}
$postPolicyCount = 0;
if (!empty($post_policy_data)) {
foreach ($post_policy_data as $p) {
if (!empty($value['post_hr_id']) && $value['post_branch_id'] === $p['branch_id']) {
$postPolicyCount++;
}
}
}
$cdCount = !empty($post_cd_data) ? count($post_cd_data) : 0;
?>
<!-- User 1 Card -->
@ -158,7 +179,7 @@
<div class="section">
<div class="section-title">
<input type="checkbox" class="main-checkbox"
onchange="toggleSection(this, '<?= 'user' . $key ?>-pre')" name="<?= 'user' . $key ?>_modules"
onchange="toggleSection(this, '<?= 'user' . $key ?>-pre', <?= $prePolicyCount ?>)" name="<?= 'user' . $key ?>_modules"
value="1" <?php if (in_array(1, $value['allowed_pre_modules'] ?? [])) {
echo 'checked';
} ?>>
@ -219,7 +240,7 @@
<div class="section">
<div class="section-title">
<input type="checkbox" class="main-checkbox"
onchange="toggleSection(this, '<?= 'user' . $key ?>-active')" name="<?= 'user' . $key ?>_modules"
onchange="toggleSection(this, '<?= 'user' . $key ?>-active', <?= $postPolicyCount ?>)" name="<?= 'user' . $key ?>_modules"
value="2" <?php if (in_array(2, $value['allowed_post_modules'])) {
echo 'checked';
} ?>>
@ -294,7 +315,7 @@
<div class="section">
<div class="section-title">
<input type="checkbox" class="main-checkbox"
onchange="toggleSection(this, '<?= 'user' . $key ?>-cd')" name="<?= 'user' . $key ?>_modules" value="3" <?php if (in_array(3, $value['allowed_post_modules'])) {
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
@ -367,4 +388,74 @@
<?php } ?>
</div>
</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>