apply the school year concept
Tests / PHPUnit (push) Failing after 1m19s

This commit is contained in:
root
2026-07-14 00:59:00 -04:00
parent 504c3bc9f9
commit feb1b29a32
73 changed files with 4288 additions and 620 deletions
+19 -15
View File
@@ -20,6 +20,8 @@ if ($currentYear === '' || $currentSem === '') {
} catch (\Throwable $e) { /* ignore */ }
}
$showSchoolYearControl = $showSchoolYearControl ?? true;
$selectedYear = (string)($schoolYear ?? ($_GET['school_year'] ?? ''));
if ($selectedYear === '') { $selectedYear = $currentYear; }
@@ -32,23 +34,25 @@ $classSectionVal = (string)($classSectionId ?? ($_GET['class_section_id'] ?? '')
<?php if ($classSectionVal !== ''): ?>
<input type="hidden" name="class_section_id" value="<?= esc($classSectionVal) ?>">
<?php endif; ?>
<div class="col-auto"><label class="form-label mb-0">School year</label></div>
<div class="col-auto">
<?php $years = isset($schoolYears) && is_array($schoolYears) ? $schoolYears : []; ?>
<select name="school_year" class="form-select form-select-sm" style="min-width: 180px;">
<?php if (!empty($years)): ?>
<?php foreach ($years as $y): $val = is_array($y) && isset($y['school_year']) ? (string)$y['school_year'] : (string)$y; ?>
<option value="<?= esc($val) ?>" <?= ($selectedYear === $val ? 'selected' : '') ?>><?= esc($val) ?></option>
<?php endforeach; ?>
<?php else: ?>
<?php if ($selectedYear !== ''): ?>
<option value="<?= esc($selectedYear) ?>" selected><?= esc($selectedYear) ?></option>
<?php if ($showSchoolYearControl): ?>
<div class="col-auto"><label class="form-label mb-0">School year</label></div>
<div class="col-auto">
<?php $years = isset($schoolYears) && is_array($schoolYears) ? $schoolYears : []; ?>
<select name="school_year" class="form-select form-select-sm" style="min-width: 180px;">
<?php if (!empty($years)): ?>
<?php foreach ($years as $y): $val = is_array($y) && isset($y['school_year']) ? (string)$y['school_year'] : (string)$y; ?>
<option value="<?= esc($val) ?>" <?= ($selectedYear === $val ? 'selected' : '') ?>><?= esc($val) ?></option>
<?php endforeach; ?>
<?php else: ?>
<option value="">—</option>
<?php if ($selectedYear !== ''): ?>
<option value="<?= esc($selectedYear) ?>" selected><?= esc($selectedYear) ?></option>
<?php else: ?>
<option value="">-</option>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
</select>
</div>
</select>
</div>
<?php endif; ?>
<div class="col-auto"><label class="form-label mb-0">Semester</label></div>
<div class="col-auto">
+10 -2
View File
@@ -60,7 +60,11 @@ switch ($role) {
}
} else {
$configModel = new \App\Models\ConfigurationModel();
$schoolYear = session()->get('school_year') ?? $configModel->getConfig('school_year');
try {
$schoolYear = service('schoolYearContext')->resolve(service('request'))->yearName();
} catch (\Throwable $e) {
$schoolYear = session()->get('school_year') ?? $configModel->getConfig('school_year');
}
$classSectionId = (int)($class_section_id ?? session()->get('class_section_id') ?? 0);
if ($classSectionId > 0 && !empty($schoolYear)) {
$scoreCardStudents = $studentModel->getByClassAndYear($classSectionId, $schoolYear);
@@ -267,7 +271,11 @@ switch ($role) {
if (!isset($activeEventCount) && ($role ?? '') === 'parent') {
$configModel = new \App\Models\ConfigurationModel();
$eventModel = new \App\Models\EventModel();
$year = $sess->get('school_year') ?? $configModel->getConfig('school_year');
try {
$year = service('schoolYearContext')->resolve(service('request'))->yearName();
} catch (\Throwable $e) {
$year = $sess->get('school_year') ?? $configModel->getConfig('school_year');
}
$semester = $sess->get('semester') ?? $configModel->getConfig('semester');
$activeEventCount = count($eventModel->getActiveEvents($year, $semester) ?? []);
}
@@ -0,0 +1,54 @@
<?php if (!empty($schoolYearSelectorEnabled) && isset($schoolYearContext, $schoolYearOptions)): ?>
<?php
$query = service('request')->getUri()->getQuery();
$returnTo = current_url() . ($query !== '' ? '?' . $query : '');
?>
<div class="school-year-context-bar border-bottom bg-light py-2">
<div class="container-fluid px-3">
<form method="post" action="<?= site_url('school-year/select') ?>" class="d-flex align-items-center gap-2 flex-wrap">
<?= csrf_field() ?>
<input type="hidden" name="return_to" value="<?= esc($returnTo) ?>">
<label for="global-school-year" class="form-label mb-0 fw-semibold">
School year
</label>
<select
id="global-school-year"
name="school_year_id"
class="form-select form-select-sm w-auto"
onchange="this.form.submit()"
aria-label="Selected school year"
>
<?php foreach ($schoolYearOptions as $year): ?>
<option
value="<?= (int) $year['id'] ?>"
<?= (int) $year['id'] === $schoolYearContext->id() ? 'selected' : '' ?>
>
<?= esc($year['name']) ?> - <?= esc(ucfirst((string) $year['status'])) ?>
</option>
<?php endforeach; ?>
</select>
<?php if ($schoolYearContext->isReadonly()): ?>
<span class="btn btn-warning btn-sm disabled" aria-disabled="true">
<i class="bi bi-lock-fill"></i> READ-ONLY
</span>
<?php else: ?>
<span class="badge text-bg-success">ACTIVE</span>
<?php endif; ?>
<span class="text-muted small"><?= esc($schoolYearContext->yearName()) ?></span>
</form>
<?php if ($schoolYearContext->isExplicitSelection()): ?>
<form method="post" action="<?= site_url('school-year/reset') ?>" class="d-inline-block mt-2 mt-sm-0 ms-sm-2">
<?= csrf_field() ?>
<input type="hidden" name="return_to" value="<?= esc($returnTo) ?>">
<button type="submit" class="btn btn-outline-secondary btn-sm">
Active year
</button>
</form>
<?php endif; ?>
</div>
</div>
<?php endif; ?>