 

<?php $__env->startSection('title', 'Booking - ' . strtoupper(str_replace('_', ' ', $room))); ?>

<?php $__env->startSection('content'); ?>
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1 class="h4 fw-bold mb-0">
            <i class="bi bi-calendar-event"></i>
            Booking - <?php echo e(strtoupper(str_replace('_', ' ', $room))); ?>

        </h1>
    </div>

    
    <div class="mb-3 d-flex gap-2 flex-wrap">
        <a href="<?php echo e(url('/booking-admin/' . $room . '/bookings')); ?>" 
           class="btn btn-sm <?php echo e(request('filter') ? 'btn-outline-secondary' : 'btn-success'); ?>">
           Semua
        </a>
        <a href="<?php echo e(url('/booking-admin/' . $room . '/bookings?filter=hari-ini')); ?>" 
           class="btn btn-sm <?php echo e(request('filter') === 'hari-ini' ? 'btn-success' : 'btn-outline-secondary'); ?>">
           Hari Ini
        </a>
        <a href="<?php echo e(url('/booking-admin/' . $room . '/bookings?filter=akan-datang')); ?>" 
           class="btn btn-sm <?php echo e(request('filter') === 'akan-datang' ? 'btn-success' : 'btn-outline-secondary'); ?>">
           Akan Datang
        </a>
        <a href="<?php echo e(url('/booking-admin/' . $room . '/bookings?filter=selesai')); ?>" 
           class="btn btn-sm <?php echo e(request('filter') === 'selesai' ? 'btn-success' : 'btn-outline-secondary'); ?>">
           Selesai
        </a>
    </div>

    
    <div class="card shadow-sm mb-4">
        <div class="card-body d-flex flex-wrap align-items-end gap-3">
            <form action="<?php echo e(url('/booking-admin/' . $room . '/bookings')); ?>" method="GET" class="d-flex flex-wrap gap-2">
                <div>
                    <label class="form-label fw-semibold mb-1">Rentang Tanggal</label>
                    <div class="d-flex gap-2">
                        <input type="date" name="start_date" class="form-control form-control-sm"
                               value="<?php echo e(request('start_date')); ?>">
                        <input type="date" name="end_date" class="form-control form-control-sm"
                               value="<?php echo e(request('end_date')); ?>">
                    </div>
                </div>

                <div>
                    <label class="form-label fw-semibold mb-1">Filter Cepat</label>
                    <select name="range" class="form-select form-select-sm">
                        <option value="">-- Pilih --</option>
                        <option value="today" <?php echo e(request('range') == 'today' ? 'selected' : ''); ?>>Hari Ini</option>
                        <option value="week" <?php echo e(request('range') == 'week' ? 'selected' : ''); ?>>Minggu Ini</option>
                        <option value="month" <?php echo e(request('range') == 'month' ? 'selected' : ''); ?>>Bulan Ini</option>
                    </select>
                </div>

                <div class="d-flex gap-2 align-items-end">
                    <button type="submit" class="btn btn-sm btn-success">
                        <i class="bi bi-funnel"></i> Tampilkan
                    </button>

                    
                    <a href="<?php echo e(url('/booking-admin/' . $room . '/bookings/export?start_date=' . request('start_date') . '&end_date=' . request('end_date') . '&range=' . request('range'))); ?>"
                        class="btn btn-sm btn-outline-primary">
                        <i class="bi bi-file-earmark-excel"></i> Export Excel
                    </a>
                </div>
            </form>
        </div>
    </div>

    
    <?php if(session('success')): ?>
        <div class="alert alert-success alert-dismissible fade show shadow-sm" role="alert">
            <i class="bi bi-check-circle-fill"></i> <?php echo e(session('success')); ?>

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

    
    <?php if(session('error')): ?>
        <div class="alert alert-danger alert-dismissible fade show shadow-sm" role="alert">
            <i class="bi bi-exclamation-triangle-fill"></i> <?php echo e(session('error')); ?>

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

    <div class="table-responsive shadow-sm rounded">
        <table class="table table-hover align-middle mb-0">
            <thead class="table-success text-dark">
                <tr>
                    <th>PIC</th>
                    <th>Tanggal</th>
                    <th>Jam</th>
                    <th>Departemen</th>
                    <th>Keterangan</th>
                    <th class="text-center">Aksi</th>
                </tr>
            </thead>
            <tbody>
                <?php $__empty_1 = true; $__currentLoopData = $bookings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $booking): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <?php
                        $today = \Carbon\Carbon::today();
                        $date = \Carbon\Carbon::parse($booking->date);
                        $rowClass = '';
                        $statusBadge = '';

                        if ($date->isToday()) {
                            $rowClass = 'table-success';
                            $statusBadge = '<span class="badge bg-success">Hari ini</span>';
                        } elseif ($date->isPast()) {
                            $rowClass = 'table-secondary';
                            $statusBadge = '<span class="badge bg-secondary">Selesai</span>';
                        } else {
                            $statusBadge = '<span class="badge bg-info text-dark">Akan datang</span>';
                        }
                    ?>

                    <tr class="<?php echo e($rowClass); ?>">
                        <td><?php echo e($booking->pic); ?></td>
                        <td>
                            <i class="bi bi-calendar-date text-success"></i>
                            <?php echo e($date->format('d M Y')); ?>

                            <?php echo $statusBadge; ?>

                        </td>
                        <td>
                            <span class="badge bg-primary">
                                <?php echo e($booking->start_time); ?> - <?php echo e($booking->end_time); ?>

                            </span>
                        </td>
                        <td><?php echo e($booking->department ?? '-'); ?></td>
                        <td><?php echo e($booking->keterangan ?? '-'); ?></td>
                        <td class="text-center">
                            <div class="d-flex justify-content-center gap-2">
                                <a href="<?php echo e(url('/booking-admin/' . $room . '/bookings/' . $booking->id . '/edit')); ?>"
                                   class="btn btn-sm btn-outline-primary">
                                   <i class="bi bi-pencil-square"></i> Edit
                                </a>
                                <form action="<?php echo e(url('/booking-admin/' . $room . '/bookings/' . $booking->id)); ?>"
                                      method="POST" onsubmit="return confirm('Yakin ingin hapus booking ini?')">
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('DELETE'); ?>
                                    <button type="submit" class="btn btn-sm btn-outline-danger">
                                        <i class="bi bi-trash"></i> Hapus
                                    </button>
                                </form>
                            </div>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="6" class="text-center text-muted py-4">
                            <i class="bi bi-calendar-x fs-4"></i> <br>
                            Belum ada data booking
                        </td>
                    </tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\Hafiiz\Project\Code Magang\Finall\Apps Asama Layer Security\booking-ruangan-tamu\resources\views/admin/bookings.blade.php ENDPATH**/ ?>