<?php
include("../includes/auth.php");
include("../config/db.php");
include("../includes/header.php");
include("../includes/sidebar.php");

$result = $conn->query("
    SELECT sr.*, u.name as requested_by_name
    FROM suspicious_requests sr
    LEFT JOIN users u ON sr.requested_by = u.id
    WHERE sr.status='approved_by_village'
    ORDER BY sr.id DESC
");
?>

<h3>Pending Approvals (Super Admin)</h3>

<table class="table table-bordered">
<tr>
    <th>ID</th>
    <th>Requested By</th>
    <th>Role</th>
    <th>Reason</th>
    <th>Status</th>
    <th>Action</th>
</tr>

<?php while($row = $result->fetch_assoc()) { ?>
<tr>
    <td><?= $row['id'] ?></td>
    <td><?= $row['requested_by_name'] ?></td>
    <td><?= $row['requested_role'] ?></td>
    <td><?= $row['reason'] ?></td>
    <td><?= $row['status'] ?></td>
    <td>
        <a href="view.php?id=<?= $row['id'] ?>" class="btn btn-primary btn-sm">View</a>
    </td>
</tr>
<?php } ?>
</table>

<?php include("../includes/footer.php"); ?>