@page "{id:int}"
@model Admin.Pages.Member.Wallet.List.ViewModel
@{
    ViewData["Title"] = "(C) 충전 하기";
}

<div class="container">
    <h3>@ViewData["Title"]</h3>
    <hr />

    <partial name="_StatusMessage" />

    <div class="alert alert-warning" role="alert">
        관리자 비밀번호 확인 후 충전 또는 차감 처리됩니다.
    </div>

    <form name="f_admin_write" id="fAdminWrite" method="post" asp-page-handler="Charge" accept-charset="utf-8" autocomplete="off">
        <div class="row mb-2">
            <label class="col-sm-2 col-form-label">회원 ID</label>
            <div class="col-sm-10">
                <input type="text" class="form-control-plaintext" value="@Model.Member.ID" readonly disabled />
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-sm-2 col-form-label">회원 이메일</label>
            <div class="col-sm-10">
                <input type="text" class="form-control-plaintext" value="@Model.Member.Email" readonly disabled />
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-sm-2 mb-2">회원 등급</label>
            <div class="col-sm-10">
                @(Model.Member.GradeName ?? "-")
            </div>
        </div>
        <div class="row mb-3">
            <label class="col-sm-2">보유 잔액(P)</label>
            <div class="col-sm-10">
                @Model.Wallet.Balance
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="Amount" class="col-sm-2 col-form-label"><span>*</span> 충전 금액</label>
            <div class="col-sm-10">
                <div class="input-group">
                    <input type="number" asp-for="Amount" class="form-control w-auto d-flex flex-grow-0" required min="-99999999" max="99999999" step="100" autofocus />
                    <span class="input-group-text">P</span>
                </div>
                <span asp-validation-for="Amount" class="text-danger"></span>
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="Password" class="col-sm-2 col-form-label"><span>*</span> 비밀번호</label>
            <div class="col-sm-10">
                <input type="password" asp-for="Password" class="form-control" required maxlength="100"/>
                <span asp-validation-for="Password" class="text-danger"></span>
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="Memo" class="col-sm-2 col-form-label">메모</label>
            <div class="col-sm-10">
                <textarea asp-for="Memo" class="form-control" rows="5" maxlength="1000"></textarea>
                <span asp-validation-for="Memo" class="text-danger"></span>
            </div>
        </div>
        <hr />
        <div class="d-grid gap-2 text-center d-md-block">
            <button type="submit" class="btn btn-sm btn-success">저장</button>
            <a href="/Member/Wallet/List" class="btn btn-sm btn-secondary">취소</a>
        </div>
        <br />
    </form>
</div>

@section Scripts {
    <script>
        $("#fAdminWrite").validate({
            rules: {
                "Amount": {
                    required: true
                },
                "Password": {
                    required: true
                }
            },
            messages: {
                "Amount": {
                    required: "충전 금액을 입력해주세요."
                },
                "Password": {
                    required: "비밀번호를 입력해주세요."
                }
            },
            submitHandler: function(form) {
                form.submit();
            }
        });
    </script>
}