diff --git a/app/Config/Routes.php b/app/Config/Routes.php index bd92e8f..d011f96 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -418,6 +418,7 @@ $routes->get('exam-drafts/files/final/(:segment)', 'View\FilesController::examDr +$routes->get('teacher/progress', 'ClassProgressController::history', ['filter' => 'auth:teacher,teacher_assistant']); $routes->get('teacher/progress/submit', 'ClassProgressController::create', ['filter' => 'auth:teacher,teacher_assistant']); $routes->post('teacher/progress/store', 'ClassProgressController::store', ['filter' => 'auth:teacher,teacher_assistant']); $routes->get('teacher/progress/history', 'ClassProgressController::history', ['filter' => 'auth:teacher,teacher_assistant']); diff --git a/app/Controllers/ClassProgressController.php b/app/Controllers/ClassProgressController.php index 64f4cb7..0fdec5c 100644 --- a/app/Controllers/ClassProgressController.php +++ b/app/Controllers/ClassProgressController.php @@ -289,7 +289,7 @@ class ClassProgressController extends BaseController } $row['status_label'] = self::STATUS_OPTIONS[$row['status']] ?? 'Unknown'; - $weeklyReports = $this->reportModel + $weeklyReportsQuery = $this->reportModel ->select('class_progress_reports.*, cs.class_section_name, CONCAT(IFNULL(u.firstname, ""), " ", IFNULL(u.lastname, "")) AS teacher_name') ->join('classSection cs', 'cs.class_section_id = class_progress_reports.class_section_id', 'left') ->join('users u', 'u.id = class_progress_reports.teacher_id', 'left') @@ -346,7 +346,7 @@ class ClassProgressController extends BaseController throw new PageNotFoundException('Progress report not found.'); } - $weeklyReports = $this->reportModel + $weeklyReportsQuery = $this->reportModel ->select('class_progress_reports.*') ->whereIn('teacher_id', $allowedTeacherIds) ->where('class_section_id', $row['class_section_id']) @@ -513,7 +513,7 @@ class ClassProgressController extends BaseController } } - $weeklyReports = $this->reportModel + $weeklyReportsQuery = $this->reportModel ->select('class_progress_reports.*') ->whereIn('teacher_id', $allowedTeacherIds) ->where('class_section_id', $classSectionId) diff --git a/app/Controllers/View/InventoryController.php b/app/Controllers/View/InventoryController.php index e7fef8f..8d41607 100644 --- a/app/Controllers/View/InventoryController.php +++ b/app/Controllers/View/InventoryController.php @@ -3,6 +3,7 @@ namespace App\Controllers\View; use App\Controllers\BaseController; +use App\Exceptions\SchoolYear\SchoolYearWriteConflictException; use App\Models\ClassSectionModel; use App\Models\InventoryItemModel; use App\Models\InventoryCategoryModel; @@ -713,6 +714,8 @@ class InventoryController extends BaseController */ public function teacherDistributeForm() { + $schoolYearContext = $this->resolveSchoolYearContext(); + // 1) Build teacher/class context (auth/role/no-class handled inside) $ctx = $this->buildTeacherClassContext(); if ($ctx instanceof \CodeIgniter\HTTP\RedirectResponse) { @@ -858,11 +861,19 @@ class InventoryController extends BaseController 'schoolYear' => $ctx['schoolYear'], 'semester' => $ctx['semester'], + 'isEditable' => ! $schoolYearContext->isReadonly(), ]); } public function teacherDistributeStore() { + $schoolYearContext = $this->resolveSchoolYearContext(); + try { + $this->assertSchoolYearWritable($schoolYearContext); + } catch (SchoolYearWriteConflictException $e) { + return redirect()->back()->withInput()->with('error', $e->getMessage()); + } + $ctx = $this->buildTeacherClassContext(); if ($ctx instanceof \CodeIgniter\HTTP\RedirectResponse) { return $ctx; diff --git a/app/Views/inventory/teacher_distribute.php b/app/Views/inventory/teacher_distribute.php index 0529875..8929142 100644 --- a/app/Views/inventory/teacher_distribute.php +++ b/app/Views/inventory/teacher_distribute.php @@ -1,9 +1,18 @@ extend('layout/main_layout') ?> section('content') ?> +

Distribute Books to Students

+ +
+ You are viewing . Book distribution actions are read-only for closed years. +
+
@@ -43,7 +52,7 @@
- + @@ -53,8 +62,8 @@
Students
- - + +
@@ -87,7 +96,7 @@ class="form-check-input student-box" name="student_ids[]" value="" - > + > @@ -111,11 +120,11 @@ @@ -129,15 +138,20 @@ section('scripts') ?> @@ -149,17 +163,20 @@ }); document.getElementById('checkAllBtn')?.addEventListener('click', () => { + if (distributeReadonly) return; document.querySelectorAll('.student-box').forEach(cb => cb.checked = true); }); document.getElementById('uncheckAllBtn')?.addEventListener('click', () => { + if (distributeReadonly) return; document.querySelectorAll('.student-box').forEach(cb => cb.checked = false); }); // Cancel button clears all checkboxes document.getElementById('clearSelectionBtn')?.addEventListener('click', () => { + if (distributeReadonly) return; document.querySelectorAll('.student-box').forEach(cb => cb.checked = false); }); -endSection() ?> \ No newline at end of file +endSection() ?> diff --git a/app/Views/layout/main_layout.php b/app/Views/layout/main_layout.php index 074988b..299054c 100644 --- a/app/Views/layout/main_layout.php +++ b/app/Views/layout/main_layout.php @@ -28,6 +28,7 @@ + renderSection('styles') ?> extend('layout/main_layout') ?> +section('styles') ?> + + +endSection() ?> section('content') ?>