Files
alrahma_sunday_school/app/Views/partials/school_year_selector.php
T
root feb1b29a32
Tests / PHPUnit (push) Failing after 1m19s
apply the school year concept
2026-07-14 00:59:00 -04:00

55 lines
2.4 KiB
PHP

<?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; ?>