<?php $__env->startSection('title', 'Riwayat Presensi'); ?>
<?php $__env->startSection('page-title', 'Riwayat Kehadiran Saya'); ?>
<?php $__env->startSection('page-subtitle', 'Daftar riwayat absensi masuk, jam pulang, keterlambatan, dan status kehadiran Anda.'); ?>

<?php $__env->startSection('content'); ?>
<div class="card shadow-sm border-0 mb-4">
    <div class="card-body p-3">
        <form method="GET" action="<?php echo e(route('employee.attendance.history')); ?>" class="row g-2 align-items-center">
            <div class="col-6 col-md-4">
                <select name="month" class="form-select bg-light border-0">
                    <option value="">Semua Bulan</option>
                    <?php for($m = 1; $m <= 12; $m++): ?>
                        <option value="<?php echo e($m); ?>" <?php echo e(request('month') == $m ? 'selected' : ''); ?>>
                            <?php echo e(\Carbon\Carbon::create(null, $m)->translatedFormat('F')); ?>

                        </option>
                    <?php endfor; ?>
                </select>
            </div>
            <div class="col-6 col-md-4">
                <select name="year" class="form-select bg-light border-0">
                    <option value="">Semua Tahun</option>
                    <?php for($y = date('Y'); $y >= date('Y') - 3; $y--): ?>
                        <option value="<?php echo e($y); ?>" <?php echo e(request('year') == $y ? 'selected' : ''); ?>><?php echo e($y); ?></option>
                    <?php endfor; ?>
                </select>
            </div>
            <div class="col-12 col-md-4 d-flex gap-1">
                <button type="submit" class="btn btn-primary w-100"><i class="bi bi-funnel me-1"></i> Filter Riwayat</button>
                <?php if(request()->hasAny(['month', 'year'])): ?>
                    <a href="<?php echo e(route('employee.attendance.history')); ?>" class="btn btn-light"><i class="bi bi-arrow-counterclockwise"></i></a>
                <?php endif; ?>
            </div>
        </form>
    </div>
</div>

<div class="card shadow-sm border-0">
    <div class="card-body p-0">
        <div class="table-responsive">
            <table class="table table-hover align-middle mb-0">
                <thead class="bg-light">
                    <tr>
                        <th class="ps-4">Tanggal</th>
                        <th>Shift</th>
                        <th>Jam Masuk</th>
                        <th>Jam Pulang</th>
                        <th>Status</th>
                        <th>Keterlambatan</th>
                        <th>Jarak Dari Kantor</th>
                        <th class="pe-4">Catatan</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $attendances; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $att): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td class="ps-4">
                                <strong><?php echo e(\Carbon\Carbon::parse($att->attendance_date)->translatedFormat('l, d F Y')); ?></strong>
                            </td>
                            <td><?php echo e($att->shift?->name ?? 'Shift Reguler'); ?></td>
                            <td>
                                <?php if($att->check_in): ?>
                                    <span class="fw-bold text-success"><?php echo e(\Carbon\Carbon::parse($att->check_in)->format('H:i')); ?> WIB</span>
                                <?php else: ?>
                                    <span class="text-muted">-</span>
                                <?php endif; ?>
                            </td>
                            <td>
                                <?php if($att->check_out): ?>
                                    <span class="fw-bold text-danger"><?php echo e(\Carbon\Carbon::parse($att->check_out)->format('H:i')); ?> WIB</span>
                                <?php else: ?>
                                    <span class="text-muted">-</span>
                                <?php endif; ?>
                            </td>
                            <td>
                                <span class="badge <?php echo e($att->status_badge); ?>"><?php echo e($att->status_label); ?></span>
                            </td>
                            <td>
                                <?php if($att->late_minutes > 0): ?>
                                    <span class="text-danger fw-bold">+<?php echo e($att->late_minutes); ?> Menit</span>
                                <?php else: ?>
                                    <span class="text-success"><i class="bi bi-check2"></i> Tepat Waktu</span>
                                <?php endif; ?>
                            </td>
                            <td>
                                <?php if($att->distance_in !== null): ?>
                                    <span class="badge bg-light-primary text-primary"><?php echo e(round($att->distance_in)); ?> m</span>
                                <?php else: ?>
                                    <span class="text-muted">-</span>
                                <?php endif; ?>
                            </td>
                            <td class="pe-4 text-xs text-muted">
                                <?php echo e($att->notes ?? '-'); ?>

                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="8" class="text-center py-5 text-muted">
                                <i class="bi bi-calendar-x fs-1 d-block mb-2 text-muted"></i>
                                Belum ada riwayat kehadiran pada filter yang dipilih.
                            </td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>

        <?php if($attendances->hasPages()): ?>
            <div class="p-3 border-top d-flex justify-content-end">
                <?php echo e($attendances->links('pagination::bootstrap-5')); ?>

            </div>
        <?php endif; ?>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\absensi\resources\views/employee/attendance/history.blade.php ENDPATH**/ ?>