fix is_active student flag logic and make moving with enrollment status
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 47s
Tests / PHPUnit (push) Successful in 1m16s

This commit is contained in:
root
2026-08-20 03:11:37 -04:00
parent 6f722795c5
commit 0a31aa1393
20 changed files with 588 additions and 489 deletions
+18 -8
View File
@@ -609,17 +609,27 @@ class PaymentController extends ResourceController
$db = $this->db;
$db->transBegin();
try {
$builder = $db->table('enrollments');
$builder->set('enrollment_status', 'enrolled')
->set('enrollment_date', local_date(utc_now(), 'Y-m-d')) // or 'CURRENT_DATE()' with false flag
->whereIn('id', $toUpdateIds);
$rowsToUpdate = $db->table('enrollments')
->whereIn('id', $toUpdateIds)
->get()
->getResultArray();
$statusService = \Config\Services::enrollmentStatus(false);
if ($builder->update() === false) {
$err = $db->error();
throw new \RuntimeException('Enrollments update failed: ' . ($err['message'] ?? 'unknown DB error'));
foreach ($rowsToUpdate as $row) {
$statusService->upsertStatus([
'id' => (int) $row['id'],
'student_id' => (int) $row['student_id'],
'parent_id' => (int) $row['parent_id'],
'school_year' => (string) $row['school_year'],
'semester' => (string) ($row['semester'] ?? ''),
'enrollment_date' => local_date(utc_now(), 'Y-m-d'),
'enrollment_status' => 'enrolled',
'admission_status' => 'accepted',
'updated_at' => utc_now(),
], (int) (session()->get('user_id') ?? 0) ?: null, 'payment_completed');
}
$affected = $db->affectedRows();
$affected = count($rowsToUpdate);
$db->transCommit();
log_message(