This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
$isEditable = isset($isEditable) ? (bool) $isEditable : true;
|
||||
$selectedYear = trim((string) ($selectedYear ?? ''));
|
||||
$disableStudentBtn = count($existingKids) >= $maxChilds;
|
||||
$disableEmergencyBtn = count($emergencies) >= $maxEmergency;
|
||||
?>
|
||||
@@ -7,6 +9,14 @@ $disableEmergencyBtn = count($emergencies) >= $maxEmergency;
|
||||
<?= $this->section('content') ?>
|
||||
<div class="container my-5">
|
||||
<h3 class="text-center text-success mb-3" style="font-family: Arial, sans-serif;">Student Registration</h3>
|
||||
<?php if ($selectedYear !== ''): ?>
|
||||
<div class="text-center text-muted mb-3">School year: <?= esc($selectedYear) ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if (!$isEditable): ?>
|
||||
<div class="alert alert-warning">
|
||||
This school year is read-only. Switch to the active school year to register or edit students.
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($disableStudentBtn): ?>
|
||||
<div class="alert alert-info mt-2">You've reached the maximum number of students (<?= $maxChilds ?>).</div>
|
||||
<?php endif; ?>
|
||||
@@ -100,7 +110,7 @@ $disableEmergencyBtn = count($emergencies) >= $maxEmergency;
|
||||
?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?php if ($kid['enrollment'] == 0): ?>
|
||||
<?php if ($isEditable && $kid['enrollment'] == 0): ?>
|
||||
<form action="<?= base_url('/parent/delete_student/' . $kid['id']) ?>"
|
||||
method="post"
|
||||
style="display:inline">
|
||||
@@ -116,7 +126,7 @@ $disableEmergencyBtn = count($emergencies) >= $maxEmergency;
|
||||
</button>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" disabled title="Student is already enrolled">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" disabled title="<?= $isEditable ? 'Student is already enrolled' : 'This school year is read-only' ?>">
|
||||
<i class="fas fa-ban"></i> Delete
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
@@ -162,7 +172,7 @@ $disableEmergencyBtn = count($emergencies) >= $maxEmergency;
|
||||
<?php
|
||||
$today = local_date(utc_now(), 'Y-m-d');
|
||||
$disableDueToDate = ($today >= $lastDayOfRegistration);
|
||||
$disableAll = $disableStudentBtn || $disableDueToDate;
|
||||
$disableAll = $disableStudentBtn || $disableDueToDate || ! $isEditable;
|
||||
?>
|
||||
<form action="<?= base_url('/parent/register_student/save') ?>"
|
||||
method="post"
|
||||
@@ -183,6 +193,8 @@ $disableEmergencyBtn = count($emergencies) >= $maxEmergency;
|
||||
title="<?php
|
||||
if ($disableStudentBtn) {
|
||||
echo "Maximum of $maxChilds students reached.";
|
||||
} elseif (!$isEditable) {
|
||||
echo "This school year is read-only.";
|
||||
} elseif ($disableDueToDate) {
|
||||
echo "Registration is closed after $lastDayOfRegistration.";
|
||||
}
|
||||
@@ -199,6 +211,8 @@ $disableEmergencyBtn = count($emergencies) >= $maxEmergency;
|
||||
title="<?php
|
||||
if ($disableStudentBtn) {
|
||||
echo "Maximum of $maxChilds students reached.";
|
||||
} elseif (!$isEditable) {
|
||||
echo "This school year is read-only.";
|
||||
} elseif ($disableDueToDate) {
|
||||
echo "Registration is closed after $lastDayOfRegistration.";
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$isEditable = (bool) ($isEditable ?? true);
|
||||
$selectedYear = (string) ($selectedYear ?? '');
|
||||
$disabledAttr = $isEditable ? '' : ' disabled';
|
||||
// Build preview/edit table for upcoming reports
|
||||
$myReports = is_array($myReports ?? null) ? $myReports : [];
|
||||
$tzName = 'UTC';
|
||||
@@ -23,6 +26,12 @@
|
||||
$nowTz = new DateTime('now', new DateTimeZone($tzName));
|
||||
?>
|
||||
|
||||
<?php if (!$isEditable): ?>
|
||||
<div class="alert alert-info">
|
||||
You are viewing <?= esc($selectedYear !== '' ? $selectedYear : 'a closed school year') ?>. Attendance report actions are read-only for closed years.
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($myReports)): ?>
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-header bg-light"><strong>Upcoming Submissions (Preview & Edit)</strong></div>
|
||||
@@ -53,7 +62,7 @@
|
||||
$cutoff = null; $editable = false;
|
||||
try { $cutoff = new DateTime($reportDate . ' 09:00:00', new DateTimeZone($tzName)); } catch (\Throwable $e) { $cutoff = null; }
|
||||
if ($cutoff) {
|
||||
$editable = ($status === 'new') && ($nowTz < $cutoff);
|
||||
$editable = $isEditable && ($status === 'new') && ($nowTz < $cutoff);
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
@@ -149,7 +158,8 @@
|
||||
data-cutoff-date="<?= esc($cutoffDate) ?>"
|
||||
data-cutoff-time="<?= esc($cutoffTime) ?>"
|
||||
data-cutoff-threshold="<?= esc($cutoffThreshold) ?>"
|
||||
data-cutoff-blocked="0">
|
||||
data-cutoff-blocked="0"
|
||||
data-readonly="<?= $isEditable ? '0' : '1' ?>">
|
||||
<input type="hidden" name="<?= csrf_token() ?>" value="<?= csrf_hash() ?>">
|
||||
|
||||
<div id="clientCheckAlert" class="alert d-none" role="alert"></div>
|
||||
@@ -168,7 +178,7 @@
|
||||
$oldStudents = (array) old('student_ids');
|
||||
$isChecked = in_array((string)$s['id'], array_map('strval', $oldStudents ?? []), true);
|
||||
?>
|
||||
<input class="form-check-input" type="checkbox" name="student_ids[]" id="stu<?= (int)$s['id'] ?>" value="<?= (int)$s['id'] ?>" <?= $isChecked ? 'checked' : '' ?>>
|
||||
<input class="form-check-input" type="checkbox" name="student_ids[]" id="stu<?= (int)$s['id'] ?>" value="<?= (int)$s['id'] ?>" <?= $isChecked ? 'checked' : '' ?><?= $disabledAttr ?>>
|
||||
<label class="form-check-label" for="stu<?= (int)$s['id'] ?>">
|
||||
<?= esc($s['firstname'] . ' ' . $s['lastname']) ?>
|
||||
</label>
|
||||
@@ -187,7 +197,7 @@
|
||||
<div class="row g-3 mb-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Sunday Date(s)</label>
|
||||
<select name="dates[]" class="form-select" required multiple size="6" style="max-height: 220px; overflow-y: auto;">
|
||||
<select name="dates[]" class="form-select" required multiple size="6" style="max-height: 220px; overflow-y: auto;"<?= $disabledAttr ?>>
|
||||
<?php
|
||||
$list = $sundays ?? [];
|
||||
$oldDatesRaw = old('dates');
|
||||
@@ -214,7 +224,7 @@
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label fw-semibold">Type</label>
|
||||
<select name="type" id="reportType" class="form-select" required>
|
||||
<select name="type" id="reportType" class="form-select" required<?= $disabledAttr ?>>
|
||||
<?php $oldType = (string) (old('type') ?: 'absent'); ?>
|
||||
<option value="absent" <?= $oldType === 'absent' ? 'selected' : '' ?>>Absent</option>
|
||||
<option value="late" <?= $oldType === 'late' ? 'selected' : '' ?>>Late</option>
|
||||
@@ -223,22 +233,22 @@
|
||||
</div>
|
||||
<div class="col-md-3" id="arrivalTimeWrap" style="display:none;">
|
||||
<label class="form-label fw-semibold">Expected Arrival Time</label>
|
||||
<input type="time" name="arrival_time" class="form-control" placeholder="HH:MM" value="<?= esc(old('arrival_time') ?: '') ?>">
|
||||
<input type="time" name="arrival_time" class="form-control" placeholder="HH:MM" value="<?= esc(old('arrival_time') ?: '') ?>"<?= $disabledAttr ?>>
|
||||
</div>
|
||||
<div class="col-md-3" id="dismissTimeWrap" style="display:none;">
|
||||
<label class="form-label fw-semibold">Dismissal Time</label>
|
||||
<input type="time" name="dismiss_time" class="form-control" placeholder="HH:MM" value="<?= esc(old('dismiss_time') ?: '') ?>">
|
||||
<input type="time" name="dismiss_time" class="form-control" placeholder="HH:MM" value="<?= esc(old('dismiss_time') ?: '') ?>"<?= $disabledAttr ?>>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold" id="reasonLabel">Reason</label>
|
||||
<textarea name="reason" id="reasonInput" rows="3" class="form-control" placeholder="Brief reason to help teachers plan."><?= esc(old('reason') ?: '') ?></textarea>
|
||||
<textarea name="reason" id="reasonInput" rows="3" class="form-control" placeholder="Brief reason to help teachers plan."<?= $disabledAttr ?>><?= esc(old('reason') ?: '') ?></textarea>
|
||||
<div class="form-text" id="reasonHelp">Required for Absence/Late so we can support your child.</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" class="btn btn-success">Submit</button>
|
||||
<button type="submit" class="btn btn-success"<?= $disabledAttr ?>>Submit</button>
|
||||
<?php $prev = previous_url() ?: site_url('/parent/attendance'); ?>
|
||||
<a href="<?= esc($prev) ?>" class="btn btn-outline-secondary">Cancel</a>
|
||||
</div>
|
||||
@@ -325,6 +335,14 @@
|
||||
const dateSel = form.querySelector('select[name="dates[]"]');
|
||||
const submitBtn = form.querySelector('button[type="submit"]');
|
||||
const alertBox = document.getElementById('clientCheckAlert');
|
||||
const isReadonly = form.getAttribute('data-readonly') === '1';
|
||||
|
||||
if (isReadonly) {
|
||||
if (submitBtn) {
|
||||
submitBtn.disabled = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function selectedIds() {
|
||||
const ids = [];
|
||||
@@ -520,6 +538,11 @@
|
||||
const cutoffDate = form.getAttribute('data-cutoff-date') || '';
|
||||
const cutoffTime = form.getAttribute('data-cutoff-time') || '';
|
||||
const cutoffThreshold = form.getAttribute('data-cutoff-threshold') || '09:00';
|
||||
const isReadonly = form.getAttribute('data-readonly') === '1';
|
||||
|
||||
if (isReadonly && submitBtn) {
|
||||
submitBtn.disabled = true;
|
||||
}
|
||||
|
||||
function parseTimeToMinutes(val) {
|
||||
const parts = (val || '').split(':');
|
||||
@@ -544,6 +567,10 @@
|
||||
if (cutoffAlert) {
|
||||
cutoffAlert.classList.toggle('d-none', !blocked);
|
||||
}
|
||||
if (submitBtn && isReadonly) {
|
||||
submitBtn.disabled = true;
|
||||
return;
|
||||
}
|
||||
if (submitBtn && blocked) {
|
||||
submitBtn.disabled = true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<?= $this->extend('layout/main_layout') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<?php
|
||||
$isEditable = (bool) ($isEditable ?? true);
|
||||
$disabledAttr = $isEditable ? '' : ' disabled';
|
||||
?>
|
||||
<div class="container my-5">
|
||||
<div class="d-flex flex-wrap align-items-center justify-content-between gap-2 mb-3">
|
||||
<div>
|
||||
@@ -16,6 +20,11 @@
|
||||
<?php if (session()->getFlashdata('success')): ?>
|
||||
<div class="alert alert-success"><?= esc(session()->getFlashdata('success')) ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if (! $isEditable): ?>
|
||||
<div class="alert alert-info">
|
||||
You are viewing <?= esc($schoolYear ?: 'a closed school year') ?>. Report card signatures are read-only for closed years.
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (empty($students)): ?>
|
||||
<div class="alert alert-info">No students available for report cards.</div>
|
||||
@@ -57,8 +66,8 @@
|
||||
<?php if (! $signedAt): ?>
|
||||
<form class="d-inline-flex align-items-center gap-2 ms-2" method="post" action="<?= base_url('parent/report-cards/sign/' . $sid) ?>">
|
||||
<?= csrf_field() ?>
|
||||
<input type="text" name="signed_name" class="form-control form-control-sm" placeholder="Full name" required>
|
||||
<button class="btn btn-sm btn-success" type="submit">Sign</button>
|
||||
<input type="text" name="signed_name" class="form-control form-control-sm" placeholder="Full name" required<?= $disabledAttr ?>>
|
||||
<button class="btn btn-sm btn-success" type="submit"<?= $disabledAttr ?>>Sign</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user