@extends('business.layouts.base')

{{-- header --}}
@section('contents-header')
    @include('business.objects.projects.search-results-header', ['title' => '分譲地'])
@endsection

@php
$buttons = [];

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

$sort = new stdClass();
$sort->name = '駅近い順';
$sort->class = 'station';
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.lot') }}"></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-lot', ['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-lot', ['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>
</div>
@if(!empty($article_list->first()))
    @include('business.objects.projects.form-to-other', ['action' => '/business/lot/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
<div id="modal-content" class="modal-contents">
    <input type="hidden" value="" id="type" >
    <div id="modal_open" class="p-print-modal">
        <header id="modal_header" style="text-align:right;">
            <button type="button" class="btn btn-default" data-dismiss="modal" id="modal-close" style="color:gray; font-weight:bold; font-size:30px; padding:0px; line-height:20px;background:none;">×</button>
        </header>
        <main id="modal_main">
            <p class="p-print-modal__title">レイアウトをお選びください。</p>
            <ul class="p-print-modal__menus d-flex">
                <li>
                    <p class="p-print-modal__menus-icon">
                        <a href="javascript:void(0);" class="btnPhotoPrint" data-n="4">
                            <span class="p-print-modal__menus-text">４枚ずつ</span>
                            <img src="/business/img/layout2x2.png" width="120">
                        </a>
                    </p>
                </li>
                <li>
                    <p class="p-print-modal__menus-icon">
                        <a href="javascript:void(0);" class="btnPhotoPrint" data-n="8">
                            <span class="p-print-modal__menus-text">８枚ずつ</span>
                            <img src="/business/img/layout2x4.png" width="120">
                        </a>
                    </p>
                </li>
                <li>
                    <p class="p-print-modal__menus-icon">
                        <a href="javascript:void(0);" class="btnPhotoPrint" data-n="18">
                            <span class="p-print-modal__menus-text">１８枚ずつ</span>
                            <img src="/business/img/layout3x6.png" width="120">
                        </a>
                    </p>
                </li>
            </ul>
        </main>
        <footer id="modal_footer">
        </footer>
    </div>
</div>
<form action="{{route('search_again', ['path' => 'lot'])}}" method="post" id="search_again_form">
    @csrf
    @if(!isset($params['search_sort']))
        <input type="hidden" name="search_sort" value="{{ !empty(request()->get('search_sort')) ? request()->get('search_sort') : "desc" }}">
    @endif
    @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>
<script>
    $(document).ready(function () {

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

    })
</script>
@endsection
