<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">
    <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
        <h1 class="h2">Attendance</h1>
        <a href="/administrator/attendance/create" class="btn btn-primary">Add New Attendance Record</a>
    </div>
    <table class="table table-striped mt-3">
        <thead>
            <tr>
                <th>ID</th>
                <th>Student Name</th>
                <th>Date</th>
                <th>Status</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
            <?php if (!empty($attendances)): ?>
                <?php foreach ($attendances as $attendance): ?>
                    <tr>
                        <td><?php echo $attendance['id']; ?></td>
                        <td><?php echo $attendance['student_name']; ?></td>
                        <td><?= !empty($attendance['date']) ? esc(local_date($attendance['date'], 'm-d-Y')) : '' ?></td>
                        <td><?php echo $attendance['status']; ?></td>
                        <td>
                            <a href="/administrator/attendance/edit/<?php echo $attendance['id']; ?>" class="btn btn-warning">Edit</a>
                            <a href="/administrator/attendance/delete/<?php echo $attendance['id']; ?>" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete this attendance record?');">Delete</a>
                        </td>
                    </tr>
                <?php endforeach; ?>
            <?php else: ?>
                <tr>
                    <td colspan="5">No attendance records found.</td>
                </tr>
            <?php endif; ?>
        </tbody>
    </table>
</main>
