<div class="p-results-sort">
    <p class="p-results-sort__title">並び替え</p>
    <ul class="p-results-sort__sort">
        <?php echo $__env->make('business.pages.buyer.partials.sort-link', ['name' => 'price', 'label' => '価格が安い順'], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
        <?php echo $__env->make('business.pages.buyer.partials.sort-link', ['name' => 'created_at', 'label' => '保存日が新しい順'], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
    </ul>
</div>
<?php if(!$article_list->isEmpty()): ?>
    <ul class="p-results-image list-unstyled tab-pane active" style="background: transparent">
        <?php echo $__env->make('business.pages.buyer.partials.form-delete-article', \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
        <?php $__currentLoopData = $article_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <?php if($item != null): ?>
            <li class="p-results-image__li row-house">
                <div class="p-results-image__li-head d-flex justify-content-between">
                    <div>
                        <div class="d-flex p-results-image__title">
                            <label for="cb-<?php echo e($key); ?>" class="label-buyer u-checkbox mb-0" style="background: #ededed">
                                <input type="checkbox" name="" value="<?php echo e($item->building_id); ?>" id="cb-<?php echo e($key); ?>" class="u-checkbox__obj checkbox-buyer">
                                <span class="u-checkbox__text"></span>
                            </label>
                            <div>
                                <div class="d-flex align-items-center justify-content-between">
                                    <ul class="d-flex list-unstyled">
                                        <?php if($item->status == 2): ?>
                                            <p class="mt-1 p-results-noimage__tbl-statusbox"><span class="p-results-noimage__tbl-status">商談中</span></p>
                                        <?php elseif($item->status == 3): ?>
                                            <p class="mt-1 p-results-noimage__tbl-statusbox"><span class="p-results-noimage__tbl-status">契約予定</span></p>
                                        <?php elseif($item->status == 4): ?>
                                            <p class="mt-1 p-results-noimage__tbl-statusbox"><span class="p-results-noimage__tbl-status">契約済</span></p>
                                        <?php elseif($item->status == 5): ?>
                                            <p class="mt-1 p-results-noimage__tbl-statusbox"><span class="p-results-noimage__tbl-status">売りやめ</span></p>
                                        <?php elseif($item->status == 6): ?>
                                            <p class="mt-1 p-results-noimage__tbl-statusbox"><span class="p-results-noimage__tbl-status">保留</span></p>
                                        <?php endif; ?>
                                        <?php if($item->property==1 or $item->property==2 or $item->property==3): ?>
                                            <li class="p-results-image__mark--land">土地</li>
                                        <?php elseif($item->property==4 or $item->property==5): ?>
                                            <?php
                                                $item->property_name=str_replace('戸建','一戸建て',$item->property_name)
                                            ?>
                                            <?php if($item->property_sub==1): ?>
                                                <li class="p-results-image__mark--nhouse"><?php echo e($item->property_name); ?></li>
                                            <?php else: ?>
                                                <li class="p-results-image__mark--uhouse"><?php echo e($item->property_name); ?></li>
                                            <?php endif; ?>
                                        <?php else: ?>
                                            <li class="p-results-image__mark--mansion"><?php echo e($item->property_name); ?></li>
                                        <?php endif; ?>
                                        <?php if($item->new): ?>
                                            <li class="p-results-image__mark--new">NEW</li><?php endif; ?>
                                        <?php if($item->exterior == 2 || $item->interior == 2): ?>
                                            <li class="p-results-image__mark--reform">リフォーム済</li><?php endif; ?>
                                    </ul>
                                    <p class="p-results-image__li-name"><?php echo e($item->name); ?><!--（<?php echo e($item->main_traffic_station); ?>）--></p>
                                </div>
                                <div>保存日: <?php echo e($item->created_at->format('Y/m/d H:i')); ?></div>
                            </div>
                            <?php if($item->property == null): ?><a href="javascript:void(0);"
                                                           class="c-circle-btn__building c-circle-btn"
                                                           id="btnParentDetail<?php echo e($item->mansion_id); ?>"><p>建物</p><img
                                    src="<?php echo e(asset('business/img/icon_building.png')); ?>"></a><?php endif; ?>
                        </div>
                    </div>
                    <ul class="p-results-image__li-btns d-flex justify-content-end list-unstyled">
                        <li>
                            <?php echo $__env->make('business.objects.components.circle-btn',
                                ['id' => 'btnCheck', 'class' => 'c-circle-btn__check', 'linkUrl' => '#',
                                'img' => asset('business/img/icon_check.png'), 'title' => '確認'], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                        </li>
                        <li>
                            <?php echo $__env->make('business.objects.components.circle-btn',
                                ['id' => 'bttnDetail'.$item->building_id, 'class' => 'c-circle-btn__detail', 'linkUrl' => 'javascript:void(0);',
                                'img' => asset('business/img/icon_detail.png'), 'title' => '詳細'], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                        </li>
                    </ul>
                </div>
                <?php if($item->event_category): ?>
                    <div class="p-results-image__event">
                        <?php if($item->event_category==1): ?>
                            【現地見学会】
                        <?php elseif($item->event_category==2): ?>
                            【現地案内会】
                        <?php elseif($item->event_category==3): ?>
                            【現地販売会】
                        <?php elseif($item->event_category==4): ?>
                            【オープンハウス】
                        <?php elseif($item->event_category==5): ?>
                            【オープンルーム】
                        <?php endif; ?>
                        <?php if($item->event_schedule==1): ?>
                            毎週土日祝
                        <?php elseif($item->event_schedule==2): ?>
                            毎週土日
                        <?php elseif($item->event_schedule==3): ?>
                            <?php echo e(date('n/j', strtotime($item->event_day))); ?>

                        <?php elseif($item->event_schedule==4): ?>
                            <?php echo e(date('n/j', strtotime($item->from_event))); ?>〜<?php echo e(date('n/j', strtotime($item->to_event))); ?>

                        <?php elseif($item->event_schedule==5): ?>
                            公開中
                        <?php endif; ?>
                        <?php if($item->from_hour or $item->to_hour): ?>
                            <?php if($item->from_hour): ?><?php echo e($item->from_hour); ?>:<?php echo e(sprintf('%02d', $item->from_minute)); ?><?php endif; ?>
                            〜<?php if($item->to_hour): ?><?php echo e($item->to_hour); ?>:<?php echo e(sprintf('%02d', $item->to_minute)); ?><?php endif; ?>
                        <?php endif; ?>
                        <?php if($item->reservation==1): ?>
                            ＜完全予約制＞
                        <?php endif; ?>
                    </div>
                <?php endif; ?>
                <div class="p-results-image__image-area d-flex">
                    <div class="p-results-image__image d-flex">
                        <?php if(!empty($item->mansion_id)): ?>
                            <?php if(!empty(optional($item)->image_mansion)): ?>
                                <div class="p-results-image__image-box"><img
                                        src="<?php echo e(str_replace('public', '/storage', optional($item)->image_mansion->file_path)); ?>"/></div>
                            <?php else: ?>
                                <div class="p-results-image__image-box"><img src="<?php echo e(root('img/noimage2.jpg')); ?>"/></div>
                            <?php endif; ?>
                            <?php if(!empty($item->floor_file_path)): ?>
                                <div class="p-results-image__image-box"><img src="<?php echo e($item->floor_file_path); ?>"/></div>
                            <?php else: ?>
                                <div class="p-results-image__image-box"><img src="<?php echo e(root('img/noimage2.jpg')); ?>"/></div>
                            <?php endif; ?>
                        <?php else: ?>
                            <?php if(!empty($item->top_file_path)): ?>
                                <div class="p-results-image__image-box"><img src="<?php echo e($item->top_file_path); ?>"/></div>
                            <?php else: ?>
                                <div class="p-results-image__image-box"><img src="<?php echo e(root('img/noimage2.jpg')); ?>"/></div>
                            <?php endif; ?>

                            <?php if(!empty($item->floor_file_path)): ?>
                                <div class="p-results-image__image-box"><img src="<?php echo e($item->floor_file_path); ?>"/></div>
                            <?php else: ?>
                                <div class="p-results-image__image-box"><img src="<?php echo e(root('img/noimage2.jpg')); ?>"/></div>
                            <?php endif; ?>
                        <?php endif; ?>

                    </div>
                    <table class="p-results-image__main-info">
                        <tr>
                            <?php if($item->status == 4): ?>
                                <th class="p-results-image__main-info-price_closing_title">物件価格</th>
                                <td class="p-results-image__main-info-price_closing" colspan="5">
                                    <span>最終：</span><?php if($item->price): ?><?php echo e(number_format($item->price, 0, ",", ",")); ?>

                                    <?php else: ?>-<?php endif; ?><span>万円</span>
                                    <span>成約：</span><?php if($item->price_closing): ?><?php echo e(number_format($item->price_closing, 0, ",", ",")); ?>

                                    <?php else: ?>-<?php endif; ?><span>万円<?php echo e($item->close_date ? '（'.date("Y.m.d" ,strtotime($item->close_date)).'）' :''); ?></span>
                                    <?php if($item->tax==2): ?><!--<span>（税込）</span>--><?php endif; ?>
                                </td>
                            <?php else: ?>
                                <th class="p-results-image__main-info-price_title">物件価格</th>
                                <td class="p-results-image__main-info-price" colspan="5">
                                    <?php echo e(number_format($item->price, 0, ",", ",")); ?>

                                    <span>万円<?php if($item->tax==2): ?><!--（税込）--><?php endif; ?></span>
                                </td>
                            <?php endif; ?>
                        </tr>
                        <tr>
                            <th class="p-results-image__main-info-address">所在地</th>
                            <td colspan="3"><?php echo e($item->address); ?></td>
                            <th style="width:16%;">物件番号</th>
                            <td colspan="2"><?php echo e($item->building_id); ?></td>
                        </tr>
                        <tr class="p-results-image__main-info-access">
                            <th>交通</th>
                            <td colspan="5">
                                <?php echo $__env->make('business.objects.projects.traffic-info', ['article' => $item], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                            </td>
                        </tr>
                        <tr>
                            <?php if($item->age_year == null && $item->age_month == null && $item->completed_contract_month != null): ?>
                                <th style="width:12%;">完成予定</th>
                                <td style="width:15%;">契約後<?php echo e($item->completed_contract_month); ?>ヶ月</td>
                            <?php elseif($item->age_year > date("Y") || ($item->age_year == date("Y") && $item->age_month >= date("m") )): ?>
                                <th style="width:12%;">完成予定</th>
                                <td style="width:15%;"><?php echo e($item->age_year?? "-"); ?>年<?php echo e($item->age_month?? "-"); ?>月</td>
                            <?php else: ?>
                                <th style="width:12%;">築年月</th>
                                <td style="width:15%;"><?php echo e($item->age_year?? "-"); ?>年<?php echo e($item->age_month?? "-"); ?>月</td>
                        <?php endif; ?>

                        <!--<th style="width:12%;">築年数</th>
                            <td style="width:12%;"><?php echo e($item->age?? "-"); ?>年</td>-->
                            <th style="width:15%;">間取り・階数</th>
                            <td>
                                <?php echo e($item->floor_plan_text?? "-"); ?>・
                                <?php if($item->whereabouts or $item->maisonette==1): ?>
                                    <?php if($item->maisonette==1): ?>
                                        <?php echo e($item->maisonette_from ? $item->maisonette_from : ''); ?>

                                        〜<?php echo e($item->maisonette_to ? $item->maisonette_to : ''); ?>階
                                    <?php elseif($item->whereabouts): ?>
                                        <?php echo e($item->whereabouts?? "-"); ?>階
                                    <?php else: ?>
                                        -
                                    <?php endif; ?>
                                <?php endif; ?>
                                <?php if($item->floor): ?>
                                    <?php if(!empty($item->mansion_id)): ?>
                                        <?php if(optional($item->getMansion())->underground): ?>
                                            /地上<?php echo e(optional($item->getMansion())->floor); ?>階 地下<?php echo e(optional($item->getMansion())->underground); ?>階建
                                        <?php elseif(optional($item->getMansion())->floor): ?>
                                            /<?php echo e(optional($item->getMansion())->floor); ?>階建
                                        <?php endif; ?>
                                    <?php else: ?>
                                        <?php if(optional($item)->underground): ?>
                                            /地上<?php echo e(optional($item)->floor); ?>階 地下<?php echo e(optional($item)->underground); ?>階建
                                        <?php elseif(optional($item)->floor): ?>
                                            /<?php echo e(optional($item)->floor); ?>階建
                                        <?php endif; ?>
                                    <?php endif; ?>
                                <?php endif; ?>
                                <?php if(!$item->whereabouts and $item->maisonette!=1 and !$item->floor): ?>
                                    -
                                <?php endif; ?>
                            </td>
                            <th style="width:12%;">延床面積</th>
                            <td style="width:12%;"><?php echo e($item->total_area_val?? "-"); ?>m&sup2;</td>
                        </tr>
                        <tr>
                            <th>現況</th>
                            <td>
                                <?php if($item->status == 4): ?>
                                    契約済<!-- / <?php echo e(number_format($item->price_closing, 0, ",", ",")); ?>万円<?php echo e($item->close_date ? '（'.$item->close_date.'）' :''); ?>-->
                                <?php elseif($item->status == 5): ?>
                                    売りやめ
                                <?php else: ?>
                                    <?php echo e($item->current_status??"-"); ?>

                                <?php endif; ?>
                            </td>
                            <th>学校区</th>
                            <td><?php echo e($item->primary_school_name?? "-"); ?>/<?php echo e($item->secondary_school_name?? "-"); ?></td>
                            <th>土地面積</th>
                            <td><?php echo e($item->land_area_val?? "-"); ?>m&sup2;</td>
                        </tr>
                    </table>
                    <p class="p-results-image__info-photo align-self-end">
                        <?php
                            $isMansion = [6,7];
                            $isHouse = [4,5];
                        ?>
                        <img src="<?php echo e(asset('business/img/icon_camera.png')); ?>" alt="写真">
                        <?php if(empty($item->property) && is_numeric($item->mansion_file_count)): ?>
                            外<?php echo e($item->mansion_file_count); ?>/内<?php echo e($item->file_count); ?>

                        <?php elseif(in_array($item->property, $isMansion)): ?>
                            外<?php echo e($item->mansion_file_count); ?>

                        <?php elseif(in_array($item->property, $isHouse)): ?>
                            外<?php echo e($item->mansion_file_count); ?>/内<?php echo e($item->file_count); ?>

                        <?php else: ?>
                            <?php echo e($item->file_count); ?>

                        <?php endif; ?>
                    </p>
                </div>
                <?php
                    $uuid = \Ramsey\Uuid\Uuid::uuid4();
                ?>
                
                <?php echo $__env->make('business.objects.projects.form-check', ['data_num' => $uuid, 'history_count' => count($item->history)], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                <?php echo $__env->make('business.objects.projects.modal-history', ['history' => $item->history, 'data_num' => $uuid], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
            </li>
            <?php endif; ?>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        <?php echo $__env->make('business.pages.buyer.partials.form-delete-article', \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
    </ul>
<?php endif; ?>
