fix is_active student flag and apply it in all pages
This commit is contained in:
@@ -148,6 +148,37 @@
|
||||
</style>
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?php
|
||||
$semesterOptions = ['Fall', 'Spring'];
|
||||
$selectedSemester = trim((string)($semester ?? ''));
|
||||
if ($selectedSemester !== '' && !in_array($selectedSemester, $semesterOptions, true)) {
|
||||
$semesterOptions[] = $selectedSemester;
|
||||
}
|
||||
$selectedSchoolYear = trim((string)($schoolYear ?? ''));
|
||||
$selectedClassId = (int)($_GET['class_id'] ?? 0);
|
||||
?>
|
||||
|
||||
<form id="attendanceTermFilter" method="get" action="<?= site_url('administrator/daily_attendance') ?>" class="row g-2 justify-content-center align-items-end mb-3">
|
||||
<input type="hidden" id="attendanceClassIdFilter" name="class_id" value="<?= $selectedClassId > 0 ? $selectedClassId : '' ?>">
|
||||
<div class="col-12 col-sm-5 col-md-3 col-lg-2">
|
||||
<label for="attendanceSemesterFilter" class="form-label mb-1">Semester</label>
|
||||
<select id="attendanceSemesterFilter" name="semester" class="form-select" onchange="this.form.submit()">
|
||||
<?php foreach ($semesterOptions as $option): ?>
|
||||
<option value="<?= esc($option) ?>" <?= $option === $selectedSemester ? 'selected' : '' ?>>
|
||||
<?= esc($option) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-12 col-sm-5 col-md-3 col-lg-2">
|
||||
<label for="attendanceSchoolYearFilter" class="form-label mb-1">School Year</label>
|
||||
<input id="attendanceSchoolYearFilter" type="text" name="school_year" class="form-control" value="<?= esc($selectedSchoolYear) ?>" placeholder="YYYY-YYYY">
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button type="submit" class="btn btn-primary">Apply</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- ===================== Global Student Search ===================== -->
|
||||
<div class="row g-2 justify-content-center mb-3">
|
||||
<div class="col-12 col-md-8 col-lg-6">
|
||||
@@ -358,8 +389,11 @@
|
||||
$studentsCountByClassId[$cid] = count($uniq);
|
||||
}
|
||||
|
||||
// Default active tab = first in sorted order (can still be overridden by ?class_id)
|
||||
$defaultId = $sortedClassIds[0] ?? null;
|
||||
// Default active tab = first in sorted order unless ?class_id selects a visible grade.
|
||||
$requestedClassId = (int)($_GET['class_id'] ?? 0);
|
||||
$defaultId = ($requestedClassId > 0 && in_array($requestedClassId, $sortedClassIds, true))
|
||||
? $requestedClassId
|
||||
: ($sortedClassIds[0] ?? null);
|
||||
|
||||
// =====================================================================
|
||||
// NEW UTILITIES (dates pivot logic) — includes "today if Sunday, else next Sunday" column
|
||||
@@ -716,18 +750,20 @@
|
||||
$tAbsent = $summary ? (int)($summary['total_absence'] ?? 0) : 0;
|
||||
|
||||
|
||||
$schoolId = esc($student['school_id']);
|
||||
$fullNameRaw = trim(($student['firstname'] ?? '') . ' ' . ($student['lastname'] ?? ''));
|
||||
$fullName = esc($fullNameRaw);
|
||||
$fullNameAttr = esc(strtolower($fullNameRaw));
|
||||
?>
|
||||
<tr
|
||||
data-student-id="<?= (int)$sid ?>"
|
||||
data-school-id="<?= $schoolId ?>"
|
||||
data-student-name="<?= $fullNameAttr ?>"
|
||||
data-student-name-display="<?= esc($fullNameRaw) ?>"
|
||||
data-class-id="<?= (int)$cid ?>"
|
||||
data-grade-label="<?= esc($headerText) ?>">
|
||||
$schoolId = esc($student['school_id']);
|
||||
$fullNameRaw = trim(($student['firstname'] ?? '') . ' ' . ($student['lastname'] ?? ''));
|
||||
$fullName = esc($fullNameRaw);
|
||||
$fullNameAttr = esc(strtolower($fullNameRaw));
|
||||
$rowLocked = student_is_non_active_for_editing($student, $schoolYear ?? null);
|
||||
?>
|
||||
<tr class="<?= $rowLocked ? 'table-secondary text-muted' : '' ?>"
|
||||
data-student-id="<?= (int)$sid ?>"
|
||||
data-student-editable="<?= $rowLocked ? '0' : '1' ?>"
|
||||
data-school-id="<?= $schoolId ?>"
|
||||
data-student-name="<?= $fullNameAttr ?>"
|
||||
data-student-name-display="<?= esc($fullNameRaw) ?>"
|
||||
data-class-id="<?= (int)$cid ?>"
|
||||
data-grade-label="<?= esc($headerText) ?>">
|
||||
<td class="school-id-col" style="min-width: <?= (int)$minIdCh ?>ch;"><?= $schoolId ?></td>
|
||||
<td class="student-name-col" style="min-width: <?= (int)$minNameCh ?>ch;">
|
||||
<a
|
||||
@@ -737,6 +773,7 @@
|
||||
title="Open family card">
|
||||
<?= $fullName ?>
|
||||
</a>
|
||||
<?= student_enrollment_status_button($student, $schoolYear ?? null) ?>
|
||||
</td>
|
||||
|
||||
<?php foreach ($dateCols as $dcol): ?>
|
||||
@@ -757,12 +794,13 @@
|
||||
<td class="text-center date-col" style="min-width:160px;">
|
||||
<select
|
||||
class="form-select form-select-sm day-select"
|
||||
data-class-id="<?= (int)$cid ?>"
|
||||
data-class-section-id="<?= esc($sectionKey) ?>"
|
||||
data-student-id="<?= (int)$sid ?>"
|
||||
data-school-id="<?= esc($student['school_id']) ?>"
|
||||
data-date="<?= esc($dcol) ?>"
|
||||
aria-label="Attendance on <?= esc($dLabel) ?>">
|
||||
data-class-id="<?= (int)$cid ?>"
|
||||
data-class-section-id="<?= esc($sectionKey) ?>"
|
||||
data-student-id="<?= (int)$sid ?>"
|
||||
data-school-id="<?= esc($student['school_id']) ?>"
|
||||
data-date="<?= esc($dcol) ?>"
|
||||
<?= $rowLocked ? 'disabled aria-disabled="true"' : '' ?>
|
||||
aria-label="Attendance on <?= esc($dLabel) ?>">
|
||||
<?php foreach ($optionDefs as $key => $def): ?>
|
||||
<option value="<?= $key ?>" <?= $key === $val ? 'selected' : '' ?>>
|
||||
<?= esc($def['label']) ?>
|
||||
@@ -865,6 +903,15 @@ $attendanceSaveUrlIndex = '/index.php/' . $savePath; // index.php fallbac
|
||||
|
||||
const TERM_SCHOOL_YEAR = <?= json_encode($schoolYear ?? '') ?>;
|
||||
const TERM_SEMESTER = <?= json_encode($semester ?? '') ?>;
|
||||
|
||||
document.querySelectorAll('#attendanceTabs [data-class-id]').forEach((tab) => {
|
||||
tab.addEventListener('shown.bs.tab', () => {
|
||||
const classIdInput = document.getElementById('attendanceClassIdFilter');
|
||||
if (classIdInput) {
|
||||
classIdInput.value = tab.getAttribute('data-class-id') || '';
|
||||
}
|
||||
});
|
||||
});
|
||||
<?php
|
||||
$___adminName = isset($currentAdminName) && $currentAdminName !== ''
|
||||
? (string)$currentAdminName
|
||||
@@ -1095,8 +1142,15 @@ $attendanceSaveUrlIndex = '/index.php/' . $savePath; // index.php fallbac
|
||||
},
|
||||
};
|
||||
|
||||
async function postAttendanceChange(selEl) {
|
||||
const v = selEl.value;
|
||||
async function postAttendanceChange(selEl) {
|
||||
if (selEl.disabled || selEl.closest('tr')?.dataset.studentEditable === '0') {
|
||||
return {
|
||||
ok: true,
|
||||
skipped: true
|
||||
};
|
||||
}
|
||||
|
||||
const v = selEl.value;
|
||||
if (v === 'none') return {
|
||||
ok: true,
|
||||
skipped: true
|
||||
@@ -1232,9 +1286,10 @@ $attendanceSaveUrlIndex = '/index.php/' . $savePath; // index.php fallbac
|
||||
badge.textContent = meta.short;
|
||||
}
|
||||
|
||||
document.addEventListener('change', async (e) => {
|
||||
const sel = e.target.closest('select.day-select');
|
||||
if (!sel) return;
|
||||
document.addEventListener('change', async (e) => {
|
||||
const sel = e.target.closest('select.day-select');
|
||||
if (!sel) return;
|
||||
if (sel.disabled || sel.closest('tr')?.dataset.studentEditable === '0') return;
|
||||
|
||||
const tr = sel.closest('tr');
|
||||
const prev = sel.getAttribute('data-prev') || sel.value;
|
||||
|
||||
Reference in New Issue
Block a user