This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user