@using PantheonRA.BackOffice.Models
@model PantheonRA.BackOffice.Models.DeliveryTypeViewModel

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

                <button id="invoiceDelete" type="button" onclick="removeDeliveryType()" 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.Delivery, Loc.Delivery, new { @class = "col-md-3 control-label" })
                                        <div class="col-md-9">
                                            @if (!Model.IsEdit)
                                            {
                                                @Html.TextBoxFor(model => model.Delivery, new { @id = "Delivery", @class = "form-control", autocomplete = "off", @maxlength = 2 })
                                                @Html.ValidationMessageFor(model => model.Delivery, "", new { @class = "text-danger" })
                                            }
                                            else
                                            {
                                                @Html.TextBoxFor(model => model.Delivery, new { @id = "Delivery", @class = "form-control", @readonly = "readonly" })
                                                @Html.ValidationMessageFor(model => model.Delivery, "", new { @class = "text-danger" })
                                            }
                                        </div>
                                    </div>

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

                                    <div class="form-group">
                                        @Html.LabelFor(model => model.Transport, Loc.TransportCode, new { @class = "col-md-3 control-label" })
                                        <div class="col-md-9">
                                            @Html.DropDownListFor(model => model.Transport, new List<SelectListItem>
                                            {
                                               new SelectListItem{ Text="1 - " + Loc.MaritimeTransport, Value = "1" },
                                               new SelectListItem{ Text="2 - " + Loc.RailwayTransport, Value = "2" },
                                               new SelectListItem{ Text="3 - " + Loc.RoadTransport, Value = "3" },
                                               new SelectListItem{ Text="4 - " + Loc.AirTransport, Value = "4" },
                                               new SelectListItem{ Text="5 - " + Loc.PostalTraffic, Value = "5" },
                                               new SelectListItem{ Text="7 - " + Loc.TransportInstallations, Value = "7" },
                                               new SelectListItem{ Text="8 - " + Loc.TrafficOnTheWaterways, Value = "8" },
                                               new SelectListItem{ Text="9 - " + Loc.OwnDrive, Value = "9" },
                                            }, HtmlAttributesHelper.CreateInputAttributes("form-control modal-dropdown-small custom-select", "Transport", false, Loc.TransportCode, false))
                                            @Html.ValidationMessageFor(model => model.Transport, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
}

<input type="hidden" id="RemoveDeliveryTypeUrl" value="@Url.Action("Remove", "DeliveryType")" />
<input type="hidden" id="DeliveryTypeIndexUrl" value="@Url.Action("Index", "DeliveryType")" />
<input type="hidden" id="DeleteWasNotSuccessfulLoc" value="@Loc.DeliveryTypeAlreadyInUse" />
<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 () {
            initializeDeliveryTypeEdit();
        });
    </script>
}