<div class="card-body rv-usertype-form">
    <div class="col-12 px-0">
        @if(Session::has('success'))
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                {{ Session::get('success') }}
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
        @elseif(Session::has('error'))
            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                {!! Session::get('error') !!}
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
        @elseif(isset($errorMsg))
            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                {!! $errorMsg !!}
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
        @endif
    </div>

    @if($isInfo || $isEdit)
        <div class="rv-usertype-form__actions-top">
            @if($isInfo)
                <a href="{{ route('usertype_add') }}" class="btn btn-default btn-sm px-4">{{ __('登録') }}</a>
                <a href="{{ route('usertype_edit', ['id' => $user_categoryid]) }}" class="btn btn-default btn-sm px-4">{{ __('編集') }}</a>
            @else
                <button type="button" class="btn btn-default btn-sm px-4 register">{{ __('登録') }}</button>
                @if($isEdit)<button type="button" class="btn btn-default btn-sm px-4 js-inline-delete">{{ __('削除') }}</button>@endif
            @endif
        </div>
    @endif

    <div class="rv-usertype-form__container">
        <div class="rv-usertype-form__panel">
            @if($isInfo || $isEdit)
                <div class="form-group row align-items-center">
                    <label class="col-sm-4 col-form-label font-weight-semibold text-sm-left">{{ __('validation.attributes.user_categoryid') }}</label>
                    <div class="col-sm-8">
                        <input type="text" value="{{ $user_categoryid }}" class="form-control-plaintext" readonly>
                    </div>
                </div>
            @endif

            <div class="form-group row align-items-center">
                <label class="col-sm-4 col-form-label font-weight-semibold text-sm-left">
                    {{ __('ソートオーダー') }}<span class="text-danger">*</span>
                </label>
                <div class="col-sm-8">
                    <input type="text" name="sort_order" value="{{ old('sort_order', $sort_order ?? '') }}" class="form-control" placeholder="{{ __('ソートオーダー') }}">
                </div>
            </div>

            <div class="form-group row align-items-center">
                <label class="col-sm-4 col-form-label font-weight-semibold text-sm-left">
                    {{ __('分類名１') }}<span class="text-danger">*</span>
                </label>
                <div class="col-sm-8">
                    <input type="text" name="usertype_subject1" value="{{ old('usertype_subject1', $usertype_subject1 ?? '') }}" class="form-control" placeholder="{{ __('分類名１') }}">
                </div>
            </div>

            <div class="form-group row align-items-center">
                <label class="col-sm-4 col-form-label font-weight-semibold text-sm-left">
                    {{ __('分類名２') }}<span class="text-danger">*</span>
                </label>
                <div class="col-sm-8">
                    <input type="text" name="usertype_subject2" value="{{ old('usertype_subject2', $usertype_subject2 ?? '') }}" class="form-control" placeholder="{{ __('分類名２') }}">
                </div>
            </div>

            <div class="form-group row align-items-center">
                <label class="col-sm-4 col-form-label font-weight-semibold text-sm-left">{{ __('分類名３') }}</label>
                <div class="col-sm-8">
                    <input type="text" name="usertype_subject3" value="{{ old('usertype_subject3', $usertype_subject3 ?? '') }}" class="form-control" placeholder="{{ __('分類名３') }}">
                </div>
            </div>

            <div class="form-group row align-items-center">
                <label class="col-sm-4 col-form-label font-weight-semibold text-sm-left">{{ __('印字名') }}</label>
                <div class="col-sm-8">
                    <input type="text" name="print_name" value="{{ old('print_name', $print_name ?? '') }}" class="form-control" placeholder="{{ __('印字名') }}">
                </div>
            </div>

            <div class="form-group row align-items-center">
                <label class="col-sm-4 col-form-label font-weight-semibold text-sm-left">{{ __('適用料率') }}</label>
                <div class="col-sm-8">
                    <input type="text" name="usertype_money" value="{{ old('usertype_money', $usertype_money ?? '') }}" class="form-control" placeholder="{{ __('適用料率') }}">
                </div>
            </div>

            <div class="form-group row align-items-center mb-0">
                <label class="col-sm-4 col-form-label font-weight-semibold text-sm-left">{{ __('備考') }}</label>
                <div class="col-sm-8">
                    <textarea name="usertype_remarks" rows="2" class="form-control" placeholder="{{ __('備考') }}">{{ old('usertype_remarks', $usertype_remarks ?? '') }}</textarea>
                </div>
            </div>
        </div>
    </div>

    <div class="rv-usertype-form__actions-bottom">
        @if($isInfo)
            <a href="{{ route('usertype_add') }}" class="btn btn-default btn-sm px-4">{{ __('登録') }}</a>
            <a href="{{ route('usertype_edit', ['id' => $user_categoryid]) }}" class="btn btn-default btn-sm px-4">{{ __('編集') }}</a>
        @else
            <button type="button" class="btn btn-default btn-sm px-4 register">
                {{ $isEdit ? __('登録') : __('登録') }}
            </button>
            @if($isEdit)
                <button type="button" class="btn btn-default btn-sm px-4 js-inline-delete">{{ __('削除') }}</button>
            @endif
        @endif
    </div>
</div>

@push('styles')
    <style>
        .rv-usertype-form .font-weight-semibold{font-weight:600;}
        .rv-usertype-form .form-group{margin-bottom:1.25rem;}
        .rv-usertype-form .form-control{border-radius:.4rem;}
        .rv-usertype-form__actions-top,
        .rv-usertype-form__actions-bottom{display:flex;align-items:center;gap:.75rem;margin-bottom:1.5rem;}
        .rv-usertype-form__container{display:flex;justify-content:flex-end;}
        .rv-usertype-form__panel{
            width:100%;
            max-width:520px;
            background:#fff;
            border:1px solid #dee2e6;
            border-radius:.5rem;
            padding:2rem 2.5rem;
        }
        .rv-usertype-form__panel .col-form-label{font-size:.95rem;color:#555;}
        .rv-usertype-form__panel .col-form-label{text-align:left;}
        .rv-usertype-form__panel .form-control{font-size:.95rem;}
        .rv-usertype-form__actions-bottom{margin-top:2rem;}
        .rv-usertype-form .btn{min-width:90px;}
    </style>
@endpush

@push('scripts')
    @once
    <script>
        (function ($) {
            $(function () {
                var $form = $('#usertype-form');
                if (!$form.length) {
                    return;
                }

                $('.register').off('click.usertypeConfirm').on('click.usertypeConfirm', function (e) {
                    e.preventDefault();
                    var submitForm = function () { $form.trigger('submit'); };
                    if (typeof $.confirm === 'function') {
                        $.confirm({
                            title: '確認ダイアログ。',
                            content: '登録してよろしいですか？はい/いいえ',
                            buttons: {
                                ok: {
                                    text: 'はい',
                                    btnClass: 'btn-primary',
                                    keys: ['enter'],
                                    action: submitForm
                                },
                                いいえ: function () {}
                            }
                        });
                    } else if (window.confirm('登録してよろしいですか？')) {
                        submitForm();
                    }
                });

                var $deleteBtn = $('#btnDeleteInline');
                var $deleteForm = $('#usertype-delete-form');
                if ($deleteBtn.length && $deleteForm.length) {
                    $deleteBtn.off('click.usertypeDelete').on('click.usertypeDelete', function (e) {
                        e.preventDefault();
                        var submitDelete = function () { $deleteForm.trigger('submit'); };
                        if (typeof $.confirm === 'function') {
                            $.confirm({
                                title: '確認ダイアログ。',
                                content: '削除してよろしいですか？はい/いいえ',
                                buttons: {
                                    ok: {
                                        text: 'はい',
                                        btnClass: 'btn-primary',
                                        keys: ['enter'],
                                        action: submitDelete
                                    },
                                    いいえ: function () {}
                                }
                            });
                        } else if (window.confirm('削除してよろしいですか？')) {
                            submitDelete();
                        }
                    });
                }
            });
        })(window.jQuery);
    </script>
    @endonce
@endpush