@extends('business.layouts.base')

{{-- header --}}
@section('contents-header')
    @include('business.objects.projects.search-results-header', ['title' => 'マンション建物'])
@endsection

@php
$buttons = [
    //['id'=>'btnAllDisp', 'title' => '全物件表示']
];

// TODO:並び替えデータ
$sorts = $sorts ?? [];

$sort = new stdClass();
$sort->name = '駅近い順';
$sort->class = 'station';
array_push($sorts, $sort);

$sort = new stdClass();
$sort->name = '築年浅い順';
$sort->class = 'age';
array_push($sorts, $sort);
/*
$sort = new stdClass();
$sort->name = '所在地順';
$sort->class = 'address';
array_push($sorts, $sort);

$sort = new stdClass();
$sort->name = '沿線・駅順';
$sort->class = 'line';
array_push($sorts, $sort);
*/
@endphp

@section('contents')
{{-- 画像有/リスト切り替え、除外ボタンリスト --}}
@include('business.objects.projects.results-switching', ['buttons' => $buttons])

{{-- 現在の検索条件 --}}
@include('business.objects.projects.results-current-condition-mansion', ['title' => 'マンション建物'])

{{-- 並び替え --}}
@include('business.objects.projects.results-sort', ['sorts' => $sorts])
@include('business.objects.projects.form-to-other', ['action' => route('business-mansion-detail', ['id' => '']), 'id' => 'link_detail', 'params' => $params])

@include('business.objects.components.loading')
<div class="d-none" id="url-ajax-pagination" url="{{ route('business.ajax.mansion') }}"></div>

{{-- 検索結果一覧 ※tab-img-or-list.bladeと連動 --}}
<a href="" class="d-none nav-link active" id="nav-image-tab"></a>
<div class="tab-content mt-3">
  <div class="tab-pane u-bg-default {{ !isset($type_page) || (isset($type_page) && $type_page == 1) ? "active" : "" }}" id="nav-image" role="tabpanel" aria-labell edby="nav-image-tab">
    @include('business.objects.projects.results-image-mansion', ['type' => 'mansion', 'flag' => 3])
  </div>
  <div class="tab-pane u-bg-default {{ (isset($type_page) && $type_page == 2) ? "active" : "" }}" id="nav-list" role="tabpanel" aria-labelledby="nav-list-tab">
    @include('business.objects.projects.results-noimage-mansion', ['data' => $article_list, 'flag' => 3])
  </div>
    @if(count($article_list) > 0)
        @include('business.objects.components.btn_more')
    @endif
    <div id="all-items" items="{{ $article_list_id ?? "" }}"></div>
    @if(!empty($article_list->first()))
        @include('business.objects.projects.form-to-other', ['action' => '/business/mansion/parentDetail/'.$article_list->first()->building_id, 'id' => 'multiPrintForm', 'params' => $params, 'print_action' => true])
        @include('business.objects.projects.form-to-other', ['action' => route('business-for-sale-print'), 'id' => 'singlePrintForm', 'params' => $params ?? []])
    @endif
    @include('business.objects.components.modal-photo-print')
    <form action="{{route('search_again', ['path' => 'mansion'])}}" method="post" id="search_again_form">
        @if(!isset($params['search_sort']))
            <input type="hidden" name="search_sort" value="{{ !empty(request()->get('search_sort')) ? request()->get('search_sort') : "desc" }}">
        @endif
        @if(strpos(url()->full(), 'sort=station') !== false)
            <input type="hidden" name="sort" value="station">
        @endif
        @if(strpos(url()->full(), 'sort=age') !== false)
            <input type="hidden" name="sort" value="age">
        @endif
        @csrf
        @foreach($params as $k => $v)
            @if(is_array($v))
                @foreach($v as $vv)
                    <input type="hidden" name="{{$k}}[]" value="{{$vv}}">
                @endforeach
            @else
                <input type="hidden" name="{{$k}}" value="{{$v}}">
            @endif
        @endforeach
    </form>
</div>
<script>
    $(document).ready(function () {

        $(".cal_picker").datepicker({
            format: "yyyy-mm-dd",
            locale: 'ja',
            language: 'ja',
            weekStart: 1,
            todayHighlight: true,
            autoclose: true,
        });

    })
</script>
@endsection
