<?php
header("Content-Type: application/json; charset=UTF-8");
include_once 'db_connect.php';

$user_id = isset($_GET['user_id']) ? $_GET['user_id'] : null;

if ($user_id) {
    try {
        // جلب البيانات من جدول المستخدمين مباشرة للأدمن
        $sql = "SELECT id, full_name, email, phone, city, address, profile_image, role_id, created_at 
                FROM users 
                WHERE id = ?";

        $stmt = $conn->prepare($sql);
        $stmt->execute([$user_id]);
        $adminData = $stmt->fetch(PDO::FETCH_ASSOC);

        if ($adminData) {
            echo json_encode([
                "status" => "success",
                "data" => $adminData
            ]);
        } else {
            echo json_encode(["status" => "error", "message" => "المستخدم غير موجود"]);
        }
    } catch (PDOException $e) {
        echo json_encode(["status" => "error", "message" => $e->getMessage()]);
    }
} else {
    echo json_encode(["status" => "error", "message" => "user_id مفقود"]);
}
?>