<?php
require_once "../includes/auth.php";
require_once "../config/db.php";
$stmt = $pdo->query("SELECT * FROM users ORDER BY id DESC");
?>
<!DOCTYPE html>
<html lang="ar">
<head>
    <meta charset="UTF-8"><title>المستخدمون</title>
</head>
<body>
    <h2>المستخدمون</h2>
    <table border="1" cellpadding="6">
        <tr>
            <th>اسم المستخدم</th>
            <th>الدور</th>
            <th>تحكم</th>
        </tr>
        <?php foreach($stmt as $u): ?>
        <tr>
            <td><?= htmlspecialchars($u['username']) ?></td>
            <td><?= htmlspecialchars($u['role']) ?></td>
            <td>
                <a href="user_edit.php?id=<?= $u['id'] ?>">تعديل</a> |
                <a href="user_delete.php?id=<?= $u['id'] ?>" onclick="return confirm('تأكيد الحذف؟')">حذف</a>
            </td>
        </tr>
        <?php endforeach; ?>
    </table>
</body>
</html>
