@extends('admin.layouts.app')

@section('content')
<div class="container-fluid">
    <h2>SMS 주소록 @if($smsBookID) 수정 @else 등록 @endif</h2>
    <hr/>
    @include('admin.messages')

    <form name="f_admin_write" id="fAdminWrite" method="post" action="{{ $actionURL }}">
        @csrf
        @if($smsBookID)
            <input type="hidden" name="sms_book_id" value="{{ $smsBookID }}" />
            @method('PUT')
        @endif
        <div class="row mb-3">
            <label for="name" class="col-sm-2 col-form-label">제목</label>
            <div class="col-sm-10">
                <input type="text" name="name" id="name" class="form-control" value="{{ $smsBookData->name ?? old('name') }}" />
            </div>
        </div>
        <div class="row mb-3">
            <label for="order" class="col-sm-2 col-form-label">순서</label>
            <div class="col-sm-10">
                <input type="text" name="order" id="order" class="form-control only-digits-input" value="{{ $smsBookData->order ?? old('order') }}" />
            </div>
        </div>
        @isset($smsBookData->updated_at)
        <div class="row mb-3">
            <label class="col-sm-2">수정일시</label>
            <div class="col-sm-10">
                {{ $smsBookData->updated_at }}
            </div>
        </div>
        @endisset
        @isset($smsBookData->created_at)
        <div class="row mb-3">
            <label class="col-sm-2">등록일시</label>
            <div class="col-sm-10">
                {{ $smsBookData->created_at }}
            </div>
        </div>
        @endisset
        <hr/>
        <div class="text-end">
            <button type="submit" class="btn btn-success">저장하기</button>
            <button type="button" class="btn btn-light btn-write-cancel" value="{{ route('admin.sms.book.list.index') }}">취소하기</button>
        </div>
    </form>
</div>

<script>
$("#fAdminWrite").validate({
    rules: {
        name: {required: true, maxlength: 255},
        order: {required: true, number: true}
    }
});
</script>
@endsection
