<?php include 'includes/header.php'; ?>
<?php include 'includes/sidebar.php'; ?>
<?php require 'includes/db_connect.php'; ?>

<div class="container mt-4">
    <h4 class="text-orange">Staff List</h4>

    <table class="table table-bordered table-striped mt-3">
        <thead class="bg-orange text-white">
            <tr>
                <th>#</th>
                <th>Full Name</th>
                <th>Email</th>
                <th>Phone</th>
                <th>Action</th>
            </tr>
        </thead>
        <tbody>
            <?php
            $staffs = $conn->query("SELECT * FROM staff ORDER BY id DESC");
            if ($staffs->num_rows > 0) {
                $sn = 1;
                while ($row = $staffs->fetch_assoc()) {
                    echo "
                    <tr>
                        <td>{$sn}</td>
                        <td>{$row['fullname']}</td>
                        <td>{$row['email']}</td>
                        <td>{$row['phone']}</td>
                        <td>
                            <a href='issue_query.php?staff_id={$row['id']}' class='btn btn-sm btn-danger'>Issue Query</a>
                            <a href='minute_mail.php?staff_id={$row['id']}' class='btn btn-sm btn-primary text-white'>Minute Mail</a>
                            <a href='send_mail.php?staff_id={$row['id']}' class='btn btn-sm btn-info text-white'>Send Email</a>
                            <a href='send_sms.php?staff_id={$row['id']}' class='btn btn-sm btn-warning'>Send SMS</a>
                        </td>
                    </tr>";
                    $sn++;
                }
            } else {
                echo "<tr><td colspan='5' class='text-center'>No Staff Found</td></tr>";
            }
            ?>
        </tbody>
    </table>
</div>

<?php include 'includes/footer.php'; ?>
