<?php $__currentLoopData = $article_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    <?php if(!in_array($item->building_id, $hide_items)): ?>
        <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">
                        <?php if(strpos(url()->full(), '/for-sale') !== false): ?>
                            <div class="label-buyer-group" data-art="<?php echo e($item->building_id); ?>">
                                <?php if(session('buyer_active') && !empty(session('buyer_active')->articles->where('article_id', $item->building_id)->first())): ?>
                                    <label class="label-buyer p-0 mb-0 delete-article">
                                        <div class="w-100 text-center">保存済</div>
                                    </label>
                                <?php else: ?>
                                    <label for="cb-<?php echo e($key); ?>" class="label-buyer u-checkbox pointer p-0 mb-0">
                                        <input type="checkbox" name="" value="<?php echo e($item->building_id); ?>" id="cb-<?php echo e($key); ?>"
                                               class="u-checkbox__obj checkbox-buyer pointer cb-<?php echo e($item->building_id); ?>">
                                        <span class="u-checkbox__text"></span>
                                    </label>
                                <?php endif; ?>
                            </div>
                        <?php endif; ?>
                        <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>
                        <?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="../../business/img/icon_building.png"></a>
                        <?php endif; ?>
                    </div>
                </div>
                <ul class="p-results-image__li-btns d-flex justify-content-end list-unstyled">
                    <?php if($flag == 1 || $flag == 2): ?>
                        <li>
                            <?php echo $__env->make('business.objects.components.circle-btn',
                                ['id' => 'btnCheck', 'class' => 'c-circle-btn__check', 'linkUrl' => '#',
                                'img' => '../../business/img/icon_check.png', 'title' => '確認'], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                        </li>
                    <?php endif; ?>
                    <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' => '../../business/img/icon_detail.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' => 'btnDisplay', 'class' => 'c-circle-btn__display', 'linkUrl' => '#',
                            'img' => '../../business/img/icon_display.png', 'title' => '非表示',
                            'attr' => 'data-id='.$item->building_id], \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
                          $eventDay = trim($item->event_day, ' ,');
                          $dates = explode(',', $eventDay);
                          $formattedDates = array_map(function($date) {
                              return date('n/j', strtotime($date));
                          }, $dates);
                          $result = count($formattedDates) > 1 ? implode('・', $formattedDates) : $formattedDates[0];
                      ?>
                      <?php echo e($result); ?>

                    <?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($item->vertical === 1): ?>
                            <?php if(!empty($item->file_path2)): ?>
                                <div class="p-results-image__image-box popup"><img src="<?php echo e($item->file_path2); ?>"/></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->floor_file_path)): ?>
                                <div class="p-results-image__image-box popup"><img src="<?php echo e($item->floor_file_path); ?>"/></div>
                            <?php elseif(!empty($item->sheet_file_path3) && $item->sheet_file_type == 1): ?>
                                <div class="p-results-image__image-box popup"><img
                                        src="<?php echo e(asset(str_replace('public/', 'storage/', $item->sheet_file_path3))); ?>"/>
                                </div>
                            <?php else: ?>
                                <div class="p-results-image__image-box"><img src="<?php echo e(root('img/noimage2.jpg')); ?>"/></div>
                            <?php endif; ?>
                        <?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($item->vertical === 1): ?>
                                <?php if(!empty($item->file_path2)): ?>
                                    <div class="p-results-image__image-box popup"><img src="<?php echo e(str_replace('public/', 'storage/', url($item->file_path2))); ?>"/></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->floor_file_path)): ?>
                                <div class="p-results-image__image-box popup"><img src="<?php echo e($item->floor_file_path); ?>"/></div>
                            <?php elseif(!empty($item->sheet_file_path3) && $item->sheet_file_type == 1): ?>
                                <div class="p-results-image__image-box popup"><img
                                        src="<?php echo e(asset(str_replace('public/', 'storage/', $item->sheet_file_path3))); ?>"/>
                                </div>
                            <?php else: ?>
                                <div class="p-results-image__image-box"><img src="<?php echo e(root('img/noimage2.jpg')); ?>"/></div>
                            <?php endif; ?>
                        <?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><span
                                    id="item-price-<?php echo e($item->building_id); ?>"><?php if($item->price): ?><?php echo e(number_format($item->price, 0, ",", ",")); ?></span>
                                <?php else: ?>-<?php endif; ?>万円
                                <span>成約：</span><?php if($item->price_closing): ?>
                                    <span
                                        id="close-price-<?php echo e($item->building_id); ?>"><?php echo e(number_format($item->price_closing, 0, ",", ",")); ?></span>
                                <?php else: ?>
                                    <span id="close-price-<?php echo e($item->building_id); ?>">-</span>
                                <?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">
                                <span
                                    id="item-price-<?php echo e($item->building_id); ?>"><?php echo e(number_format($item->price, 0, ",", ",")); ?></span>
                                万円<?php if($item->tax==2): ?>
                                    <!--（税込）-->
                                <?php endif; ?>
                            </td>
                        <?php endif; ?>
                    </tr>
                    <tr>
                        <th class="p-results-image__main-info-address">所在地</th>
                        <td colspan="3">
                            <?php
                                if (!is_null($item->mansion_id) && \App\Models\Article::getDataById($item->mansion_id))
                                    $address = \App\Models\Article::getDataById($item->mansion_id);
                                else
                                    $address = $item;
                            ?>
                            <?php echo e($address->address_info); ?>








                        </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-summary', ['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 if(isset($item->primary_school_name) || isset($item->secondary_school_name)): ?>
                                <?php echo e($item->primary_school_name?? "-"); ?>/<?php echo e($item->secondary_school_name?? "-"); ?>

                            <?php elseif(isset($item->other_primary_school_2) || isset($item->other_secondary_school_2)): ?>
                                <?php echo e($item->other_primary_school_2 ?? "-"); ?>/<?php echo e($item->other_secondary_school_2 ?? "-"); ?>

                            <?php else: ?>
                                -/-
                            <?php endif; ?>
                        </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="../../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),
                'isShowOwnCompany' => $isShowOwnCompany ?? false,
            ], \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(); ?>
