@extends('admin.layouts.base')
@section('styles')
    <script type="text/javascript" src="/admin/js/mst_store.js"></script>
@endsection
<style type="text/css">
    .ml100{
        margin-left: 100px;
    }
</style>
@section('contents')
    <div class="mt5">
    @include('admin.objects.components.hp-tab', ['title' => 'HP管理ー店舗情報', 'type' => 'store'])
@if($store->disp == 1)
    @php $url = ""; if($store->name_kana != null && $store->name_kana != ""){ $url = '/shop/'.$store->name_kana.'.html'; } @endphp
    @include('admin.objects.components.regist-band', ['title' => '店舗情報一覧', 'conf_url' => $url])
@else
    @include('admin.objects.components.regist-band', ['title' => '店舗情報一覧'])
@endif
    @php
        $linked = [
            ['code' => 1, 'name' => '契約'],
            ['code' => 2, 'name' => '未契約'],
        ];
        $org = [
            ['code' => 1, 'name' => '他店舗と共有のアカウント'],
        ];
    @endphp
    <div class="news_regist">
        @if($errors->any())
        <div class="error">
        <ul>
            @foreach($errors->all() as $message)
            <li>{{ $message }}</li>
            @endforeach
        </ul>
        </div>
        @endif
        @if (session('message'))
            <div class="flash_message">
                {{ session('message') }}
            </div>
        @endif
        <form method="POST" action="{{ route('store-edit', ['id' => $store->code]) }}" enctype="multipart/form-data">
        {{ csrf_field() }}
            <div>
                <table class="p-search-common__tbl">
                    <tr>
                        <th class="w200" style="width: 200px;">店舗番号</th>
                        <td>{{$store->code}}</td>
                    </tr>
                    <tr>
                        <th>店舗名</th>
                        <td>
                        @include('admin.objects.components.input', ['name' => 'name', 'class' => 'w250', 'placeholder' => '店舗名を入力', 'value' => $store->name])
                        </td>
                    </tr>
                    <tr>
                        <th>店舗名（英字）</th>
                        <td>
                        @include('admin.objects.components.input', ['name' => 'name_kana', 'class' => 'w250', 'placeholder' => 'eiji', 'value' => $store->name_kana])
                        </td>
                    </tr>
                    <tr>
                        <th>住所</th>
                        <td>
                        @include('admin.objects.projects.form-address-store')
                        </td>
                    </tr>
                    <tr>
                        <th>フリーダイヤル</th>
                        <td>
                        @include('admin.objects.components.input', ['name' => 'freedial', 'class' => 'w250', 'placeholder' => '000-00-000', 'value' => $store->freedial])
                        </td>
                    </tr>
                    <tr>
                        <th>電話番号</th>
                        <td>
                        @include('admin.objects.components.input', ['name' => 'tel', 'class' => 'w250', 'placeholder' => '000-00-000', 'value' => $store->tel])
                        </td>
                    </tr>
                    <tr>
                        <th>FAX番号</th>
                        <td>
                        @include('admin.objects.components.input', ['name' => 'fax', 'class' => 'w250', 'placeholder' => '000-00-000', 'value' => $store->fax])
                        </td>
                    </tr>
                    <tr>
                        <th>メール</th>
                        <td>
                            @if(Auth::user()->role == 1)
                                @include('admin.objects.components.input', ['name' => 'email', 'class' => 'w250', 'placeholder' => '000@000', 'value' => $store->email])
                            @else
                               {{ $store->email }}
                            @endif
                        </td>
                    </tr>
                    <tr>
                        <th>営業時間</th>
                        <td>
                        @include('admin.objects.components.input', ['name' => 'business_hours', 'class' => 'w250', 'placeholder' => '00:00〜00:00', 'value' => $store->business_hours])
                        </td>
                    </tr>
                    <tr>
                        <th>定休日</th>
                        <td>
                        @include('admin.objects.components.input', ['name' => 'holiday', 'class' => 'w250', 'placeholder' => '曜日', 'value' => $store->holiday])
                        </td>
                    </tr>
                    <tr>
                        <th>駐車場台数</th>
                        <td>
                        @include('admin.objects.components.input', ['name' => 'parking', 'class' => 'w500', 'value' => $store->parking])
                        </td>
                    </tr>
                    <tr>
                        <th>Suumo</th>
                        <td>
                            @include('admin.objects.components.radio', ['name' => 'suumo_linked', 'radio' => $linked, 'default' => 0, 'checked' => $store->suumo_linked])
                        </td>
                    </tr>
                    <tr class="suumo">
                        <th>Suumo_ID</th>
                        <td>
                            @include('admin.objects.components.input', ['name' => 'suumo_id', 'class' => 'w500 suumo_id', 'value' => $store->suumo_id])
                        </td>
                    </tr>
                    <tr class="suumo">
                        <th>Suumo_Password</th>
                        <td>
                            @include('admin.objects.components.input', ['name' => 'suumo_pw', 'class' => 'w500 suumo_pass', 'value' => $store->suumo_pw])
                        </td>
                    </tr>
                    <tr>
                        <th>Homes</th>
                        <td>
                            @include('admin.objects.components.radio', ['name' => 'homes_linked',  'radio' => $linked, 'default' => 0, 'checked' => $store->homes_linked])
                            @if(auth()->user()->company_id === 4)
                                @include('admin.objects.components.checkbox', ['name' => 'homes_org_checked',  'class' => 'ml100', 'checkbox' => $org, 'checked' => $store->homes_org_checked??0])
                                @include('admin.objects.components.input', ['name' => 'homes_org_name', 'class' => 'w300', 'value' => $store->homes_org_name, 'placeholder' => 'HOMESで選択する店舗・組織名を入力'])
                            @endif
                        </td>
                    </tr>
                    <tr class="homes">
                        <th>Homes_ID</th>
                        <td>
                            @include('admin.objects.components.input', ['name' => 'homes_id', 'class' => 'w500 homes_id', 'value' => $store->homes_id])
                        </td>
                    </tr>
                    <tr class="homes">
                        <th>Homes_Password</th>
                        <td>
                            @include('admin.objects.components.input', ['name' => 'homes_pw', 'class' => 'w500 homes_pass', 'value' => $store->homes_pw])
                        </td>
                    </tr>
                    <tr>
                        <th>Athome</th>
                        <td>
                            @include('admin.objects.components.radio', ['name' => 'athome_linked', 'radio' => $linked, 'default' => 0, 'checked' => $store->athome_linked])
                        </td>
                    </tr>
                    <tr class="athome">
                        <th>Athome_ID</th>
                        <td>
                            @include('admin.objects.components.input', ['name' => 'athome_id', 'class' => 'w500 athome_id', 'value' => $store->athome_id])
                        </td>
                    </tr>
                    <tr class="athome">
                        <th>Athome_Password</th>
                        <td>
                            @include('admin.objects.components.input', ['name' => 'athome_pw', 'class' => 'w500 athome_pass', 'value' => $store->athome_pw])
                        </td>
                    </tr>
                    <tr>
                        <th>メッセージ</th>
                        <td>
                        @include('admin.objects.components.textarea', ['name' => 'comment', 'class' => 'ta500', 'count' => 500, 'placeholder' => '備考を500文字以内で入力してください', 'value' => $store->comment])
                        </td>
                    </tr>
                    <tr>
                        <th>物件資料（マイソク）<br />帯情報</th>
                        <td>
                        @include('admin.objects.components.textarea', ['name' => 'obi', 'class' => 'ta500', 'placeholder' => '免許番号、所属団体などを5行以内で入力してください', 'value' => $store->obi])
                        </td>
                    </tr>
                    @if(Auth::user()->role == 1)
                        <tr>
                            <th>登録日</th>
                            <td>
                                {{ $store->created_at }}
                            </td>
                        </tr>
                        <tr>
                            <th>更新日</th>
                            <td>
                                {{ $store->updated_at }}
                            </td>
                        </tr>
                        <tr>
                            <th>更新した人</th>
                            <td>
                                {{ $store->last_user_name }}
                            </td>
                        </tr>
                    @endif
                </table>
            </div>
            <div class="search_vendor__btn">
                @include('admin.objects.components.regist-btn', ['class' => '', 'title' => '登録・保存'])
            </div>
            <table class="p-regist__table mt10">
                <tbody>
                @include('admin.objects.projects.image-upload-large-store', ['id' => 'iamgeAreaMulti', 'cid' => 'iamgeAreaMultiChild'])
                <tr>
                    <td colspan="8">
                        <table id="sortable_store_image">
                            <tbody id="image_list">
                        @include('admin.objects.components.add-store-template')
                        @foreach($photos as $photo)
                            @include('admin.objects.components.add-store-template-edit', ['num' => $loop->iteration+1])
                        @endforeach
                            </tbody>
                        </table>
                    </td>
                </tr>

                </tbody>
            </table>
            <div class="regist__div">
                @include('admin.objects.components.regist-btn', ['class' => '', 'title' => '登録・保存'])
            </div>
        </form>
            @if (session('message_modal'))
                <input type="hidden" name="" id="message" value="{{ session('message_modal') }}">
                @include('admin.objects.projects.modal-message', ['ok' => "OK"])
                <script type="text/javascript">
                    window.onload = function(){
                        var message = $("#message").val();
                        $('#saved_message').text(message);
                        openMessageModal();
                        $(".btn-close-modal").click(function () {
                            $("#modal-overlay").remove();
                            $("#modal-message-content").remove();
                        });
                    };
                </script>
            @endif
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function (){
        if($('#suumo_linked-1').is(':checked')){
            // $('.suumo').show()
            // $(".suumo_id, .suumo_pass").removeAttr('disabled');
        }
        if($('#suumo_linked-2').is(':checked')){
            // $('.suumo').hide()
            // $(".suumo_id, .suumo_pass").attr('disabled','disabled');
        }

        $('#suumo_linked-1').click(function (){
            // $('.suumo').fadeIn('slow')
            // $(".suumo_id, .suumo_pass").removeAttr('disabled');
        })
        $('#suumo_linked-2').click(function (){
            // $('.suumo').fadeOut('slow')
            // $(".suumo_id, .suumo_pass").attr('disabled','disabled');
        })

        if($('#homes_linked-1').is(':checked')){
            // $('.homes').show()
            // $(".homes_id, .homes_pass").removeAttr('disabled');
        }
        if($('#homes_linked-2').is(':checked')){
            // $('.homes').hide()
            // $(".homes_id, .homes_pass").attr('disabled','disabled');
        }

        $('#homes_linked-1').click(function (){
            // $('.homes').fadeIn('slow')
            // $(".homes_id, .homes_pass").removeAttr('disabled');
        })
        $('#homes_linked-2').click(function (){
            // $('.homes').fadeOut('slow')
            // $(".homes_id, .homes_pass").attr('disabled','disabled');
        })

        if($('#athome_linked-1').is(':checked')){
            // $('.athome').show()
            // $(".athome_id, .athome_pass").removeAttr('disabled');
        }
        if($('#athome_linked-2').is(':checked')){
            // $('.athome').hide()
            // $(".athome_id, .athome_pass").attr('disabled','disabled');
        }

        $('#athome_linked-1').click(function (){
            // $('.athome').fadeIn('slow')
            // $(".athome_id, .athome_pass").removeAttr('disabled');
        })
        $('#athome_linked-2').click(function (){
            // $('.athome').fadeOut('slow')
            // $(".athome_id, .athome_pass").attr('disabled','disabled');
        })
    })
</script>
@endsection
