@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>
        @media all and (max-width: 1366px){
            ul.pictures li div{
                height:100%;
            }
        }

        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;
        }


        .justify-content-between li {
            display: inline-block;
        }

        .p-detail-main-sheet__left-image {
            width: 100% !important;
        }

        .pictures li {
            float: left;
            list-style: none;
            padding: 5px;
            box-sizing: border-box;
        }
        .list_pictures_4 li {
            width: 50%;
            height:auto;
            max-height:50%;
            overflow: hidden;
        }
        .list_pictures_4 li div {
            position: relative;
            width: 90%;
            border:1px solid #ccc;
        }
        .list_pictures_8 li{
            width: calc(100% / 4);
            overflow: hidden;
        }

        .list_pictures_8 li:nth-child(5){
            clear: left;
        }
        .list_pictures_12 li {
            width: 25%;
            overflow: hidden;
        }
        .list_pictures_12 li div {
            position: relative;
            width: 100%;
            border:1px solid #ccc
        }
        .list_pictures_18 li{
            width: calc(100% / 6);
            overflow: hidden;
        }
        .list_pictures_18 li:nth-child(7){
            clear: left;
        }
        .list_pictures_24 li {
            width: 16.6666666667%;
            overflow: hidden;
        }
        .list_pictures_24 li div {
            position: relative;
            width: 100%;
            border:1px solid #ccc
        }
        .list_pictures_0 li{
            margin:10% 25%;
            width: 50%;
            overflow: hidden;
        }
        /*.pictures li div:before {
            content:"";
            display: block;
            padding-top: 66%; !* 高さを幅の66%に固定 *!
        }*/
        .pictures li div{
            text-align: center;
        }
        .pictures li  div img {
            width:auto;
            max-width:100%;
            height:auto;
            max-height:100%;
            margin:auto;
            /* position: absolute; */
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            object-fit: cover;
        }
        .list_pictures_4 li div img {
            height: 280px;
        }
        .list_pictures_8 li div img, .list_pictures_12 li div img {
            height: 150px;
        }

        .list_pictures_18 li div img, .list_pictures_24 li div img {
            height: 95px;
        }
        .sheet {
            padding:9mm 0 0 0;
            width: 251mm;
            height: 177mm;
            margin:0;
            page-break-after: always;
        }
        _::-webkit-full-page-media, _:future, :root .sheet {
            padding-top:0;
        }
        .sheet_pictures {
            padding-top:0;
            width: 251mm;
            height: 165mm;
        }
        .p-print {
            margin:0 auto;
            padding:0;
        }
        h3{
            padding:9mm 0 0 0;
        }
        _::-webkit-full-page-media, _:future, :root h3 {
            padding:0 0 0 0;
        }
        .print_header{
            margin-top: 10px;
        }
        .f-left, .f-right{
            padding:5px 0
        }
    </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>
                    @if(strstr($_SERVER["REQUEST_URI"],'close'))
                        成約物件
                    @else
                        売出物件
                    @endif
                </b></p>
            @php
            if(!isset($total)){
                if(isset($count)){
                    $total = $count;
                }else{
                    $total = $article_list->total();
                }
            }
            if(isset($hide_items) && !empty($hide_items)){
                $hide_items = count($article_list->whereIn('building_id', $hide_items));
            }else{
                $hide_items = 0;
            }
            @endphp
            @if(isset($set_count))
                <p class="f-right"><b>該当件数：1</b></p>
            @else
                <p class="f-right"><b>該当件数：{{$total - $hide_items}}</b></p>
            @endif
            <div class="clear"></div>
            <hr>
        </div>
        <div class="p-detail-main-sheet">
            @foreach($article_list as $item)
                <h3>{{$item->article_name}}<!--（{{$item->main_traffic_station}} 駅）{{$item->property_name}}--><span class="p-detail-summary__price">{{number_format($item->price, 0, ",", ",")}}万円</span></h3>
                @if(count($item->photos) == 0)
                <!--<ul class="pictures list_pictures_0">
                        <li>
                          <div class="p-detail-main-sheet__left-noimage"><span>No Image</span></div>
                        </li>
                    </ul>-->
                @else
                    <div class="sheet sheet_pictures">
                        <ul class="pictures list_pictures_{{request('number')}} 1">
                        @foreach($item->photos as $index => $p)
                            @if($index % request('number') == 0 && $index != 0)
                                <!--<div class="clear"></div>-->
                        </ul>
                    </div>
                    <div class="sheet">
                        <ul class="pictures list_pictures_{{request('number')}}">
                            @endif
                            <li>
                                <div><img src="{{url($p->disp_file_path)}}"></div>
                            </li>
                        @endforeach
                        <div class="clear"></div>
                        </ul>
                    </div>
                @endif
                @if(isset($item->photos_mansion) && !empty($item->photos_mansion) && $item->photos_mansion!='[]')
                    <div class="sheet
                        @if(count($item->photos) == 0)
                            sheet_pictures
@endif
                            ">
                        <ul class="pictures list_pictures_{{request('number')}} 2">
                            @php $arrCol = [
                                    4 => 6,
                                    12 => 3,
                                    24 => 2
                                ] @endphp
                            @foreach($item->photos_mansion as $index => $p)
                                @if($index % request('number') == 0 && $index != 0)
                        </ul>
                    </div>
                    <div class="sheet">
                        <ul class="pictures list_pictures_{{request('number')}}">
                            @endif
                            <li><div><img style="max-width: 100%" src="{{ url(str_replace('public', '/storage', $p->file_path)) }}" /></div></li>
                            @endforeach
                        </ul>
                    </div>
                @endif
                @if(count($item->photos) == 0 and (!isset($item->photos_mansion) or empty($item->photos_mansion) or $item->photos_mansion=='[]'))
                    <div class="sheet sheet_pictures">
                        <ul class="pictures list_pictures_0">
                            <li>
                                <div class="p-detail-main-sheet__left-noimage"><span>No Image</span></div>
                            </li>
                        </ul>
                    </div>
                @endif
            @endforeach
        </div>
    </div>
@endsection
