@php
    $is_opended = isset($params['is_opended']) && $params['is_opended'] == '1';

    function outputSelected($val) {
        if($val == 2) {
            return '<span class="round-checked"></span>';
        }
        return '<span class="round-uncheck"></span>';
    }

    function getMannerName($manner, $vendor) {
        foreach ($manner as $m) {
            if($m['code'] == $vendor['manner']) {
                    return $m['name'];
            }
        }
    }
@endphp


@extends('business.layouts.print-layout')

@section('print-content')
    <style>
        .sheet {
            page-break-after: auto !important;
        }
        .mansion-list:nth-child(9n) {
            page-break-after: always;
        }
        .p-results-image__li-link-mansion{
            display:none;
        }
        i.fa{
          display:none;
        }
        .p-results-noimage__tbl {
          font-size:10px;
        }
        .p-results-noimage__tbl-number, .p-results-noimage__tbl-date {
          font-size:10px;
        }
        .p-results-noimage__tbl-num-date a {
          font-size:10px;
        }
        .p-results-noimage__tbl-num-date{
          width:80px;
        }
        .w300{
          width:220px;
        }
        .p-mansion-room__tbl {
          font-size:10px;
        }
        input {
          border: none;
          background-image: none;
          background:none;
          font-size:10px;
        }
        .cal_picker{
          background-image: none;
        }
        .c-selectbox {
          border: none;
          background:none;
          -webkit-appearance: none;
          -moz-appearance: none;
          appearance: none;
        }
        .p-form-check__status {
          width: 80px;
          padding: 2px;
          font-size:10px;
        }
        .p-form-check .article_conf .c-input {
          width: 100%;
        }
        .p-form-check__div{
          width: calc(70% - 80px);
          overflow-x: hidden;
          height:130px;
        }
        .p-form-check__tblsub{
          width: 30%;
        }
        .p-form-check__tbl {
          font-size:10px;
        }
        .p-form-check__tblsub {
          font-size:10px;
        }
        .p-form-check__tbl-list li p {
          font-size:10px;
          text-align: left;
          margin-left:2px;
        }
        .p-form-check__tbl-change-day, .p-form-check__tbl-closed-day, .p-form-check__tbl-checked-day, .p-form-check__tbl-flyer-day-txt{
          font-size:10px;
        }
        .p-form-check__tbl-name{
          width:auto;
        }
        .p-form-check__tbl-person{
          width:20%;
        }
        .p-form-check__tbl-tel{
          width:20%;
        }
        .p-form-check__tblsub tr td{
          height:auto;
          padding:2px !important;
        }
        .p-form-check__etc{
          height:60px;
        }
        .p-form-check__tbl-link-history{
          display:none;
        }
        .p-form-check__tbl-link-id{
          color:#000;
        }
        .p-form-check__tbl-list li.p-form-check__tbl-list-allx{
          display:none;
        }
        .p-mansion-room__tbl th, .p-mansion-room__tbl td {
          padding:5px;
        }
        .w90 {
          width:80px;
        }
        .w120 {
          width:100px;
        }
        .w160 {
          width:100px;
        }
        .no-print{
          display:none;
        }
        .w100 {
          width:60px;
        }
        .p-form-check__tbl-closed-day{
          width:60px;
        }
        .mb-3 {margin-top: 1.5rem;}
    </style>

    <style type="text/css" media="print">
        @page
        {
            size: auto;   /* auto is the initial value */
            margin: 0mm;  /* this affects the margin in the printer settings */
        }
    </style>

<div class="p-print">
    <div class="print_header">
        <p class="f-left"><b>マンション建物</b></p>
        <p class="f-right"><b>該当件数：{{ $total }}</b></p>
        <div class="clear"></div>
        <hr>
        @if(isset($condition['count_search']))
            <div class="">
                {{--                <p class="p-results-current-condition__panel--number">01</p>--}}
                @for($i = 0; $i < $condition['count_search']; $i++)
                    <p class="mt-2">
                        @if($condition['count_search'] > 1)
                            <span class="mr-1 p-2">{{$i + 1}}</span>
                        @endif
                        @foreach($condition as $key => $val)
                            @if(is_array($val))
                                @if(isset($val[$i]))
                                    <span class="p-results-current-condition__panel--title">{{$key}}：</span>
                                    <span class="border-right border-dark pr-2 mr-1">{{$val[$i]}}</span>
                                @endif
                            @endif
                        @endforeach
                    </p>
                @endfor
            </div>
        @else
            @foreach($condition as $key => $val)
                <p><span class="p-results-current-condition__panel--title">{{$key}}：</span>{{$val}}</p>
            @endforeach
        @endif
        <hr>
    </div>

    @include('business.objects.projects.results-noimage-mansion', ['data' => $article_list, 'flag' => 3, 'print' => 1])

    <!--
    <div class="p-results-noimage">
        @foreach($article_list as $item)
            <div class="mb-3 target_list sheet">
                <table class="p-results-noimage__tbl">
                    <tr>
                        <td rowspan="2" class="p-results-noimage__tbl-num-date">
                            <p><span class="p-results-noimage__tbl-number">物件番号</span><br>{{$item->building_id}}</p>
                            <p class="mt-1"><span class="p-results-noimage__tbl-date">物件登録日</span><br>{{$item->created_at}}
                            </p>
                        </td>
                        <th>物件名</th>
                        <td colspan="3">
                            <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_detail.png"></a>@endif                </div>
                        </td>
                        <th>所在地</th>
                        <td>{{$item->pref_name}}{{$item->city_name}}{{$item->town_name}}</td>
                        <th>価格</th>
                        <td><span>{{number_format($item->price, 0, ",", ",")}}</span>万円</td>
                        <th>土地</th>
                        <td>{{$item->land_area_val?? "-"}}m&sup2;</td>
                        <th>校区</th>
                        <td>{{$item->primary_school_name?? "-"}}<br/>{{$item->secondary_school_name?? "-"}}</td>
                    </tr>
                    <tr>
                        <th>種別</th>
                        <td>{{$item->property_name?? "-"}}</td>
                        <th>間取り</th>
                        {{--            <td>{{$item->floor_plan_text?? "-"}}</td>--}}
                        <td>{{$item->floor_plan}}{{$item->floor_plan_name}}</td>
                        <th>交通</th>
                        <td>
                            {{$item->main_traffic_line?? "-"}}「{{$item->main_traffic_station?? "-"}}」駅　
                            @if($item->main_traffic_time == null)
                                @if($item->main_traffic_bus_time)
                                    バス{{$item->main_traffic_bus_time?? "-"}}分
                                @endif
                                @if ($item->main_traffic_bus)
                                    「{{$item->main_traffic_bus}}」
                                @endif
                                @if($item->main_traffic_bus_walk)
                                    停歩{{$item->main_traffic_bus_walk?? "-"}}分
                                @endif
                            @else
                                徒歩{{$item->main_traffic_time?? "-"}}分
                            @endif
                        </td>
                        <th>築年月</th>
                        <td>{{$item->age_year?? "-"}}年{{$item->age_month?? "-"}}月</td>
                        <th>延床</th>
                        <td>{{$item->total_area_val?? "-"}}m&sup2;</td>
                        <th>階数</th>
                        <td>
                            @if($item->floor)
                                @if($item->whereabouts)
                                    {{$item->whereabouts?? "-"}}階/
                                @endif
                                {{$item->floor}}階建
                            @else
                                -
                            @endif
                        </td>
                    </tr>
                </table>
                {{-- 確認ボタンクリック時に表示する --}}
                @php
                    $count = 0;
                    if(isset($item->history)) {
                        $count = count($item->history);
                    }
                    $data_num = $loop->iteration;
                    $history_count = $count;

                    $target = [
                      ['code' => '', 'name' => ''],
                      ['code' => '1', 'name' => '未'],
                      ['code' => '2', 'name' => '可'],
                      ['code' => '3', 'name' => '不可'],
                    ];
                @endphp
                <div class="p-form-check" style="display:{{ (isset($is_opended) && $is_opended == true) ? 'block': 'none'}}">
                    <div class="p-form-check__status f-left">
                        <p>公開中</p>
                    </div>
                    <div class="p-form-check__div">
                        @if(isset($item['vendor_info']))
                            <table class="p-form-check__tbl">
                                @foreach($item['vendor_info'] as $vendor)
                                    <tr>
                                        <th>業者名</th>
                                        <td colspan="3" class="p-form-check__tbl-name p-1">{{$vendor['name']}}</td>
                                        <th>担当</th><td class="p-form-check__tbl-person">{{$vendor['charge']}}</td>
                                        <th>電話</th><td class="p-form-check__tbl-tel">{{$vendor['vendor_tel1']}}</td>
                                    </tr>
                                    <tr>
                                        <th>業者ID</th><td colspan="3">{{$vendor['vendor_id']}}</td>
                                        <th>態様</th><td>
                                            {{getMannerName($manner, $vendor)}}
{{--                                                    @include('business.objects.components.selectbox', ['name' => 'manner[]', 'options' => $manner, 'class' => 'ml-1', 'selected' => $vendor['manner']])--}}
                                        </td>
                                        <th>FAX</th><td>{{$vendor['vendor_fax']}}</td>
                                    </tr>
                                    <tr style="height:85px;">
                                        <td colspan="1">
                                            <p class="pl-2">物件確認日</p>{{$vendor['article_conf_day']}}</td>
                                        <td colspan="7" class="p-2">
                                            <ul class="d-flex p-form-check__tbl-list p-0">
                                                <li><p>チラシ</p>{!! outputSelected($vendor['flyer']) !!}</li>
                                                <li><p>情報誌</p>{!! outputSelected($vendor['freepaper']) !!}</li>
                                                <li><p>自社HP</p>{!! outputSelected($vendor['house_hp']) !!}</li>
                                                <li><p>ポータル</p>{!! outputSelected($vendor['portal']) !!}</li>
                                                <li><p>現地看板</p>{!! outputSelected($vendor['signboard']) !!}</li>
                                                <li class=" p-form-check__tbl-list-allx"><p>全X</p></li>
                                                <li><p>確認手法</p>{{$vendor['ad_conf'] == 1? 'TEL': 'FAX'}}</li>
                                                <li class="p-form-check__tbl-flyer-day"><p>広告確認日</p>{{$vendor['ad_conf_day']}}</li>
                                            </ul>
                                        </td>
                                    </tr>
                                @endforeach
                            </table>
                        @endif
                    </div>
                    <table class="p-form-check__tblsub p-form-check__tbl">
                        <tr>
                            <td class="p-form-check__tbl-history" style="overflow-y:unset">
                                <div class="p-form-check__tbl-history-div" style="margin-left: 10px">
                                    @include('admin.objects.components.checkbox', ['name' => 'change_flag', 'checkbox' => [['code' => 1, 'name' => '価格変更']]])
{{--                                            @include('business.objects.components.input', ['name' => 'change_price', 'class' => 'p-form-check__tbl-txt-change-price'])<span>万円</span>--}}
{{--                                            @include('business.objects.components.input', ['name' => 'change_price_date', 'class' => 'cal_picker p-form-check__tbl-change-day'])--}}
{{--                                            @include('business.objects.components.link', ['url' => '', 'title' => '履歴('.($history_count?? 0).')', 'class' => 'modal-open-history p-form-check__tbl-link-history', 'data_num' => $data_num??''])--}}
                                </div>
                            </td>
                            <td class="p-form-check__tbl-closed">{{$item['price']}}万円</td>
                            <td class="p-form-check__tbl-closed">{{$item['price_date']}}</td>
                        </tr>
                        <tr>
                            <td class="p-form-check__tbl-closed">{{getStatus($item['status'])}}</td>
                            <td class="p-form-check__tbl-closed">{{$item['price_closing']}}万円</td>
                            <td class="p-form-check__tbl-closed">{{$item['close_date']}}</td>
                        </tr>
                        <tr style="height:85px;">
                            <td>BK {{$item['bk']}} - 鍵 {{$item['key_text']}}</td>
                            <td colspan="2">備考 {{$item['memo1']}}</td>
                        </tr>
                    </table>
                    <div class="clear"></div>
                </div>
            </div>
        @endforeach
    </div>-->
</div>
@endsection
