catalog.blade.php 19.2 KB
@extends('layout.site', ['title' => 'Каталог RentTorg'])

@section('filter')
   @include('part.filter.catalog')
@endsection

@section('custom_js')
    @include('js.filter_value');
    <script>
       /*
        $(window).load(function() {
          var url_str = "<?=url()->full();?>";
          var url = new URL(url_str);
          var searchParams = new URLSearchParams(url.search.substring(1));

          var area = searchParams.get("area"),
              type_area = searchParams.get("type_area"),
              format_area= searchParams.get("format_area"),
              address= searchParams.get("address");

          var area_name = $('#area_name');
          var type_area_name = $('#type_area_name');
          var format_area_name = $('#format_area_name');
          var address_name = $('#address');

          if ((area !== "") || (type_area !== "") || (format_area !== "") || (address !== ""))
           {
               $.ajax({
                   type: "GET",
                   url: "{{ route('catalog_ajax_filter') }}",
                   data: "area=" + area + "&type_area=" + type_area + "&format_area=" + format_area + "&address=" + address + "",
                   success: function (data) {
                       console.log('Фильтры данных были переданы ');
                       data = JSON.parse(data);
                       console.log(data);

                       if (area !== "") {
                           area_name.html(data[0]);
                       }
                       if (type_area !== "") {
                           type_area_name.html(data[1]);
                       }
                       if (format_area !== "") {
                           format_area_name.html(data[2]);
                       }
                       if (address !== "") {
                           address_name.html(data[3]);
                       }

                   },
                   headers: {
                       'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                   },
                   error: function (data) {
                       console.log('Error: ' + data);
                   }
               });
           }
       });
*/
        $(document).on('click', '.js_sort_group_item', function() {
                var val = $(this).data('val');
                var sort_price_val = '';
                var sort_area_val = '';
                var sort_new_val = '';

                $('.sort-price').each(function() {
                    var this_ = $(this);
                    var v = $(this).data('val');
                    if (this_.hasClass('active'))
                        sort_price_val = v;
                });

                $('.sort-new').each(function() {
                    var v = $(this).data('val');
                    var this_ = $(this);
                    if (this_.hasClass('active'))
                        sort_new_val = v;
                });

                $('.sort-area').each(function() {
                    var v = $(this).data('val');
                    var this_ = $(this);
                    if (this_.hasClass('active'))
                        sort_area_val = v;

                });

                console.log('-------------------');
                $.ajax({
                    type: "GET",
                    url: "{{ route('catalog') }}",
                    data: "view=arenda&sort_price="+sort_price_val+"&sort_new="+sort_new_val+"&sort_area="+sort_area_val+""+
                          "&area=<?if (isset($_GET['area'])) echo $_GET['area'];?>&type_area=<?if (isset($_GET['type_area'])) echo $_GET['type_area'];?>&format_area=<? if (isset($_GET['format_area'])) echo $_GET['format_area'];?>"+
                          "&area_m2_min=<? if (isset($_GET['area_m2_min'])) echo $_GET['area_m2_min'];?>&area_m2_max=<? if (isset($_GET['area_m2_max'])) echo $_GET['area_m2_max'];?>"+
                          "&price_min=<? if (isset($_GET['price_min'])) echo $_GET['price_min'];?>&price_max=<? if (isset($_GET['price_max'])) echo $_GET['price_max'];?>&address=<? if (isset($_GET['address'])) echo $_GET['address'];?>",
                    success: function(data) {
                        console.log('Успешно обновлены данные АРЕНДА таблиц ');
                        $('#arenda_block').html(data);
                    },
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    error: function(data) {
                        console.log('Error: '+ data);
                    }
                });

                $.ajax({
                    type: "GET",
                    url: "{{ route('catalog') }}",
                    data: "view=prodaja&sort_price="+sort_price_val+"&sort_new="+sort_new_val+"&sort_area="+sort_area_val+""+
                          "&area=<?if (isset($_GET['area'])) echo $_GET['area'];?>&type_area=<?if (isset($_GET['type_area'])) echo $_GET['type_area'];?>&format_area=<? if (isset($_GET['format_area'])) echo $_GET['format_area'];?>"+
                          "&area_m2_min=<? if (isset($_GET['area_m2_min'])) echo $_GET['area_m2_min'];?>&area_m2_max=<? if (isset($_GET['area_m2_max'])) echo $_GET['area_m2_max'];?>"+
                          "&price_min=<? if (isset($_GET['price_min'])) echo $_GET['price_min'];?>&price_max=<? if (isset($_GET['price_max'])) echo $_GET['price_max'];?>&address=<? if (isset($_GET['address'])) echo $_GET['address'];?>",
                    success: function(data) {
                        console.log('Успешно обновлены данные ПРОДАЖА таблиц ');
                        $('#prodaja_block').html(data);
                    },
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    error: function(data) {
                        console.log('Error: '+ data);
                    }
                });

                $.ajax({
                    type: "GET",
                    url: "{{ route('catalog') }}",
                    data: "view=bissnes&sort_price="+sort_price_val+"&sort_new="+sort_new_val+"&sort_area="+sort_area_val+""+
                            "&area=<?if (isset($_GET['area'])) echo $_GET['area'];?>&type_area=<?if (isset($_GET['type_area'])) echo $_GET['type_area'];?>&format_area=<? if (isset($_GET['format_area'])) echo $_GET['format_area'];?>"+
                            "&area_m2_min=<? if (isset($_GET['area_m2_min'])) echo $_GET['area_m2_min'];?>&area_m2_max=<? if (isset($_GET['area_m2_max'])) echo $_GET['area_m2_max'];?>"+
                            "&price_min=<? if (isset($_GET['price_min'])) echo $_GET['price_min'];?>&price_max=<? if (isset($_GET['price_max'])) echo $_GET['price_max'];?>&address=<? if (isset($_GET['address'])) echo $_GET['address'];?>",
                    success: function(data) {
                        console.log('Успешно обновлены данные БИЗНЕС таблиц ');
                        $('#bissnes_block').html(data);
                    },
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    error: function(data) {
                        console.log('Error: '+ data);
                    }
                });

                $.ajax({
                    type: "GET",
                    url: "{{ route('catalog') }}",
                    data: "view=arendovannie&sort_price="+sort_price_val+"&sort_new="+sort_new_val+"&sort_area="+sort_area_val+""+
                            "&area=<?if (isset($_GET['area'])) echo $_GET['area'];?>&type_area=<?if (isset($_GET['type_area'])) echo $_GET['type_area'];?>&format_area=<? if (isset($_GET['format_area'])) echo $_GET['format_area'];?>"+
                            "&area_m2_min=<? if (isset($_GET['area_m2_min'])) echo $_GET['area_m2_min'];?>&area_m2_max=<? if (isset($_GET['area_m2_max'])) echo $_GET['area_m2_max'];?>"+
                            "&price_min=<? if (isset($_GET['price_min'])) echo $_GET['price_min'];?>&price_max=<? if (isset($_GET['price_max'])) echo $_GET['price_max'];?>&address=<? if (isset($_GET['address'])) echo $_GET['address'];?>",
                    success: function(data) {
                        console.log('Успешно обновлены данные таблиц ');
                        $('#arendovannie_block').html(data);
                        //.append(data);
                    },
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    error: function(data) {
                        console.log('Error: '+ data);
                    }
                });

            }
        );
    </script>
@endsection

@section('content')
    <section class="catalog">
        <div class="container">
            <div class="catalog__top top-catalog">
                <div class="top-catalog__inner">
                    <h2 class="top-catalog__title title">Каталог коммерческой недвижимости</h2>
                    <div class="top-catalog__result">Найдено объектов по Вашему запросу: <span><?=$house_arenda->count()+$house_prodaja->count()+$house_bissnes->count()+$house_arendovannie->count(); ?></span></div>
                </div>
                <form class="top-catalog__sorts">
                    <div class="top-catalog__sort-group sort-group js_sort_group">
                        <input class="js_sort_group_input" type="hidden">
                        <div class="sort-group__current js_sort_group_current">Сначала дешевле</div>
                        <ul class="sort-group__list js_sort_group_list">
                            <li class="sort-price sort-group__item js_sort_group_item active" data-val="1">Сначала дешевле</li>
                            <li class="sort-price sort-group__item js_sort_group_item" data-val="2">Сначала дороже</li>
                        </ul>
                    </div>
                    <div class="top-catalog__sort-group sort-group js_sort_group">
                        <input class="js_sort_group_input" type="hidden">
                        <div class="sort-group__current js_sort_group_current">Сначала новые</div>
                        <ul class="sort-group__list js_sort_group_list">
                            <li class="sort-new sort-group__item js_sort_group_item active" data-val="1">Сначала новые</li>
                            <li class="sort-new sort-group__item js_sort_group_item" data-val="2">Сначала старые</li>
                        </ul>
                    </div>
                    <div class="top-catalog__sort-group sort-group sort-group--wide js_sort_group">
                        <input class="js_sort_group_input" type="hidden">
                        <div class="sort-group__current js_sort_group_current">Сначала с большей площадью</div>
                        <ul class="sort-group__list js_sort_group_list">
                            <li class="sort-area sort-group__item js_sort_group_item active" data-val="1">Сначала с большей площадью</li>
                            <li class="sort-area sort-group__item js_sort_group_item" data-val="2">Сначала с меньшей площадью</li>
                        </ul>
                    </div>
                </form>
            </div>
        </div>
        <div class="complex__sliders">
            <section class="slider">
                <div class="container">
                    <div class="slider__wrap">
                        <div class="slider__top">
                            <h2 class="slider__title title">Аренда торговых помещений</h2><a class="slider__more" href="#">Показать все объекты</a>
                            <div class="slider__control">
                                <div class="swiper-button-prev">
                                    <svg width="10" height="17">
                                        <use xlink:href="{{ asset('images/sprite.svg#slider-arrow') }}"></use>
                                    </svg>
                                </div>
                                <div class="swiper-button-next">
                                    <svg width="10" height="17">
                                        <use xlink:href="{{ asset('images/sprite.svg#slider-arrow') }}"></use>
                                    </svg>
                                </div>
                            </div>
                        </div>
                        <div class="slider__swiper swiper">
                            <div class="swiper-wrapper" id="arenda_block">
                                @if ($house_arenda->count())
                                    @foreach ($house_arenda as $house1)
                                        @include('catalogs.elemhouse', ['house' => $house1])
                                    @endforeach
                                @else
                                    <h3>Здесь пока что нет предложений</h3>
                            @endif

                            </div>
                        </div>
                        <div class="swiper-pagination"></div>
                    </div>
                </div>
            </section>
            <section class="slider">
                <div class="container">
                    <div class="slider__wrap">
                        <div class="slider__top">
                            <h2 class="slider__title title">Продажа торговых помещений</h2><a class="slider__more" href="#">Показать все объекты</a>
                            <div class="slider__control">
                                <div class="swiper-button-prev">
                                    <svg width="10" height="17">
                                        <use xlink:href="{{ asset('images/sprite.svg#slider-arrow') }}"></use>
                                    </svg>
                                </div>
                                <div class="swiper-button-next">
                                    <svg width="10" height="17">
                                        <use xlink:href="{{ asset('images/sprite.svg#slider-arrow') }}"></use>
                                    </svg>
                                </div>
                            </div>
                        </div>
                        <div class="slider__swiper swiper">
                            <div class="swiper-wrapper" id="prodaja_block">
                                @if ($house_prodaja->count())
                                    @foreach ($house_prodaja as $house2)
                                        @include('catalogs.elemhouse', ['house' => $house2])
                                    @endforeach
                                @else
                                    <h3>Здесь пока что нет предложений</h3>
                            @endif
                            </div>
                        </div>
                        <div class="swiper-pagination"></div>
                    </div>
                </div>
            </section>
            <section class="slider">
                <div class="container">
                    <div class="slider__wrap">
                        <div class="slider__top">
                            <h2 class="slider__title title">Арендный бизнес</h2><a class="slider__more" href="#">Показать все объекты</a>
                            <div class="slider__control">
                                <div class="swiper-button-prev">
                                    <svg width="10" height="17">
                                        <use xlink:href="{{ asset('images/sprite.svg#slider-arrow') }}"></use>
                                    </svg>
                                </div>
                                <div class="swiper-button-next">
                                    <svg width="10" height="17">
                                        <use xlink:href="{{ asset('images/sprite.svg#slider-arrow') }}"></use>
                                    </svg>
                                </div>
                            </div>
                        </div>
                        <div class="slider__swiper swiper">
                            <div class="swiper-wrapper" id="bissnes_block">
                                @if ($house_bissnes->count())
                                    @foreach ($house_bissnes as $house3)
                                        @include('catalogs.elemhouse', ['house' => $house3])
                                    @endforeach
                                @else
                                    <h3>Здесь пока что нет предложений</h3>
                            @endif
                            </div>
                        </div>
                        <div class="swiper-pagination"></div>
                    </div>
                </div>
            </section>
            <section class="slider">
                <div class="container">
                    <div class="slider__wrap">
                        <div class="slider__top">
                            <h2 class="slider__title title">Арендованные</h2><a class="slider__more" href="#">Показать все объекты</a>
                            <div class="slider__control">
                                <div class="swiper-button-prev">
                                    <svg width="10" height="17">
                                        <use xlink:href="{{ asset('images/sprite.svg#slider-arrow') }}"></use>
                                    </svg>
                                </div>
                                <div class="swiper-button-next">
                                    <svg width="10" height="17">
                                        <use xlink:href="{{ asset('images/sprite.svg#slider-arrow') }}"></use>
                                    </svg>
                                </div>
                            </div>
                        </div>
                        <div class="slider__swiper swiper">
                            <div class="swiper-wrapper" id="arendovannie_block">
                                @if ($house_arendovannie->count())
                                    @foreach ($house_arendovannie as $house1)
                                        @include('catalogs.elemhouse', ['house' => $house1])
                                    @endforeach
                                @else
                                    <h3>Здесь пока что нет предложений</h3>
                            @endif

                            </div>
                        </div>
                        <div class="swiper-pagination"></div>
                    </div>
                </div>
            </section>
        </div>
    </section>
@endsection

@section('form_feedback')
    <!-- Форма обратной связи -->
    @include('form.form_feedback')
@endsection