<?php
    $title = 'Бронирования — Hotel Pineta';
    $heading = 'Бронирования';
    $subheading = 'Журнал бронирований новой Laravel-базы';
?>



<?php $__env->startSection('content'); ?>
    <div class="card">
        <div class="actions-row" style="justify-content: space-between; margin-bottom: 14px;">
            <h3 style="margin:0;">Фильтры</h3>
            <a href="<?php echo e(route('admin.bookings.create')); ?>" class="primary">Новая бронь</a>
        </div>

        <form method="get" class="filters">
            <div class="field">
                <label for="status">Статус</label>
                <select id="status" name="status">
                    <option value="">Все</option>
                    <?php $__currentLoopData = $statuses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($value); ?>" <?php if($filters['status'] === $value): echo 'selected'; endif; ?>><?php echo e($label); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>

            <div class="field">
                <label for="source">Источник</label>
                <select id="source" name="source">
                    <option value="">Все</option>
                    <?php $__currentLoopData = $sources; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($value); ?>" <?php if($filters['source'] === $value): echo 'selected'; endif; ?>><?php echo e($label); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>

            <div class="field">
                <label for="room_id">Комната</label>
                <select id="room_id" name="room_id">
                    <option value="">Все</option>
                    <?php $__currentLoopData = $rooms; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $room): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($room->id); ?>" <?php if($filters['room_id'] === (string) $room->id): echo 'selected'; endif; ?>>№ <?php echo e($room->code); ?> — <?php echo e($room->title); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>

            <div class="field">
                <label for="arrival_date">Дата заезда</label>
                <input id="arrival_date" type="date" name="arrival_date" value="<?php echo e($filters['arrival_date']); ?>">
            </div>

            <div class="field">
                <label for="search">Поиск</label>
                <input id="search" type="text" name="search" value="<?php echo e($filters['search']); ?>" placeholder="Имя, телефон, e-mail, номер брони">
            </div>

            <div class="field-inline" style="grid-column: 1 / -1;">
                <div class="help">Фильтры уже работают по статусу, источнику, комнате, дате заезда и поисковой строке.</div>
                <div class="actions-row">
                    <a href="<?php echo e(route('admin.bookings.index')); ?>" class="secondary">Сбросить</a>
                    <button type="submit" class="primary">Применить</button>
                </div>
            </div>
        </form>
    </div>

    <div class="card" style="margin-top: 18px;">
        <h3>Журнал бронирований</h3>

        <?php if($bookings->isEmpty()): ?>
            <div class="empty">
                Пока бронирований нет. Создайте первую запись через админскую форму.
            </div>
        <?php else: ?>
            <div class="table-wrap">
                <table>
                    <thead>
                    <tr>
                        <th>Номер брони</th>
                        <th>Гость</th>
                        <th>Контакт</th>
                        <th>Комната</th>
                        <th>Заезд / выезд</th>
                        <th>Статус</th>
                        <th>Источник</th>
                        <th>Оценка</th>
                        <th>Сумма</th>
                        <th>Создано</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $__currentLoopData = $bookings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $booking): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><a href="<?php echo e(route('admin.bookings.show', $booking)); ?>"><?php echo e($booking->booking_number); ?></a></td>
                            <td><?php echo e($booking->guest_name); ?></td>
                            <td>
                                <div><?php echo e($booking->phone ?: '—'); ?></div>
                                <div class="muted"><?php echo e($booking->email ?: '—'); ?></div>
                            </td>
                            <td>№ <?php echo e($booking->room?->code); ?> — <?php echo e($booking->room?->title); ?></td>
                            <td>
                                <div><?php echo e($booking->arrival_date?->format('d.m.Y') ?: '—'); ?></div>
                                <div class="muted"><?php echo e($booking->departure_date?->format('d.m.Y') ?: '—'); ?></div>
                            </td>
                            <td><span class="badge <?php echo e($booking->status); ?>"><?php echo e(\App\Models\Booking::statusOptions()[$booking->status] ?? $booking->status); ?></span></td>
                            <td><?php echo e(\App\Models\Booking::sourceOptions()[$booking->source] ?? $booking->source); ?></td>
                            <td><?php echo e($booking->guest_rating ?: ($booking->guest?->admin_rating ?: '—')); ?></td>
                            <td><?php echo e(number_format((float) $booking->full_amount, 2, '.', ' ')); ?> €</td>
                            <td><?php echo e($booking->created_at?->format('d.m.Y H:i')); ?></td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            </div>

            <div class="admin-pagination">
                <div class="admin-pagination-summary">
                    Показано с <?php echo e($bookings->firstItem()); ?> по <?php echo e($bookings->lastItem()); ?> из <?php echo e($bookings->total()); ?> записей
                </div>

                <?php if($bookings->hasPages()): ?>
                    <div class="admin-pagination-actions">
                        <?php if($bookings->onFirstPage()): ?>
                            <span class="secondary disabled">Назад</span>
                        <?php else: ?>
                            <a class="secondary" href="<?php echo e($bookings->previousPageUrl()); ?>" rel="prev">Назад</a>
                        <?php endif; ?>

                        <span class="admin-pagination-page">Страница <?php echo e($bookings->currentPage()); ?> из <?php echo e($bookings->lastPage()); ?></span>

                        <?php if($bookings->hasMorePages()): ?>
                            <a class="secondary" href="<?php echo e($bookings->nextPageUrl()); ?>" rel="next">Вперёд</a>
                        <?php else: ?>
                            <span class="secondary disabled">Вперёд</span>
                        <?php endif; ?>
                    </div>
                <?php endif; ?>
            </div>
        <?php endif; ?>
    </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\OSPanel6\home\hotel-pineta-laravel.local\resources\views/admin/bookings/index.blade.php ENDPATH**/ ?>