<?php $__env->startSection('contents'); ?>
<div class="loading_disp loading_hide"></div>
<div class="mt5">
    <?php if(session('message')): ?>
        <div class="flash_message">
            <?php echo e(session('message')); ?>

        </div>
    <?php endif; ?>
    <?php echo $__env->make('admin.objects.components.facility-tab', ['title' => '施設管理'], \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(); ?>
    <div class="search_vendor">
        <form method="POST" class="enter-off" action="<?php echo e(route('facility-top')); ?>" id="test">
        <?php echo e(csrf_field()); ?>

        <dl class="d-flex search_vendor__con">
            <dt>施設名</dt>
            <dd><?php echo $__env->make('admin.objects.components.input', ['name' => 'search_name', 'class' => 'w400', 'value' => $search['search_name']?? ''], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?></dd>
            <dt class="ml-5">施設番号</dt>
            <dd><?php echo $__env->make('admin.objects.components.input', ['name' => 'search_id', 'class' => '', 'value' => $search['search_id']?? ''], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?></dd>
        </dl>
        <dl class="d-flex search_vendor__con">
            <dt>施設種別</dt>
            <dd>
            <?php echo $__env->make('admin.objects.components.selectbox', ['name' => 'search_property', 'class' => 'mb-2', 'options' => $facility_property, 'title' => '施設種別', 'selected' => $search['search_property']?? ''], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
            </dd>

            <dt>住所</dt>
            <dd>
              <div class="cs-flex p-search-common__tbl border-0">
                  <?php echo $__env->make('admin.objects.components.selectbox', ['name' => 'address1', 'class' => 'mb-2', 'options' => $pref, 'default' => Config::get('const.DEFAULT_PREF'), 'selected' => $search['address1']?? ''], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>

                  <div class="h-100 data-address">
                      <?php echo $__env->make('admin.objects.components.data-list', ['name' => 'list-address2', 'options' => $city, 'placeholder' => '市区郡選択', 'class' => 'list-address2',
                      'value' => !empty(request()->get('list-address2')) ? request()->get('list-address2') : "",
                        'code' => !empty(request()->get('address2')) ? request()->get('address2') : ""], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>

                      <div class="d-none">
                          <?php echo $__env->make('admin.objects.components.selectbox', ['name' => 'address2', 'class' => 'mb-2', 'options' => $city, 'title' => '市区郡', 'selected' => $search['address2']?? ''], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                      </div>
                  </div>
                  <div class="h-100 data-address">
                      <?php echo $__env->make('admin.objects.components.data-list', ['name' => 'list-address3', 'options' => $town, 'placeholder' => '町村選択', 'class' => 'list-address3 facility-address3',
                      'value' => !empty(request()->get('list-address3')) ? request()->get('list-address3') : "",
                        'code' => !empty(request()->get('address3')) ? request()->get('address3') : ""], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                      <input type="hidden" name="" id="search_address3" value="<?php echo e(isset( $search['address3']) ?  $search['address3'] : ""); ?>">
                      <div class="d-none">
                          <?php echo $__env->make('admin.objects.components.selectbox', ['name' => 'address3', 'class' => 'mb-2', 'options' => $town, 'title' => '町村', 'selected' => $search['address3']?? ''], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>

                      </div>
                  </div>
              </div>
            </dd>
        </dl>

        <div class="search_vendor__btn">
        <?php echo $__env->make('admin.objects.components.btn', ['title' => '検索', 'class'=> 'btn_search w120'], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
        <a href="<?php echo e(route('facility-regist')); ?>" class="btn_imagesave w120">新規登録</a>

        <a href="javascript:void(0);" class="facility_clear">条件をクリア</a>
        </div>
        </form>
    </div>
    <?php if(isset($facility_list)): ?>
    <?php unset($search["page"]) ?>
    <?php echo $__env->make('business.objects.projects.form-to-other', ['action' => route('business-for-sale-detail', ['id' => '']), 'id' => 'link_detail', 'params' => $search], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
    <div class="facility_list">
        <div class="d-flex justify-content-between pager mt10">
            <div class="m-2"><span class="pager-total">検索結果&nbsp;<?php echo e($facility_list->total()); ?></span><span>件中&nbsp; <?php echo e($first); ?>〜<?php echo e($last); ?>件表示</span></div>
            <div class="mt-2 business_search"><?php echo e($facility_list->links()); ?></div>
        </div>
        <table>
            <tr>
                <th class="w150">写真画像</th>
                <th >施設番号</th>
                <th class="w200">施設種別</th>
                <th class="w200">施設名</th>
                <th class="w200">住所</th>
                <?php if($user->company_id == 3): ?>
                <th class="w100">公開/非公開</th>
                <?php endif; ?>
                <th></th>
            </tr>
            <?php $__currentLoopData = $facility_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <tr id="fac_<?php echo e($item['id']); ?>">
                <td>
                    <div class="d-flex justify-content-center" style="width: 150px; height: 100px">
                        <?php if(!empty($item['file_path'])): ?>
                            <img class="img-contain" src="<?php echo e($item['file_path']); ?>" />
                        <?php else: ?>
                            <img class="img-contain" src="<?php echo e(root('img/noimage2.jpg')); ?>"/>
                        <?php endif; ?>
                    </div>
                </td>
                <td name="user_id"><a class="target_link_id" href="/admin/editFacility/<?php echo e($item['id']); ?>"><?php echo e($item['id']); ?></a></td>
                <td><?php echo e($item['property']); ?></td>
                <td><?php echo e($item['name']); ?></td>
                <td><?php echo e($item->address_info); ?></td>
                <?php if($user->company_id == 3): ?>
                <td class="text-center"><?php echo $__env->make('admin.objects.components.switch', ['name' => 'facility_disp', 'checked' => $item['kokai']], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?></td>
                <?php endif; ?>
                <td>
                    <div class="d-flex justify-content-center">
                        <?php echo $__env->make('admin.objects.components.hidden', ['name' => 'facility_id', 'value' => $item['id']], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                        <?php echo $__env->make('admin.objects.components.link-btn-nostyle', ['name' => 'edit_facility', 'url' => '/admin/editFacility/'.$item['id'], 'class' => 'edit_facilirty_btn ', 'title' => '編集'], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                        <?php if(auth()->user()->isAdministrator()): ?>
                        <button class="del_news_btn unset-modal-overlay" name="" data-toggle="modal" data-target="#deleteModal<?php echo e($item['id']); ?>">削除</button>
                        
                            <?php echo csrf_field(); ?>
                            <?php echo $__env->make('admin.objects.components.modal_confirm_delete_fac', ['id' => $item['id'], 'message' => 'この施設を削除しますがよろしいですか？'], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                        
                        <?php endif; ?>
                    </div>
                </td>
            </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </table>
        <div class="d-flex justify-content-between pager mt10">
            <div class="m-2"><span class="pager-total">検索結果&nbsp;<?php echo e($facility_list->total()); ?></span><span>件中&nbsp; <?php echo e($first); ?>〜<?php echo e($last); ?>件表示</span></div>
            <div class="mt-2 business_search"><?php echo e($facility_list->links()); ?></div>
        </div>
    </div>
    <?php endif; ?>
</div>
<?php echo $__env->make('admin.objects.projects.modal-message', \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<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>
    $(document).ready(function () {
        $(".data-list .facility-address3").keyup(function () {
            $(this).closest('.data-address').find('select').val("").trigger('change');
        });
    });
</script>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('footer-script'); ?>
    <?php if(isset($user) && $user->company_id == 3): ?>
        <script src="/admin/js/add-cp3.js"></script>
    <?php endif; ?>
<?php $__env->stopSection(); ?>

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