@extends('admin.layouts.container')

@section('content')
    <div class="side-title">
        <h3>{{ $head ?? ''}}</h3>
    </div>

    <div class="border-item">
        <form class="form-row" method="post" onsubmit="saveForm(this)" action="{{ $action }}" enctype="multipart/form-data">
            @if($room ?? ''  && $room->id)
                @method('PUT')
            @endif
            @csrf

            <div class="form-group col-lg-6">
                <label>{{ meta('room_id', getCurrentLocale()) ?? __('rooms.room_id')}}</label>
                <input type="number"  class="form-control  {{ $errors->has('room_id') ? 'is-invalid' : '' }}" name="room_id" placeholder="{{ meta('room_id', getCurrentLocale()) ?? __('rooms.room_id') }}" value='{{ old("room_id", $room->room_id ?? "") }}'/>
            </div>
{{--
            <div class="form-group col-lg-6">
                <label>{{ meta('start_count', getCurrentLocale()) ?? __('rooms.start_count')}}</label>
                <input type="number"  class="form-control  {{ $errors->has('start_count') ? 'is-invalid' : '' }}" name="start_count" placeholder="{{ meta('start_count', getCurrentLocale()) ?? __('rooms.start_count') }}" value='{{ old("start_count", $room->start_count ?? "") }}'/>
            </div>
            <div class="form-group col-lg-6">
                <label>{{ meta('end_count', getCurrentLocale()) ?? __('rooms.end_count')}}</label>
                <input type="number"  class="form-control  {{ $errors->has('end_count') ? 'is-invalid' : '' }}" name="end_count" placeholder="{{ meta('end_count', getCurrentLocale()) ?? __('rooms.end_count') }}" value='{{ old("end_count", $room->end_count ?? "") }}'/>
            </div>
            --}}
            <div class="form-group col-lg-6">
                <label>{{ meta('cost', getCurrentLocale()) ?? __('rooms.cost')}}</label>
                <input type="number"  class="form-control  {{ $errors->has('cost') ? 'is-invalid' : '' }}" name="cost" placeholder="{{ meta('cost', getCurrentLocale()) ?? __('rooms.cost') }}" value='{{ old("cost", $room->cost ?? "") }}'/>
            </div>
            <div class="form-group col-lg-6">
                <label>{{ __('rooms.status_min') }} </label>
                <select  id="status_min" class="form-control {{ $errors->has('status_min') ? 'is-invalid' : '' }}" name="status_min">
                    <option {{ (isset($room) ? $room->status_min : null) == 'true' ? 'selected' : '' }} value="true">{{__('rooms.true')}}</option>
                    <option {{ (isset($room) ? $room->status_min : null) == 'false' ? 'selected' : '' }} value="false">{{__('rooms.false')}}</option>
                </select>
            </div>
            <div class="form-group col-lg-6" id="min_count">
                <label>{{ meta('min_count', getCurrentLocale()) ?? __('rooms.min_count')}}</label>
                <input type="number" min="1" class="form-control  {{ $errors->has('min_count') ? 'is-invalid' : '' }}" name="min_count" placeholder="{{ meta('min_count', getCurrentLocale()) ?? __('rooms.min_count') }}" value='{{ old("min_count", $room->min_count ?? "") }}'/>
            </div>

            <div class="form-group col-lg-6">
                <label>{{ meta('max_count', getCurrentLocale()) ?? __('rooms.max_count')}}</label>
                <input type="number" min="1" class="form-control  {{ $errors->has('max_count') ? 'is-invalid' : '' }}" name="max_count" placeholder="{{ meta('max_count', getCurrentLocale()) ?? __('rooms.max_count') }}" value='{{ old("max_count", $room->max_count ?? "") }}'/>
            </div>
            
            @foreach($languages as $language)

                <div class="form-group col-lg-6">
                    <label>{{ meta('name', $language->local) ?? __('rooms.name') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
                    <input type="text" class="form-control {{ $errors->has('name_'.$language->local) ? 'is-invalid' : '' }}" name="name_{{ $language->local }}" placeholder="{{ meta('name', $language->local) ?? __('rooms.name') }}" value='{{ old("name_{$language->local}", $room[$language->local]->name ?? "") }}'/>
                </div>
                <div class="form-group col-lg-12">
                    <label>{{ meta('description', $language->local) ?? __('rooms.description') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
                    <textarea class="form-control {{ $errors->has('description_'.$language->local) ? 'is-invalid' : '' }}" name="description_{{ $language->local }}" placeholder="{{ meta('description', $language->local) ?? __('rooms.description') }}" >{{ old("description_{$language->local}", $room[$language->local]->description ?? "") }}</textarea>
                </div>
            @endforeach


            <div class="form-group col-lg-12">
                <label>{{ meta('external_image', getCurrentLocale()) ?? __('rooms.external_image') }} </label>
                <input id="image_thumbnail" class="image_thumbnail" type="hidden" name="external_image" value="{{old("external_image", $room->external_image ?? "")}}"/>

                <div class="photos main_photo {{ old('external_image', $room->external_image ?? '') ? ' wow fadeInUp' : 'hide' }}">
                    <div class="col-lg-4">
                        <div class="items">
                            <div class="img">
                                <a href="#" id="lfm" data-input=".image_thumbnail" data-preview=".image_holder" class="lfm" data-hide=".pick_button">
                                    <img src="{{asset(old('external_image', $room->external_image ?? ''))}} "  id="image_holder" class="image_holder"/>
                                </a>
                            </div>
                            <a href="#" class="showHide resetImage close" data-empty=".image_thumbnail" data-hide=".main_photo" data-show=".pick_button"><i class="fas fa-times"></i></a>
                        </div>
                    </div>
                </div>

                <div class="clearfix"></div>
                <span class="input-group-btn pick_button {{ old('external_image', $room->external_image ?? '') ? 'hide' : '' }} ">
                    <a id="lfm" data-input=".image_thumbnail" data-preview=".image_holder" data-show=".main_photo" data-hide=".pick_button" class="lfm btn btn-primary text-light">
                        <i class="fas fa-camera-retro"></i> {{__('dashboard.select')}}
                    </a>
                </span>
            </div>

            <div class="form-group col-lg-12">
                <label>{{ meta('internal_image', getCurrentLocale()) ?? __('rooms.internal_image') }} </label>
                <input id="internal_image_thumbnail" class="internal_image_thumbnail" type="hidden" name="internal_image" value="{{old("internal_image", $room->internal_image ?? "")}}"/>

                <div class="photos main_internal_photo {{ old('internal_image', $room->internal_image ?? '') ? ' wow fadeInUp' : 'hide' }}">
                    <div class="col-lg-4">
                        <div class="items">
                            <div class="img">
                                <a href="#" id="lfm" data-input=".internal_image_thumbnail" data-preview=".internal_image_holder" class="lfm" data-hide=".internal_pick_button">
                                    <img src="{{asset(old('internal_image', $room->internal_image ?? ''))}} "  id="internal_image_holder" class="internal_image_holder"/>
                                </a>
                            </div>
                            <a href="#" class="showHide resetImage close" data-empty=".internal_image_thumbnail" data-hide=".main_internal_photo" data-show=".internal_pick_button"><i class="fas fa-times"></i></a>
                        </div>
                    </div>
                </div>

                <div class="clearfix"></div>
                <span class="input-group-btn internal_pick_button {{ old('internal_image', $room->internal_image ?? '') ? 'hide' : '' }} ">
                    <a id="lfm" data-input=".internal_image_thumbnail" data-preview=".internal_image_holder" data-show=".main_internal_photo" data-hide=".internal_pick_button" class="lfm btn btn-primary text-light">
                        <i class="fas fa-camera-retro"></i> {{__('dashboard.select')}}
                    </a>
                </span>
            </div>

            <div class="text-center mt-5 col-12">
                <button class="butn"><span>{{ __('dashboard.save') }}</span></button>
            </div>
        </form>
    </div>

@endsection

@section('inner_js')
    <!-- Editor JS orders -->
    <script src="{{ asset('/assets/admin/js/lib/tinymce.min.js') }}"></script>
    <script>
        // function selectStatus()
        // {
        //     let status = $('#status_min').val()
        //     if(status == 'true')
        //     {
        //         $('#min_count').show()
        //     }
        //     else
        //     {
        //         $('#min_count').hide()
        //     }
        // }
        // $('#status_min').trigger('change')
    </script>
    <script>
        var route_prefix = "{{ url(config('lfm.prefix')) }}";
        var url = "{{url('/')}}/";
        var urrentLanguage = "{{getCurrentLocale()}}";
        var imagePath = "{{asset('')}}";
    </script>
    

    <script src="{{ asset('assets/admin/js/editor.js') }}"></script>
    <script src="{{ asset('assets/admin/js/lfm.js') }}"></script>
@endsection



