{{-- 自社物件シート
    $type : 'for-sale', 'close', 'houses', 'mansion'のいずれかを設定。表示制御に利用。
--}}
<?php
$primary_school_name=$item->primary_school_name;
if(!strstr($primary_school_name,'義務教育学校')){$primary_school_name=str_replace('学校','',$primary_school_name);}
$primary_school_name2=$item->primary_school_name2;
if(!strstr($primary_school_name2,'義務教育学校')){$primary_school_name2=str_replace('学校','',$primary_school_name2);}
$primary_school_name3=$item->primary_school_name3;
if(!strstr($primary_school_name3,'義務教育学校')){$primary_school_name3=str_replace('学校','',$primary_school_name3);}
$secondary_school_name=$item->secondary_school_name;
if(!strstr($secondary_school_name,'義務教育学校')){$secondary_school_name=str_replace('学校','',$secondary_school_name);}
$secondary_school_name2=$item->secondary_school_name2;
if(!strstr($secondary_school_name2,'義務教育学校')){$secondary_school_name2=str_replace('学校','',$secondary_school_name2);}
$secondary_school_name3=$item->secondary_school_name3;
if(!strstr($secondary_school_name3,'義務教育学校')){$secondary_school_name3=str_replace('学校','',$secondary_school_name3);}
?>
@php
    $type = $type ?? 'for-sale';
@endphp
<style type="text/css" media="print">
    @page {
        size: A4 landscape;
        margin: 0mm;
    }
</style>
<style>
    li.p-detail-main-sheet__left-image:first-child {
        width: calc(100% - 190px);
        /*float: left;*/
    }

    li.p-detail-main-sheet__left-image {
        display: inline-block;
        padding: 8px !important;
    }

    .p-detail-main-sheet {
        page-break-after: always;
    }
</style>

<div class="p-detail-main-sheet">
    <div class="d-flex justify-content-between">
        <div class="p-detail-main-sheet__left">
            <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 class="p-detail-main-sheet__left-box">
                <p class="p-detail-main-sheet__left-catch">{{$item->catchcopy}}</p>
                @if (!empty($item->point))
                    <ul class="p-detail-main-sheet__left-points">
                        <li class="p-detail-main-sheet__left-point">{!! nl2br(e($item->point)) !!}</li>
                    </ul>
                @endif
                <ul class="w-100 list-unstyled">
                    @if(!empty($photos) && is_array($photos))
                        @foreach($photos as $index => $photo)
                            <li class="p-detail-main-sheet__left-photo p-detail-main-sheet__left-photo-mansion">
                                <div class="p-detail-main-sheet__left-border"><img
                                        src="{{$photo->disp_file_path}}" {{$index != 0 ? 'style=width:100%' : ''}}>
                                </div>
                            </li>
                            @php if($index==3){ break; } @endphp
                        @endforeach
                    @else
                        <li class="p-detail-main-sheet__left-photo" style="width: 100%">
                            <div class="p-detail-main-sheet__left-noimage">
                                <span>No Image</span>
                            </div>
                        </li>
                    @endif
                </ul>
            </div>
            <div class="p-detail-main-sheet__comment">{{$item->comment}}</div>
            <span class="p-detail-main-sheet__left-right">
      @if($item->land_right == 2 or $item->land_right == 3)
                    @switch($item->land_right)
                        @case(0)
                            @break
                        @case(1)
                            @break
                        @case(2)
                        @case(3)
                            <br>
                            <span>
                ■借地権種別：{{ getLeaseholdKind($item->leasehold_kind) }}
            </span>
                            <br>
                            <span>
                地代：
                @if ($item->land_rent == 1)
                                    {{ $item->land_rent_val }}円/
                                    @php
                                        $landUnits = ["", "月", "年", "一括"];
                                    @endphp
                                    {{ $landUnits[$item->land_rent_unit] ?? "" }}
                                @else
                                    無
                                @endif
            </span>
                            <br>
                            <span>
                借地期間：{{ $item->leasehold_period == 1 ? "残存" : "新規" }} ({{ $item->leasehold_period_year }}年{{ $item->leasehold_period_month }}ヶ月)
            </span>
                            <br>
                            <span>
                権利金：
                @if ($item->right_cost == 0)
                                    無
                                @else
                                    有(価格に含む) ({{ $item->right_cost_val }}万円)
                                @endif
            </span>
                            <br>
                            <span>
                保証金：
                @if ($item->deposit_cost == 0)
                                    無
                                @else
                                    有 ({{ $item->deposit_cost_val }}万円)
                                @endif
            </span>
                            <br>
                            <span>
                敷金：
                @if ($item->security_deposit_cost == 0)
                                    無
                                @else
                                    有 ({{ $item->security_deposit_cost_val }}万円)
                                @endif
            </span>
                            <br>
                            <span>
                借地権その他契約事項：{{ $item->other_leasehold }}
            </span>
                            <br>
                            @if ($item->land_right == 3)
                                <span>
                    借地権割合：{{ $item->leasehold_rate }}%
                </span>
                                <br>
                            @endif
                            @php
                                $isMore = [3, 4, 7, 8];
                            @endphp
                            @if (in_array($item->leasehold_kind, $isMore))
                                <span>
                    @php
                        $registrationsText = ["未選択", "可", "不可", "相談"];
                    @endphp
                    定期借地権設定登記：{{ $registrationsText[$item->regular_leased_registration] ?? "" }}
                </span>
                                <br>
                                <span>
                    @php
                        $seasonsText = ["未選択", "一定期間毎", "事前協議により決定"];
                    @endphp
                    定期借地権賃料改定時期：{{ $seasonsText[$item->regular_leased_season] ?? "" }}
                                    {{ $item->regular_leased_season == 1 ? $item->regular_leased_season_nen . "年毎" : "" }}
                </span>
                                <br>
                                <span>
                    @php
                        $costsText = ["未選択", "公式", "事前協議により決定"];
                    @endphp
                    定期借地権賃料改定額：{{ $costsText[$item->regular_leased_cost] ?? "" }}
                </span>
                                <br>
                                <span>
                    @php
                        $transfersText = ["未選択", "可", "不可"];
                    @endphp
                    定期借地権譲渡転貸：{{ $transfersText[$item->regular_leased_transfer] ?? "" }}
                                    @if ($item->regular_leased_transfer == 1)
                                        <br>
                                        <span>
                            @php
                                $transferMethodsText = ["未選択", "承諾不要", "通知要", "承諾要"];
                            @endphp
                            &nbsp;&nbsp;&nbsp;承諾要否・方法：{{ $transferMethodsText[$item->regular_leased_transfer_method] }}
                        </span>
                                        <br>
                                        <span>
                            @php
                                $transferNecessitiesText = ["未選択", "要", "不要", "未定"];
                            @endphp
                            &nbsp;&nbsp;&nbsp;承諾料要否：{{ $transferNecessitiesText[$item->regular_leased_transfer_necessity] }}
                        </span>
                                        <br>
                                        <span>
                            @php
                                $transferConsentsText = ["未選択", "地主", "転貸主"];
                            @endphp
                            &nbsp;&nbsp;&nbsp;承諾者：{{ $transferConsentsText[$item->regular_leased_transfer_consent] }}
                        </span>
                                    @endif
                </span>
                                <br>
                            @endif
                            @break
                    @endswitch
                @endif
                @if ($item->getLowRestrictionName())
                    ■法令上の制限：{{str_replace('<br>',', ',$item->getLowRestrictionName())}}
                @endif
                @if ($item->getOtherRestriction())
                    ■その他制限事項：{{str_replace('<br>',', ',$item->getOtherRestriction())}}
                @endif
    </span>
        </div>
        <div class="p-detail-main-sheet__right">
            <table class="p-detail-main-sheet__right-tbl">
                <tr>
                    <th>物件種別</th>
                    <td colspan="3">{{$item->property_name}}</td>
                </tr>
                <tr>
                    <th class="p-detail-main-sheet__right-tbl-double">所在地</th>
                    <td colspan="3"  class="p-detail-main-sheet__right-tbl-double">
                        {{ $item->address_info }}
                        @if(request('action') == null)
                            <a class="ml-2 float-right p-detail-main-sheet__right-tbl-link" target="_blank"
                               href="https://maps.google.co.jp/maps/search/{{ $item->address_info }}">&gt;Googleマップ</a>
                        @endif
{{--                        @if(isset($item->other_address))--}}
{{--                            {{$item->other_address}}--}}
{{--                        @endif--}}
                    </td>
                </tr>
                <tr>
                    <th class="p-detail-main-sheet__right-tbl-double">主要交通</th>
                    <td colspan="3" class="p-detail-main-sheet__right-tbl-double">
                        @include('business.objects.projects.traffic-info-other', ['article' => $item])
                    </td>
                </tr>

                <tr>
                    <th>建物構造</th>
                    <td colspan="3">{{ $item->construction_name == "鉄骨" ? "ブロック" : $item->construction_name }}
                        @if($item->construction_sub != 0)
                            ・{{$item->construction_sub_name}}
                        @endif</td>
                </tr>
                <tr>
                    <th>階数</th>
                    <td colspan="3">
                        @if($item->underground>0)
                            地上{{$item->floor ? $item->floor.'階' : ''}}
                            地下{{$item->underground ? $item->underground.'階' : ''}}建
                        @else
                            {{$item->floor ? $item->floor.'階' : ''}}建
                        @endif
                    </td>
                </tr>
                <tr>
                    @if($item->age_year == null && $item->age_month == null)
                        <th>築年月</th>
                        <td colspan="3">-</td>
                    @elseif($item->age_year > date("Y") || ($item->age_year == date("Y") && $item->age_month >= date("m") ))
                        <th>完成予定</th>
                        <td colspan="3">{{$item->age_year?? "-"}}年{{$item->age_month?? "-"}}月</td>
                    @else
                        <th>築年月</th>
                        <td colspan="3">{{$item->age_year?? "-"}}年{{$item->age_month?? "-"}}月</td>
                    @endif
                </tr>
                <tr>
                    <th>総戸数</th>
                    <td colspan="3">{{$item->total_unit}}戸</td>
                </tr>
                <tr>
                    <th>土地権利</th>
                    <td colspan="3">{{$item->land_right_name}}</td>
                </tr>
                <tr>
                    <th>敷地面積</th>
                    <td colspan="3">{{$item->land_area_val}}m&sup2;</td>
                </tr>

                <tr>
                    <th class="p-detail-main-sheet__right-tbl-double">用途地域</th>
                    <td colspan="3" class="p-detail-main-sheet__right-tbl-double">
                        {{$item->use_area_name??'-'}}@if($item->use_area_name != "" || $item->use_area_name != null)
                        @endif
                        @if($item->use_area_name_sub != "")
                            ・{{$item->use_area_name_sub}}
                        @endif
                        @if($item->use_area_name_sub2 != "")
                            ・{{$item->use_area_name_sub2}}
                        @endif
                    </td>
                </tr>
                <tr>
                    <th>都市計画</th>
                    <td colspan="3">
                        @if ($item->city_plan == 2)
                            {{ $item->getCityPlanName() }}
                        @else
                            {{ $item->getCityPlanName() }}
                        @endif
                    </td>
                </tr>
                <tr>
                    <th class="p-detail-main-sheet__right-tbl-triple">共用部</th>
                    <td colspan="3" class="p-detail-main-sheet__right-tbl-triple">
                        @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">@if($item->management_form_name)
                            {{$item->management_form_name}}@else-
                        @endif</td>
                </tr>
                <tr>
                    <!--<th>ペット飼育</th>
          <td colspan="3">
              <?php
                    if ($item->pet != null) {
                        $names = ['-', '不可', '可', '相談'];
                        echo $names[$item->pet];
                    } else {
                        echo '-';
                    }
                    ?>
                        </td>-->
                    <th>設備</th>
                    <td colspan="3">
                        {{$item->getGasName()}}
                    </td>
                </tr>
                <tr>
                    <th class="p-detail-main-sheet__right-tbl-double">学校区</th>
                    <td colspan="3" class="p-detail-main-sheet__right-tbl-double">
                        @if(!isset($item->primary_school_name) and !isset($item->secondary_school_name) && !isset($item->other_secondary_school_2) && !isset($item->other_primary_school_2))
                            -
                        @endif
                        @if(isset($item->primary_school_name))
                            {{$primary_school_name}} @if(isset($item->primary_school_distance))
                                約{{$item->primary_school_distance}}m
                            @endif @if(isset($item->primary_school_time))
                                /&nbsp;徒歩{{$item->primary_school_time}}分
                            @endif
                        @endif
                        @if(isset($item->primary_school_name2))
                            {{$primary_school_name2}} @if(isset($item->primary_school2_distance))
                                約{{$item->primary_school2_distance}}m
                            @endif @if(isset($item->primary_school_time2))
                                /&nbsp;徒歩{{$item->primary_school_time2}}分
                            @endif
                        @endif
                        @if(isset($item->primary_school_name3))
                            {{$primary_school_name3}} @if(isset($item->primary_school3_distance))
                                約{{$item->primary_school3_distance}}m
                            @endif @if(isset($item->primary_school_time3))
                                /&nbsp;徒歩{{$item->primary_school_time3}}分
                            @endif
                        @endif
                        @if(isset($item->secondary_school_name))
                            {{$secondary_school_name}} @if(isset($item->secondary_school_distance))
                                約{{$item->secondary_school_distance}}m
                            @endif @if(isset($item->secondary_school_time))
                                /&nbsp;徒歩{{$item->secondary_school_time}}分
                            @endif
                        @endif
                        @if(isset($item->secondary_school_name2))
                            {{$secondary_school_name2}} @if(isset($item->secondary_school2_distance))
                                約{{$item->secondary_school2_distance}}m
                            @endif @if(isset($item->secondary_school_time2))
                                /&nbsp;徒歩{{$item->secondary_school_time2}}分
                            @endif
                        @endif
                        @if(isset($item->secondary_school_name3))
                            {{$secondary_school_name3}} @if(isset($item->secondary_school3_distance))
                                約{{$item->secondary_school3_distance}}m
                            @endif @if(isset($item->secondary_school_time3))
                                /&nbsp;徒歩{{$item->secondary_school_time3}}分
                            @endif
                        @endif

                        @if(isset($item->other_primary_school_2))
                            {{$item->other_primary_school_2}}約{{$item->other_primary_school_3}}m
                            @if(isset($item->other_primary_school_3))
                                /徒歩{{ceil($item->other_primary_school_3/80)}}分　
                            @endif<br>
                        @endif
                        @if(isset($item->other_secondary_school_2))
                            {{$item->other_secondary_school_2}}約{{$item->other_secondary_school_3}}m
                            @if(isset($item->other_secondary_school_3))
                                /徒歩{{ceil($item->other_secondary_school_3/80)}}分　
                            @endif<br>
                        @endif
                    </td>
                </tr>
                <!--<tr>
            <th class="p-detail-main-sheet__right-tbl-border">マンション<br />コメント</th>
            <td colspan="3">
              {{$item->comment}}
                </td>
              </tr>-->
                <!--<tr>
              <th>
                  <div>備考</div>
              </th>
              <td colspan="3">{{ $item->memo_business }}</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>
    <div class="p-detail-main-sheet__shop">
        <ul class="justify-content-between list-unstyled list-inline">
            <li>
                <p class="p-detail-main-sheet__shop-name">{{ auth()->user()->companyName }} @if(auth()->user()->company_id!=2)
                        {{ $shop->name }}
                    @endif</p>
                <p class="p-detail-main-sheet__shop-address">〒{{$shop->zip??''}}
                    <span
                        style="margin-left:10px; float: right; text-align: right;">{{ $shop->address_info }}</span>
                </p>
            </li>
            <li>
                <p class="p-detail-main-sheet__shop-tel">
                    TEL.{{$shop->freedial??''}}
                </p>
                <p class="p-detail-main-sheet__shop-subtel">
                    @if(auth()->user()->company_id !== 3)
                        Tel.{{$shop->tel??'-'}}
                    @endif
                    Fax.{{$shop->fax??''}}</p>
            </li>
            <li>
                <p class="p-detail-main-sheet__shop-etc"><?php echo nl2br($shop->obi) ?? ''?></p>
            </li>
            <li class="p-detail-main-sheet__shop-number-type pr-4">
                <p class="mb-1">物件番号：<a href="/admin/editMansion/{{$item->building_id}}"
                                        target="_blank">{{$item->building_id}}</a></p>
                <!--<p class="">取引態様：{{ !in_array($item->property, [4, 5]) ? '仲介（媒介）' : $manner_name}}</p>-->
            </li>
        </ul>
    </div>
</div>
<!--@include("business.objects.components.store-info")-->
