security fix and fix parent pages
API CI/CD / Validate (composer + pint) (push) Successful in 3m7s
API CI/CD / Test (PHPUnit) (push) Failing after 5m46s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 49s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped

This commit is contained in:
root
2026-07-06 02:14:16 -04:00
parent 39228168c8
commit 90f9857b06
43 changed files with 4323 additions and 132 deletions
@@ -27,10 +27,11 @@ class ReportCardService
$this->semester = trim((string) (Configuration::getConfig('semester') ?? ''));
}
public function meta(?string $schoolYear, ?string $semester): array
public function meta(?string $schoolYear, ?string $semester, ?int $parentId = null): array
{
$year = trim((string) ($schoolYear ?? $this->schoolYear));
$sem = trim((string) ($semester ?? $this->semester));
$parentId = (int) ($parentId ?? 0);
if ($year === '') {
$yr = DB::table('classSection')->select('school_year')->orderBy('school_year', 'DESC')->first();
@@ -117,6 +118,9 @@ class ReportCardService
->leftJoin('classSection as cs', 'cs.class_section_id', '=', 'sc.class_section_id')
->where('s.is_active', 1)
->where('ss.school_year', $year);
if ($parentId > 0) {
$builder->where('s.parent_id', $parentId);
}
if ($sem !== '') {
$this->applySemesterFilter($builder, $sem, 'ss.semester');
}
@@ -141,6 +145,9 @@ class ReportCardService
if ($year !== '') {
$fallback->where('sc.school_year', $year);
}
if ($parentId > 0) {
$fallback->where('students.parent_id', $parentId);
}
$students = $fallback
->where('students.is_active', 1)
->groupBy('students.id', 'students.firstname', 'students.lastname')
@@ -160,6 +167,9 @@ class ReportCardService
->join('students as s', 's.id', '=', 'sc.student_id')
->where('s.is_active', 1)
->where('sc.school_year', $year);
if ($parentId > 0) {
$builder->where('s.parent_id', $parentId);
}
$classSections = $builder
->groupBy('cs.id', 'cs.class_section_id', 'cs.class_section_name', 'cs.school_year')
->orderBy('cs.class_section_name', 'ASC')
@@ -174,6 +184,7 @@ class ReportCardService
->join('students as s', 's.id', '=', 'sc.student_id')
->where('s.is_active', 1)
->where('sc.school_year', $year)
->when($parentId > 0, fn ($query) => $query->where('s.parent_id', $parentId))
->groupBy('cs.id', 'cs.class_section_id', 'cs.class_section_name', 'cs.school_year')
->orderBy('cs.class_section_name', 'ASC')
->get()
@@ -571,6 +582,10 @@ class ReportCardService
$data['report_date'] = $reportDate['iso'];
$data['report_date_display'] = $reportDate['display'];
if (! $this->ensureFpdfAvailable()) {
return ['ok' => false, 'message' => 'Report card PDF renderer is unavailable.'];
}
$pdf = new \FPDF('P', 'mm', 'Letter');
$this->formatReportPDF($pdf, $data);
@@ -613,6 +628,10 @@ class ReportCardService
return ['ok' => false, 'message' => 'No students found for this class section.'];
}
if (! $this->ensureFpdfAvailable()) {
return ['ok' => false, 'message' => 'Report card PDF renderer is unavailable.'];
}
$pdf = new \FPDF('P', 'mm', 'Letter');
foreach ($scores as $score) {
@@ -749,6 +768,22 @@ class ReportCardService
];
}
private function ensureFpdfAvailable(): bool
{
if (class_exists('FPDF', false)) {
return true;
}
$path = base_path('app/ThirdParty/fpdf/fpdf.php');
if (! is_file($path)) {
return false;
}
require_once $path;
return class_exists('FPDF', false);
}
private function resolveAnchorSunday(): string
{
$tzName = (string) (config('School')->attendance['timezone'] ?? config('app.timezone'));