db = \Config\Database::connect(); $this->userModel = new UserModel(); $this->studentModel = new StudentModel(); $this->classSectionModel = new ClassSectionModel(); $this->configModel = new ConfigurationModel(); $this->semesterScoreModel = new SemesterScoreModel(); $this->studentClassModel = new StudentClassModel(); $this->teacherClassModel = new TeacherClassModel(); $this->staffModel = new StaffModel(); $this->badgePrintLogModel = new BadgePrintLogModel(); $this->scoreCommentModel = new ScoreCommentModel(); $this->attendanceRecordModel = new AttendanceRecordModel(); $this->schoolYear = $this->configModel->getConfig('school_year'); $this->semester = $this->configModel->getConfig('semester'); $this->stickerWidth = $this->configModel->getConfig('stickerWidth'); $this->stickerHeight = $this->configModel->getConfig('stickerHeight'); $this->pageW = $this->configModel->getConfig('pageWidth'); $this->pageH = $this->configModel->getConfig('pageHeight'); $this->marginL = $this->configModel->getConfig('leftMargin'); $this->marginT = $this->configModel->getConfig('topMargin'); $this->gapX = $this->configModel->getConfig('horizontalGap'); $this->gapY = $this->configModel->getConfig('verticalGap'); } protected function firstExisting(array $paths) { foreach ($paths as $p) { if (is_string($p) && file_exists($p)) { return $p; } } return null; } protected function resolveClassName($db, $classId) { $tables = [ ['classSection', 'class_section_id'], ['classSection', 'id'], ['class_sections', 'class_section_id'], ['class_sections', 'id'], ]; foreach ($tables as [$table, $pk]) { $result = $db->table($table) ->select('class_section_name') ->where($pk, $classId) ->get() ->getRowArray(); if ($result) { return $result['class_section_name'] ?? null; } } return null; } protected function fetchStudentsByClass(int $sectionId, ?string $schoolYear) { $b = $this->studentClassModel ->select('s.id, s.firstname, s.lastname, s.registration_grade, s.gender') ->join('students s', 's.id = student_class.student_id', 'inner') ->where('student_class.class_section_id', $sectionId) ->orderBy('s.lastname', 'ASC'); if (!empty($schoolYear)) { $b->where('student_class.school_year', $schoolYear); } return $b->findAll(); } }