@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>
    li.p-detail-main-sheet__left-image:first-child {
        width: 100%;
        float: left;
    }
    li.p-detail-main-sheet__left-image {
        display: inline-block;
        padding: 8px !important;
        width:49%;
        margin-bottom: 10px;
    }
    li.p-detail-main-sheet__left-image:nth-child(2) {
        margin-left: 2%;
    }

    .justify-content-between {
        /*text-align: center;*/
    }

    .justify-content-between li {
        display: inline-block;
    }
     .sheet {
         page-break-after: auto !important;
     }
</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="p-results-noimage">
        <div class="p-detail-main-sheet mb-3 target_list sheet">
            <div class="p-content">
                <div class="f-left p-detail-main-sheet__left" style="width: 49%">
                    <div class="p-detail-main-sheet__left-name d-flex justify-content-between">
                        <h3>{{$item->article_name}}</h3>
                    </div>
                    @if($item->status == 4)
                        <p class="p-detail-main-sheet__left-closed-price">契約済み
                            / {{date('Y年m月d日', strtotime($item->close_date))}}</p>
                    @endif
                    <div>
                        <p class="p-detail-main-sheet__left-catch">{{$item->catchcopy}}</p>
                        <ul class="p-detail-main-sheet__left-points">
                            <li class="p-detail-main-sheet__left-point">{!! nl2br(e($item->point)) !!}</li>
                        </ul>
                        <ul class="w-100 list-unstyled">
                            @foreach($photos as $index => $photo)
                                <li class="p-detail-main-sheet__left-image">
                                    <img
                                        src="{{$photo->disp_file_path}}" {{$index != 0 ? 'style=width:171px !important' : ''}}>
                                </li>
                                @if($loop->iteration == 3)
                                    @php break; @endphp
                                @endif
                            @endforeach
                        </ul>
                        <table class="p-detail-main-sheet__left-etc">
                            <tr>
                                <th>マンションコメント</th>
                                <td class="p-detail-main-sheet__left-etc-facility">
                                    <p>{{$item->comment}}</p>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="f-right p-detail-main-sheet__right" style="width: 49%">
                    <table class="p-detail-main-sheet__right-tbl">
                        <tr>
                            <th>物件種別</th>
                            <td colspan="3">{{$item->property_name}}</td>
                        </tr>
                        <tr>
                            <th>所在地</th>
                            <td colspan="3"
                                class="clearfix">{{$item->pref_name}}{{$item->city_name}}{{$item->town_name}}{{$item->address}}{{$item->address}}
                                <a class="ml-2 float-right p-detail-main-sheet__right-tbl-link" target="_blank"
                                   href="https://maps.google.co.jp/maps/search/{{$item->pref_name}}{{$item->city_name}}{{$item->town_name}}{{$item->address}}">&gt;Googleマップ</a>
                            </td>
                        </tr>
                        <tr>
                            <th>交通</th>
                            <td colspan="3">
                                {{$item->main_traffic_line}}「{{$item->main_traffic_station}}」駅　
                                @if($item->main_traffic==1)
                                    徒歩{{$item->main_traffic_time??'-'}}分
                                @else
                                    @if (! empty($item->main_traffic_bus_time))
                                        バス{{$item->main_traffic_bus_time}}分　
                                    @endif
                                    @if (! empty($item->main_traffic_bus))
                                        「{{$item->main_traffic_bus}}」　
                                    @endif
                                    @if (! empty($item->main_traffic_bus_walk))
                                        停歩{{$item->main_traffic_bus_walk}}分
                                    @endif
                                @endif

                                @if($item->sub_traffic1_station)<br/>
                                {{$item->sub_traffic1_line}}「{{$item->sub_traffic1_station}}」駅　
                                @if($item->sub_traffic1==1)
                                    徒歩{{$item->sub_traffic1_time??'-'}}分
                                @else
                                    @if (! empty($item->sub_traffic1_bus_time))
                                        バス{{$item->sub_traffic1_bus_time}}分　
                                    @endif
                                    @if (! empty($item->sub_traffic1_bus))
                                        「{{$item->sub_traffic1_bus}}」　
                                    @endif
                                    @if (! empty($item->sub_traffic1_bus_walk))
                                        停歩{{$item->sub_traffic1_bus_walk}}分
                                    @endif
                                @endif
                                @endif

                                @if($item->sub_traffic2_station)<br/>
                                {{$item->sub_traffic2_line}}「{{$item->sub_traffic2_station}}」駅　
                                @if($item->sub_traffic2==1)
                                    徒歩{{$item->sub_traffic2_time??'-'}}分
                                @else
                                    @if (! empty($item->sub_traffic2_bus_time))
                                        バス{{$item->sub_traffic2_bus_time}}分　
                                    @endif
                                    @if (! empty($item->sub_traffic2_bus))
                                        「{{$item->sub_traffic2_bus}}」　
                                    @endif
                                    @if (! empty($item->sub_traffic2_bus_walk))
                                        停歩{{$item->sub_traffic2_bus_walk}}分
                                    @endif
                                @endif
                                @endif
                            </td>
                        </tr>
                        <tr>
                            <th>建物構造</th>
                            <td colspan="3">{{$item->construction_name}}
                                @if($item->construction_sub_name != "")
                                    ・一部{{$item->construction_sub_name}}@endif</td>
                        </tr>
                        {{--        <tr class="p-detail-main-sheet__right-tbl-row4">--}}
                        {{--          <th>建ぺい率</th><td>{{$item->building_rate}}&nbsp;m&sup2;</td>--}}
                        {{--          <th>容積率</th><td>{{$item->volume_rate}}</td>--}}
                        {{--        </tr>--}}
                        <tr class="p-detail-main-sheet__right-tbl-row4">
                            <th>築年月</th>
                            <td>{{$item->age_year}}年{{$item->age_month}}月</td>
                            <th>総戸数</th>
                            <td>{{$item->total_unit}}戸</td>
                        </tr>
                        <tr class="p-detail-main-sheet__right-tbl-row4">
                            <th>土地権利</th>
                            <td>{{$item->land_right_name}}</td>
                            <th>敷地面積</th>
                            <td>{{$item->land_area_val}}m&sup2;</td>
                        </tr>

                        <tr>
                            <th>用途地域</th>
                            <td colspan="3">
                                {{$item->use_area_name}}
                                @if($item->use_area_name_sub != "")
                                    一部{{$item->use_area_name_sub}}を含む
                                @endif
                            </td>
                        </tr>
                        <tr>
                            <th>共用部</th>
                            <td colspan="3">
                                @php
                                    $sharedNames = ['','ゲストルーム', '24時間ゴミ出し可', 'プール', 'エレベーター', '宅配ボックス', 'キッズルーム・託児所', '共用露天風呂', 'オートロック'];
                                    $text = '';
                                    foreach ($item->shared as $vl) {
                                        if(isset($sharedNames[$vl->item_id])) {
                                            $text .= $sharedNames[$vl->item_id].', ';
                                        }
                                    }
                                    echo rtrim($text, ', ');
                                @endphp
                            </td>
                        </tr>
                        <tr>
                            <th>分譲会社</th>
                            <td colspan="3">{{$item->sales_company?? '-'}}</td>
                        </tr>
                        <tr>
                            <th>施工会社</th>
                            <td colspan="3">{{$item->construction_company?? '-'}}</td>
                        </tr>
                        <tr>
                            <th>管理会社</th>
                            <td colspan="3">{{$item->management_company}}</td>
                        </tr>
                        <tr>
                            <th>管理形態</th>
                            <td colspan="3">{{$item->management_form_name}}</td>
                        </tr>
                        <tr>
                            <th>ペット飼育</th>
                            <td colspan="3">
                                <?php
                                if ($item->pet != null) {
                                    $names = ['未設定', '不可', '可（制限あり）'];
                                    echo $names[$item->pet];
                                    if ($item->pet == 2) {
                                        echo '/' . ($this->pet_count ?? 0) . '匹';
                                    }
                                }
                                ?>
                            </td>
                        </tr>
                        <tr>
                            <th>学校区</th>
                            <td colspan="3">
                                {{--            {{$item->primary_school_name}} / {{$item->secondary_school_name}}--}}
                                @if(isset($item->primary_school_name))
                                    {{$item->primary_school_name}}&nbsp;約{{$item->primary_school_distance}}m
                                    &nbsp; @if(isset($item->primary_school_time))/&nbsp;
                                    徒歩{{$item->primary_school_time}}分 @endif <br>
                                @endif
                                @if(isset($item->primary_school_name2))
                                    {{$item->primary_school_name2}}&nbsp;約{{$item->primary_school2_distance}}m
                                    &nbsp; @if(isset($item->primary_school_time2))/&nbsp;
                                    徒歩{{$item->primary_school_time2}}分 @endif <br>
                                @endif
                                @if(isset($item->secondary_school_name))
                                    {{$item->secondary_school_name}}&nbsp;約{{$item->secondary_school_distance}}m
                                    &nbsp; @if(isset($item->secondary_school_time))/&nbsp;
                                    徒歩{{$item->secondary_school_time}}分 @endif <br>
                                @endif
                                @if(isset($item->secondary_school_name2))
                                    {{$item->secondary_school_name2}}&nbsp;約{{$item->secondary_school2_distance}}m
                                    &nbsp; @if(isset($item->secondary_school_time2))/&nbsp;
                                    徒歩{{$item->secondary_school_time2}}分 @endif
                                @endif
                            </td>
                        </tr>
                        <tr>
                            <th>おすすめポイント</th>
                            <td colspan="3">{{$item->memo1}} {{$item->memo2}}</td>
                        </tr>
                        <tr>
                            <th>周辺施設</th>
                            <td colspan="3">
                                @foreach($item->facilirty_few as $facility)
                                    {{ $facility->name }}&nbsp;徒歩{{$facility->time}}分({{$facility->distance}}m)
                                @endforeach
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="clear"></div>
            </div>-->
            <!--<div class="p-detail-main-sheet__shop">
                <ul class="justify-content-between list-unstyled">
                    <li>
                        <p class="p-detail-main-sheet__shop-name">株式会社三春情報センター　{{$shop->name??''}}</p>
                    </li>
                    <li>
                        <p class="p-detail-main-sheet__shop-tel">TEL.{{$shop->freedial??''}}</p>
                    </li>
                    <li>
                        <p class="p-detail-main-sheet__shop-tel">
                            〒{{$shop->zip??''}}{{$shop->pref_name??''}}{{$shop->city_name??''}}{{$shop->town_name??''}}</p>
                    </li>
                    <li>
                        <p class="mb-1">マンションID：{{$item->building_id}}</p>
                    </li>
                </ul>
            </div>
            @include('business.pages.print.address-print',['pref' => $pref, 'city' =>$city,'town'=>$town])-->

        <!--</div>
    </div>-->
    <div class="p-detail-main-sheet">
            <div class="sheet">
                @include('business.objects.projects.detail-main-mansion-sheet')
            </div>
    </div>
</div>
@endsection
