

<?php $__env->startSection('title', ''); ?>

<?php $__env->startSection('content'); ?>

<style>
    .bg-pink { background-color: #667722ff !important; }
</style>

<div class="card">
    <div class="card-header bg-pink text-white d-flex justify-content-between align-items-center">
            <div>
                <h5 class="mb-0"><i class="bi bi-star me-1"></i> Kehadiran</h5>
                <p class="mb-0 small text-white-50">Halaman Data Kehadiran Peserta Didik</p>
            </div>
        </div>
        <?php
            $activePeriode = \App\Models\Periode::where('status', \App\Models\Periode::STATUS_AKTIF)->first();
            $tahunPel = $activePeriode->tahun_pelajaran ?? '-';
            $semester = $activePeriode->semester ?? '-';
        ?>
        <div class="card-body">
            <div class="mb-3 d-flex justify-content-between align-items-start">
                <div>
                    <h5 class="mb-1">Data Kehadiran Peserta Didik</h5>
                    <div class="small text-muted">Tahun Pelajaran: <strong><?php echo e($tahunPel); ?></strong> &nbsp;|&nbsp; Semester: <strong><?php echo e($semester); ?></strong></div>
                </div>
                <div>
                    <a href="<?php echo e(url('guru/pendukung/kehadiran')); ?>" class="btn btn-primary btn-sm"><i class="bi bi-search me-1"></i> Pilih Kelas</a>
                </div>
            </div>

            <?php if(session('status')): ?>
                <div class="alert alert-success alert-dismissible fade show" role="alert">
                    <?php echo e(session('status')); ?>

                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                </div>
            <?php endif; ?>

            <?php if($errors->any()): ?>
                <div class="alert alert-danger"><?php echo e($errors->first()); ?></div>
            <?php endif; ?>

            <form method="GET" class="mb-3">
                <div class="row g-2 align-items-end">
                    <div class="col-md-6">
                        <label class="form-label">Pilih Kelas</label>
                        <select name="kelas_id" class="form-select" onchange="this.form.submit()">
                            <option value="">-- Pilih Kelas --</option>
                            <?php $__currentLoopData = $kelasList ?? []; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($k->id); ?>" <?php if(isset($selected) && $selected && $selected->id == $k->id): ?> selected <?php endif; ?>><?php echo e($k->nama); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div class="col-md-6">
                        <a href="<?php echo e(url('guru/pendukung/kehadiran')); ?>" class="btn btn-secondary">Reset</a>
                    </div>
                </div>
            </form>

            <?php if(isset($selected) && $selected): ?>
                <div class="mb-2"><strong>Menampilkan data untuk :</strong> <?php echo e($selected->nama); ?> </div>

                <form method="POST" action="<?php echo e(url('guru/pendukung/kehadiran/update')); ?>">
                    <?php echo csrf_field(); ?>
                    <input type="hidden" name="kelas_id" value="<?php echo e($selected->id); ?>">
                    <div class="table-responsive">
                        <table class="table table-striped table-sm table-bordered">
                        <thead>
                            <tr>
                                <th>Nama Peserta Didik</th>
                                <th class="small-col">NIS</th>
                                <th class="small-col">NISN</th>
                                <th class="small-col">Sakit</th>
                                <th class="small-col">Ijin</th>
                                <th class="small-col">Tanpa Keterangan</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $pesertas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td><?php echo e($p->nama ?? '-'); ?></td>
                                    <td><?php echo e($p->nis ?? '-'); ?></td>
                                    <td><?php echo e($p->nisn ?? '-'); ?></td>
                                    <td>
                                        <input type="number" min="0" name="attendance[<?php echo e($p->id); ?>][sakit]" value="<?php echo e(old('attendance.'.$p->id.'.sakit', $p->sakit ?? 0)); ?>" class="form-control form-control-sm">
                                    </td>
                                    <td>
                                        <input type="number" min="0" name="attendance[<?php echo e($p->id); ?>][ijin]" value="<?php echo e(old('attendance.'.$p->id.'.ijin', $p->ijin ?? 0)); ?>" class="form-control form-control-sm">
                                    </td>
                                    <td>
                                        <input type="number" min="0" name="attendance[<?php echo e($p->id); ?>][tanpa_keterangan]" value="<?php echo e(old('attendance.'.$p->id.'.tanpa_keterangan', $p->tanpa_keterangan ?? 0)); ?>" class="form-control form-control-sm">
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="6" class="text-center">Tidak ada data peserta untuk kelas ini.</td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                    <div class="d-flex justify-content-end">
                        <button type="submit" class="btn btn-success">Simpan Kehadiran</button>
                    </div>
                </form>
                </div>
            <?php endif; ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('guru.layout', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\App\laravel\laravel\resources\views/guru/pendukung/kehadiran/index.blade.php ENDPATH**/ ?>