Update: 2026-07-12 05:40:28
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
// transit/enrollment/approve.php — المشرف يوافق على طلب عضوية أو يرفضه
|
||||
|
||||
require_once __DIR__ . '/../../transit/connect_admin.php';
|
||||
|
||||
requireTransitFields(['enrollment_id', 'action']);
|
||||
|
||||
$enrollId = filterRequest('enrollment_id', 'int');
|
||||
$action = filterRequest('action');
|
||||
$expiresAt = filterRequest('expires_at');
|
||||
|
||||
if (!in_array($action, ['approve', 'reject'])) jsonError('Invalid action. Use: approve or reject', 400);
|
||||
|
||||
$st = $transit_con->prepare(
|
||||
"SELECT id, passenger_id, status FROM transit_enrollments WHERE id=? AND org_id=? LIMIT 1"
|
||||
);
|
||||
$st->execute([$enrollId, $transit_org_id]);
|
||||
$enroll = $st->fetch();
|
||||
|
||||
if (!$enroll) jsonError('Enrollment not found', 404);
|
||||
if ($enroll['status'] !== 'pending') jsonError('Enrollment is not pending', 409);
|
||||
|
||||
$newStatus = ($action === 'approve') ? 'active' : 'suspended';
|
||||
$transit_con->prepare(
|
||||
"UPDATE transit_enrollments
|
||||
SET status=?, verified_at=NOW(), verify_method='manual_admin', expires_at=?
|
||||
WHERE id=?"
|
||||
)->execute([$newStatus, $expiresAt, $enrollId]);
|
||||
|
||||
if ($action === 'approve' && $enroll['passenger_id']) {
|
||||
transitSendTopicNotification(
|
||||
'passenger_' . $enroll['passenger_id'],
|
||||
'تم تفعيل عضويتك',
|
||||
'يمكنك الآن متابعة باصات جامعتك عبر مواصلاتي',
|
||||
['type' => 'transit_enrollment_approved']
|
||||
);
|
||||
}
|
||||
|
||||
jsonSuccess(['enrollment_id' => $enrollId, 'status' => $newStatus]);
|
||||
Reference in New Issue
Block a user