<?= $this->extend('layouts/enterprise') ?>

<?= $this->section('content') ?>

<?= view('partials/workspace_hero', [
    'workspaceCrumbPill'    => 'Reports',
    'workspaceCrumbCurrent' => 'Early Exits',
    'workspaceTitle'        => 'Early Exit Report',
    'workspaceDesc'         => 'Employees who left before their scheduled shift end time.',
]) ?>

<?= $this->include('Modules\Attendance\Views\reports\_filter') ?>

<div class="enterprise-data-panel">
    <div class="enterprise-data-panel__body">
        <div class="table-responsive">
            <table class="enterprise-data-table">
                <thead>
                    <tr>
                        <th>Date</th>
                        <th>Employee</th>
                        <th>Shift</th>
                        <th>Clock Out</th>
                        <th>Early By</th>
                        <th>Status</th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($records as $r): ?>
                        <tr>
                            <td><?= esc(date('M j, Y', strtotime($r['attendance_date']))) ?></td>
                            <td>
                                <span class="enterprise-data-table__primary"><?= esc($r['full_name']) ?></span>
                                <br><small class="text-muted"><?= esc($r['employee_number']) ?></small>
                            </td>
                            <td><?= esc($r['shift_name'] ?? '—') ?></td>
                            <td><?= $r['clock_out'] ? esc(date('h:i A', strtotime($r['clock_out']))) : '—' ?></td>
                            <td class="text-danger fw-semibold"><?= esc($r['early_exit_minutes']) ?> min</td>
                            <td><?= esc(ucwords(str_replace('_', ' ', $r['status']))) ?></td>
                        </tr>
                    <?php endforeach; ?>
                    <?php if (count($records) === 0): ?>
                        <tr><td colspan="6" class="text-center text-muted py-5">No early exits in this period.</td></tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>

<?= $this->endSection() ?>
