This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Exceptions\SchoolYear\SchoolYearWriteConflictException;
|
||||
use App\Models\ConfigurationModel;
|
||||
use App\Models\ReportCardAcknowledgementModel;
|
||||
use App\Models\StudentModel;
|
||||
@@ -31,7 +32,8 @@ class ParentReportCardController extends BaseController
|
||||
return redirect()->back()->with('error', 'Unable to retrieve student data. Please contact support.');
|
||||
}
|
||||
|
||||
$schoolYear = trim((string) $this->currentSchoolYearName());
|
||||
$schoolYearContext = $this->resolveSchoolYearContext();
|
||||
$schoolYear = trim($schoolYearContext->yearName());
|
||||
$semester = trim((string) ($this->request->getGet('semester') ?? $this->configModel->getConfig('semester') ?? ''));
|
||||
|
||||
$builder = $this->db->table('students s')
|
||||
@@ -67,6 +69,7 @@ class ParentReportCardController extends BaseController
|
||||
'ackMap' => $ackMap,
|
||||
'schoolYear' => $schoolYear,
|
||||
'semester' => $semester,
|
||||
'isEditable' => ! $schoolYearContext->isReadonly(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -82,12 +85,15 @@ class ParentReportCardController extends BaseController
|
||||
throw new PageNotFoundException('Student not found.');
|
||||
}
|
||||
|
||||
$schoolYear = trim((string) $this->currentSchoolYearName());
|
||||
$schoolYearContext = $this->resolveSchoolYearContext();
|
||||
$schoolYear = trim($schoolYearContext->yearName());
|
||||
$semester = trim((string) ($this->request->getGet('semester') ?? $this->configModel->getConfig('semester') ?? ''));
|
||||
|
||||
$this->touchAcknowledgement($parentId, (int) $studentId, $schoolYear, $semester, [
|
||||
'viewed_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
if (! $schoolYearContext->isReadonly()) {
|
||||
$this->touchAcknowledgement($parentId, (int) $studentId, $schoolYear, $semester, [
|
||||
'viewed_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
}
|
||||
|
||||
$url = site_url('report-card/student/' . (int) $studentId);
|
||||
$query = [];
|
||||
@@ -111,6 +117,13 @@ class ParentReportCardController extends BaseController
|
||||
return redirect()->back()->with('error', 'Unable to retrieve student data. Please contact support.');
|
||||
}
|
||||
|
||||
$schoolYearContext = $this->resolveSchoolYearContext();
|
||||
try {
|
||||
$this->assertSchoolYearWritable($schoolYearContext);
|
||||
} catch (SchoolYearWriteConflictException $e) {
|
||||
return redirect()->back()->withInput()->with('error', $e->getMessage());
|
||||
}
|
||||
|
||||
$student = $this->studentModel->find((int) $studentId);
|
||||
if (! $student || (int) ($student['parent_id'] ?? 0) !== $parentId) {
|
||||
throw new PageNotFoundException('Student not found.');
|
||||
@@ -121,7 +134,7 @@ class ParentReportCardController extends BaseController
|
||||
return redirect()->back()->with('error', 'Please type your full name to sign.');
|
||||
}
|
||||
|
||||
$schoolYear = trim((string) $this->currentSchoolYearName());
|
||||
$schoolYear = trim($schoolYearContext->yearName());
|
||||
$semester = trim((string) ($this->configModel->getConfig('semester') ?? ''));
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$this->touchAcknowledgement($parentId, (int) $studentId, $schoolYear, $semester, [
|
||||
|
||||
Reference in New Issue
Block a user