fix score submission, and class progress
This commit is contained in:
@@ -77,39 +77,25 @@
|
||||
<div class="card shadow-sm mb-3">
|
||||
<div class="card-header bg-white d-flex flex-wrap align-items-center justify-content-between gap-3">
|
||||
<strong class="mb-0">Date Selection</strong>
|
||||
<?php if ($isEdit): ?>
|
||||
<div class="text-muted small">
|
||||
<?php
|
||||
try {
|
||||
$displayStart = (new \DateTime($weekStartSelected))->format('M d, Y');
|
||||
} catch (\Exception $e) {
|
||||
$displayStart = $weekStartSelected;
|
||||
}
|
||||
?>
|
||||
Week of <?= esc($displayStart ?: 'N/A') ?>
|
||||
</div>
|
||||
<input type="hidden" name="week_start" value="<?= esc($weekStartSelected) ?>">
|
||||
<?php else: ?>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<select id="weekStartSelect" name="week_start" class="form-select form-select-sm" required>
|
||||
<option value="">Select week</option>
|
||||
<?php foreach ($sundayOptions as $sunday): ?>
|
||||
<?php
|
||||
try {
|
||||
$startDt = new \DateTime($sunday);
|
||||
$displayStart = $startDt->format('M d, Y');
|
||||
} catch (\Exception $e) {
|
||||
$displayStart = $sunday;
|
||||
}
|
||||
?>
|
||||
<option value="<?= esc($sunday) ?>" <?= $sunday === $weekStartSelected ? 'selected' : '' ?>>
|
||||
<?= esc($displayStart) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<div class="invalid-feedback">Week start is required.</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<select id="weekStartSelect" name="week_start" class="form-select form-select-sm" required <?= $isEdit ? 'data-original-week="' . esc($weekStartSelected) . '"' : '' ?>>
|
||||
<option value="">Select week</option>
|
||||
<?php foreach ($sundayOptions as $sunday): ?>
|
||||
<?php
|
||||
try {
|
||||
$startDt = new \DateTime($sunday);
|
||||
$displayStart = $startDt->format('M d, Y');
|
||||
} catch (\Exception $e) {
|
||||
$displayStart = $sunday;
|
||||
}
|
||||
?>
|
||||
<option value="<?= esc($sunday) ?>" <?= $sunday === $weekStartSelected ? 'selected' : '' ?>>
|
||||
<?= esc($displayStart) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<div class="invalid-feedback">Week start is required.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<input type="hidden" name="week_end" id="weekEndInput" value="<?= esc($weekEndValue) ?>" required>
|
||||
@@ -306,6 +292,19 @@
|
||||
const forms = document.querySelectorAll('.needs-validation');
|
||||
Array.from(forms).forEach(form => {
|
||||
form.addEventListener('submit', event => {
|
||||
const originalWeek = weekStartSelect?.dataset.originalWeek || '';
|
||||
if (originalWeek && weekStartSelect && weekStartSelect.value && weekStartSelect.value !== originalWeek) {
|
||||
const ok = confirm('A progress report already exists for the original week. Change the week and override any existing report for the new date?');
|
||||
if (!ok) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return;
|
||||
}
|
||||
const confirmInput = document.getElementById('confirmOverwriteInput');
|
||||
if (confirmInput) {
|
||||
confirmInput.value = '1';
|
||||
}
|
||||
}
|
||||
const islamicUnits = form.querySelectorAll('input[name="unit_islamic[]"]');
|
||||
const hasIslamicUnit = Array.from(islamicUnits).some(input => input.value.trim() !== '');
|
||||
if (!hasIslamicUnit) {
|
||||
|
||||
Reference in New Issue
Block a user