<link href="{{ asset('css/pages/particular/home.css') }}" rel="stylesheet">
<link href="{{ asset('css/components/tables/reservation-components.css') }}" rel="stylesheet">
<link href="{{ asset('css/components/forms/reservation-form-modal.css') }}" rel="stylesheet">

<link href="{{ asset('css/components/custom/harsiScrollBar.css') }}" rel="stylesheet">

@extends('layouts.app')

@section('title')
    {{ __('navbar')['navigation']['home'] }}
@endsection

@section('content')
    {{-- Imports --}}
    @php
      //* Imports
        use \App\Helpers\Environment\SystemFeaturesHelper;
        use \App\Helpers\Environment\SystemParametersHelper;

      //* Features
        $has_pax_pricing = SystemFeaturesHelper::getFeatureStatus('pax_pricing');
        $has_control_hours = SystemFeaturesHelper::getFeatureStatus("control_hours");
        $has_express_reservations = SystemFeaturesHelper::getFeatureStatus('express_reservations');

        $has_additional_pax_charge = SystemFeaturesHelper::getFeatureStatus('additional_pax_charge');

      //* Parameters
        $express_tolerance_minutes = (int) SystemParametersHelper::getValueOf('hotel.express_tolerance_minutes');
    @endphp

    {{--Panel del Hotel--}}
    <div class="px-3 mt-4 d-flex justify-content-between align-items-start g-2">

        {{-- LLEGADAS --}}
        <div class="panel-card w-100">
            <h5 class="pb-3 title-section section-divider">{{ __('home')['arrivals'] }}</h5>

            <div id="reservation-arrives" class="pt-2 ml-1 mr-2 card-height g-1 d-flex flex-column align-items-center">
                <div class="text-center">
                    @for ($i = 0; $i <= 2; $i++)
                        <div class="mx-2 mt-3 spinner-grow spinner-custom"></div>
                    @endfor
                </div>
            </div>
        </div>

        {{-- OCUPACIÓN --}}
        <div class="panel-card w-100">
            <h5 class="pb-3 title-section section-divider">{{ __('home')['in_hotel'] }}</h5>

            <div id="reservation-occupancy" class="pt-2 ml-1 mr-2 card-height g-1 d-flex flex-column align-items-center">
                <div class="text-center">
                    @for ($i = 0; $i <= 2; $i++)
                        <div class="mx-2 mt-3 spinner-grow spinner-custom"></div>
                    @endfor
                </div>
            </div>
        </div>

        {{-- SALIDAS --}}
        <div class="panel-card w-100">
            <h5 class="pb-3 title-section section-divider">{{ __('home')['departures'] }}</h5>

            <div id="reservation-departures" class="pt-2 ml-1 mr-2 card-height g-1 d-flex flex-column align-items-center">
                <div class="text-center">
                    @for ($i = 0; $i <= 2; $i++)
                        <div class="mx-2 mt-3 spinner-grow spinner-custom"></div>
                    @endfor
                </div>
            </div>
        </div>

    </div>

    {{-- Modales & Formularios de Reservas --}}
        {{-- Papeleta --}}
        @include('home.components.reservation-ballot')

        {{-- Básico --}}
        @include('shared.utils.reservation-form.basic.base', ['is_external' => true])

        {{-- Avanzado (OTAs) --}}
        {{-- <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#advanced_form_modal">
            Launch
        </button> --}}
        @include('shared.utils.reservation-form.complex.base', ['is_external' => true])

    {{-- JS --}}
        {{-- Variables Globales --}}
        <script>
            window.config = {
                routes: {
                    // For Reservation Interactions
                    reservationUpdate: "{{ route('reservations.update') }}",

                    // For Lodgings (Store)
                    lodgingPayment: "{{ route('reservationPayments.lodging.store') }}",
                    // For Consumptions (Store)
                    consumptionPayment: "{{ route('reservationPayments.consumption.store') }}",
                    consumptionCharge: "{{ route('reservationCharges.consumption.store') }}",
                    // For Extras (Store)
                    extraPayment: "{{ route('reservationPayments.extra.store') }}",
                    extraCharge: "{{ route('reservationCharges.extra.store') }}",

                    // For Lodgings (Update)
                    updateLodgingPayment: "{{ route('reservationPayments.lodging.update') }}",
                    // For Consumptions (Update)
                    updateConsumptionPayment: "{{ route('reservationPayments.consumption.update') }}",
                    updateConsumptionCharge: "{{ route('reservationCharges.consumption.update') }}",
                    // For Extras (Update)
                    updateExtraPayment: "{{ route('reservationPayments.extra.update') }}",
                    updateExtraCharge: "{{ route('reservationCharges.extra.update') }}",
                },
                data: {
                    receptionist: '{{ Auth::user()->name }}',
                    features: {
                        has_express_reservations : @json($has_express_reservations),
                        has_control_hours : @json($has_control_hours),
                        has_pax_pricing : @json($has_pax_pricing),

                        has_additional_pax_charge : @json($has_additional_pax_charge),
                    },
                    parameters: {
                        express_tolerance_minutes : @json($express_tolerance_minutes)
                    },

                    statuses:`
                            @foreach($statuses as $status)
                                @if ($status->status_type === "Creation")
                                    <option value="{{ $status->id }}">
                                        {{ __('seeders')['statuses'][$status->status_name] }}
                                    </option>
                                @endif
                            @endforeach
                        `,
                    guestStatuses:`
                            @foreach($statuses as $status)
                                @if ($status->status_type === "Guest")
                                    <option value="{{ $status->id }}">
                                        {{ __('seeders')['statuses'][$status->status_name] }}
                                    </option>
                                @endif
                            @endforeach
                        `,

                    waitingCheckinStatuses: `
                            @foreach($statuses as $status)
                                @if ($status->status_type === "Shared")
                                    <option value="{{ $status->id }}">
                                        {{ __('seeders')['statuses'][$status->status_name] }}
                                    </option>
                                @endif
                            @endforeach
                        `,

                    normalRoomTypes: `
                            @foreach ($roomTypes as $tyroom)
                                @if (
                                    (
                                        (Auth::check() && in_array(Auth::user()->role, ['administrador','gerente']))
                                        || $tyroom->id != 1
                                    ) && !$tyroom->is_express_type
                                )
                                    <option value="{{ $tyroom->id }}" data-limit="{{ $tyroom->pax_room_limit }}"
                                        @if ($has_express_reservations)
                                            data-minimum-stay="{{ $tyroom->minimum_express_stay }}"
                                        @endif
                                    >
                                        {{ $tyroom->tr_name }}
                                    </option>
                                @endif
                            @endforeach
                        `,

                    expressRoomTypes: `
                            @foreach ($roomTypes as $tyroom)
                                @if (
                                    (
                                        (Auth::check() && in_array(Auth::user()->role, ['administrador','gerente']))
                                        || $tyroom->id != 1
                                    ) && $tyroom->is_express_type
                                )
                                    <option value="{{ $tyroom->id }}" data-limit="{{ $tyroom->pax_room_limit }}"
                                        @if ($has_express_reservations)
                                            data-minimum-stay="{{ $tyroom->minimum_express_stay }}"
                                        @endif
                                    >
                                        {{ $tyroom->tr_name }}
                                    </option>
                                @endif
                            @endforeach
                        `,
                },
                assets: {
                    toastInfoIcon: "{{ asset('images/toast-info-icon.png') }}",
                }
            };
        </script>

        <script src="{{ asset('js/modules/manifestCheck.js') }}"></script>

        {{-- Secondary Imports --}}
        @include('home.complements.home-scripts')

@endsection

@section('footer')
    @include('shared.components.footer.basic-footer')
@endsection
