@extends('admin.layouts.base')
@section('contents')
<div class="loading_disp loading_hide"></div>
<div class="mt5">
    @include('admin.objects.components.facility-tab', ['title' => '施設管理'])
    @include('admin.objects.components.regist-band', ['title' => '施設登録'])
    <form method="POST" action="{{ route('facility-edit', ['id' => $facility_info->id]) }}" enctype="multipart/form-data" id="enter-off">
    {{ csrf_field() }}
    <div id="@if(isset($tmp_id)){{$tmp_id}}@endif"  class="facility_regist @if(isset($add_class)) {{$add_class}} @endif">
        <div id="image_list">
            <table style="margin-bottom: 0">
                <tr>
                    <td rowspan="8" colspan="2">
                        <div class="facility_image_area">
                            @include('admin.objects.components.add-facility-image', ['id' => 'imageArea'])
                        </div>
                        <div class="facility_image_area_sub">
                            @include('admin.objects.components.hidden', ['name' => 'del_img'])
                            @include('admin.objects.components.btn', ['name' => 'del_facility_img', 'type' => 'button', 'title' => '削除'])
                        </div>
                        <div class="mt-2">※縦横比が縦3:横4の画像を推奨します</div>
                    </td>
                    <th width="10%">施設ID</th>
                    <td colspan="3">
                        {{$facility_info->id}}
                    </td>
                </tr>
                <tr>
                    <th>施設名</th>
                    <td>
                        @include('admin.objects.components.input', ['name' => 'name', 'class' => 'w200', 'value' => $facility_info->name])
                    </td>
                    <th>施設種別</th>
                    <td>
                        @include('admin.objects.components.selectbox', ['name' => 'kind', 'options' => $kind, 'title' => '施設種別', 'selected' => $facility_info->kind])
                    </td>
                </tr>
                <tr>
                    <th>住所</th>
                    <td colspan="3">
                        <div>
                            &#12306;@include('admin.objects.components.input', ['name' => 'zip', 'class' => 'mb-2', 'placeholder' => '000-0000', 'class' => 'zip', 'value' => $facility_info['zip']])
                            @include('admin.objects.components.btn', ['title' => '郵便番号から住所決定', 'class' => 'btn_decision', 'id'=>'zipToAddress', 'type' => 'button', 'class' => 'zipToAddress btn_decision'])
                            @include('admin.objects.components.btn', ['title' => '住所から郵便番号決定', 'class' => 'btn_decision', 'id' => 'addressToZip', 'type' => 'button', 'class' => 'addressToZip btn_decision'])
                        </div>
                        <div class="d-flex p-search-common__tbl border-0">
                            @include('admin.objects.components.selectbox', ['name' => 'address1', 'class' => 'mb-2 address1', 'options' => $pref, 'selected' => !empty($facility_info['address1']) ? $facility_info['address1'] : Config::get('const.DEFAULT_PREF')])
                            @if (auth()->user()->isOwnerOfSaiKyoto())
                                <div class="h-100 data-address ml-2">
                                    @include('admin.objects.components.data-list', ['name' => 'list-address2[]', 'options' => $city, 'placeholder' => '市区郡選択',
                                    'class' => 'list-address2', 'value' => !empty(request()->get('list-address2')[0]) ? request()->get('list-address2')[0] : (!empty($facility_info['address2']) ? $facility_info['address2'] : ""),
                                    'code' => !empty(request()->get('address2')[0]) ? request()->get('address2')[0] : (!empty($facility_info['address2']) ? $facility_info['address2'] : "")])
                                    <div style="display: none">
                                        @include('admin.objects.components.selectbox', ['name' => 'address2', 'class' => 'mb-2 sai-kyoto address2', 'options' => $city, 'title' => '市区郡', 'selected' => $facility_info['address2']])
                                    </div>
                                </div>
                                <div class="h-100 data-address ml-2">
                                    @include('admin.objects.components.data-list', ['name' => 'list-address3[]', 'placeholder' => '町村選択', 'options' => $town,
                                    'class' => 'list-address3', 'value' => !empty(request()->get('list-address3')[0]) ? request()->get('list-address3')[0] : (!empty($facility_info['address3']) ? $facility_info['address3'] : ""),
                                    'code' => !empty(request()->get('address3')[0]) ? request()->get('address3')[0] : (!empty($facility_info['address3']) ? $facility_info['address3'] : "")])
                                    <div style="display: none">
                                        @include('admin.objects.components.selectbox', ['name' => 'address3', 'class' => 'mb-2 address3', 'options' => $town, 'title' => '町村', 'selected' => $facility_info['address3']])
                                    </div>
                                </div>

                            @else

                                <div class="h-100 data-address ml-2">
                                    @include('admin.objects.components.data-list', ['name' => 'list-address2[]', 'options' => $city, 'placeholder' => '市区郡選択',
                                    'class' => 'list-address2', 'value' => !empty(request()->get('list-address2')[0]) ? request()->get('list-address2')[0] : (!empty($facility_info['address2']) ? $facility_info['address2'] : ""),
                                    'code' => !empty(request()->get('address2')[0]) ? request()->get('address2')[0] : (!empty($facility_info['address2']) ? $facility_info['address2'] : "")])
                                    <div style="display: none">
                                        @include('admin.objects.components.selectbox', ['name' => 'address2', 'class' => 'mb-2 address2', 'options' => $city, 'title' => '市区郡', 'selected' => $facility_info['address2']])
                                    </div>
                                </div>
                                <div class="h-100 data-address ml-2">
                                    @include('admin.objects.components.data-list', ['name' => 'list-address3[]', 'placeholder' => '町村選択', 'options' => $town,
                                    'class' => 'list-address3', 'value' => !empty(request()->get('list-address3')[0]) ? request()->get('list-address3')[0] : (!empty($facility_info['address3']) ? $facility_info['address3'] : ""),
                                    'code' => !empty(request()->get('address3')[0]) ? request()->get('address3')[0] : (!empty($facility_info['address3']) ? $facility_info['address3'] : "")])
                                    <div style="display: none">
                                        @include('admin.objects.components.selectbox', ['name' => 'address3', 'class' => 'mb-2 address3', 'options' => $town, 'title' => '町村', 'selected' => $facility_info['address3']])
                                    </div>
                                </div>
                            @endif

                        </div>
                        <div>
                            @include('admin.objects.components.input', ['name' => 'address4', 'class' => 'w-50', 'placeholder' => '町村以降を入力', 'value' => $facility_info['address4']])
                        </div>
                        <script src="{{ asset("admin/js/forsale_address.js") }}"></script>

                    </td>
                </tr>
                <tr>
                    <th>物件位置情報</th>
                    <td colspan="3">
                        緯度&nbsp;@include('admin.objects.components.input', ['name' => 'lat', 'value' => $facility_info->lat])<span class="d-none" name="lat_text">未設定</span>経度&nbsp;@include('admin.objects.components.input', ['name' => 'lng', 'value' => $facility_info->lng])<span class="d-none" name="lng_text">未設定</span>
                        @include('admin.objects.components.modal-btn', ['title' => '位置確認・修正', 'class' => 'btn_position', 'data' => 2])
                    </td>

                </tr>
                <tr>
                    <th>キャプション</th>
                    <td colspan="3">
                        @include('admin.objects.components.textarea', ['name' => 'memo', 'class' => 'w500', 'count' => 100, 'placeholder' => 'キャプションを入力してください', 'value' => $facility_info->memo])
                    </td>
                </tr>
                <tr>
                    <th>エリア</th>
                    <td>
                        @include('admin.objects.components.selectbox', ['name' => 'area', 'class' => 'w200', 'options' => config('const.FACILITY_CATE_FACILITY'), 'selected' => $facility_info['area']])
                    </td>
                    <th>担当スタッフ</th>
                    <td>
                        @include('admin.objects.components.selectbox', ['name' => 'staff', 'class' => 'w200', 'options' => $staff_list, 'selected' => $facility_info['staff']])
                    </td>
                </tr>
                <tr>
                    <th>ハッシュタグ</th>
                    <td colspan="3">
                        @include('admin.objects.components.input', ['name' => 'tag', 'class' => 'w-50', 'placeholder' => 'ハッシュタグを入力してください', 'value' => $facility_info['tag']]) ※「,」区切りで複数のタグを登録可能
                    </td>
                </tr>
                <tr>
                    <th>キャンペーン</th>
                    <td colspan="3">
                        @include('admin.objects.components.textarea', ['name' => 'campaign', 'class' => 'w500', 'count' => 100, 'placeholder' => 'キャンペーン内容を入力してください', 'value' => $facility_info['campaign']])
                    </td>
                </tr>
                <tr>
                    <th colspan="2">カテゴリー</th>
                    <td colspan="5">
                        @include('admin.objects.components.selectbox', ['name' => 'category', 'class' => 'w200 cateOnchange',  'id'    =>  '', 'options' => config('const.FACILITY_CATEGORIES'), 'title' => '', 'selected' => $facility_info['category']])
                    </td>
                </tr>
                <tr class="cate_facility_1 @if(isset($facility_info['category']) && !in_array($facility_info['category'], [1,2,4]))d-none @endif">
                    <th rowspan="14" class="w115">カテゴリー別詳細</th>
                    <th class="label">商品カテゴリ</th>
                    <td colspan="4">
                        @include('admin.objects.components.input', ['name' => 'type', 'class' => 'w-50', 'placeholder' => '商品カテゴリを入力してください', 'value' => $facility_info['type']])
                    </td>
                </tr>
                <tr class="cate_facility_14 @if(isset($facility_info['category']) && !in_array($facility_info['category'], [3,5]))d-none @endif">
                    @if($facility_info['category'] == 5 || $facility_info['category'] == 3)
                        <th rowspan="14" class="w115">カテゴリー別詳細</th>
                        <th>対象者</th>
                        <td colspan="4">
                    @else
                        <th rowspan="14" class="w115 d-none">カテゴリー別詳細</th>
                        <th>対象者</th>
                        <td colspan="4">
                    @endif
                        @include('admin.objects.components.input', ['name' => 'target', 'class' => 'w-50', 'placeholder' => '対象者を入力してください', 'value' => $facility_info['target']])
                    </td>
                </tr>
                <tr class="cate_facility_15 @if(isset($facility_info['category']) && $facility_info['category'] != 6)d-none @endif">
                    <th rowspan="14">カテゴリー別詳細</th>
                    <th>広さ</th>
                    <td colspan="4">
                        @include('admin.objects.components.selectbox', ['name' => 'breadth', 'class' => 'w200', 'options' => config('const.FACILITY_BREADTHES'), 'title' => '', 'selected' => $facility_info['breadth']])
                    </td>
                </tr>
                <tr class="cate_facility_2 @if(isset($facility_info['category']) && !in_array($facility_info['category'], [1,2,3,4,5]))d-none @endif">
                    <th>営業時間</th>
                    <td colspan="4">
                        @include('admin.objects.components.input', ['name' => 'open', 'class' => 'w-50', 'placeholder' => '営業時間を入力してください', 'value' => $facility_info['open']])
                    </td>
                </tr>
                <tr class="cate_facility_3 @if(isset($facility_info['category']) && !in_array($facility_info['category'], [1,2,4]))d-none @endif">
                    <th>ピークタイム</th>
                    <td colspan="4">
                        @include('admin.objects.components.input', ['name' => 'peak', 'class' => 'w-50', 'placeholder' => 'ピークタイムを入力してください', 'value' => $facility_info['peak']])
                    </td>
                </tr>
                <tr class="cate_facility_4 @if(isset($facility_info['category']) && !in_array($facility_info['category'], [1,2,3,4,5]))d-none @endif">
                    <th>定休日</th>
                    <td colspan="4">
                        @include('admin.objects.components.input', ['name' => 'holiday', 'class' => 'w-50', 'placeholder' => '定休日を入力してください', 'value' => $facility_info['holiday']])
                    </td>
                </tr>
                <tr class="cate_facility_5 @if(isset($facility_info['category']) && $facility_info['category'] != 1)d-none @endif">
                    <th>予算</th>
                    <td colspan="4">
                        @include('admin.objects.components.input', ['name' => 'budget', 'class' => 'w-50', 'placeholder' => '予算を入力してください', 'value' => $facility_info['budget']])
                    </td>
                </tr>
                <tr class="cate_facility_6 @if(isset($facility_info['category']) && !in_array($facility_info['category'], [1,2,4]))d-none @endif">
                    <th>支払い方法</th>
                    <td colspan="4">
                        @include('admin.objects.components.input', ['name' => 'payment', 'class' => 'w-50', 'placeholder' => '支払い方法を入力してください', 'value' => $facility_info['payment']])
                    </td>
                </tr>
                <tr class="cate_facility_7 @if(isset($facility_info['category']) && !in_array($facility_info['category'], [1,4]))d-none @endif">
                    <th>予約可/不可</th>
                    <td colspan="4">
                        @include('admin.objects.components.input', ['name' => 'reserve', 'class' => 'w-50', 'placeholder' => '予約可、不可を入力してください', 'value' => $facility_info['reserve']])
                    </td>
                </tr>
                <tr class="cate_facility_8 @if(isset($facility_info['category']) && !in_array($facility_info['category'], [1,2,3,4,5]))d-none @endif">
                    <th>電話番号</th>
                    <td colspan="4">
                        @include('admin.objects.components.input', ['name' => 'tel', 'class' => 'w-50', 'placeholder' => '電話番号を入力してください', 'value' => $facility_info['tel']])
                    </td>
                </tr>
                <tr class="cate_facility_9 @if(isset($facility_info['category']) && !in_array($facility_info['category'], [1,2,3,4,5]))d-none @endif">
                    <th>公式サイトURL</th>
                    <td colspan="4">
                        @include('admin.objects.components.input', ['name' => 'url', 'class' => 'w-50', 'placeholder' => '公式サイトURLを入力してください', 'value' => $facility_info['url']])
                    </td>
                </tr>
                <tr class="cate_facility_10 @if(isset($facility_info['category']) && !in_array($facility_info['category'], [1,2,3,4,5,6]))d-none @endif">
                    <th>アクセス</th>
                    <td colspan="4">
                        @include('admin.objects.components.input', ['name' => 'access', 'class' => 'w-50', 'placeholder' => 'アクセスについて入力してください', 'value' => $facility_info['access']])
                    </td>
                </tr>
                <tr class="cate_facility_16 @if(isset($facility_info['category']) && $facility_info['category'] != 6)d-none @endif">
                    <th>設備</th>
                    <td colspan="4">
                        @include('admin.objects.components.textarea', ['name' => 'facility_other', 'class' => 'w500', 'count' => 200, 'placeholder' => '設備内容を入力してください', 'value' => $facility_info['facility']])
                    </td>
                </tr>
                <tr class="cate_facility_11 @if(isset($facility_info['category']) && !in_array($facility_info['category'], [1,2,3,4,5]))d-none @endif">
                    <th>駐車場</th>
                    <td colspan="4">
                        @include('admin.objects.components.input', ['name' => 'parking', 'class' => 'w-50', 'placeholder' => '駐車場の有無を入力してください', 'value' => $facility_info['parking']])
                    </td>
                </tr>
                <tr class="cate_facility_12 @if(isset($facility_info['category']) && !in_array($facility_info['category'], [1,2,5]))d-none @endif">
                    <th>コース（料金表）</th>
                    <td colspan="4">
                        @include('admin.objects.components.textarea', ['name' => 'menu', 'class' => 'facility-menu w500', 'count' => 200, 'placeholder' => 'コース（料金表）を入力してください', 'value' => $facility_info['menu']])
                    </td>
                </tr>
                <tr class="cate_facility_13 @if(isset($facility_info['category']) && !in_array($facility_info['category'], [1,2,3,4,5,6]))d-none @endif">
                    <th>おすすめポイント</th>
                    <td colspan="4">
                        @include('admin.objects.components.textarea', ['name' => 'comment', 'class' => 'facility-comment w500', 'count' => 200, 'placeholder' => 'おすすめポイントを入力してください', 'value' => $facility_info['comment']])
                    </td>
                </tr>
            </table>
            <table>
                <tr>
                    <th style="width: 242px">写真１</th>
                    <td>
                        <div class="d-flex">
                            <div>
                                @include('admin.objects.components.add-facility-image-cp3', ['id' => '1'])
                            </div>
                            <div class="ml10 w50_per">
                                @include('admin.objects.components.textarea', ['name' => 'p1_comment', 'class' => 'w-100 p_comment', 'count' => 200, 'placeholder' => '写真１のコメントを入力してください', 'value' => $facility_info['p1_comment']])
                            </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>写真2</th>
                    <td>
                        <div class="d-flex">
                            <div>
                                @include('admin.objects.components.add-facility-image-cp3', ['id' => '2'])
                            </div>
                            <div class="ml10 w50_per">
                                @include('admin.objects.components.textarea', ['name' => 'p2_comment', 'class' => 'w-100 p_comment', 'count' => 200, 'placeholder' => '写真2のコメントを入力してください', 'value' => $facility_info['p2_comment']])
                            </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>写真3</th>
                    <td>
                        <div class="d-flex">
                            <div>
                                @include('admin.objects.components.add-facility-image-cp3', ['id' => '3'])
                            </div>
                            <div class="ml10 w50_per">
                                @include('admin.objects.components.textarea', ['name' => 'p3_comment', 'class' => 'w-100 p_comment', 'count' => 200, 'placeholder' => '写真3のコメントを入力してください', 'value' => $facility_info['p3_comment']])
                            </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>写真4</th>
                    <td>
                        <div class="d-flex">
                            <div>
                                @include('admin.objects.components.add-facility-image-cp3', ['id' => '4'])
                            </div>
                            <div class="ml10 w50_per">
                                @include('admin.objects.components.textarea', ['name' => 'p4_comment', 'class' => 'w-100 p_comment', 'count' => 200, 'placeholder' => '写真4のコメントを入力してください', 'value' => $facility_info['p4_comment']])
                            </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>写真5</th>
                    <td>
                        <div class="d-flex">
                            <div>
                                @include('admin.objects.components.add-facility-image-cp3', ['id' => '5'])
                            </div>
                            <div class="ml10 w50_per">
                                @include('admin.objects.components.textarea', ['name' => 'p5_comment', 'class' => 'w-100 p_comment', 'count' => 200, 'placeholder' => '写真5のコメントを入力してください', 'value' => $facility_info['p5_comment']])
                            </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>写真6</th>
                    <td>
                        <div class="d-flex">
                            <div>
                                @include('admin.objects.components.add-facility-image-cp3', ['id' => '6'])
                            </div>
                            <div class="ml10 w50_per">
                                @include('admin.objects.components.textarea', ['name' => 'p6_comment', 'class' => 'w-100 p_comment', 'count' => 200, 'placeholder' => '写真6のコメントを入力してください', 'value' => $facility_info['p6_comment']])
                            </div>
                        </div>
                    </td>
                </tr>

            </table>
        </div>
    </div>
        <div class="regist__div">
            <a style="min-width: 220px" href="{{ route('facility-top') }}" class="c-linkbtn d-inline-block c-tab__backbtn mr-0 ml-0 btn-close-modal">戻る</a>
            <input type="submit" style="min-width: 220px" class="c-registbtn ml10 mr10" id="" value="登録・保存" autocomplete="off">
            <a href="javascript:void(0)" class="c-base-tab__image saved_to_review un-required">保存して口コミページへ</a>
        </div>
    </form>
</div>
@include('admin.objects.projects.modal-map', ['no' => 2])
@if (session('message'))
    @include('admin.objects.projects.modal-message')
    <script type="text/javascript">
        window.onload = function(){
            var message = '登録・保存しました。';
            $('#saved_message').text(message);
            openMessageModal();
        };

    </script>
@endif
@endsection
@section('footer-script')
    @if(isset($user) && $user->company_id == 3)
        <script src="/admin/js/add-cp3.js"></script>
    @endif
@endsection
