<?php $__env->startSection("styles"); ?>
    <script src="/admin/js/search.js"></script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('contents'); ?>
    <?php if(false): ?>
<script type="text/javascript">
$(document).on('change', '[name^=address2]', function(){
        var cityId = $(this).val();
        var obj = $(this);
        var prefId = $('[name^=address1]').val();
        $.ajax({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            type: 'POST',
            datatype: 'json',
            url: '/admin/city_search',
            data: {
                prefId: prefId,
                cityId: cityId
            }
        })
        .done(function(data){ //ajaxの通信に成功した場合
            // alert("success!");
            $(obj).next('[name^=address3]').children('option').remove();
            $(obj).next('[name^=address3]').append($('<option>').text('町村を選択').attr('value', ''));
            $.each(data[0], function(row, value){
                $(obj).next('[name^=address3]').append($('<option>').text(value['name']).attr('value', value['code']));
            });

            $('[name=primary_school]').children('option').remove();
            $('[name=primary_school]').append($('<option>').text('小学校区を選択').attr('value', ''));
            $.each(data[1], function(row, value){
                $('[name=primary_school]').append($('<option>').text(value['name']).attr('value', value['code']));
            });

            $('[name=secondary_school]').children('option').remove();
            $('[name=secondary_school]').append($('<option>').text('中学校区を選択').attr('value', ''));
            $.each(data[2], function(row, value){
                $('[name=secondary_school]').append($('<option>').text(value['name']).attr('value', value['code']));
            });

        })
        .fail(function(data){ //ajaxの通信に失敗した場合
            alert("error!");
        });
    });
</script>
    <?php endif; ?>
<div class="mt5">
    <?php echo $__env->make('admin.objects.components.hp-tab', ['title' => 'HP管理ーおすすめ物件', 'type' => 'recommend'], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
    <?php echo $__env->make('admin.objects.components.regist-band', ['title' => 'おすすめ物件一覧'], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
    <form method="POST" action="<?php echo e(route('recommend-regist')); ?>#recommend_list" enctype="multipart/form-data" id="form-forsale">
    <?php echo e(csrf_field()); ?>

        <?php echo $__env->make('admin.objects.projects.search-common-multi', ['isForSale' => true, 'isregistRecommend'=> true], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
        <?php echo $__env->make('admin.objects.projects.search-footer-recommend', \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
        <?php echo $__env->make('admin.objects.components.hidden', ['name' => 'recommend', 'value' => 2], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>

<?php if(isset($recommend)): ?>
    <div id="recommend_list" class="recommend_list">

        <?php echo $__env->make('admin.objects.components.hidden', ['name' => 'remaining', 'value' => $remaining], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
        <div class="d-flex justify-content-between pager mt10">
            <div class="m-2"><span class="pager-total">検索結果&nbsp;<?php echo e($recommend->total()); ?></span><span>件中&nbsp; <?php echo e($recommend->first); ?>〜<?php echo e($recommend->last); ?>件表示</span></div>
            <div class="mt-2"><?php echo $recommend->appends($con)->fragment("recommend_list")->render(); ?></div>

        </div>
        <div>
            <a href="javascript:void(0);" name="recommend_save" class="recommend_save_btn">チェックした物件を登録する</a>
        </div>
        <table>
            <tr>
                <th class="" rowspan="2"></th>
                <th class="w150">
                    <input type="hidden" name="sort_type" value="<?php echo e(!empty(request("sort_type")) ? request("sort_type") : "desc"); ?>">
                    <div class="sort-link" sort="id">物件番号
                        <?php if(!empty(request("sort_recommend")["building_id"]) && request("sort_type") == "desc" ): ?>
                            <i class="fa fa-long-arrow-down" aria-hidden="true"></i>
                        <?php endif; ?>
                        <?php if(!empty(request("sort_recommend")["building_id"]) && request("sort_type") == "asc" ): ?>
                            <i class="fa fa-long-arrow-up" aria-hidden="true"></i>
                        <?php endif; ?>
                        <input type="hidden" name="sort_recommend[building_id]">
                    </div>
                </th>
                <th class="" colspan="2">
                    <div class="sort-link" sort="name">物件名
                        <?php if(!empty(request("sort_recommend")["name"]) && request("sort_type") == "desc" ): ?>
                            <i class="fa fa-long-arrow-down" aria-hidden="true"></i>
                        <?php endif; ?>
                        <?php if(!empty(request("sort_recommend")["name"]) && request("sort_type") == "asc" ): ?>
                            <i class="fa fa-long-arrow-up" aria-hidden="true"></i>
                        <?php endif; ?>
                        <input type="hidden" name="sort_recommend[name]">
                    </div>
                </th>
                <th class="">
                    <div class="sort-link" sort="location">所在地
                        <?php if(!empty(request("sort_recommend")["location"]) && request("sort_type") == "desc" ): ?>
                            <i class="fa fa-long-arrow-down" aria-hidden="true"></i>
                        <?php endif; ?>
                        <?php if(!empty(request("sort_recommend")["location"]) && request("sort_type") == "asc" ): ?>
                            <i class="fa fa-long-arrow-up" aria-hidden="true"></i>
                        <?php endif; ?>
                        <input type="hidden" name="sort_recommend[location]">
                    </div>
                </th>
                <th class="">
                    <div class="sort-link" sort="price">価格
                        <?php if(!empty(request("sort_recommend")["price"]) && request("sort_type") == "desc" ): ?>
                            <i class="fa fa-long-arrow-down" aria-hidden="true"></i>
                        <?php endif; ?>
                        <?php if(!empty(request("sort_recommend")["price"]) && request("sort_type") == "asc" ): ?>
                            <i class="fa fa-long-arrow-up" aria-hidden="true"></i>
                        <?php endif; ?>
                        <input type="hidden" name="sort_recommend[price]">
                    </div>
                </th>
                <th class="">
                    <div class="sort-link" sort="land_area">土地面積
                        <?php if(!empty(request("sort_recommend")["land_area_val"]) && request("sort_type") == "desc" ): ?>
                            <i class="fa fa-long-arrow-down" aria-hidden="true"></i>
                        <?php endif; ?>
                        <?php if(!empty(request("sort_recommend")["land_area_val"]) && request("sort_type") == "asc" ): ?>
                            <i class="fa fa-long-arrow-up" aria-hidden="true"></i>
                        <?php endif; ?>
                        <input type="hidden" name="sort_recommend[land_area_val]">
                    </div>
                </th>
                <th class="">
                    <div class="sort-link" sort="school">小学校区/中学校区
                        <?php if(!empty(request("sort_recommend")["school"]) && request("sort_type") == "desc" ): ?>
                            <i class="fa fa-long-arrow-down" aria-hidden="true"></i>
                        <?php endif; ?>
                        <?php if(!empty(request("sort_recommend")["school"]) && request("sort_type") == "asc" ): ?>
                            <i class="fa fa-long-arrow-up" aria-hidden="true"></i>
                        <?php endif; ?>
                        <input type="hidden" name="sort_recommend[school]">
                    </div>
                </th>
            </tr>
            <tr>
                <th class="">
                    <div class="sort-link" sort="registration_date">物件登録日
                        <?php if(!empty(request("sort_recommend")["created_at"]) && request("sort_type") == "desc" ): ?>
                            <i class="fa fa-long-arrow-down" aria-hidden="true"></i>
                        <?php endif; ?>
                        <?php if(!empty(request("sort_recommend")["created_at"]) && request("sort_type") == "asc" ): ?>
                            <i class="fa fa-long-arrow-up" aria-hidden="true"></i>
                        <?php endif; ?>
                        <input type="hidden" name="sort_recommend[created_at]">
                    </div>
                </th>
                <th class="">
                    <div class="sort-link" sort="property">物件種別
                        <?php if(!empty(request("sort_recommend")["property"]) && request("sort_type") == "desc" ): ?>
                            <i class="fa fa-long-arrow-down" aria-hidden="true"></i>
                        <?php endif; ?>
                        <?php if(!empty(request("sort_recommend")["property"]) && request("sort_type") == "asc" ): ?>
                            <i class="fa fa-long-arrow-up" aria-hidden="true"></i>
                        <?php endif; ?>
                        <input type="hidden" name="sort_recommend[property]">
                    </div>
                </th>
                <th class="">
                    <div class="sort-link" sort="floor_plan">間取り
                        <?php if(!empty(request("sort_recommend")["floor_plan"]) && request("sort_type") == "desc" ): ?>
                            <i class="fa fa-long-arrow-down" aria-hidden="true"></i>
                        <?php endif; ?>
                        <?php if(!empty(request("sort_recommend")["floor_plan"]) && request("sort_type") == "asc" ): ?>
                            <i class="fa fa-long-arrow-up" aria-hidden="true"></i>
                        <?php endif; ?>
                        <input type="hidden" name="sort_recommend[floor_plan]">
                    </div>
                </th>
                <th class="">
                    <div class="sort-link" sort="traffic">交通
                        <?php if(!empty(request("sort_recommend")["traffic"]) && request("sort_type") == "desc" ): ?>
                            <i class="fa fa-long-arrow-down" aria-hidden="true"></i>
                        <?php endif; ?>
                        <?php if(!empty(request("sort_recommend")["traffic"]) && request("sort_type") == "asc" ): ?>
                            <i class="fa fa-long-arrow-up" aria-hidden="true"></i>
                        <?php endif; ?>
                        <input type="hidden" name="sort_recommend[traffic]">
                    </div>
                </th>
                <th class="">
                    <div class="sort-link" sort="year_month">築年月
                        <?php if(!empty(request("sort_recommend")["year_month"]) && request("sort_type") == "desc" ): ?>
                            <i class="fa fa-long-arrow-down" aria-hidden="true"></i>
                        <?php endif; ?>
                        <?php if(!empty(request("sort_recommend")["year_month"]) && request("sort_type") == "asc" ): ?>
                            <i class="fa fa-long-arrow-up" aria-hidden="true"></i>
                        <?php endif; ?>
                        <input type="hidden" name="sort_recommend[year_month]">
                    </div>
                </th>
                <th class="">
                    <div class="sort-link" sort="total_area">延床面積
                        <?php if(!empty(request("sort_recommend")["total_area_val"]) && request("sort_type") == "desc" ): ?>
                            <i class="fa fa-long-arrow-down" aria-hidden="true"></i>
                        <?php endif; ?>
                        <?php if(!empty(request("sort_recommend")["total_area_val"]) && request("sort_type") == "asc" ): ?>
                            <i class="fa fa-long-arrow-up" aria-hidden="true"></i>
                        <?php endif; ?>
                        <input type="hidden" name="sort_recommend[total_area_val]">
                    </div>
                </th>
                <th class="">
                    <div class="sort-link" sort="whereabouts">階/階建
                        <?php if(!empty(request("sort_recommend")["whereabouts"]) && request("sort_type") == "desc" ): ?>
                            <i class="fa fa-long-arrow-down" aria-hidden="true"></i>
                        <?php endif; ?>
                        <?php if(!empty(request("sort_recommend")["whereabouts"]) && request("sort_type") == "asc" ): ?>
                            <i class="fa fa-long-arrow-up" aria-hidden="true"></i>
                        <?php endif; ?>
                        <input type="hidden" name="sort_recommend[whereabouts]">
                    </div>
                </th>
            </tr>
            <?php $__currentLoopData = $recommend; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <tr class="<?php if($loop->iteration % 2 == 0): ?> even <?php else: ?> odd <?php endif; ?>">
                <td rowspan="2">
                <?php echo $__env->make('admin.objects.components.checkbox', ['name' => 'recommend_target[]', 'checkbox' => [['code' => $item->building_id, 'name' => '']], 'nocheck' => true], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                </td>
                <td>物件番号<br><a class="target_link_id" href="
                    <?php if($item->property == null): ?>
                    /admin/editRoom/<?php echo e($item->mansion_id); ?>/<?php echo e($item->building_id); ?>

                    <?php elseif($item->property < 4): ?>
					/admin/editLand/<?php echo e($item->building_id); ?>

                    <?php elseif($item->property < 6): ?>
                    /admin/editHouse/<?php echo e($item->building_id); ?>

                    <?php elseif($item->property < 8): ?>
                    /admin/editMansion/<?php echo e($item->building_id); ?>

                    <?php elseif($item->property == 99): ?>
                    /admin/editLot/<?php echo e($item->building_id); ?>

					<?php endif; ?>
                "><?php echo e($item->building_id); ?></a></td>
                <td colspan="2"><?php echo e($item->name); ?></td>
                <td><?php echo e($item->address_info); ?></td>
                <td><span class="price_text"><?php echo e(number_format($item->price, 0, ",", ",")); ?></span><span>万円</span><br /><?php echo e($item->tax == 2 ? ' (税込)' : null); ?></td>
                <td><?php echo e($item->land_area_val?? "-"); ?>m&sup2;</td>
                <td><?php echo e($item->primary_school_name?? "-"); ?>/<?php echo e($item->secondary_school_name?? "-"); ?></td>
            </tr>
            <tr class="<?php if($loop->iteration % 2 == 0): ?> even <?php else: ?> odd <?php endif; ?>">
                <td>物件登録日<br /><?php echo e(date('Y/m/d', strtotime($item->created_at))); ?></td>
                <td>
                    <?php if($item->property != 1 && $item->property != 2 && $item->property != 3): ?>
                        <?php if(isset($item->property_sub) && $item->property_sub == 1): ?>
                            新築
                        <?php elseif(isset($item->property_sub) && $item->property_sub == 2): ?>
                            中古
                        <?php endif; ?>
                    <?php endif; ?>

                    <?php if(isset($item->property) && $item->property == 1): ?>
                        土地
                    <?php elseif(isset($item->property) && $item->property == 2): ?>
                        土地（借地権）
                    <?php elseif(isset($item->property) && $item->property == 3): ?>
                        土地（底地権）
                    <?php elseif(isset($item->property) && $item->property == 4): ?>
                        戸建
                    <?php elseif(isset($item->property) && $item->property == 5): ?>
                        テラスハウス
                    <?php elseif(isset($item->property) && $item->property == 6): ?>
                        マンション
                    <?php elseif(isset($item->property) && $item->property == 7): ?>
                        タウンハウス
                    <?php elseif(isset($item->m_property) && $item->m_property == 7): ?>
                        タウンハウス
                    <?php else: ?>
                        マンション
                    <?php endif; ?>
                </td>
                <td><?php echo e($item->floor_plan_text?? "-"); ?></td>
                <td><?php echo e($item->main_traffic_line); ?>「<?php echo e($item->main_traffic_station); ?>」徒歩<?php echo e($item->main_traffic_time??'-'); ?>分</td>
                <td><?php echo e($item->age_year?? "-"); ?>年<?php echo e($item->age_month?? "-"); ?>月</td>
                <td><?php echo e($item->total_area_val?? "-"); ?>m&sup2;</td>
                <td>
                    <?php echo e($item->whereabouts); ?>階/<?php echo e($item->floor); ?>階建
                </td>
            </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </table>
        <div>
            <a href="javascript:void(0);" name="recommend_save" class="recommend_save_btn">チェックした物件を登録する</a>
        </div>
        <div class="d-flex justify-content-between pager mt10">
            <div class="m-2"><span class="pager-total">検索結果&nbsp;<?php echo e($recommend->total()); ?></span><span>件中&nbsp; <?php echo e($recommend->first); ?>〜<?php echo e($recommend->last); ?>件表示</span></div>
            <div class="mt-2"><?php echo $recommend->appends($con)->fragment("recommend_list")->render(); ?></div>

        </div>
    </div>
<?php endif; ?>
    </form>
</div>
<input type="hidden" id="address3" value="<?php echo e(isset($con["address3"]) ? array_first($con["address3"]) : ""); ?>">
<input type="hidden" id="primary_school" value="<?php echo e(isset($con["primary_school"]) ? array_first($con["primary_school"]) : ""); ?>">
<input type="hidden" id="secondary_school" value="<?php echo e(isset($con["secondary_school"]) ? array_first($con["secondary_school"]) : ""); ?>">
<input type="hidden" id="access2" value="<?php echo e(isset($con["access2"]) ? array_first($con["access2"]) : ""); ?>">
<input type="hidden" id="access3" value="<?php echo e(isset($con["access3"]) ? array_first($con["access3"]) : ""); ?>">
<script src="<?php echo e(asset("admin/js/fillable_search.js")); ?>"></script>
<script src="<?php echo e(asset("admin/js/forsale_address.js")); ?>"></script>

<script>
    $(".sort-link").click(function () {
        var action = $("#form-forsale").attr("action");
        var url = window.location.href;
        action = action.replace("#recommend_list", "");
        $(this).find("input").val($(this).attr("sort"));
        if (url.indexOf("sort="+$(this).attr("sort")) !== -1) {
            var type = $("input[name='sort_type']").val();
            if (type == "desc") {
                $("input[name='sort_type']").val("asc");
            } else {
                $("input[name='sort_type']").val("desc");
            }
        } else {
            $("input[name='sort_type']").val("desc")
        }
        action = action + "?sort=" + $(this).attr("sort") + "&" + $("input[name='sort_type']").val();
        action = action + "#recommend_list";

        $("#form-forsale").attr("action", action);
        $("#form-forsale").submit();
    });
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.base', \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>