fix is_active student flag logic and make moving with enrollment status
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 47s
Tests / PHPUnit (push) Successful in 1m16s

This commit is contained in:
root
2026-08-20 03:11:37 -04:00
parent 6f722795c5
commit 0a31aa1393
20 changed files with 588 additions and 489 deletions
@@ -54,7 +54,7 @@ if (!function_exists('enrollment_admin_flag_label')) {
{
return match ($type) {
'CLASS_REASSIGNMENT_REQUIRED' => 'Assign a class',
'PENDING_MAKE_UP_EXAM_PROMOTION' => 'Makeup exam result',
'PENDING_MAKE_UP_EXAM_PROMOTION' => 'Makeup exam',
'AGE_EXCEPTION_REQUIRED' => 'Age exception',
'LATE_REGISTRATION_EXCEPTION' => 'Late registration',
'FINANCIAL_REVIEW_REQUIRED' => 'Finance review',
@@ -359,7 +359,7 @@ $reasonCodes = is_array($exceptionReasonCodes ?? null) ? $exceptionReasonCodes :
<?php elseif ($flagTypeValue === 'PENDING_MAKE_UP_EXAM_PROMOTION'): ?>
<form method="post" action="<?= site_url('administrator/enrollment-admin/flags/' . $flagId . '/makeup-promotion') ?>" class="mb-2">
<?= csrf_field() ?>
<div class="small fw-semibold mb-1">Record the makeup exam result</div>
<div class="small fw-semibold mb-1">Record the makeup exam</div>
<select class="form-select form-select-sm mb-2" name="exam_result" required>
<option value="">Exam result</option>
<option value="passed">Passed</option>
@@ -1,135 +0,0 @@
<?php
$activeStudents = $active_students ?? [];
$removedStudents = $removed_students ?? [];
$schoolYear = $school_year ?? '';
$activeSchoolYear = $active_school_year ?? '';
?>
<?= $this->extend('layout/management_layout') ?>
<?= $this->section('content') ?>
<div class="container-fluid">
<div class="wrapper">
<div class="content">
<h2 class="text-center mt-4 mb-2">Student Removal</h2>
<p class="text-center text-muted mb-4">
Active school year: <?= esc($schoolYear !== '' ? $schoolYear : $activeSchoolYear) ?>.
Active students have a class assignment in the active school year. Removed students are inactive or have no active-year assignment.
</p>
<?= $this->include('partials/flash_messages') ?>
<div class="card mb-4 shadow-sm">
<div class="card-header d-flex align-items-center justify-content-between">
<span>Active Students</span>
<span class="badge bg-primary"><?= count($activeStudents) ?></span>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="activeStudentsTable" class="table table-striped table-hover align-middle">
<thead class="table-dark">
<tr>
<th>School ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Class</th>
<th style="min-width: 140px;">Action</th>
</tr>
</thead>
<tbody>
<?php if (!empty($activeStudents)): ?>
<?php foreach ($activeStudents as $student): ?>
<tr>
<td><?= esc($student['school_id'] ?? '') ?></td>
<td><?= esc($student['firstname'] ?? '') ?></td>
<td><?= esc($student['lastname'] ?? '') ?></td>
<td><?= esc($student['class_section_name'] ?? 'No class assigned') ?></td>
<td>
<form method="post" action="<?= site_url('administrator/students/set-active') ?>" class="d-inline">
<?= csrf_field() ?>
<input type="hidden" name="student_id" value="<?= (int)($student['id'] ?? 0) ?>">
<input type="hidden" name="is_active" value="0">
<button type="submit" class="btn btn-outline-danger btn-sm" onclick="return confirm('Remove this student from classes and attendance?');">
Remove
</button>
</form>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="5" class="text-center">No active students found.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
<div class="card shadow-sm">
<div class="card-header d-flex align-items-center justify-content-between">
<span>Removed Students</span>
<span class="badge bg-secondary"><?= count($removedStudents) ?></span>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="removedStudentsTable" class="table table-striped table-hover align-middle">
<thead class="table-dark">
<tr>
<th>School ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Last Class</th>
<th style="min-width: 140px;">Action</th>
</tr>
</thead>
<tbody>
<?php if (!empty($removedStudents)): ?>
<?php foreach ($removedStudents as $student): ?>
<tr>
<td><?= esc($student['school_id'] ?? '') ?></td>
<td><?= esc($student['firstname'] ?? '') ?></td>
<td><?= esc($student['lastname'] ?? '') ?></td>
<td><?= esc($student['class_section_name'] ?? 'No class assigned') ?></td>
<td>
<form method="post" action="<?= site_url('administrator/students/set-active') ?>" class="d-inline">
<?= csrf_field() ?>
<input type="hidden" name="student_id" value="<?= (int)($student['id'] ?? 0) ?>">
<input type="hidden" name="is_active" value="1">
<button type="submit" class="btn btn-outline-success btn-sm" onclick="return confirm('Restore this student to classes and attendance?');">
Restore
</button>
</form>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="5" class="text-center">No removed students found.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<?= $this->endSection() ?>
<?= $this->section('scripts') ?>
<script>
document.addEventListener('DOMContentLoaded', () => {
if (window.jQuery && typeof jQuery.fn.DataTable === 'function') {
if (document.getElementById('activeStudentsTable')) {
jQuery('#activeStudentsTable').DataTable();
}
if (document.getElementById('removedStudentsTable')) {
jQuery('#removedStudentsTable').DataTable();
}
}
});
</script>
<?= $this->endSection() ?>
+4 -6
View File
@@ -381,14 +381,12 @@ $selectedYear = trim((string)($selectedYear ?? ''));
</select>
</div>
<!-- is_active -->
<div class="col-md-3">
<label class="form-label d-block">Active Status</label>
<input type="hidden" name="is_active" value="0">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" value="1" id="is_active_<?= (int)$student['id'] ?>" name="is_active" <?= $isActive ? 'checked' : '' ?>>
<label class="form-check-label" for="is_active_<?= (int)$student['id'] ?>">Show in classes/attendance</label>
</div>
<span class="badge <?= $isActive ? 'bg-success' : 'bg-secondary' ?>">
<?= $isActive ? 'Visible' : 'Hidden' ?>
</span>
<div class="form-text">Controlled by current enrollment status.</div>
</div>
<!-- photo_consent -->