fix school year and related issues
Tests / PHPUnit (push) Failing after 34s

This commit is contained in:
root
2026-07-30 00:48:54 -04:00
parent f8f00c70c8
commit 81a72a4c59
27 changed files with 1512 additions and 52 deletions
+2 -32
View File
@@ -218,30 +218,6 @@
<div class="fw-semibold"><?= esc((string) ($promotionSummary['pass'] ?? 0)) ?></div>
</div>
</div>
<div class="col-lg-2 col-md-3 col-6">
<div class="border rounded p-2 h-100">
<div class="text-muted small">Other</div>
<div class="fw-semibold"><?= esc((string) ($promotionSummary['other_decision'] ?? 0)) ?></div>
</div>
</div>
<div class="col-lg-2 col-md-3 col-6">
<div class="border rounded p-2 h-100">
<div class="text-muted small">Queued</div>
<div class="fw-semibold"><?= esc((string) ($promotionSummary['queued'] ?? 0)) ?></div>
</div>
</div>
<div class="col-lg-2 col-md-3 col-6">
<div class="border rounded p-2 h-100">
<div class="text-muted small">Assigned</div>
<div class="fw-semibold"><?= esc((string) ($promotionSummary['assigned'] ?? 0)) ?></div>
</div>
</div>
<div class="col-lg-2 col-md-3 col-6">
<div class="border rounded p-2 h-100">
<div class="text-muted small">Applied</div>
<div class="fw-semibold"><?= esc((string) ($promotionSummary['applied'] ?? 0)) ?></div>
</div>
</div>
<div class="col-lg-2 col-md-3 col-6">
<div class="border rounded p-2 h-100">
<div class="text-muted small">Pending</div>
@@ -250,14 +226,8 @@
</div>
<div class="col-lg-2 col-md-3 col-6">
<div class="border rounded p-2 h-100">
<div class="text-muted small">Missing</div>
<div class="fw-semibold text-danger"><?= esc((string) ($promotionSummary['missing_decision'] ?? 0)) ?></div>
</div>
</div>
<div class="col-lg-2 col-md-3 col-6">
<div class="border rounded p-2 h-100">
<div class="text-muted small">Missing Queue</div>
<div class="fw-semibold text-danger"><?= esc((string) ($promotionSummary['missing_queue'] ?? 0)) ?></div>
<div class="text-muted small">Other</div>
<div class="fw-semibold"><?= esc((string) ($promotionSummary['other_decision'] ?? 0)) ?></div>
</div>
</div>
</div>
+42 -7
View File
@@ -13,6 +13,15 @@
$money = static fn ($value): string => '$' . number_format((float) $value, 2);
$activeId = (int) ($activeYear['id'] ?? 0);
$nextDraftId = (int) ($nextDraftYear['id'] ?? 0);
$defaultNewPreviousYear = $activeYear ?: ($schoolYears[0] ?? null);
$defaultNewPreviousYearName = (string) ($defaultNewPreviousYear['name'] ?? 'None');
$previousYearNameByNewYearName = [];
foreach (($schoolYears ?? []) as $existingYear) {
$existingName = (string) ($existingYear['name'] ?? '');
if (preg_match('/^(\d{4})-(\d{4})$/', $existingName, $matches)) {
$previousYearNameByNewYearName[$matches[2] . '-' . ((int) $matches[2] + 1)] = $existingName;
}
}
$closingPreviewUrl = $activeId > 0
? site_url('administrator/school-years/' . $activeId . '/closing/preview' . ($nextDraftId > 0 ? '?' . http_build_query(['target_school_year_id' => $nextDraftId]) : ''))
: '';
@@ -85,13 +94,15 @@
<input class="form-control" id="new_school_year_name" name="name" placeholder="2026-2027" required pattern="\d{4}-\d{4}">
</div>
<div class="col-md-2">
<label class="form-label" for="new_previous_school_year_id">Previous Year</label>
<select class="form-select" id="new_previous_school_year_id" name="previous_school_year_id">
<option value="">None</option>
<?php foreach (($schoolYears ?? []) as $existingYear): ?>
<option value="<?= (int) ($existingYear['id'] ?? 0) ?>"><?= esc($existingYear['name'] ?? '') ?></option>
<?php endforeach; ?>
</select>
<label class="form-label" for="new_previous_school_year_display">Previous Year</label>
<input
class="form-control"
id="new_previous_school_year_display"
type="text"
value="<?= esc($defaultNewPreviousYearName, 'attr') ?>"
data-default-previous-year="<?= esc($defaultNewPreviousYearName, 'attr') ?>"
readonly
>
</div>
<div class="col-md-2">
<label class="form-label" for="new_school_year_starts_on">Starts On</label>
@@ -109,6 +120,10 @@
<label class="form-label" for="new_registration_ends_on">Registration Ends</label>
<input class="form-control" id="new_registration_ends_on" name="registration_ends_on" type="date">
</div>
<div class="col-md-2">
<label class="form-label" for="new_fall_makeup_exam_on">Fall Makeup Exam</label>
<input class="form-control" id="new_fall_makeup_exam_on" name="fall_makeup_exam_on" type="date">
</div>
<div class="col-md-2 d-flex gap-2">
<button class="btn btn-primary" type="submit">Save Draft</button>
<button class="btn btn-secondary" type="button" data-bs-toggle="collapse" data-bs-target="#schoolYearCreateForm">Cancel</button>
@@ -149,6 +164,7 @@
<td>
<div><?= $formatDate($year['starts_on'] ?? null) ?></div>
<div class="text-muted small"><?= $formatDate($year['ends_on'] ?? null) ?></div>
<div class="text-muted small">Fall makeup: <?= $formatDate($year['fall_makeup_exam_on'] ?? null) ?></div>
</td>
<td>
<span class="badge <?= esc($statusClasses[$status] ?? 'bg-secondary') ?>">
@@ -338,6 +354,10 @@
<label class="form-label" for="registration_ends_on_<?= $id ?>">Registration Ends</label>
<input class="form-control" id="registration_ends_on_<?= $id ?>" name="registration_ends_on" type="date" value="<?= esc($year['registration_ends_on'] ?? '') ?>">
</div>
<div class="col-md-6 mb-3">
<label class="form-label" for="fall_makeup_exam_on_<?= $id ?>">Fall Makeup Exam</label>
<input class="form-control" id="fall_makeup_exam_on_<?= $id ?>" name="fall_makeup_exam_on" type="date" value="<?= esc($year['fall_makeup_exam_on'] ?? '') ?>">
</div>
</div>
<label class="form-label" for="description_<?= $id ?>">Description</label>
<textarea class="form-control" id="description_<?= $id ?>" name="description" rows="3"><?= esc($year['description'] ?? '') ?></textarea>
@@ -415,6 +435,21 @@ document.addEventListener('DOMContentLoaded', function () {
order: [[0, 'desc']]
});
}
const newYearInput = document.getElementById('new_school_year_name');
const previousYearDisplay = document.getElementById('new_previous_school_year_display');
const previousYearByNewYear = <?= json_encode($previousYearNameByNewYearName, JSON_UNESCAPED_SLASHES) ?>;
if (newYearInput && previousYearDisplay) {
const defaultPreviousYear = previousYearDisplay.dataset.defaultPreviousYear || 'None';
const updatePreviousYear = function () {
const newYearName = newYearInput.value.trim();
previousYearDisplay.value = previousYearByNewYear[newYearName] || defaultPreviousYear;
};
newYearInput.addEventListener('input', updatePreviousYear);
updatePreviousYear();
}
});
</script>
<?= $this->endSection() ?>