@extends('business.layouts.base')


{{-- header --}}
@section('contents-header')
    @include('business.objects.projects.search-results-header', ['title' => $title ?? '売出物件', 'isForSale' => true])
@endsection

@php
if(isset($_GET['notcondition']) and $_GET['notcondition']=='notHold'){
  $buttons = [
      ['id'=>'notHold', 'title' => '「商談中・契約予定」再表示', 'class' => 'notCondition'],
      ['id'=>'btnAllDisp', 'title' => '全物件表示', 'class' => 'btnAllDisp']
  ];
}else{
  $buttons = [
      //['id'=>'notHold', 'title' => '「済・保」除外', 'class' => 'notCondition'],
      //['id'=>'notClosed', 'title' => '「済」除外', 'class' => 'notCondition'],
      //['id'=>'notEtc', 'title' => '「済等」除外', 'class' => 'notCondition'],
      ['id'=>'notHold', 'title' => '「商談中・契約予定」除外', 'class' => 'notCondition'],
      ['id'=>'btnAllDisp', 'title' => '全物件表示', 'class' => 'btnAllDisp']
  ];
}

// 並び替えデータ
$sorts = $sorts ?? [];
/*
$sort = new stdClass();
$sort->name = '新着順';
$sort->class = 'new';
array_push($sorts, $sort);

$sort = new stdClass();
$sort->name = '新価格';
$sort->class = 'newprice';
array_push($sorts, $sort);
*/
$sort = new stdClass();
$sort->name = '価格が安い順';
$sort->class = 'inexpensive';
array_push($sorts, $sort);

$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 = 'land';
array_push($sorts, $sort);

$sort = new stdClass();
$sort->name = '延べ床面積広い順';
$sort->class = 'floor';
array_push($sorts, $sort);

$sort = new stdClass();
$sort->name = '物件確認日';
$sort->class = 'conf_day';
array_push($sorts, $sort);

$sort = new stdClass();
$sort->name = '物件登録日';
$sort->class = 'created_at';
array_push($sorts, $sort);

$sort = new stdClass();
$sort->name = '物件種別';
$sort->class = 'property';
array_push($sorts, $sort);
/*
$sort = new stdClass();
$sort->name = '物件種別順';
$sort->class = 'property';
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);

$sort = new stdClass();
$sort->name = '業者順';
$sort->class = 'vendor';
array_push($sorts, $sort);
*/

$sort = new stdClass();
$sort->name = '業者電話順';
$sort->class = 'vendor_tel';
array_push($sorts, $sort);

@endphp

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

{{-- 現在の検索条件 --}}
@include('business.objects.projects.results-current-condition', ['title' => $title ?? '売出物件'])
{{-- 並び替え --}}
@include('business.objects.projects.results-sort', ['sorts' => $sorts])

@include('business.objects.projects.form-to-other', ['action' => route('business-for-sale-detail', ['id' => '']), 'id' => 'link_detail', 'params' => $params])

<script>
    localStorage.setItem("is_opended", 0);
</script>

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

{{-- 検索結果一覧 ※tab-img-or-list.bladeと連動 --}}
<div id="url-delete-article" url="{{ route('buyer.delete-article') }}"></div>
@if(strpos(url()->full(), '/for-sale') !== false  && !empty($article_list))
    <div class="buyer-action mb-3 d-flex align-items-center justify-content-between">
        <div class="container" style="max-width: 1200px; padding: 0">
            <div class="d-flex align-items-center justify-content-between">
                @include('business.pages.buyer.partials.form-save-article')
                <div class="st-count">該当物件：
                    <span class="p-search-results-header__results-total">
                            <span id="count-article-show" class="count-article-show">{{ $article_list->total() - count($article_list->whereIn('building_id', $hide_items)) }}</span>
                        </span>件表示
                    <span>/</span>
                    {{$article_list->total()}}件中
                </div>
            </div>
        </div>
    </div>
    @if(session('buyer_active'))
        @php
            $buyer = session('buyer_active');
            $buyerArticle = $buyer->articles;
        @endphp
        @include('business.pages.buyer.partials.modal-save-buyer')
    @endif
@endif
<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', [
        'type' => 'for-sale',
        'flag' => 1,
        'isShowOwnCompany' => true,
    ])
  </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', [
        'data' => $article_list,
        'flag' => 1,
        'controlArticleBuyer' => true,
        'isShowOwnCompany' => true,
    ])
  </div>
    @php $params_single = [] @endphp
    @include('business.objects.projects.form-to-other', ['action' => route('business-for-sale-setprint'), 'id' => 'multiPrintForm', 'params' => $params])
    @include('business.objects.projects.form-to-other', ['action' => route('business-for-sale-print'), 'id' => 'singlePrintForm', 'params' => $params])
    @include('business.objects.projects.form-to-other', ['action' => route('business-for-sale-setprint-vendor'), 'id' => 'multiPrintFormVendor', 'params' => $params])
    @include('business.objects.projects.form-to-other', ['action' => route('business-for-sale-print-vendor'), 'id' => 'singlePrintFormVendor', 'params' => $params])
    @include('business.objects.projects.form-to-other', ['action' => route('business-for-sale-setprint-set1'), 'id' => 'multiPrintFormSet1', 'params' => $params])
    @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) && strpos(url()->full(), '/for-sale') !== false)
    <div class="mb-3">
        @include('business.pages.buyer.partials.form-save-article', ['bottom' => true])
    </div>
@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' => 'for-sale'])}}" 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
    @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>

</form>
<form action="{{route('business-for-sale-list')}}" method="post" id="search_forsale_form">
    @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>
<script>
    $(document).ready(function () {

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

    })
</script>
@endsection
@push('scripts')
    <script src="{{ asset('/business/js/buyer.js') }}"></script>
@endpush
