@using PantheonRA.BackOffice.Models
@model PantheonRA.BackOffice.Models.DocTextViewModel
@{
    ViewBag.Title = string.IsNullOrEmpty(Model.Id) ? Loc.CreateNewDocumentText : Loc.EditDocumentText;
}

@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "docTextForm" }))
{
    <div class="tabs-container">
        @Html.Partial("~/Views/Products/_CodeListTabNavigation.cshtml")
        <div class="tab-content">
            <div class="row buttons-tabbed">
                @Html.Partial("_FormButtons", new FormButtonsViewModel
                {
                    BackUrl = Url.Action("Index", "DocumentText"),
                    SaveButtonGroup = new FormButtonGroup
                    {
                        Buttons = new List<FormButton>
                        {
                            new FormButton { Text = Loc.Save, Icon = "fa fa-save fa-lg", IsSubmit = true, OnClick="$('#docTextForm').submit();" }
                        }
                    }
                })

                <button id="invoiceDelete" type="button" onclick="removeDocText()" title="@Loc.Delete"
                        class="btn btn-danger btn-outline pull-right collapsable-form-button @(Model.IsEdit ? string.Empty : " hidden")">
                    <i class="far fa-trash-alt m-r-xs"></i>
                    <span class="visible-lg-inline visible-md-inline">@Loc.Delete</span>
                </button>
            </div>
            <div class="divided-content clearfix">
                <div class="divided-content-main divided-content-full">
                    <div class="row">
                        <div class="col-xs-12 col-md-6 col-lg-5">
                            <div class="form-horizontal form-md m-t-md">
                                <div class="col-xs-12">
                                    @Html.HiddenFor(model => model.IsEdit)

                                    <div class="form-group">
                                        @Html.LabelFor(model => model.IsActive, Loc.IsActive, new { @class = "col-md-3 control-label" })
                                        <div class="col-md-9">
                                            @Html.CheckBoxFor(model => model.IsActive, new { @id = "IsActive", @class = "form-control js-switch" })
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        @Html.LabelFor(model => model.Id, Loc.Code, new { @class = "col-md-3 control-label" })
                                        <div class="col-md-9">
                                            @if (!Model.IsEdit)
                                            {
                                                @Html.TextBoxFor(model => model.Id, new { @id = "Id", @class = "form-control", autocomplete = "off" })
                                                @Html.ValidationMessageFor(model => model.Id, "", new { @class = "text-danger" })
                                            }
                                            else
                                            {
                                                @Html.TextBoxFor(model => model.Id, new { @id = "Id", @class = "form-control", @readonly = "readonly" })
                                                @Html.ValidationMessageFor(model => model.Id, "", new { @class = "text-danger" })
                                            }
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        @Html.LabelFor(model => model.Description, Loc.Description, new { @class = "col-md-3 control-label" })
                                        <div class="col-md-9">
                                            @Html.TextBoxFor(model => model.Description, new { @id = "Description", @class = "form-control", autocomplete = "off" })
                                            @Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" })
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        @Html.LabelFor(model => model.Name, Loc.Text, new { @class = "col-md-3 control-label" })
                                        <div class="col-md-9">
                                            @Html.TextAreaFor(model => model.Name, new { @id = "Name", @class = "form-control", @rows = "3" })
                                            @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
}

<input type="hidden" id="RemoveDocTextUrl" value="@Url.Action("Remove", "DocumentText")" />
<input type="hidden" id="DocTextIndexUrl" value="@Url.Action("Index", "DocumentText")" />
<input type="hidden" id="DeleteWasNotSuccessfulLoc" value="@Loc.DocTextAlreadyInUse" />
<input type="hidden" id="ConfirmDeleteLoc" value="@Loc.ConfirmDeleteMessage" />
<input type="hidden" id="GeneralErrorLoc" value="@Loc.GeneralError" />
<input type="hidden" id="ConfirmLoc" value="@Loc.Confirm" />
<input type="hidden" id="YesLoc" value="@Loc.Yes" />
<input type="hidden" id="NoLoc" value="@Loc.No" />

@section pageScripts{
    @Scripts.Render("~/bundles/product")
    <script>
        $(document).ready(function () {
            initializeDocumentTextEdit();
        });
    </script>
}