@using PantheonRA.BackOffice.Enums
@using PantheonRA.BackOffice.Models
@model PantheonRA.BackOffice.Models.SetItemTypeCreateModel
@{
    ViewBag.Title = string.IsNullOrEmpty(Model.Id) ? Loc.CreateNewProductType : Loc.EditProductType;
}

@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "productTypeForm" }))
{
    <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", "ProductTypes"),
                    SaveButtonGroup = new FormButtonGroup
                    {
                        Buttons = new List<FormButton>
                        {
                            new FormButton { Text = Loc.Save, Icon = "fa fa-save fa-lg", IsSubmit = true, OnClick="$('#productTypeForm').submit();" }
                        }
                    }
                })

                <a href="@Url.Action("Create", "ProductTypes")" title="@Loc.New"
                   class="btn btn-primary btn-outline pull-right">
                    <i class="fas fa-plus m-r-xs"></i>
                    <span class="visible-lg-inline visible-md-inline">@Loc.New</span>
                </a>
            </div>
            <div class="divided-content">
                <div class="divided-content-main divided-content-full">
                    <div class="form-horizontal form-md m-t-md">
                        <div class="row">
                            <div class="col-xs-12 col-md-6 col-lg-4">
                                <div class="row">
                                    <div class="col-xs-12">
                                        <h3>@Loc.ProductType</h3>
                                        @Html.HiddenFor(model => model.IsEdit)
                                        <div class="form-group">
                                            @Html.LabelFor(model => model.Id, Loc.Type, new { @class = "col-md-4 control-label" })
                                            <div class="col-md-8">
                                                @if (!string.IsNullOrEmpty(Model.Id) && Model.IsEdit)
                                                {
                                                    @Html.TextBoxFor(model => model.Id, new { @id = "Name", @class = "form-control", @readonly = "readonly", @placeholder = Loc.Type })
                                                    @Html.ValidationMessageFor(model => model.Id, "", new { @class = "text-danger" })
                                                }
                                                else
                                                {
                                                    @Html.TextBoxFor(model => model.Id, new { @id = "Name", @class = "form-control", @placeholder = Loc.Type, maxlength = "3", autocomplete = "off" })
                                                    @Html.ValidationMessageFor(model => model.Id, "", new { @class = "text-danger" })
                                                }
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-xs-12">
                                        <div class="form-group">
                                            @Html.LabelFor(model => model.Name, Loc.Name, new { @class = "col-md-4 control-label" })
                                            <div class="col-md-8">
                                                @Html.TextBoxFor(model => model.Name, new { @id = "Name", @class = "form-control", @placeholder = Loc.Name, autocomplete = "off" })
                                                @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            @Html.LabelFor(model => model.Type, Loc.TypeShort, new { @class = "col-md-4 control-label" })
                                            <div class="col-md-8">
                                                @Html.DropDownListFor(model => model.Type, new List<SelectListItem>
                                                {
                                                    new SelectListItem{ Text = ProductType.Product.ToString() + " - " + Loc.ProductEnum, Value = ProductType.Product },
                                                    new SelectListItem{ Text = ProductType.Goods.ToString() + " - " + Loc.Goods, Value = ProductType.Goods },
                                                    new SelectListItem{ Text = ProductType.CompositeGoods.ToString() + " - " + Loc.CompositeGoods, Value = ProductType.CompositeGoods },
                                                    new SelectListItem{ Text = ProductType.CommissionGoods.ToString() + " - " + Loc.CommissionGoods, Value = ProductType.CommissionGoods },
                                                    new SelectListItem{ Text = ProductType.PackagedGoods.ToString() + " - " + Loc.PackagedGoods, Value = ProductType.PackagedGoods },
                                                    new SelectListItem{ Text = ProductType.Material.ToString() + " - " + Loc.Material, Value = ProductType.Material },
                                                    new SelectListItem{ Text = ProductType.Packaging.ToString() + " - " + Loc.Packaging, Value = ProductType.Packaging },
                                                    new SelectListItem{ Text = ProductType.Service.ToString() + " - " + Loc.Service, Value = ProductType.Service },
                                                    new SelectListItem{ Text = ProductType.CompiledService.ToString() + " - " + Loc.CompiledService, Value = ProductType.CompiledService },
                                                    new SelectListItem{ Text = ProductType.CommodityPackage.ToString() + " - " + Loc.CommodityPackage, Value = ProductType.CommodityPackage },
                                                    new SelectListItem{ Text = ProductType.ServicePackage.ToString() + " - " + Loc.ServicePackage, Value = ProductType.ServicePackage },
                                                    new SelectListItem{ Text = ProductType.FixedAssets.ToString() + " - " + Loc.FixedAssets, Value = ProductType.FixedAssets },
                                                    new SelectListItem{ Text = ProductType.Rent.ToString() + " - " + Loc.Rent, Value = ProductType.Rent }
                                                }, HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "Type", false, Loc.TypeShort, false))
                                                @Html.ValidationMessageFor(model => model.Type, "", new { @class = "text-danger" })
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
}

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