merge prod to main

This commit is contained in:
root
2026-05-16 13:44:12 -04:00
parent 663c0cdbda
commit b32fb853f6
901 changed files with 11241 additions and 1340 deletions
+56
View File
@@ -4,18 +4,21 @@ namespace App\Controllers\View;
use App\Models\CalendarModel;
use App\Models\AttendanceDataModel;
use App\Models\ReportCardAcknowledgementModel;
use App\Services\SemesterRangeService;
class ReportCardsController extends PrintablesBaseController
{
protected $calendarModel;
protected $semesterRangeService;
protected $ackModel;
public function __construct()
{
parent::__construct();
$this->calendarModel = new CalendarModel();
$this->semesterRangeService = new SemesterRangeService($this->configModel);
$this->ackModel = new ReportCardAcknowledgementModel();
}
public function report_card()
@@ -369,6 +372,24 @@ class ReportCardsController extends PrintablesBaseController
$isNumeric = static fn($v) => $v !== null && $v !== '' && is_numeric($v);
$ackMap = [];
try {
$ackRows = $this->ackModel
->whereIn('student_id', $studentIds)
->where('school_year', $year)
->where('semester', $sem)
->orderBy('updated_at', 'DESC')
->findAll();
foreach ($ackRows as $row) {
$sid = (int) ($row['student_id'] ?? 0);
if ($sid > 0 && ! isset($ackMap[$sid])) {
$ackMap[$sid] = $row;
}
}
} catch (\Throwable $e) {
$ackMap = [];
}
$results = [];
$completeCount = 0;
$warningCount = 0;
@@ -471,12 +492,16 @@ class ReportCardsController extends PrintablesBaseController
$warningCount++;
}
$ack = $sid > 0 ? ($ackMap[$sid] ?? null) : null;
$results[] = [
'id' => $sid,
'name' => $name !== '' ? $name : 'N/A',
'missing' => $missing,
'warnings' => $warnings,
'complete' => $isComplete,
'viewed_at' => $ack['viewed_at'] ?? null,
'signed_at' => $ack['signed_at'] ?? null,
'signed_name' => $ack['signed_name'] ?? null,
];
}
@@ -501,6 +526,37 @@ class ReportCardsController extends PrintablesBaseController
]);
}
/**
* API: report card parent acknowledgement status
* GET params: student_id, school_year, semester
*/
public function reportCardAcknowledgement()
{
$studentId = (int) ($this->request->getGet('student_id') ?? 0);
if ($studentId <= 0) {
return $this->response->setJSON(['ok' => false, 'error' => 'Missing student_id'])->setStatusCode(400);
}
$schoolYear = trim((string) ($this->request->getGet('school_year') ?? $this->schoolYear ?? ''));
$semester = trim((string) ($this->request->getGet('semester') ?? $this->semester ?? ''));
$row = $this->ackModel
->where('student_id', $studentId)
->where('school_year', $schoolYear)
->where('semester', $semester)
->orderBy('updated_at', 'DESC')
->first();
return $this->response->setJSON([
'ok' => true,
'student_id' => $studentId,
'school_year' => $schoolYear,
'semester' => $semester,
'viewed_at' => $row['viewed_at'] ?? null,
'signed_at' => $row['signed_at'] ?? null,
'signed_name' => $row['signed_name'] ?? null,
]);
}
protected function fetchStudentsByClass(int $sectionId, ?string $schoolYear)
{
$b = $this->studentClassModel