fix deployment db issue and widthrawal administration page
This commit is contained in:
@@ -8,6 +8,7 @@ use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Throwable;
|
||||
use App\Support\Enrollment\DeliberationDecision;
|
||||
|
||||
class EnrollmentAdminController extends BaseController
|
||||
{
|
||||
@@ -503,12 +504,67 @@ class EnrollmentAdminController extends BaseController
|
||||
$row['assignee_name'] = trim((string) ($row['assignee_firstname'] ?? '') . ' ' . (string) ($row['assignee_lastname'] ?? ''));
|
||||
$row['parent_name'] = trim((string) ($row['parent_firstname'] ?? '') . ' ' . (string) ($row['parent_lastname'] ?? '')) ?: ((int) ($row['parent_id'] ?? 0) > 0 ? 'Parent #' . (int) $row['parent_id'] : '');
|
||||
$row['details'] = json_decode((string) ($row['details_json'] ?? ''), true) ?: [];
|
||||
if (! isset($row['details']['rule_code'])) {
|
||||
$ruleCode = $this->ruleCodeForExistingFlag($row);
|
||||
if ($ruleCode !== null) {
|
||||
$row['details']['rule_code'] = $ruleCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($row);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
private function ruleCodeForExistingFlag(array $flag): ?string
|
||||
{
|
||||
$type = strtoupper(trim((string) ($flag['flag_type'] ?? '')));
|
||||
if (! in_array($type, ['DEFERRED_DELIBERATION', 'RESTRICTED_ADMINISTRATIVE_REVIEW', 'WITHDRAWAL_REVIEW_REQUIRED', 'PENDING_MAKE_UP_EXAM_PROMOTION'], true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$studentId = (int) ($flag['student_id'] ?? 0);
|
||||
$sourceSchoolYear = trim((string) ($flag['source_school_year'] ?? ''));
|
||||
if ($studentId <= 0 || $sourceSchoolYear === '' || ! $this->db->tableExists('student_decisions')) {
|
||||
return $type === 'WITHDRAWAL_REVIEW_REQUIRED' ? 'WITHDRAWN' : null;
|
||||
}
|
||||
|
||||
$select = ['decision'];
|
||||
if ($this->db->fieldExists('deliberation_decision_standard', 'student_decisions')) {
|
||||
$select[] = 'deliberation_decision_standard';
|
||||
}
|
||||
|
||||
$row = $this->db->table('student_decisions')
|
||||
->select($select)
|
||||
->where('student_id', $studentId)
|
||||
->where('school_year', $sourceSchoolYear)
|
||||
->orderBy('updated_at', 'DESC')
|
||||
->orderBy('id', 'DESC')
|
||||
->limit(1)
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
if ($row === null) {
|
||||
return match ($type) {
|
||||
'DEFERRED_DELIBERATION' => 'NO_FINAL_DECISION',
|
||||
'WITHDRAWAL_REVIEW_REQUIRED' => 'WITHDRAWN',
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
$decision = DeliberationDecision::normalize($row['deliberation_decision_standard'] ?? null)
|
||||
?? DeliberationDecision::normalize($row['decision'] ?? null);
|
||||
|
||||
return match ($decision) {
|
||||
DeliberationDecision::DEFERRED_DECISION => 'DEFERRED_DECISION',
|
||||
DeliberationDecision::EXPELLED => 'EXPELLED',
|
||||
DeliberationDecision::WITHDRAWN => 'WITHDRAWN',
|
||||
DeliberationDecision::MAKE_UP_EXAM => 'MAKE_UP_EXAM',
|
||||
null => $type === 'DEFERRED_DELIBERATION' ? 'UNRECOGNIZED_DECISION' : null,
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
private function enrollmentFollowups(string $schoolYear, array $flags = []): array
|
||||
{
|
||||
if (! $this->db->tableExists('enrollments')) {
|
||||
|
||||
Reference in New Issue
Block a user