<?php
require './partials/head.php';
?>
<body>
    <?php require './partials/sidebar.php'; ?>
    <main class="dashboard-main">
        <?php require './partials/header.php'; ?>
        <!-- </?php require './successerror.php'; ?> -->

        <div class="dashboard-main-body">
            <div class="d-flex flex-wrap align-items-center justify-content-between gap-3 mb-24">
                <h6 class="fw-semibold mb-0">suspended Users</h6>
                <ul class="d-flex align-items-center gap-2">
                    <li class="fw-medium">
                        <a href="dashboard" class="d-flex align-items-center gap-1 hover-text-primary">
                            <iconify-icon icon="solar:home-smile-angle-outline" class="icon text-lg"></iconify-icon>
                            Dashboard
                        </a>
                    </li>
                </ul>
            </div>
            <div class="row gy-4">
                <div class="col-lg-12">
                    <div class="card">
                        <div class="card-body">
                            <div class="table-responsive">
                                <table class="table table-hover style-1 bordered-table mb-0" id="dataTable">
                                    <thead>
                                        <tr>
                                            <th>#Date</th>
                                            <th>Full Name</th>
                                            <th>Phone Number</th>
                                            <th>Email</th>
                                            <th>Action</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        $query = "SELECT * FROM users WHERE status = 'suspended' ORDER BY dname ASC";
                                        $stmt = $conn->prepare($query);
                                        $stmt->execute();
                                        $result = $stmt->get_result();

                                        if ($result->num_rows > 0) {
                                            while ($row = $result->fetch_assoc()) {
                                        ?>
                                                <tr>
                                                    <td><?= formatDateTime($row['date'])?></td>
                                                    <td><?= $row['dname'] ?></td>
                                                    <td><?= $row['dnumber'] ?></td>
                                                    <td><?= $row['demail'] ?></td>
                                                    <td>
                                                        <a href="users/<?= ($row['userid']) ?>" class="btn btn-primary btn-sm">
                                                            <i class="fas fa-eye" style="color: white;"></i> Details
                                                        </a>
                                                    </td>

                                                </tr>
                                        <?php
                                            }
                                        } else {
                                            echo "<tr><td colspan='7' class='text-center alert alert-danger'>No users suspended found yet.</td></tr>";

                                        }
                                        ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <?php require './partials/footer.php'; ?>
    </main>
    <?php require './partials/scripts.php'; ?>
    
</body>

</html>