authenticate(); $authRole = $auth->role ?? ''; if ($authRole !== 'super_admin' && $authRole !== 'admin') { jsonError("غير مصرح لك. فقط المشرف العام يمكنه تفعيل الحسابات."); exit; } if ($type === 'admin') { $stmt = $con->prepare("UPDATE adminUser SET status = 'active' WHERE id = :id AND status = 'pending'"); $stmt->execute([':id' => $userId]); if ($stmt->rowCount() > 0) { printSuccess(["message" => "تم تفعيل حساب المشرف بنجاح."]); } else { jsonError("لم يتم العثور على حساب مشرف معلق بهذا المعرف."); } } elseif ($type === 'service') { $stmt = $con->prepare("UPDATE users SET status = 'approved' WHERE id = :id AND status = 'pending' AND user_type = 'service'"); $stmt->execute([':id' => $userId]); if ($stmt->rowCount() > 0) { printSuccess(["message" => "تم تفعيل حساب موظف الخدمة بنجاح."]); } else { jsonError("لم يتم العثور على حساب موظف خدمة معلق بهذا المعرف."); } } else { jsonError("نوع حساب غير صالح."); } } catch (Exception $e) { error_log("[Staff Activate Error] " . $e->getMessage()); jsonError("An internal error occurred. Please try again later."); } exit();