<?php $__env->startSection('css'); ?>
    <link rel="stylesheet" href="<?php echo e(asset('assets/admin/css/lib/toastr.css')); ?>">

    <style>
        .highlight{
            background: #FC0 !important;
        }
    </style>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
    <div class="side-title">
        <h3><?php echo e($head ?? ''); ?></h3>
    </div>

    <div class="border-item">
        <form class="form-row add_hall_from" method="post" action="<?php echo e($action); ?>" enctype="multipart/form-data" autocomplete="off">
            <?php if($hotel ?? ''  && $hotel->id): ?>
                <?php echo method_field('PUT'); ?>
            <?php endif; ?>
            <?php echo csrf_field(); ?>
            <div class="form-group col-lg-12">
                <label for="location"><?php echo e(meta('address', $local) ?? __('hotels.address')); ?></label>
                <div class="d-flex justify-content-between align-items-center">
                    <input type="text" name="address" id="location" class="form-control" placeholder="<?php echo e(__('hotels.address') . __('hotels.choose_address_via_map')); ?>" value='<?php echo e($hotel->address ?? ""); ?>'>
                    <button style="font-size: 12px" type="button" class="butn small modal-btn mr-2" data-toggle="modal" data-target="#exampleModalCenter">
                        <span><?php echo e(__('hotels.location')); ?></span>
                    </button>
                    <input type="hidden" name="lat" value='<?php echo e($hotel->lat ?? ""); ?>'>
                    <input type="hidden" name="lng" value='<?php echo e($hotel->lng ?? ""); ?>'>
                </div>
            </div>
            <div class="form-group col-lg-4">
                <label><?php echo e(meta('city_id', $local) ?? __('hotels.city_id')); ?> </label>
                <select name="city_id" class="form-control">
                    <option value=""><?php echo e(meta('city_id', $local) ?? __('hotels.city_id')); ?></option>
                    <?php if(count($cities)): ?>
                        <?php $__currentLoopData = $cities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $city): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option <?php echo e(($hotel->city_id ?? null) == $city->id ? 'selected': ''); ?> value="<?php echo e($city->id); ?>"><?php echo e($city->name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php endif; ?>
                </select>
            </div>
            <div class="form-group col-lg-4">
                <label><?php echo e(meta('email', $local) ?? __('hotels.email')); ?> </label>
                <input type="email" class="form-control" name="email" placeholder="<?php echo e(meta('email', $local) ?? __('hotels.email')); ?>" value='<?php echo e($hotel->email ?? ""); ?>'/>
            </div>
            <div class="form-group col-lg-4">
            <label><?php echo e(meta('status', $local) ?? __('hotels.status')); ?> </label>
            <select name="status" class="form-control">

                <option <?php echo e(($hotel->status ?? null) == 1 ? 'selected': ''); ?> value="1"><?php echo e(__('hotels.active')); ?></option>
                <option <?php echo e(($hotel->status?? null) == 0 ? 'selected': ''); ?> value="0"><?php echo e(__('hotels.non_active')); ?></option>
            </select>
        </div>

            <div class="card p-3 mb-3 col-lg-12">
                <label><?php echo e(meta('added_service', $local) ??  __('hotels.added_service')); ?> </label>
                <div class="row card-body">
                    <?php if(count($added_service)): ?>
                        <?php $__currentLoopData = $added_service; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value => $service): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="col-md-4">
                                <div class="custom-control custom-checkbox mb-2">
                                    <input data-price=".added_service_price_<?php echo e($value); ?>" type="checkbox" <?php echo e(in_array($value, $hotel['added_service'] ?? []) ? 'checked' : ''); ?> value="<?php echo e($value); ?>" class="custom-control-input" id="<?php echo e($value); ?>" name="added_service[]">
                                    <label class="custom-control-label" for="<?php echo e($value); ?>"> <?php echo e($service); ?></label>
                                </div>
                                <input readonly type="number" min="1" name="added_service_price[<?php echo e($value); ?>]" class="form-control added_service_price_<?php echo e($value); ?>" placeholder="<?php echo e(meta('added_service_price', $local) ??  __('hotels.added_service_price')); ?>" value="<?php echo e(($hotel ?? null) ? $hotel['added_service_price'][$loop->index] : ''); ?>">
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php endif; ?>
                </div>
            </div>
            <div class="card p-3 mb-3 col-lg-12">
                <label><?php echo e(meta('room_type', $local) ??  __('hotels.room_type')); ?> </label>
                <div class="row card-body">
                    <?php if(count($room_type)): ?>
                        <?php $__currentLoopData = $room_type; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value => $type): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="col-md-3">
                                <div class="custom-control custom-checkbox mb-2">
                                    <input data-price=".room_type_price_<?php echo e($value); ?>" type="checkbox" <?php echo e(in_array($value, $hotel['room_type'] ?? []) ? 'checked' : ''); ?> value="<?php echo e($value); ?>" class="custom-control-input" id="room_type_<?php echo e($value); ?>" name="room_type[]">
                                    <label class="custom-control-label" for="room_type_<?php echo e($value); ?>"> <?php echo e($type); ?></label>
                                </div>
                                <input readonly type="number" min="1" name="room_type_price[<?php echo e($value); ?>]" class="form-control room_type_price_<?php echo e($value); ?>" placeholder="<?php echo e(meta('room_type_price', $local) ??  __('hotels.room_type_price')); ?>" value="<?php echo e(($hotel ?? null) ? $hotel['room_type_price'][$loop->index] : ''); ?>">
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php endif; ?>
                </div>
            </div>

            <?php $__currentLoopData = languages(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $language): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="form-group col-lg-6">
                <label><?php echo e(meta('name', $language->local) ?? __('hotels.name')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?> </label>
                <input type="text" class="form-control" name="name_<?php echo e($language->local); ?>" placeholder="<?php echo e(meta('name', $language->local) ?? __('hotels.name')); ?>" value='<?php echo e($hotel[$language->local]->name ?? ""); ?>'/>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <div class="col-md-12">
                <div class="custom-control custom-checkbox mb-2">
                    <input type="checkbox" <?php echo e(($hotel->include_breakfast ?? null) ? 'checked' : ''); ?> value="1" class="custom-control-input" id="include_breakfast" name="include_breakfast">
                    <label class="custom-control-label" for="include_breakfast"> <?php echo e(__('hotels.include_breakfast')); ?></label>
                </div>
            </div>

            <div class="border-item photos col-md-12 other_image_container">
                <div class="row">
                    <?php if($hotel ?? false): ?>
                        <?php $__currentLoopData = $hotel['images']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $photo): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="col-md-4">
                                <div class="items">
                                    <div class="img">
                                        <a href="<?php echo e(asset($photo ?? '')); ?>" data-fancybox="gallery"><img src="<?php echo e(asset($photo ?? '')); ?>" alt=""></a>
                                    </div>
                                    <input type="hidden" name="images[]" value="<?php echo e($photo ?? ""); ?>">
                                    <a href="#" class="close"><i class="fas fa-times"></i></a>
                                </div>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php endif; ?>
                </div>
                <div class="text-center">
                    <input id="other_image_thumbnail" class="other_image_thumbnail" type="hidden"/>
                    <div class="clearfix"></div>
                    <span id="add">
                    <a id="lfm" data-width="" data-cache="article_gallery" data-input=".other_image_thumbnail" data-preview="" data-show="" data-hide="" class="lfm add">
                        Add New Item
                    </a>
                </span>
                </div>
            </div>

            <div class="text-center mt-5 col-12">
                <button class="butn add_hall_button"><span><?php echo e(__('dashboard.save')); ?></span></button>
            </div>
        </form>
    </div>


    <div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
        <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLongTitle"><?php echo e(__('hotels.location')); ?></h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <div style="border:0; height: 400px; width: 100%" class="map" id="map"></div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="butn color small save_location"><span><?php echo e(__('hotels.save_location')); ?></span></button>
                </div>
            </div>
        </div>
    </div>


<?php $__env->stopSection(); ?>

<?php $__env->startSection('inner_js'); ?>
    <!-- Editor JS files -->
    <script src="<?php echo e(asset('/assets/admin/js/lib/tinymce.min.js')); ?>"></script>
    
    <script>
        var route_prefix = "<?php echo e(url(config('lfm.prefix'))); ?>";
        var url = "<?php echo e(url('/')); ?>/",
            currentLanguage = "<?php echo e($local); ?>",
            inputName = '';
    </script>
    <script src="<?php echo e(asset('assets/admin/js/editor.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/admin/js/lfm.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/admin/js/articles.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/admin/js/lib/toastr.min.js')); ?>"></script>



    <script>

        let getCityAndSectorRoute = "<?php echo e(route('hotels.getCityAndSector')); ?>";

        localStorage.setItem('articleGallery', null);
        localStorage.setItem('oldArticleStorage', null);

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

            let form = $('.add_hall_from'),
                data = new FormData(form[0]),
                url = form.attr('action'),
                method = form.attr('method');

            $('.discount_dates_input').each(function () {
                if ($(this).prop('checked') === false){
                    data.append('discount_dates[]', 0);
                    data.append('discount_percentage[]', 'empty');
                } else {
                    data.append('discount_dates[]', 1);
                    let inputSibling = $(this).siblings('.discount_percentage');
                    data.append('discount_percentage[]', inputSibling.val());

                }});


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

            if (response.url){
                window.location.href = response.url;
            }

            if (response.errors){
                toasterError(response.errors);
            }


        });

        $(document).on('click', '.active_hall' , async function (e) {
            e.preventDefault();
            let url = $(this).data('href'),
                method = 'get';

            const response=await ajax({
                url,
                dataType: 'json',
                method,
            });
            if (response.message) {
                $(this).children('i').toggleClass('fa-check text-success fa-times text-danger')

            }
        });

        let checkBoxInputs = $('input[type="checkbox"]');
        checkBoxInputs.click(function () {
            if($(this).prop('checked') === true){
                $($(this).data('price')).removeAttr('readonly')
            } else {
                $($(this).data('price')).val('');
                $($(this).data('price')).attr('readonly', 'readonly');
            }
        });

        checkBoxInputs.each(function () {
            if($(this).prop('checked') === true){
                $($(this).data('price')).removeAttr('readonly')
            } else {
                $($(this).data('price')).val('');
                $($(this).data('price')).attr('readonly', 'readonly');
            }
        });

    </script>

    <script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>
    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA5HuBEjkPPxQH4c7Nhfx2-u5XXCtSIzUk&callback=initMap&libraries=&v=weekly" defer></script>


    <script>
        // The following example creates a marker in Stockholm, Sweden using a DROP
        // animation. Clicking on the marker will toggle the animation between a BOUNCE
        // animation and no animation.

        let latitude = null,
            longitude = null;
        if (navigator.geolocation) {
            navigator.geolocation.watchPosition(function (position) {
                // let lat = $('input.latitude'),
                //     lng = $('input.longitude');
                // latitude = lat.val(parseFloat(position.coords.latitude));
                // longitude = lng.val(parseFloat(position.coords.longitude));
                latitude = parseFloat(position.coords.latitude);
                longitude = parseFloat(position.coords.longitude);
                localStorage.setItem('lat', latitude);
                localStorage.setItem('lng', longitude);
            });
        } else {
            alert('Geolocation is not supported by this browser')
        }

        var marker;
        var save_location = $('.save_location');
        function initMap() {
            var map = new google.maps.Map(document.getElementById("map"), {
                zoom: 7,
                center: { lat: parseFloat(latitude) , lng: parseFloat(longitude) }
            });

            marker = new google.maps.Marker({
                map: map,
                draggable: true,
                animation: google.maps.Animation.DROP,
                position: { lat: parseFloat(latitude) , lng: parseFloat(longitude) }
            });

            marker.addListener("dragend", function (map) {
                let lat = map.latLng.lat(), lng = map.latLng.lng();
                localStorage.setItem('lat', lat);
                localStorage.setItem('lng', lng);
                $('#latitude').val(lat);
                $('#longitude').val(lng);
                var geocoder = new google.maps.Geocoder();
                var infowindow = new google.maps.InfoWindow();

                google.maps.event.addListener(marker, 'dragend', function() {
                    infowindow.close();
                });

                var latlng = { lat: parseFloat(lat), lng: parseFloat(lng) };
                geocoder.geocode({ location: latlng }, function(results, status) {
                    if (status === "OK") {
                        if (results[0]) {
                            infowindow.setContent(results[0].formatted_address);
                            infowindow.open(map, marker);
                            document.getElementById('location').value = results[0].formatted_address
                        } else {
                            window.alert("No results found");
                        }
                    } else {
                        window.alert("Geocoder failed due to: " + status);
                    }
                });
                if (marker.getAnimation() !== null) {
                    marker.setAnimation(null);
                } else {
                    marker.setAnimation(google.maps.Animation.BOUNCE);
                }
            });
        }

        save_location.click(function (map) {
            let lat = localStorage.getItem('lat'),
                lng = localStorage.getItem('lng');
            localStorage.setItem('lat', lat);
            localStorage.setItem('lng', lng);
            $('input[name="lat"]').val(lat);
            $('input[name="lng"]').val(lng);
            var geocoder = new google.maps.Geocoder();
            var infowindow = new google.maps.InfoWindow();

            var latlng = { lat: parseFloat(lat), lng: parseFloat(lng) };
            geocoder.geocode({ location: latlng }, function(results, status) {
                if (status === "OK") {
                    if (results[0]) {
                        infowindow.setContent(results[0].formatted_address);
                        infowindow.open(map, marker);
                        document.getElementById('location').value = results[0].formatted_address
                    } else {
                        window.alert("No results found");
                    }
                } else {
                    window.alert("Geocoder failed due to: " + status);
                }
            });
            if (marker.getAnimation() !== null) {
                marker.setAnimation(null);
            } else {
                marker.setAnimation(google.maps.Animation.BOUNCE);
            }

            $('.modal').modal('hide')
        });
    </script>

<?php $__env->stopSection(); ?>




<?php echo $__env->make('admin.layouts.container', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/balyomhost/public_html/nosk/resources/views/admin/hotels/form.blade.php ENDPATH**/ ?>