@extends('admin.layouts.container')

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

                <a href="{{ route ('hotel_reservations.destroyAll') }}" data-method="delete" class="butn statusButns status_0 tableAction btn disabled bg-danger force"> <span> {{ __('dashboard.delete') }} </span></a>
                <a href="{{ route ('hotel_reservations.restoreAll') }}" data-method="put" class="butn statusButns status_0 tableAction btn disabled bg-info"> <span> {{ __('dashboard.restore') }} </span></a>
                <a href="#" class="butn statusButns status_0 showActive bg-primary"> <span> {{ __('dashboard.displayActive') }} </span></a>
            </div>
        </div>
        <div class="col-lg-12 valign mb-3">
            <div class="edit-buttons text-right w-100 d-flex justify-content-start">
                <a href="{{ route ('hotel_reservations.reports') }}"  class="butn btn bg-secondary export_link"><span><i class="fa fa-file-excel"></i> {{ __('hotel_reservations.export_excel') }}</span></a>
            </div>
        </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">{{ __('hotel_reservations.city_name') }}</th>
            <th scope="col">{{ __('hotel_reservations.hotel_name') }}</th>
            <th scope="col">{{ __('hotel_reservations.user_id') }}</th>
            <th scope="col">{{ __('hotel_reservations.user_email') }}</th>
            <th scope="col">{{ __('hotel_reservations.room_type') }}</th>
            <th scope="col">{{ __('hotel_reservations.days_count') }}</th>
            <th scope="col">{{ __('hotel_reservations.person_count') }}</th>
            <th scope="col" colspan="2">{{ __('dashboard.created_at') }}</th>
            <th scope="col">{{ __('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="">{{__('hotel_reservations.city_name')}}</option>
                    @if(count($cities))
                        @foreach($cities as $city)
                            <option value="{{$city->id}}">{{$city->name}}</option>
                        @endforeach
                    @endif
                </select>
            </th>
            <th scope="row">
                <select name="hotel_id" class="form-control">
                    <option value="">{{__('hotel_reservations.hotel_name')}}</option>
                    @if(count($hotels))
                        @foreach($hotels as $hotel)
                            <option value="{{$hotel->id}}">{{$hotel->name}}</option>
                        @endforeach
                    @endif
                </select>
            </th>
            <th scope="row">
                <input type="text" name="user_name" value="{{ $request->user_name ?? '' }}" class="form-control" placeholder="">
            </th>
            <th scope="row">
                <input type="text" name="user_email" value="{{ $request->user_email ?? '' }}" class="form-control" placeholder="">
            </th>
            <th scope="row">
                <select name="room_type" class="form-control">
                    <option value="">{{__('hotels.room_type')}}</option>
                    <option value="1">{{__('hotels.individually')}}</option>
                    <option value="2">{{__('hotels.couple')}}</option>
                    <option value="3">{{__('hotels.tripartite')}}</option>
                    <option value="4">{{__('hotels.quadrilateral')}}</option>
                </select>
            </th>
            <th scope="row">
                <input type="text" name="days_count" value="{{ $request->days_count ?? '' }}" class="form-control" placeholder="">
            </th>
            <th scope="row">
                <input type="text" name="person_count" value="{{ $request->person_count ?? '' }}" class="form-control" placeholder="">
            </th>
            <td>
                <input type="text" placeholder="{{ __('dashboard.date_from') }}" name="date_from" value="{{ $request->date_from ?? '' }}" class="date_from form-control">
            </td>
            <td>
                <input type="text" placeholder="{{ __('dashboard.date_to') }}" name="date_to" value="{{ $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>
@endsection



<script>
/**
 * Importat to handle ajax requests for filters, deletes, trash and any proccess done on the table's data
 */
var dataTable={
    route: '{{ route("hotel_reservations.grid") }}'
}
</script>
@section('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);
            }

        });
    </script>
@endsection
