fix is_active student flag and apply it in all pages
This commit is contained in:
@@ -237,7 +237,10 @@
|
||||
<tr>
|
||||
<td><?= $i + 1 ?></td>
|
||||
<td><?= esc($s['school_id']) ?></td>
|
||||
<td><?= esc(trim(($s['firstname'] ?? '') . ' ' . ($s['lastname'] ?? ''))) ?></td>
|
||||
<td>
|
||||
<?= esc(trim(($s['firstname'] ?? '') . ' ' . ($s['lastname'] ?? ''))) ?>
|
||||
<?= student_enrollment_status_button($s, $schoolYear ?? null) ?>
|
||||
</td>
|
||||
<td><?= esc($s['gender'] ?? '') ?></td>
|
||||
<td><?= esc($s['dob'] ?? '') ?></td>
|
||||
<td><?= esc($s['rfid_tag'] ?? '') ?></td>
|
||||
@@ -375,7 +378,10 @@
|
||||
<tr>
|
||||
<td><?= $i + 1 ?></td>
|
||||
<td><?= esc($s['school_id'] ?? '') ?></td>
|
||||
<td><?= esc(trim(($s['firstname'] ?? '') . ' ' . ($s['lastname'] ?? ''))) ?></td>
|
||||
<td>
|
||||
<?= esc(trim(($s['firstname'] ?? '') . ' ' . ($s['lastname'] ?? ''))) ?>
|
||||
<?= student_enrollment_status_button($s, $schoolYear ?? null) ?>
|
||||
</td>
|
||||
<td><?= esc($s['dob'] ?? '') ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@@ -72,8 +72,10 @@
|
||||
<a href="#" class="text-decoration-none" data-family-student-id="<?= $sid ?>">
|
||||
<?= esc($student['firstname']) ?>
|
||||
</a>
|
||||
<?= student_enrollment_status_button($student, $selectedYear ?? $schoolYear ?? null) ?>
|
||||
<?php else: ?>
|
||||
<?= esc($student['firstname']) ?>
|
||||
<?= student_enrollment_status_button($student, $selectedYear ?? $schoolYear ?? null) ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -441,7 +441,10 @@
|
||||
<?php else: ?>
|
||||
<?php foreach ($studentIssueRows as $row): ?>
|
||||
<tr>
|
||||
<td><?= esc($row['name']) ?></td>
|
||||
<td>
|
||||
<?= esc($row['name']) ?>
|
||||
<?= student_enrollment_status_button($row, $schoolYear ?? null) ?>
|
||||
</td>
|
||||
<td><?= esc($row['section']) ?></td>
|
||||
<td class="text-end"><?= (int)$row['absent'] ?></td>
|
||||
<td class="text-end"><?= (int)$row['late'] ?></td>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
$sid = (int)($s['id'] ?? $s['student_id'] ?? 0);
|
||||
$label = esc(($s['firstname'] ?? '') . ' ' . ($s['lastname'] ?? ''));
|
||||
if ($sid > 0) {
|
||||
return '<a href="#" class="text-decoration-none" data-family-student-id="' . $sid . '">' . $label . '</a>';
|
||||
return '<a href="#" class="text-decoration-none" data-family-student-id="' . $sid . '">' . $label . '</a>' . student_enrollment_status_button(['student_id' => $sid]);
|
||||
}
|
||||
return $label;
|
||||
}, $group['students']);
|
||||
|
||||
@@ -326,7 +326,10 @@ $reasonCodes = is_array($exceptionReasonCodes ?? null) ? $exceptionReasonCodes :
|
||||
$priorityClass = strtolower($priorityValue) === 'high' ? 'bg-danger' : 'bg-secondary';
|
||||
?>
|
||||
<tr>
|
||||
<td><?= esc($flag['student_name'] ?? '') ?></td>
|
||||
<td>
|
||||
<?= esc($flag['student_name'] ?? '') ?>
|
||||
<?= student_enrollment_status_button($flag, $schoolYear ?? null) ?>
|
||||
</td>
|
||||
<td><?= esc($flag['school_id'] ?? '') ?></td>
|
||||
<td><span class="badge bg-secondary"><?= esc(enrollment_admin_flag_label($flagTypeValue)) ?></span></td>
|
||||
<td><span class="badge <?= esc($priorityClass) ?>"><?= esc(enrollment_admin_priority_label($priorityValue)) ?></span></td>
|
||||
@@ -427,7 +430,10 @@ $reasonCodes = is_array($exceptionReasonCodes ?? null) ? $exceptionReasonCodes :
|
||||
};
|
||||
?>
|
||||
<tr>
|
||||
<td><?= esc($row['student_name'] ?? '') ?></td>
|
||||
<td>
|
||||
<?= esc($row['student_name'] ?? '') ?>
|
||||
<?= student_enrollment_status_button($row, $schoolYear ?? null) ?>
|
||||
</td>
|
||||
<td><?= esc($row['school_id'] ?? '') ?></td>
|
||||
<td><span class="badge <?= esc($statusClass) ?>"><?= esc($statusValue) ?></span></td>
|
||||
<td><?= esc($decisionValue !== '' ? ucwords(str_replace('_', ' ', $decisionValue)) : 'Pending') ?></td>
|
||||
@@ -539,6 +545,7 @@ $reasonCodes = is_array($exceptionReasonCodes ?? null) ? $exceptionReasonCodes :
|
||||
</td>
|
||||
<td>
|
||||
<?= esc($studentPreview['student_name'] ?? '') ?>
|
||||
<?= student_enrollment_status_button($studentPreview, $schoolYear ?? null) ?>
|
||||
<div class="small text-muted"><?= esc($studentPreview['school_id'] ?? '') ?></div>
|
||||
</td>
|
||||
<td><span class="badge <?= $canEnroll ? 'bg-success' : 'bg-warning text-dark' ?>"><?= esc(enrollment_admin_decision_label($decision)) ?></span></td>
|
||||
@@ -648,6 +655,7 @@ $reasonCodes = is_array($exceptionReasonCodes ?? null) ? $exceptionReasonCodes :
|
||||
<tr>
|
||||
<td>
|
||||
<?= esc($exception['student_name'] ?? '') ?>
|
||||
<?= student_enrollment_status_button($exception, $schoolYear ?? null) ?>
|
||||
<div class="small text-muted"><?= esc($exception['school_id'] ?? '') ?></div>
|
||||
</td>
|
||||
<td><?= esc($exception['parent_name'] ?? '') ?></td>
|
||||
@@ -817,7 +825,10 @@ $reasonCodes = is_array($exceptionReasonCodes ?? null) ? $exceptionReasonCodes :
|
||||
<?php foreach ($auditRows as $row): ?>
|
||||
<tr>
|
||||
<td><?= esc(!empty($row['created_at']) ? local_datetime($row['created_at'], 'm-d-Y H:i') : '') ?></td>
|
||||
<td><?= esc($row['student_name'] ?? '') ?></td>
|
||||
<td>
|
||||
<?= esc($row['student_name'] ?? '') ?>
|
||||
<?= student_enrollment_status_button($row, $schoolYear ?? null) ?>
|
||||
</td>
|
||||
<td><?= esc(enrollment_admin_audit_action_label((string) ($row['action'] ?? ''))) ?></td>
|
||||
<td><?= esc($row['performed_by_name'] ?? '') ?></td>
|
||||
<td><?= esc($row['reason'] ?? '') ?></td>
|
||||
|
||||
@@ -348,6 +348,7 @@
|
||||
<td data-sort-value="<?= esc(strtolower($parentColumnName)) ?>"><?= esc($parentColumnName) ?></td>
|
||||
<td data-sort-value="<?= esc(strtolower($displayName)) ?>">
|
||||
<?= esc($displayName) ?>
|
||||
<?= student_enrollment_status_button(['student_id' => $charge['student_id'] ?? 0, 'enrollment_status' => $charge['enrollment_status'] ?? ''], $schoolYear ?? null) ?>
|
||||
<?php if ($externalNote): ?>
|
||||
<small class="text-muted d-block"><?= esc($externalNote) ?></small>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -19,7 +19,10 @@
|
||||
<div><strong>Students</strong></div>
|
||||
<ul>
|
||||
<?php foreach (($students ?? []) as $student): ?>
|
||||
<li><?= esc(trim(($student['firstname'] ?? '') . ' ' . ($student['lastname'] ?? ''))) ?></li>
|
||||
<li>
|
||||
<?= esc(trim(($student['firstname'] ?? '') . ' ' . ($student['lastname'] ?? ''))) ?>
|
||||
<?= student_enrollment_status_button($student, $schoolYear ?? null) ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -48,7 +48,10 @@
|
||||
<tbody>
|
||||
<?php foreach ($studentsBySection[$sectionId] as $student): ?>
|
||||
<tr>
|
||||
<td><?= esc($student['firstname'] . ' ' . $student['lastname']) ?></td>
|
||||
<td>
|
||||
<?= esc($student['firstname'] . ' ' . $student['lastname']) ?>
|
||||
<?= student_enrollment_status_button($student, $schoolYear ?? null) ?>
|
||||
</td>
|
||||
<td><?= esc($student['school_id']) ?></td>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
@@ -63,7 +63,10 @@
|
||||
<tr>
|
||||
<td><?= (int)($r['id'] ?? 0) ?></td>
|
||||
<td><?= esc(!empty($r['printed_at']) ? local_datetime($r['printed_at'], 'm-d-Y H:i') : '') ?></td>
|
||||
<td><?= esc($r['student_name'] ?? '') ?></td>
|
||||
<td>
|
||||
<?= esc($r['student_name'] ?? '') ?>
|
||||
<?= student_enrollment_status_button($r, $schoolYear ?? null) ?>
|
||||
</td>
|
||||
<td><?= esc($r['grade'] ?? '') ?></td>
|
||||
<td><?= esc(!empty($r['slip_date']) ? local_date($r['slip_date'], 'm-d-Y') : '') ?></td>
|
||||
<td><?= esc($r['time_in'] ?? '') ?></td>
|
||||
|
||||
@@ -65,7 +65,10 @@
|
||||
<?php foreach ($results['students'] as $student): ?>
|
||||
<tr>
|
||||
<td><?= esc($student['school_id'] ?? 'N/A') ?></td>
|
||||
<td><?= esc($student['firstname'] ?? 'N/A') ?></td>
|
||||
<td>
|
||||
<?= esc($student['firstname'] ?? 'N/A') ?>
|
||||
<?= student_enrollment_status_button($student, $schoolYear ?? null) ?>
|
||||
</td>
|
||||
<td><?= esc($student['lastname'] ?? 'N/A') ?></td>
|
||||
<td><?= esc($student['dob'] ?? 'N/A') ?></td>
|
||||
</tr>
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
<a href="#" class="text-decoration-none" data-family-student-id="<?= (int)($student['student_id'] ?? 0) ?>">
|
||||
<?= esc($student['name']) ?>
|
||||
</a>
|
||||
<?= student_enrollment_status_button($student, $selectedYear ?? $schoolYear ?? null) ?>
|
||||
</td>
|
||||
<td><?= esc($student['age']) ?></td>
|
||||
<td><?= esc($student['registration_grade']) ?></td>
|
||||
|
||||
@@ -156,6 +156,7 @@ $selectedYear = trim((string)($selectedYear ?? ''));
|
||||
<a href="#" class="text-decoration-none" data-family-student-id="<?= (int)($student['id'] ?? 0) ?>">
|
||||
<?= esc($student['firstname']) ?>
|
||||
</a>
|
||||
<?= student_enrollment_status_button($student, $selectedYear) ?>
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" class="text-decoration-none" data-family-student-id="<?= (int)($student['id'] ?? 0) ?>">
|
||||
|
||||
@@ -202,7 +202,10 @@ $warningText = static function (array $warnings): string {
|
||||
<tbody>
|
||||
<?php foreach (($family['student_details'] ?? []) as $detail): ?>
|
||||
<tr>
|
||||
<td><?= esc($detail['student_name'] ?? '') ?></td>
|
||||
<td>
|
||||
<?= esc($detail['student_name'] ?? '') ?>
|
||||
<?= student_enrollment_status_button($detail, $schoolYear ?? null) ?>
|
||||
</td>
|
||||
<td><?= esc($detail['grade_level'] ?? '') ?></td>
|
||||
<td><?= !empty($detail['billable']) ? 'Yes' : 'No' ?></td>
|
||||
<td><?= esc((string) ($detail['excluded_reason'] ?? '')) ?></td>
|
||||
|
||||
Reference in New Issue
Block a user