@foreach($article_list as $item)
    @if (!in_array($item->building_id, $hide_items))
        @php
            if($item->mansion_id!=null){
                $mansion = $item->getMansion();
            }
        @endphp
        <div class="mb-3 target_list row-house">
            @if(!isset($hide_flag))
                <div class="clearfix">
                    @if(isset($disp_flag) && $disp_flag == 1)
                        <ul class="p-results-noimage__btns d-flex justify-content-center list-unstyled float-right">
                            <li>
                                <a href="javascript:void(0);" name="c-circle-btn__check"><img
                                        src="/business/img/icon_check.png"></a>
                            </li>
                            <li>
                                <a href="javascript:void(0);" id="bttnDetail{{$item['building_id']}}"><img
                                        src="/business/img/icon_detail.png"></a>
                            </li>
                            <li>
                                <a href="javascript:void(0);" {{$attr ?? ''}} class="c-circle-btn__display__list"
                                   data-id="{{$item->building_id}}"><img
                                        src="/business/img/icon_display.png"></a>
                            </li>
                        </ul>
                    @elseif(!isset($disp_flag))
                        <ul class="p-results-noimage__btns d-flex justify-content-center list-unstyled float-right">
                            <li>
                                <a href="javascript:void(0);" name="c-circle-btn__check"><img
                                        src="/business/img/icon_check.png"></a>
                            </li>
                            <li>
                                <a href="javascript:void(0);" id="bttnDetail{{$item['building_id']}}"><img
                                        src="/business/img/icon_detail.png"></a>
                            </li>
                            <li>
                                <a href="javascript:void(0);" {{$attr ?? ''}} data-id="{{$item->building_id}}"
                                   class="c-circle-btn__display__list"><img src="/business/img/icon_display.png"></a>
                            </li>
                        </ul>
                    @else
                        <div class="d-flex align-items-center justify-content-end">
                            @if(isset($isForSale) && $isForSale == true)
                                @if(session('buyer_active'))
                                    @csrf
                                    @php
                                        $buyer = session('buyer_active');
                                        $buyerArticle = $buyer->articles;
                                    @endphp

                                @endif
                                @if(session('buyer_active') && !empty($buyerArticle->where('article_id', $item->building_id)->first()))
                                    <div class="flex-center btn-buyer-action mr-1 active"
                                         data-art="{{ $item->building_id }}">
                                        保存済
                                    </div>
                                @elseif(session('buyer_active'))
                                    <div class="flex-center btn-buyer-action mr-1" data-art="{{ $item->building_id }}">
                                        <img src="{{ asset('business/img/icon_keep_green.png') }}" alt="">
                                        保存する
                                    </div>
                                @endif
                            @endif
                            <ul class="p-results-noimage__btns p-results-noimage__btns-detail d-flex justify-content-center list-unstyled">
                                <li>
                                    <a href="javascript:void(0);" name="c-circle-btn__check"><img
                                            src="/business/img/icon_check.png"></a>
                                </li>
                            </ul>
                            @if(isset($isForSale) && $isForSale == true)
                                <ul class="p-results-noimage__btns p-results-noimage__btns-detail d-flex justify-content-center list-unstyled ml-1">
                                    <li>
                                        <a href="javascript:void(0);" {{$attr ?? ''}} data-id="{{$item->building_id}}"
                                           class="c-circle-btn__display__list"><img
                                                src="/business/img/icon_display.png"></a>
                                    </li>
                                </ul>
                            @endif
                        </div>
                    @endif
                </div>
            @endif
            @if($item->event_category)
                <div class="p-results-image__event">
                    @if($item->event_category==1)
                        【現地見学会】
                    @elseif($item->event_category==2)
                        【現地案内会】
                    @elseif($item->event_category==3)
                        【現地販売会】
                    @elseif($item->event_category==4)
                        【オープンハウス】
                    @elseif($item->event_category==5)
                        【オープンルーム】
                    @endif
                    @if($item->event_schedule==1)
                        毎週土日祝
                    @elseif($item->event_schedule==2)
                        毎週土日
                    @elseif($item->event_schedule == 3)
                      @php
                          $eventDay = trim($item->event_day, ' ,');
                          $dates = explode(',', $eventDay);
                          $formattedDates = array_map(function($date) {
                              return date('n/j', strtotime($date));
                          }, $dates);
                          $result = count($formattedDates) > 1 ? implode('・', $formattedDates) : $formattedDates[0];
                      @endphp
                      {{ $result }}
                    @elseif($item->event_schedule==4)
                        {{date('n/j', strtotime($item->from_event))}}〜{{date('n/j', strtotime($item->to_event))}}
                    @elseif($item->event_schedule==5)
                        公開中
                    @endif
                    @if($item->from_hour or $item->to_hour)
                        @if($item->from_hour)
                            {{$item->from_hour}}:{{sprintf('%02d', $item->from_minute)}}
                        @endif〜@if($item->to_hour)
                            {{$item->to_hour}}:{{sprintf('%02d', $item->to_minute)}}
                        @endif
                    @endif
                    @if($item->reservation==1)
                        ＜完全予約制＞
                    @endif
                </div>
            @endif

            <table class="p-results-noimage__tbl">
                <tr>
                    @if(isset($controlArticleBuyer) && $controlArticleBuyer == true)
                        <td rowspan="3">
                            @if(strpos(url()->full(), '/for-sale') !== false)
                                <div class="label-buyer-group flex-center noimage" data-art="{{ $item->building_id }}">
                                    @if(session('buyer_active') && !empty($buyerArticle->where('article_id', $item->building_id)->first()))
                                        <label class="label-buyer p-0 mb-0 delete-article">
                                            <div class="w-100 text-center">保存済</div>
                                        </label>
                                    @else
                                        <label for="cbn-{{$item->building_id}}"
                                               class="label-buyer u-checkbox pointer p-0 mb-0">
                                            <input type="checkbox" name="" value="{{ $item->building_id }}"
                                                   id="cbn-{{$item->building_id}}"
                                                   class="u-checkbox__obj checkbox-buyer pointer cb-{{ $item->building_id }}">
                                            <span class="u-checkbox__text"></span>
                                        </label>
                                    @endif
                                </div>
                            @endif
                        </td>
                    @endif
                    <td rowspan="3" class="p-results-noimage__tbl-num-date">
                        @if($item->status == 2)
                            <p class="mt-1 p-results-noimage__tbl-statusbox"><span
                                    class="p-results-noimage__tbl-status">商談中</span></p>
                        @elseif($item->status == 3)
                            <p class="mt-1 p-results-noimage__tbl-statusbox"><span
                                    class="p-results-noimage__tbl-status">契約予定</span></p>
                        @elseif($item->status == 4)
                            <p class="mt-1 p-results-noimage__tbl-statusbox"><span
                                    class="p-results-noimage__tbl-status">契約済</span></p>
                        @elseif($item->status == 5)
                            <p class="mt-1 p-results-noimage__tbl-statusbox"><span
                                    class="p-results-noimage__tbl-status">売りやめ</span></p>
                        @elseif($item->status == 6)
                            <p class="mt-1 p-results-noimage__tbl-statusbox"><span
                                    class="p-results-noimage__tbl-status">保留</span></p>
                        @endif
                        <p><span
                                class="p-results-noimage__tbl-number">物件番号</span> <!--<a href="javascript:void(0);" id="@if(strstr($_SERVER['REQUEST_URI'],'detail'))
                                ../../
                            @endif btnDetail{{$item['building_id']}}">-->{{$item->building_id}}<!--</a>--></p>
                        <p class="mt-1"><span class="p-results-noimage__tbl-date">物件登録日</span><br>@if($item->created_at)
                                {{$item->created_at->format('Y/m/d')}}
                            @endif
                        </p>
                        {{--<p class="mt-1">--}}
                        {{--@if($item->event_category==1)--}}
                        {{--【現地見学会】--}}
                        {{--@elseif($item->event_category==2)--}}
                        {{--【現地案内会】--}}
                        {{--@elseif($item->event_category==3)--}}
                        {{--【現地販売会】--}}
                        {{--@elseif($item->event_category==4)--}}
                        {{--【オープンハウス】--}}
                        {{--@elseif($item->event_category==5)--}}
                        {{--【オープンルーム】--}}
                        {{--@endif--}}
                        {{--<br />--}}
                        {{--@if($item->event_schedule==1)--}}
                        {{--毎週土日祝--}}
                        {{--@elseif($item->event_schedule==2)--}}
                        {{--毎週土日--}}
                        {{--@elseif($item->event_schedule==3)--}}
                        {{--日時指定--}}
                        {{--@elseif($item->event_schedule==4)--}}
                        {{--期間限定--}}
                        {{--@elseif($item->event_schedule==5)--}}
                        {{--公開中--}}
                        {{--@endif--}}
                        {{--<br />--}}
                        {{--{{$item->from_hour}}:{{$item->from_minute}}〜{{$item->to_hour}}:{{$item->to_minute}}--}}
                        {{--</p>--}}
                    </td>
                    <th>物件名</th>
                    <td>
                        <div class="d-flex justify-content-between">
                            <p>{{$item->name}}</p>
                            @if($item->property == null)
                                <a href="javascript:void(0);"
                                   class="p-results-image__li-link-mansion"
                                   id="btnParentDetail{{$item->mansion_id}}"><img
                                        src="/business/img/icon_building.png"></a>
                            @endif</div>
                    </td>
                    <th>所在地</th>
                    <td class="p-results-noimage__tbl-address">
                        {{ $item->address_info }}
                    </td>
                    <th>価格</th>
                    <td class="p-results-noimage__tbl-price">
                        @if($item->status == 4)
                            <p>最終：<span>{{number_format($item->price, 0, ",", ",")}}</span>万円
                            </p>
                            <p>成約：<span>@if($item->price_closing)
                                        {{number_format($item->price_closing, 0, ",", ",")}}@else-
                                    @endif</span>万円{{$item->close_date ? '（'.$item->close_date.'）' :'' }}</p>
                            @if($item->tax==2)
                                <!--<p>（税込）</p>-->
                            @endif
                        @else
                            <span>{{number_format($item->price, 0, ",", ",")}}</span>万円@if($item->tax==2)
                                <!--（税込）-->
                            @endif
                        @endif
                    </td>
                    <th>土地</th>
                    <td class="p-results-noimage__tbl-area">@if(isset($mansion))
                            {{$mansion->land_area_val?? "-"}}
                        @elseif(strstr($item->property_name,'マンション') or strstr($item->property_name,'タウンハウス'))
                            -
                        @else
                            {{$item->land_area_val?? "-"}}
                        @endif m&sup2;
                    </td>
                </tr>
                <tr>
                    <th>種別</th>
                    <td>{{$item->property_name?? "-"}}</td>
                    <th rowspan="2">交通</th>
                    <td rowspan="2">
                        @include('business.objects.projects.traffic-info', ['article' => $mansion ?? $item])
                    </td>


                    {{--                    <th>築年月xx</th>--}}
                    @if (empty($mansion))
                        @if($item->age_year == null && $item->age_month == null && $item->completed_contract_month != null)
                            <th>完成予定</th>
                            <td>契約後{{$item->completed_contract_month}}ヶ月</td>
                        @elseif($item->age_year > date("Y") || ($item->age_year == date("Y") && $item->age_month >= date("m") ))
                            <th>完成予定</th>
                            <td>{{$item->age_year?? "-"}}年{{$item->age_month?? "-"}}月</td>
                        @else
                            <th>築年月</th>
                            <td>{{$item->age_year?? "-"}}年{{$item->age_month?? "-"}}月</td>
                        @endif
                    @else
                        @if($mansion->age_year == null && $mansion->age_month == null)
                            <th>築年月</th>
                            <td>-</td>
                        @elseif($mansion->age_year > date("Y") || ($mansion->age_year == date("Y") && $mansion->age_month >= date("m") ))
                            <th>完成予定</th>
                            <td>{{$mansion->age_year?? "-"}}年{{$mansion->age_month?? "-"}}月</td>
                        @else
                            <th>築年月</th>
                            <td>{{$mansion->age_year?? "-"}}年{{$mansion->age_month?? "-"}}月</td>
                        @endif
                    @endif
                    <th>延床</th>
                    <td>{{$item->total_area_val?? "-"}}m&sup2;</td>
                </tr>
                <tr>
                    <th>校区</th>
                    <td>
                        @if(isset($item->primary_school_name) || isset($item->secondary_school_name))
                            {{$item->primary_school_name?? "-"}}/{{$item->secondary_school_name?? "-"}}
                            <br>
                        @endif
                        @if(isset($item->other_primary_school_2) || isset($item->other_secondary_school_2))
                            {{$item->other_primary_school_2?? "-"}}/{{$item->other_secondary_school_2?? "-"}}
                        @endif
                    </td>
                    <th>階数</th>
                    <td>
                        @if($item->whereabouts or $item->maisonette==1)
                            @if($item->maisonette==1)
                                {{$item->maisonette_from ? $item->maisonette_from : ''}}
                                〜{{$item->maisonette_to ? $item->maisonette_to : ''}}階
                            @elseif($item->whereabouts)
                                {{$item->whereabouts?? "-"}}階
                            @else
                                -
                            @endif
                        @endif
                        @if($item->floor)
                            @if(!empty($item->mansion_id))
                                @if(optional($item->getMansion())->underground)
                                    /地上{{optional($item->getMansion())->floor}}階
                                    地下{{ optional($item->getMansion())->underground }}階建
                                @elseif(optional($item->getMansion())->floor)
                                    /{{optional($item->getMansion())->floor}}階建
                                @endif
                            @else
                                @if(optional($item)->underground)
                                    /地上{{optional($item)->floor}}階 地下{{ optional($item)->underground }}階建
                                @elseif(optional($item)->floor)
                                    /{{optional($item)->floor}}階建
                                @endif
                            @endif
                        @endif
                        @if(!$item->whereabouts and $item->maisonette!=1 and !$item->floor)
                            -
                        @endif
                    </td>
                    <th>間取り</th>
                    {{--<td>{{$item->floor_plan_text?? "-"}}</td>--}}
                    <td>@if($item->floor_plan_name!='')
                            {{$item->floor_plan}}{{$item->floor_plan_name}}
                        @else
                            {{ '-' }}
                        @endif</td>
                </tr>
            </table>
            {{-- 確認ボタンクリック時に表示する --}}
            @php
                $count = 0;
                if(isset($item->history)) {
                    $count = count($item->history);
                }
                $uuid = \Ramsey\Uuid\Uuid::uuid4();
            @endphp
            @include('business.objects.projects.form-check', [
                'data_num' => $uuid,
                'history_count' => $count,
                'showFormCheck' => $showFormCheck ?? '',
                'isShowOwnCompany' => $isShowOwnCompany ?? false,
            ])
            @include('business.objects.projects.modal-history', ['history' => $item->history, 'data_num' => $uuid])
        </div>
    @endif
@endforeach
