fix family card issue
This commit is contained in:
@@ -181,7 +181,6 @@ if ($returnUrl === '') {
|
||||
<?php
|
||||
$studentId = (int)($s['id'] ?? 0);
|
||||
$detailId = 'fc-student-details-' . (int)($f['id'] ?? 0) . '-' . $studentId;
|
||||
$isSelected = $selectedStudentId > 0 && $selectedStudentId === $studentId;
|
||||
$allergies = array_values(array_filter(array_map('trim', (array)($s['allergies'] ?? []))));
|
||||
$conditions = array_values(array_filter(array_map('trim', (array)($s['medical_conditions'] ?? []))));
|
||||
?>
|
||||
@@ -189,10 +188,10 @@ if ($returnUrl === '') {
|
||||
<h2 class="accordion-header">
|
||||
<button
|
||||
type="button"
|
||||
class="accordion-button <?= $isSelected ? '' : 'collapsed' ?>"
|
||||
class="accordion-button collapsed"
|
||||
data-bs-toggle="collapse"
|
||||
data-bs-target="#<?= esc($detailId) ?>"
|
||||
aria-expanded="<?= $isSelected ? 'true' : 'false' ?>"
|
||||
aria-expanded="false"
|
||||
aria-controls="<?= esc($detailId) ?>"
|
||||
>
|
||||
<span class="fc-name">
|
||||
@@ -206,7 +205,7 @@ if ($returnUrl === '') {
|
||||
|
||||
<div
|
||||
id="<?= esc($detailId) ?>"
|
||||
class="accordion-collapse collapse <?= $isSelected ? 'show' : '' ?>"
|
||||
class="accordion-collapse collapse"
|
||||
data-bs-parent="#fc-students-<?= (int)($f['id'] ?? 0) ?>"
|
||||
>
|
||||
<div class="accordion-body fc-student-details">
|
||||
|
||||
@@ -356,8 +356,20 @@ html, body { overflow-x: hidden; }
|
||||
try {
|
||||
const gid = params && params.guardian_id;
|
||||
const sid = params && params.student_id;
|
||||
if (gid) window.location.href = '<?= site_url('family') ?>' + '?guardian_id=' + encodeURIComponent(gid);
|
||||
else if (sid) window.location.href = '<?= site_url('family') ?>' + '?student_id=' + encodeURIComponent(sid);
|
||||
const familyUrl = new URL('<?= site_url('family') ?>', window.location.origin);
|
||||
const currentPath = window.location.pathname.replace(/\/+$/, '');
|
||||
const familyPath = familyUrl.pathname.replace(/\/+$/, '');
|
||||
const familyIndexPath = familyPath + '/index';
|
||||
if (currentPath !== familyPath && currentPath !== familyIndexPath && (gid || sid)) {
|
||||
familyUrl.searchParams.set(gid ? 'guardian_id' : 'student_id', gid || sid);
|
||||
window.location.href = familyUrl.toString();
|
||||
return;
|
||||
}
|
||||
|
||||
const target = document.getElementById('familyCardContent');
|
||||
if (target) target.innerHTML = '<div class="p-3 text-danger">The family card could not be loaded. Please refresh and try again.</div>';
|
||||
const m = ensureModal();
|
||||
if (m) m.show();
|
||||
} catch(_) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -614,12 +614,26 @@
|
||||
const m = ensureModal();
|
||||
if (m) m.show();
|
||||
} catch (e) {
|
||||
// Fallback: redirect to /family filtered page
|
||||
try {
|
||||
const gid = params && params.guardian_id;
|
||||
const sid = params && params.student_id;
|
||||
if (gid) window.location.href = '<?= site_url('family') ?>' + '?guardian_id=' + encodeURIComponent(gid);
|
||||
else if (sid) window.location.href = '<?= site_url('family') ?>' + '?student_id=' + encodeURIComponent(sid);
|
||||
const familyUrl = new URL('<?= site_url('family') ?>', window.location.origin);
|
||||
const currentPath = window.location.pathname.replace(/\/+$/, '');
|
||||
const familyPath = familyUrl.pathname.replace(/\/+$/, '');
|
||||
const familyIndexPath = familyPath + '/index';
|
||||
|
||||
// A failed card request used to redirect the family page back to
|
||||
// itself. Its automatic card loader then repeated that forever.
|
||||
if (currentPath !== familyPath && currentPath !== familyIndexPath && (gid || sid)) {
|
||||
familyUrl.searchParams.set(gid ? 'guardian_id' : 'student_id', gid || sid);
|
||||
window.location.href = familyUrl.toString();
|
||||
return;
|
||||
}
|
||||
|
||||
const target = document.getElementById('familyCardContent');
|
||||
if (target) target.innerHTML = '<div class="p-3 text-danger">The family card could not be loaded. Please refresh and try again.</div>';
|
||||
const m = ensureModal();
|
||||
if (m) m.show();
|
||||
} catch(_) {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user