<?php $__env->startSection('content'); ?>
    <div
        class="mb-6 flex flex-col gap-3 md:flex-row md:items-end md:justify-between"
    >
        <div>
            <div class="text-2xl font-bold text-slate-800 dark:text-white">
                Rekap Kehadiran
            </div>
            <div class="text-sm text-slate-500 dark:text-slate-400">
                <?php if($periode == 'harian'): ?>
    Menampilkan data tanggal:
    <strong><?php echo e(\Carbon\Carbon::parse($tanggal)->format('d M Y')); ?></strong>
<?php endif; ?>

<?php if($periode == 'bulanan'): ?>
    Menampilkan data bulan:
    <strong><?php echo e(\Carbon\Carbon::parse($bulan)->translatedFormat('F Y')); ?></strong>
<?php endif; ?>

<?php if($periode == 'tahunan'): ?>
    Menampilkan data tahun:
    <strong><?php echo e($tahun); ?></strong>
<?php endif; ?>
                
            </div>
        </div>

        <form
            action="<?php echo e(route('guru.rekap-kehadiran.index')); ?>"
            method="GET"
            class="flex items-center gap-2"
        >
           <div class="flex items-center gap-2">

    <select
        name="periode"
        id="periode"
        class="rounded-xl border border-slate-200 bg-white px-4 py-2 text-sm dark:border-slate-800 dark:bg-slate-950 dark:text-white"
        onchange="this.form.submit()"
    >
        <option value="harian" <?php echo e($periode == 'harian' ? 'selected' : ''); ?>>
            Harian
        </option>

        <option value="bulanan" <?php echo e($periode == 'bulanan' ? 'selected' : ''); ?>>
            Bulanan
        </option>

        <option value="tahunan" <?php echo e($periode == 'tahunan' ? 'selected' : ''); ?>>
            Tahunan
        </option>
    </select>
    
    <select
        name="jadwal_id"
        class="rounded-xl border border-slate-200 bg-white px-4 py-2 text-sm dark:border-slate-800 dark:bg-slate-950 dark:text-white"
    >
        <option value="">Pilih Jadwal</option>

        <?php $__currentLoopData = $jadwals; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $jadwal): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <option
                value="<?php echo e($jadwal->jadwal_id); ?>"
                <?php echo e(request('jadwal_id') == $jadwal->jadwal_id ? 'selected' : ''); ?>

            >
                <?php echo e($jadwal->mapel->nama_mapel); ?>

                -
                <?php echo e($jadwal->kelas->nama_kelas); ?>

            </option>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </select>

    <?php if($periode == 'harian'): ?>
        <input
            type="date"
            name="tanggal"
            value="<?php echo e($tanggal); ?>"
            class="rounded-xl border border-slate-200 bg-white px-4 py-2 text-sm dark:border-slate-800 dark:bg-slate-950 dark:text-white"
        >
    <?php endif; ?>

    
    <?php if($periode == 'bulanan'): ?>
        <input
            type="month"
            name="bulan"
            value="<?php echo e($bulan); ?>"
            class="rounded-xl border border-slate-200 bg-white px-4 py-2 text-sm dark:border-slate-800 dark:bg-slate-950 dark:text-white"
        >
    <?php endif; ?>

    <?php if($periode == 'tahunan'): ?>
        <input
            type="number"
            name="tahun"
            value="<?php echo e($tahun); ?>"
            min="2020"
            max="2100"
            class="rounded-xl border border-slate-200 bg-white px-4 py-2 text-sm dark:border-slate-800 dark:bg-slate-950 dark:text-white"
        >
    <?php endif; ?>

</div>
            <button
                type="submit"
                class="inline-flex items-center gap-2 rounded-xl bg-blue-600 px-4 py-2 text-sm font-semibold text-white hover:bg-blue-700 transition-colors"
            >
                <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
                </svg>
                Tampilkan
            </button>
        </form>
    </div>
    <div
        class="overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm dark:border-slate-800 dark:bg-slate-950"
    >
        <div class="overflow-x-auto">
            <table class="w-full text-left text-sm">
                <thead
                    class="bg-slate-50 text-slate-600 dark:bg-slate-900/40 dark:text-slate-300"
                >
                    <tr class="border-b border-slate-200 dark:border-slate-800">
                        <th class="px-4 py-4 font-bold text-center w-12">NO</th>
                        <th class="px-4 py-4 font-bold">NIS</th>
                        <th class="px-4 py-4 font-bold">Nama</th>
                        <th class="px-4 py-4 font-bold text-center">
                            Hadir (H)
                        </th>
                        <th class="px-4 py-4 font-bold text-center">
                            Sakit (S)
                        </th>
                        <th class="px-4 py-4 font-bold text-center">
                            Izin (I)
                        </th>
                        <th class="px-4 py-4 font-bold text-center">
                            Alfa (A)
                        </th>
                    </tr>
                </thead>
                <?php $__currentLoopData = $items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr
                        class="hover:bg-slate-50/50 dark:hover:bg-slate-900/50 transition-colors"
                    >
                        <td class="px-4 py-3 text-center">
                            <?php echo e($items->firstItem() + $index); ?>

                        </td>

                        <td
                            class="px-4 py-3 font-medium text-slate-700 dark:text-slate-200"
                        >
                            <?php echo e($item->nis); ?>

                        </td>

                        <td
                            class="px-4 py-3 text-slate-700 dark:text-slate-200"
                        >
                            <?php echo e($item->nama_siswa); ?>

                        </td>

                        <td
                            class="px-4 py-3 text-center font-semibold text-green-600"
                        >
                            <?php echo e($item->total_hadir ?? 0); ?>

                        </td>
                        <td
                            class="px-4 py-3 text-center font-semibold text-yellow-600"
                        >
                            <?php echo e($item->total_sakit ?? 0); ?>

                        </td>
                        <td
                            class="px-4 py-3 text-center font-semibold text-blue-600"
                        >
                            <?php echo e($item->total_izin ?? 0); ?>

                        </td>
                        <td
                            class="px-4 py-3 text-center font-semibold text-red-600"
                        >
                            <?php echo e($item->total_alfa ?? 0); ?>

                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <tfoot class="bg-slate-50 font-bold dark:bg-slate-900/40">
                    <tr>
                        <td
                            colspan="3"
                            class="px-4 py-3 text-right uppercase tracking-wider"
                        >
                            Total
                        </td>
                        <td class="px-4 py-3 text-center text-green-600">
                            <?php echo e($items->sum('total_hadir')); ?>

                        </td>
                        <td class="px-4 py-3 text-center text-yellow-600">
                            <?php echo e($items->sum('total_sakit')); ?>

                        </td>
                        <td class="px-4 py-3 text-center text-blue-600">
                            <?php echo e($items->sum('total_izin')); ?>

                        </td>
                        <td class="px-4 py-3 text-center text-red-600">
                            <?php echo e($items->sum('total_alfa')); ?>

                        </td>
                    </tr>
                </tfoot>
            </table>
        </div>
    <div class="mt-6 flex justify-end gap-2">

    <a
       href="<?php echo e(route('guru.rekap-kehadiran.pdf', [
    'periode' => $periode,
    'jadwal_id' => request('jadwal_id'),
    'tanggal' => $tanggal,
    'bulan' => $bulan,
    'tahun' => $tahun
])); ?>"
        target="_blank"
        class="inline-flex items-center gap-2 rounded-xl bg-emerald-600 px-4 py-2 text-sm font-bold text-white shadow-md hover:bg-emerald-700 transition-all"
    >
        Cetak PDF
    </a>

    <a
       href="<?php echo e(route('guru.rekap-kehadiran.excel', [
    'periode' => $periode,
    'jadwal_id' => request('jadwal_id'),
    'tanggal' => $tanggal,
    'bulan' => $bulan,
    'tahun' => $tahun
])); ?>"
        class="inline-flex items-center gap-2 rounded-xl bg-green-600 px-4 py-2 text-sm font-bold text-white shadow-md hover:bg-green-700 transition-all"
    >
        Export Excel
    </a>

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

<?php echo $__env->make('layouts.app', ['title' => 'Guru - Rekap Kehadiran'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\sistem-absensi-smkn-2-rupat\resources\views/guru/rekap-kehadiran/index.blade.php ENDPATH**/ ?>