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 @@ = $this->extend('layout/main_layout') ?> = $this->section('content') ?> +