fix enrollment, invoice, payment and financila aid
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 47s
Tests / PHPUnit (push) Failing after 1m19s

This commit is contained in:
root
2026-08-24 21:20:58 -04:00
parent 576da3bd78
commit 608aca79b8
30 changed files with 3327 additions and 774 deletions
+55 -15
View File
@@ -54,12 +54,26 @@ $selectedClasses = array_values(array_intersect(range(1,13), $selectedClasses));
</div>
<div class="col-md-6">
<label class="form-label">Category</label>
<?php
$selectedCategoryId = (int) old('category_id', $item['category_id'] ?? 0);
$selectedCat = null;
if ($selectedCategoryId > 0) {
foreach ($categories as $c) {
if ((int)($c['id'] ?? 0) === $selectedCategoryId) {
$selectedCat = $c;
break;
}
}
}
$editGmin = old('grade_min', $selectedCat['grade_min'] ?? '');
$editGmax = old('grade_max', $selectedCat['grade_max'] ?? '');
?>
<select class="form-select" name="category_id" id="bookCategorySelect">
<option value="">— None —</option>
<?php foreach ($categories as $c): ?>
<?php
$cid = (int)($c['id'] ?? 0);
$sel = isset($item['category_id']) && (int)$item['category_id'] === $cid ? 'selected' : '';
$sel = $selectedCategoryId === $cid ? 'selected' : '';
$gmin = $c['grade_min'] ?? '';
$gmax = $c['grade_max'] ?? '';
?>
@@ -71,9 +85,20 @@ $selectedClasses = array_values(array_intersect(range(1,13), $selectedClasses));
</option>
<?php endforeach; ?>
</select>
<div class="row g-2 mt-2">
<div class="col-6">
<label class="form-label" for="bookGradeMin">Grade Min</label>
<input type="number" class="form-control" name="grade_min" id="bookGradeMin"
min="0" max="13" value="<?= esc((string)$editGmin) ?>">
</div>
<div class="col-6">
<label class="form-label" for="bookGradeMax">Grade Max</label>
<input type="number" class="form-control" name="grade_max" id="bookGradeMax"
min="0" max="13" value="<?= esc((string)$editGmax) ?>">
</div>
</div>
<div class="form-text">
Grade Range:
<span id="catGradeRange">—</span>
Grade range is saved on the selected category (shared by all books in that category).
</div>
</div>
@@ -141,20 +166,35 @@ $selectedClasses = array_values(array_intersect(range(1,13), $selectedClasses));
<script>
(function() {
// Category grade range helper
const sel = document.getElementById('bookCategorySelect');
const out = document.getElementById('catGradeRange');
function label(opt) {
if (!opt) { out.textContent = '—'; return; }
const gmin = opt.getAttribute('data-gmin');
const gmax = opt.getAttribute('data-gmax');
if ((gmin && gmin !== '') && (gmax && gmax !== '')) out.textContent = `G${gmin}G${gmax}`;
else if (gmin && gmin !== '') out.textContent = `G${gmin}+`;
else if (gmax && gmax !== '') out.textContent = `≤G${gmax}`;
else out.textContent = '';
const gminInput = document.getElementById('bookGradeMin');
const gmaxInput = document.getElementById('bookGradeMax');
function syncGradeInputsFromCategory() {
if (!sel || !gminInput || !gmaxInput) return;
const hasCategory = sel.value !== '';
if (!hasCategory) {
gminInput.value = '';
gmaxInput.value = '';
return;
}
const opt = sel.options[sel.selectedIndex];
gminInput.value = opt?.getAttribute('data-gmin') ?? '';
gmaxInput.value = opt?.getAttribute('data-gmax') ?? '';
}
sel?.addEventListener('change', () => label(sel.options[sel.selectedIndex]));
if (sel) label(sel.options[sel.selectedIndex]); // init on load
// Keep option dataset in sync so re-selecting the same category shows latest typed values
function mirrorInputsOntoSelectedOption() {
if (!sel || !sel.value) return;
const opt = sel.options[sel.selectedIndex];
if (!opt) return;
opt.setAttribute('data-gmin', gminInput?.value ?? '');
opt.setAttribute('data-gmax', gmaxInput?.value ?? '');
}
sel?.addEventListener('change', syncGradeInputsFromCategory);
gminInput?.addEventListener('change', mirrorInputsOntoSelectedOption);
gmaxInput?.addEventListener('change', mirrorInputsOntoSelectedOption);
// Classes select all / clear
const selectAllBtn = document.getElementById('btnSelectAllClasses');
+100 -3
View File
@@ -8,6 +8,7 @@
<a class="btn btn-outline-primary" href="<?= site_url('inventory/book-prices') ?>">Book Prices</a>
<a class="btn btn-primary" href="<?= site_url('inventory/create/book') ?>">Add Book</a>
<button class="btn btn-outline-secondary" data-bs-toggle="modal" data-bs-target="#addCategoryModal">Add Category</button>
<button class="btn btn-outline-secondary" data-bs-toggle="modal" data-bs-target="#editCategoryModal">Edit Category</button>
</div>
</div>
@@ -65,7 +66,19 @@
<td><?= esc($i['isbn']) ?></td>
<td><?= esc($i['edition']) ?></td>
<td><?= esc($catName) ?></td>
<td><?= esc($catGrades) ?></td> <!-- NEW -->
<td>
<?php if (!empty($cat['id'])): ?>
<button type="button"
class="btn btn-link p-0 text-decoration-none js-edit-category-grades"
data-bs-toggle="modal"
data-bs-target="#editCategoryModal"
data-category-id="<?= (int) $cat['id'] ?>">
<?= esc($catGrades) ?>
</button>
<?php else: ?>
<?= esc($catGrades) ?>
<?php endif; ?>
</td>
<td><?= esc($i['quantity']) ?></td>
<td><?= esc($i['unit']) ?></td>
<td><?= esc($userNames[(int)($i['updated_by'] ?? 0)] ?? '—') ?></td>
@@ -102,7 +115,6 @@
<input type="text" name="name" class="form-control" required>
</div>
<!-- NEW: Grade range -->
<div class="row g-2 mb-3">
<div class="col-6">
<label class="form-label">Grade Min</label>
@@ -127,6 +139,65 @@
</div>
</div>
<!-- Edit Category Modal -->
<div class="modal fade" id="editCategoryModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<form class="modal-content" method="post" action="<?= site_url('inventory/category/save') ?>" id="editCategoryForm">
<?= csrf_field() ?>
<input type="hidden" name="type" value="book">
<div class="modal-header">
<h5 class="modal-title">Edit Category (Books)</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label class="form-label">Category</label>
<select class="form-select" name="id" id="editCategorySelect" required>
<option value="">— Select category —</option>
<?php foreach ($categories as $c): ?>
<option
value="<?= (int)($c['id'] ?? 0) ?>"
data-name="<?= esc($c['name'] ?? '', 'attr') ?>"
data-description="<?= esc($c['description'] ?? '', 'attr') ?>"
data-gmin="<?= esc((string)($c['grade_min'] ?? ''), 'attr') ?>"
data-gmax="<?= esc((string)($c['grade_max'] ?? ''), 'attr') ?>"
><?= esc(($c['name'] ?? '') . ($gradeLabel($c) !== '—' ? ' (' . $gradeLabel($c) . ')' : '')) ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="mb-3">
<label class="form-label">Name</label>
<input type="text" name="name" id="editCategoryName" class="form-control" required>
</div>
<div class="row g-2 mb-3">
<div class="col-6">
<label class="form-label">Grade Min</label>
<input type="number" name="grade_min" id="editCategoryGradeMin" class="form-control" min="0" max="13" placeholder="e.g., 1">
</div>
<div class="col-6">
<label class="form-label">Grade Max</label>
<input type="number" name="grade_max" id="editCategoryGradeMax" class="form-control" min="0" max="13" placeholder="e.g., 3">
</div>
<div class="col-12">
<small class="text-muted">Optional. Changing grade range updates every book in this category.</small>
</div>
</div>
<div class="mb-0">
<label class="form-label">Description (optional)</label>
<textarea name="description" id="editCategoryDescription" class="form-control" rows="2"></textarea>
</div>
</div>
<div class="modal-footer"><button type="submit" class="btn btn-primary" id="editCategorySaveBtn">Update Category</button></div>
</form>
</div>
</div>
<?= $this->endSection() ?>
<?= $this->section('scripts') ?>
<script>
document.getElementById('categoryFilter')?.addEventListener('change', function() {
const val = this.value;
@@ -134,6 +205,32 @@ document.getElementById('categoryFilter')?.addEventListener('change', function()
tr.style.display = (!val || tr.getAttribute('data-category') === val) ? '' : 'none';
});
});
</script>
(function() {
const select = document.getElementById('editCategorySelect');
const nameInput = document.getElementById('editCategoryName');
const descInput = document.getElementById('editCategoryDescription');
const gminInput = document.getElementById('editCategoryGradeMin');
const gmaxInput = document.getElementById('editCategoryGradeMax');
function fillEditCategory() {
const opt = select?.options[select.selectedIndex];
const has = !!(select && select.value);
if (nameInput) nameInput.value = has ? (opt.getAttribute('data-name') || '') : '';
if (descInput) descInput.value = has ? (opt.getAttribute('data-description') || '') : '';
if (gminInput) gminInput.value = has ? (opt.getAttribute('data-gmin') || '') : '';
if (gmaxInput) gmaxInput.value = has ? (opt.getAttribute('data-gmax') || '') : '';
}
select?.addEventListener('change', fillEditCategory);
document.getElementById('editCategoryModal')?.addEventListener('show.bs.modal', function (e) {
const trigger = e.relatedTarget;
const preselect = trigger && trigger.getAttribute ? trigger.getAttribute('data-category-id') : null;
if (preselect && select) {
select.value = preselect;
}
fillEditCategory();
});
})();
</script>
<?= $this->endSection() ?>