LocalGovIMS_localgov-ims/src/Admin/Views/AccountHolder/Edit.cshtml
@model Admin.Models.AccountHolder.EditViewModel
@{
    ViewBag.Title = "Edit account holder";
}

@section Messages {
    @if (TempData.ContainsKey("Message") && TempData["Message"] != null) { Html.RenderPartial("_Message", TempData["Message"]); }
}

@section Header { @Model.AccountReference }

@section Subheader { Account holder details }

@using (Html.BeginForm("Edit", "AccountHolder", FormMethod.Post))
{
    @Html.HiddenFor(m => m.AccountReference)

    <div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.Title, new { @class = "form-label" })
                @Html.TextBoxFor(m => m.Title, new { @class = "form-control" })
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.Title)
                </div>
            </div>
        </div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.Forename, new { @class = "form-label" })
                @Html.TextBoxFor(m => m.Forename, new { @class = "form-control" })
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.Forename)
                </div>
            </div>
        </div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.Surname, new { @class = "form-label" })
                @Html.TextBoxFor(m => m.Surname, new { @class = "form-control" })
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.Surname)
                </div>
            </div>
        </div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.AddressLine1, new { @class = "form-label" })
                @Html.TextBoxFor(m => m.AddressLine1, new { @class = "form-control" })
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.AddressLine1)
                </div>
            </div>
        </div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.AddressLine2, new { @class = "form-label" })
                @Html.TextBoxFor(m => m.AddressLine2, new { @class = "form-control" })
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.AddressLine2)
                </div>
            </div>
        </div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.AddressLine3, new { @class = "form-label" })
                @Html.TextBoxFor(m => m.AddressLine3, new { @class = "form-control" })
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.AddressLine3)
                </div>
            </div>
        </div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.AddressLine4, new { @class = "form-label" })
                @Html.TextBoxFor(m => m.AddressLine4, new { @class = "form-control" })
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.AddressLine4)
                </div>
            </div>
        </div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.Postcode, new { @class = "form-label" })
                @Html.TextBoxFor(m => m.Postcode, new { @class = "form-control" })
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.Postcode)
                </div>
            </div>
        </div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.FundCode, new { @class = "form-label" })
                <select id="FundCode" name="FundCode">
                    <option value="">None</option>
                    @foreach (var item in Model.Funds.Items)
                    {
                        <option class="item" value="@item.Value" @(!Model.FundCode.IsNullOrEmpty() && Model.FundCode.Equals(item.Value) ? "selected" : String.Empty)>@item.Text</option>
                    }
                </select>
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.FundCode)
                </div>
            </div>
        </div>

        <div class="row mb-3 fund-message-selector">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.FundMessageId, new { @class = "form-label" })
                @Html.HiddenFor(m => m.FundMessageId)
                <div id="FundMessageIdAccessibleAutocompleteWrapper"></div>
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.FundMessageId)
                </div>
            </div>
        </div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.PeriodDebit, new { @class = "form-label" })
                @Html.TextBoxFor(m => m.PeriodDebit, new { @class = "form-control" })
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.PeriodDebit)
                </div>
            </div>
        </div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.PeriodCredit, new { @class = "form-label" })
                @Html.TextBoxFor(m => m.PeriodCredit, new { @class = "form-control" })
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.PeriodCredit)
                </div>
            </div>
        </div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.CurrentBalance, new { @class = "form-label" })
                @Html.TextBoxFor(m => m.CurrentBalance, new { @class = "form-control" })
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.CurrentBalance)
                </div>
            </div>
        </div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.UserField1, new { @class = "form-label" })
                @Html.TextBoxFor(m => m.UserField1, new { @class = "form-control" })
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.UserField1)
                </div>
            </div>
        </div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.UserField2, new { @class = "form-label" })
                @Html.TextBoxFor(m => m.UserField2, new { @class = "form-control" })
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.UserField2)
                </div>
            </div>
        </div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.UserField3, new { @class = "form-label" })
                @Html.TextBoxFor(m => m.UserField3, new { @class = "form-control" })
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.UserField3)
                </div>
            </div>
        </div>

        <div>
            <input type="submit" value="Save" class="btn btn-primary" />
            @Html.ActionLink("Back", "Back", "AccountHolder", null, new { @class = "btn btn-secondary" })
        </div>

    </div>
}

@section Scripts {

    <script type="text/javascript">
        $(document).ready(function () {

            paymentsAdmin.pages.accountHolder.fundMessageOptions = JSON.parse('@Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.FundMessages.Items.Select(x => new { id = x.Value, text = x.Text, data = x.DataAttributes })))');

        });
    </script>

    @Scripts.Render("~/bundles/app/account-holders")
}