<?php $__env->startSection('content'); ?>
<form>
<div class="side-title">
    <div class="row">
        <div class="col-lg-6">
            <h3><?php echo e($title); ?></h3>
        </div>
        <div class="col-lg-6 valign">
            <div class="edit-buttons text-right w-100">
                <a href="<?php echo e(route ('hotel_reservations.destroyAll')); ?>" data-method="delete" class="butn statusButns status_1 tableAction btn disabled bg-warning"> <span><?php echo e(__('dashboard.sendToTrash')); ?></span></a>
                <a href="#" class="butn statusButns status_1 showArchive bg-primary"> <span> <?php echo e(__('dashboard.displayTrash')); ?> </span></a>

                <a href="<?php echo e(route ('hotel_reservations.destroyAll')); ?>" data-method="delete" class="butn statusButns status_0 tableAction btn disabled bg-danger force"> <span> <?php echo e(__('dashboard.delete')); ?> </span></a>
                <a href="<?php echo e(route ('hotel_reservations.restoreAll')); ?>" data-method="put" class="butn statusButns status_0 tableAction btn disabled bg-info"> <span> <?php echo e(__('dashboard.restore')); ?> </span></a>
                <a href="#" class="butn statusButns status_0 showActive bg-primary"> <span> <?php echo e(__('dashboard.displayActive')); ?> </span></a>
            </div>
        </div>
        <div class="col-lg-12 valign mb-3 d-flex justify-content-between">
            <a href="<?php echo e(route ('hotel_reservations.reports')); ?>"  class="butn btn bg-secondary export_link"><span><i class="fa fa-file-excel"></i> <?php echo e(__('hotel_reservations.export_excel')); ?></span></a>
            <a href="<?php echo e(route ('hotel_reservations.finishReservations')); ?>"  class="butn btn bg-danger finish_reservation_link"><span> <?php echo e(__('hotel_reservations.finish_reservations')); ?></span></a>
        </div>
    </div>
</div>

<!-- ------------ data table ------------- -->
<table class="table table-hover table-bordered">
    <thead>
        <tr>
            <th scope="col">
            <div class="custom-control custom-checkbox">
                <input type="checkbox" class="custom-control-input select_all" id="selectall" name="example1">
                <label class="custom-control-label" for="selectall"> </label>
            </div>
            </th>
            <th scope="col"><?php echo e(__('hotel_reservations.city_name')); ?></th>
            <th scope="col"><?php echo e(__('hotel_reservations.hotel_name')); ?></th>
            <th scope="col"><?php echo e(__('hotel_reservations.user_id')); ?></th>
            <th scope="col"><?php echo e(__('hotel_reservations.user_email')); ?></th>
            <th scope="col"><?php echo e(__('hotel_reservations.room_type')); ?></th>
            <th scope="col"><?php echo e(__('hotel_reservations.status')); ?></th>
            <th scope="col"><?php echo e(__('hotel_reservations.days_count')); ?></th>
            <th scope="col"><?php echo e(__('hotel_reservations.person_count')); ?></th>
            <th scope="col" colspan="2"><?php echo e(__('dashboard.created_at')); ?></th>
            <th scope="col"><?php echo e(__('dashboard.processes')); ?></th>
        </tr>
    </thead>

    <tbody class="response">
        <tr class="search_filter_form">
            <th scope="row"></th>
            <th scope="row">
                <select name="city_id" class="form-control">
                    <option value=""><?php echo e(__('hotel_reservations.city_name')); ?></option>
                    <?php if(count($cities)): ?>
                        <?php $__currentLoopData = $cities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $city): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($city->id); ?>"><?php echo e($city->name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php endif; ?>
                </select>
            </th>
            <th scope="row">
                <select name="hotel_id" class="form-control">
                    <option value=""><?php echo e(__('hotel_reservations.hotel_name')); ?></option>
                    <?php if(count($hotels)): ?>
                        <?php $__currentLoopData = $hotels; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $hotel): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($hotel->id); ?>"><?php echo e($hotel->name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php endif; ?>
                </select>
            </th>
            <th scope="row">
                <input type="text" name="user_name" value="<?php echo e($request->user_name ?? ''); ?>" class="form-control" placeholder="">
            </th>
            <th scope="row">
                <input type="text" name="user_email" value="<?php echo e($request->user_email ?? ''); ?>" class="form-control" placeholder="">
            </th>
            <th scope="row">
                <select name="room_type" class="form-control">
                    <option value=""><?php echo e(__('hotels.room_type')); ?></option>
                    <?php if(count($rooms)): ?>
                        <?php $__currentLoopData = $rooms; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $room): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($room->id); ?>"><?php echo e($room->name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php endif; ?>
                </select>
            </th>
            <th scope="row">
                <select name="reservation_status" class="form-control">
                    <option value=""><?php echo e(__('hotel_reservations.status')); ?></option>
                    <option value="current"><?php echo e(__('hotel_reservations.current')); ?></option>
                    <option value="confirmed"><?php echo e(__('hotel_reservations.confirmed')); ?></option>
                    <option value="refund"><?php echo e(__('hotel_reservations.refund')); ?></option>
                    <option value="finished"><?php echo e(__('hotel_reservations.finished')); ?></option>
                </select>
            </th>
            <th scope="row">
                <input type="text" name="days_count" value="<?php echo e($request->days_count ?? ''); ?>" class="form-control" placeholder="">
            </th>
            <th scope="row">
                <input type="text" name="person_count" value="<?php echo e($request->person_count ?? ''); ?>" class="form-control" placeholder="">
            </th>
            <td>
                <input type="text" placeholder="<?php echo e(__('dashboard.date_from')); ?>" name="date_from" value="<?php echo e($request->date_from ?? ''); ?>" class="date_from form-control">
            </td>
            <td>
                <input type="text" placeholder="<?php echo e(__('dashboard.date_to')); ?>" name="date_to" value="<?php echo e($request->date_to ?? ''); ?>" class="date_to form-control">
            </td>
            <th scope="col"><button type="button" class="butn color small search"><span><i class="fas fa-search"></i></span></button></th>
        </tr>
    </tbody>


</table>
<!-- ------------ sidemenu links ------------- -->
</form>
<?php $__env->stopSection(); ?>



<script>
/**
 * Importat to handle ajax requests for filters, deletes, trash and any proccess done on the table's data
 */
var dataTable={
    route: '<?php echo e(route("hotel_reservations.grid")); ?>'
}
</script>
<?php $__env->startSection('inner_js'); ?>
    <script>
        let exportLink = $('.export_link'),
            href = exportLink.attr('href');

        $(document).on('click', '.select_all, .single_select', function () {
            let ids = [];
            if ($(this).prop('checked') === true){
                $('.single_select:checked').each(function () {
                    ids.push($(this).val());
                });
            }
            console.log(ids);
            if (ids.length){
                exportLink.attr('href', href+'/?ids='+ids)
            } else {
                exportLink.attr('href', href);
            }

        });

        $('.finish_reservation_link').click(async function (e) {
            e.preventDefault();

            let url = $(this).attr('href'),
                method = 'get';

            const response=await ajax({
                url,
                dataType: 'json',
                method
            });

            if (response.message){
                toasterSuccess(response.message);
            }

            if (response.errors){
                toasterError(response.errors);
            }
        })
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.container', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\wamp64\www\nosk\resources\views/admin/hotel_reservations/index.blade.php ENDPATH**/ ?>