<?php $__env->startSection('title', 'Hari Libur - MagangTime'); ?>
<?php $__env->startSection('page-title', 'Hari Libur'); ?>

<?php $__env->startSection('content'); ?>
<div class="card">
    <div class="card-header bg-white">
        <div class="row align-items-center">
            <div class="col-12 col-md-6 mb-2 mb-md-0">
                <h5 class="mb-0"><i class="fas fa-calendar-alt me-2"></i>Kelola Hari Libur</h5>
            </div>
            <div class="col-12 col-md-6 text-md-end">
                <button type="button" class="btn btn-primary w-100 w-md-auto" data-bs-toggle="modal" data-bs-target="#addHolidayModal">
                    <i class="fas fa-plus me-2"></i>Tambah Hari Libur
                </button>
            </div>
        </div>
        
        <div class="row mt-3">
            <div class="col-12 col-md-8">
                <form method="GET" action="<?php echo e(route('admin.holidays')); ?>" class="d-flex flex-column flex-sm-row">
                    <input type="text" name="search" class="form-control me-sm-2 mb-2 mb-sm-0" 
                           placeholder="Cari deskripsi atau tanggal..." 
                           value="<?php echo e(request('search')); ?>">
                    <div class="d-flex">
                        <button type="submit" class="btn btn-outline-primary flex-fill"><i class="fas fa-search"></i></button>
                        <?php if(request('search')): ?>
                            <a href="<?php echo e(route('admin.holidays')); ?>" class="btn btn-outline-secondary ms-2"><i class="fas fa-times"></i></a>
                        <?php endif; ?>
                    </div>
                </form>
            </div>
        </div>
    </div>
    
    <div class="card-body">
        <?php if($errors->any()): ?>
            <div class="alert alert-danger">
                <ul class="mb-0">
                    <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <li><?php echo e($error); ?></li>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </ul>
            </div>
        <?php endif; ?>
        
        
        <div class="table-responsive d-none d-md-block">
            <table class="table table-striped table-hover">
                <thead class="table-dark">
                    <tr>
                        <th width="5%" class="text-center">No</th>
                        <th>Tanggal</th>
                        <th class="text-center" width="50%">Deskripsi</th>
                        <th width="10%" class="text-center">Status</th>
                        <th width="8%" class="text-center">Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $holidays; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $holiday): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td class="text-center"><?php echo e($holidays->firstItem() + $index); ?></td>
                        <td><?php echo e($holiday->date->isoFormat('dddd, D MMMM Y')); ?></td>
                        <td class="text-center"><?php echo e($holiday->description); ?></td>
                        <td class="text-center">
                            <?php if($holiday->date->isPast()): ?>
                                <span class="badge bg-secondary">Lewat</span>
                            <?php elseif($holiday->date->isToday()): ?>
                                <span class="badge bg-info">Hari Ini</span>
                            <?php else: ?>
                                <span class="badge bg-success">Mendatang</span>
                            <?php endif; ?>
                        </td>
                        <td>
                            <div class="btn-group text-center" role="group">
                                <button class="btn btn-sm btn-warning" onclick="editHoliday(<?php echo e($holiday->id); ?>, '<?php echo e($holiday->date->format('Y-m-d')); ?>', '<?php echo e($holiday->description); ?>')">
                                    <i class="fas fa-edit"></i>
                                </button>
                                <button class="btn btn-sm btn-danger" onclick="confirmDelete(<?php echo e($holiday->id); ?>, '<?php echo e($holiday->description); ?>')">
                                    <i class="fas fa-trash"></i>
                                </button>
                            </div>
                        </td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="5" class="text-center text-muted py-4">
                            <i class="fas fa-calendar-alt fa-3x mb-3"></i>
                            <p><?php echo e(request('search') ? 'Tidak ditemukan hari libur' : 'Belum ada hari libur yang ditetapkan'); ?></p>
                        </td>
                    </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>

        
        <div class="d-block d-md-none">
            <?php $__empty_1 = true; $__currentLoopData = $holidays; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $holiday): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <div class="card mb-3 border-start border-primary border-4">
                <div class="card-body py-3">
                    <div class="d-flex justify-content-between align-items-start mb-2">
                        <h6 class="fw-bold mb-1"><?php echo e($holiday->description); ?></h6>
                        <small class="text-muted">#<?php echo e($holidays->firstItem() + $index); ?></small>
                    </div>
                    <div class="row">
                        <div class="col-6">
                            <small class="text-muted">Tanggal:</small><br>
                            <small><?php echo e($holiday->date->isoFormat('dddd, D MMMM Y')); ?></small>
                        </div>
                        <div class="col-6">
                            <small class="text-muted">Status:</small><br>
                            <?php if($holiday->date->isPast()): ?>
                                <span class="badge bg-secondary">Lewat</span>
                            <?php elseif($holiday->date->isToday()): ?>
                                <span class="badge bg-info">Hari Ini</span>
                            <?php else: ?>
                                <span class="badge bg-success">Mendatang</span>
                            <?php endif; ?>
                        </div>
                    </div>
                    <div class="d-flex gap-2 mt-3">
                        <button class="btn btn-sm btn-warning flex-fill" onclick="editHoliday(<?php echo e($holiday->id); ?>, '<?php echo e($holiday->date->format('Y-m-d')); ?>', '<?php echo e($holiday->description); ?>')">
                            <i class="fas fa-edit me-1"></i>Edit
                        </button>
                        <button class="btn btn-sm btn-danger flex-fill" onclick="confirmDelete(<?php echo e($holiday->id); ?>, '<?php echo e($holiday->description); ?>')">
                            <i class="fas fa-trash me-1"></i>Hapus
                        </button>
                    </div>
                </div>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <div class="text-center text-muted py-5">
                <i class="fas fa-calendar-alt fa-3x mb-3"></i>
                <p><?php echo e(request('search') ? 'Tidak ditemukan hari libur' : 'Belum ada hari libur yang ditetapkan'); ?></p>
            </div>
            <?php endif; ?>
        </div>
        
        <?php if($holidays->hasPages()): ?>
            <?php echo e($holidays->appends(request()->query())->links('pagination::bootstrap-4')); ?>

        <?php endif; ?>
    </div>
</div>

<?php echo $__env->make('admin.libur.tambah', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<?php echo $__env->make('admin.libur.edit', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<?php echo $__env->make('admin.libur.hapus', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<?php echo $__env->make('admin.libur.script', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

<?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\presensi-magang\resources\views/admin/libur/index.blade.php ENDPATH**/ ?>