<?php $__currentLoopData = $article_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    <?php if(!in_array($item->building_id, $hide_items)): ?>
        <?php
            if($item->mansion_id!=null){
                $mansion = $item->getMansion();
            }
        ?>
        <div class="mb-3 target_list row-house">
            <?php if(!isset($hide_flag)): ?>
                <div class="clearfix">
                    <?php if(isset($disp_flag) && $disp_flag == 1): ?>
                        <ul class="p-results-noimage__btns d-flex justify-content-center list-unstyled float-right">
                            <li>
                                <a href="javascript:void(0);" name="c-circle-btn__check"><img
                                        src="/business/img/icon_check.png"></a>
                            </li>
                            <li>
                                <a href="javascript:void(0);" id="bttnDetail<?php echo e($item['building_id']); ?>"><img
                                        src="/business/img/icon_detail.png"></a>
                            </li>
                            <li>
                                <a href="javascript:void(0);" <?php echo e($attr ?? ''); ?> class="c-circle-btn__display__list"
                                   data-id="<?php echo e($item->building_id); ?>"><img
                                        src="/business/img/icon_display.png"></a>
                            </li>
                        </ul>
                    <?php elseif(!isset($disp_flag)): ?>
                        <ul class="p-results-noimage__btns d-flex justify-content-center list-unstyled float-right">
                            <li>
                                <a href="javascript:void(0);" name="c-circle-btn__check"><img
                                        src="/business/img/icon_check.png"></a>
                            </li>
                            <li>
                                <a href="javascript:void(0);" id="bttnDetail<?php echo e($item['building_id']); ?>"><img
                                        src="/business/img/icon_detail.png"></a>
                            </li>
                            <li>
                                <a href="javascript:void(0);" <?php echo e($attr ?? ''); ?> data-id="<?php echo e($item->building_id); ?>"
                                   class="c-circle-btn__display__list"><img src="/business/img/icon_display.png"></a>
                            </li>
                        </ul>
                    <?php else: ?>
                        <div class="d-flex align-items-center justify-content-end">
                            <?php if(isset($isForSale) && $isForSale == true): ?>
                                <?php if(session('buyer_active')): ?>
                                    <?php echo csrf_field(); ?>
                                    <?php
                                        $buyer = session('buyer_active');
                                        $buyerArticle = $buyer->articles;
                                    ?>

                                <?php endif; ?>
                                <?php if(session('buyer_active') && !empty($buyerArticle->where('article_id', $item->building_id)->first())): ?>
                                    <div class="flex-center btn-buyer-action mr-1 active"
                                         data-art="<?php echo e($item->building_id); ?>">
                                        保存済
                                    </div>
                                <?php elseif(session('buyer_active')): ?>
                                    <div class="flex-center btn-buyer-action mr-1" data-art="<?php echo e($item->building_id); ?>">
                                        <img src="<?php echo e(asset('business/img/icon_keep_green.png')); ?>" alt="">
                                        保存する
                                    </div>
                                <?php endif; ?>
                            <?php endif; ?>
                            <ul class="p-results-noimage__btns p-results-noimage__btns-detail d-flex justify-content-center list-unstyled">
                                <li>
                                    <a href="javascript:void(0);" name="c-circle-btn__check"><img
                                            src="/business/img/icon_check.png"></a>
                                </li>
                            </ul>
                            <?php if(isset($isForSale) && $isForSale == true): ?>
                                <ul class="p-results-noimage__btns p-results-noimage__btns-detail d-flex justify-content-center list-unstyled ml-1">
                                    <li>
                                        <a href="javascript:void(0);" <?php echo e($attr ?? ''); ?> data-id="<?php echo e($item->building_id); ?>"
                                           class="c-circle-btn__display__list"><img
                                                src="/business/img/icon_display.png"></a>
                                    </li>
                                </ul>
                            <?php endif; ?>
                        </div>
                    <?php endif; ?>
                </div>
            <?php endif; ?>
            <?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; ?>

            <table class="p-results-noimage__tbl">
                <tr>
                    <?php if(isset($controlArticleBuyer) && $controlArticleBuyer == true): ?>
                        <td rowspan="3">
                            <?php if(strpos(url()->full(), '/for-sale') !== false): ?>
                                <div class="label-buyer-group flex-center noimage" data-art="<?php echo e($item->building_id); ?>">
                                    <?php if(session('buyer_active') && !empty($buyerArticle->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="cbn-<?php echo e($item->building_id); ?>"
                                               class="label-buyer u-checkbox pointer p-0 mb-0">
                                            <input type="checkbox" name="" value="<?php echo e($item->building_id); ?>"
                                                   id="cbn-<?php echo e($item->building_id); ?>"
                                                   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; ?>
                        </td>
                    <?php endif; ?>
                    <td rowspan="3" class="p-results-noimage__tbl-num-date">
                        <?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; ?>
                        <p><span
                                class="p-results-noimage__tbl-number">物件番号</span> <!--<a href="javascript:void(0);" id="<?php if(strstr($_SERVER['REQUEST_URI'],'detail')): ?>
                                ../../
                            <?php endif; ?> btnDetail<?php echo e($item['building_id']); ?>">--><?php echo e($item->building_id); ?><!--</a>--></p>
                        <p class="mt-1"><span class="p-results-noimage__tbl-date">物件登録日</span><br><?php if($item->created_at): ?>
                                <?php echo e($item->created_at->format('Y/m/d')); ?>

                            <?php endif; ?>
                        </p>
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                    </td>
                    <th>物件名</th>
                    <td>
                        <div class="d-flex justify-content-between">
                            <p><?php echo e($item->name); ?></p>
                            <?php if($item->property == null): ?>
                                <a href="javascript:void(0);"
                                   class="p-results-image__li-link-mansion"
                                   id="btnParentDetail<?php echo e($item->mansion_id); ?>"><img
                                        src="/business/img/icon_building.png"></a>
                            <?php endif; ?></div>
                    </td>
                    <th>所在地</th>
                    <td class="p-results-noimage__tbl-address">
                        <?php echo e($item->address_info); ?>

                    </td>
                    <th>価格</th>
                    <td class="p-results-noimage__tbl-price">
                        <?php if($item->status == 4): ?>
                            <p>最終：<span><?php echo e(number_format($item->price, 0, ",", ",")); ?></span>万円
                            </p>
                            <p>成約：<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 ? '（'.$item->close_date.'）' :''); ?></p>
                            <?php if($item->tax==2): ?>
                                <!--<p>（税込）</p>-->
                            <?php endif; ?>
                        <?php else: ?>
                            <span><?php echo e(number_format($item->price, 0, ",", ",")); ?></span>万円<?php if($item->tax==2): ?>
                                <!--（税込）-->
                            <?php endif; ?>
                        <?php endif; ?>
                    </td>
                    <th>土地</th>
                    <td class="p-results-noimage__tbl-area"><?php if(isset($mansion)): ?>
                            <?php echo e($mansion->land_area_val?? "-"); ?>

                        <?php elseif(strstr($item->property_name,'マンション') or strstr($item->property_name,'タウンハウス')): ?>
                            -
                        <?php else: ?>
                            <?php echo e($item->land_area_val?? "-"); ?>

                        <?php endif; ?> m&sup2;
                    </td>
                </tr>
                <tr>
                    <th>種別</th>
                    <td><?php echo e($item->property_name?? "-"); ?></td>
                    <th rowspan="2">交通</th>
                    <td rowspan="2">
                        <?php echo $__env->make('business.objects.projects.traffic-info', ['article' => $mansion ?? $item], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                    </td>


                    
                    <?php if(empty($mansion)): ?>
                        <?php if($item->age_year == null && $item->age_month == null && $item->completed_contract_month != null): ?>
                            <th>完成予定</th>
                            <td>契約後<?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>完成予定</th>
                            <td><?php echo e($item->age_year?? "-"); ?>年<?php echo e($item->age_month?? "-"); ?>月</td>
                        <?php else: ?>
                            <th>築年月</th>
                            <td><?php echo e($item->age_year?? "-"); ?>年<?php echo e($item->age_month?? "-"); ?>月</td>
                        <?php endif; ?>
                    <?php else: ?>
                        <?php if($mansion->age_year == null && $mansion->age_month == null): ?>
                            <th>築年月</th>
                            <td>-</td>
                        <?php elseif($mansion->age_year > date("Y") || ($mansion->age_year == date("Y") && $mansion->age_month >= date("m") )): ?>
                            <th>完成予定</th>
                            <td><?php echo e($mansion->age_year?? "-"); ?>年<?php echo e($mansion->age_month?? "-"); ?>月</td>
                        <?php else: ?>
                            <th>築年月</th>
                            <td><?php echo e($mansion->age_year?? "-"); ?>年<?php echo e($mansion->age_month?? "-"); ?>月</td>
                        <?php endif; ?>
                    <?php endif; ?>
                    <th>延床</th>
                    <td><?php echo e($item->total_area_val?? "-"); ?>m&sup2;</td>
                </tr>
                <tr>
                    <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?? "-"); ?>

                            <br>
                        <?php endif; ?>
                        <?php if(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 endif; ?>
                    </td>
                    <th>階数</th>
                    <td>
                        <?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>間取り</th>
                    
                    <td><?php if($item->floor_plan_name!=''): ?>
                            <?php echo e($item->floor_plan); ?><?php echo e($item->floor_plan_name); ?>

                        <?php else: ?>
                            <?php echo e('-'); ?>

                        <?php endif; ?></td>
                </tr>
            </table>
            
            <?php
                $count = 0;
                if(isset($item->history)) {
                    $count = count($item->history);
                }
                $uuid = \Ramsey\Uuid\Uuid::uuid4();
            ?>
            <?php echo $__env->make('business.objects.projects.form-check', [
                'data_num' => $uuid,
                'history_count' => $count,
                'showFormCheck' => $showFormCheck ?? '',
                '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(); ?>
        </div>
    <?php endif; ?>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
