@using PantheonRA.BackOffice.Enums
@model PantheonRA.WebApi.Contracts.Vehicle
@using PantheonRA.BackOffice.Models

<script src="~/Scripts/custom/vehicles/vehicles.js"></script>

@{
    ViewBag.Title = Loc.Create;
}

@{
    string ActionMethod = "Create";
    if (!string.IsNullOrWhiteSpace(Model.InventNum))
    {
        ActionMethod = "Edit";
    }
}

@Html.Hidden("ShouldOpenNewRecord", "false")
@Html.Hidden("ActionMethod", ActionMethod)

<div class="wrapper wrapper-content">
    <div class="tabs-container">
        <nav>
            <ul class="nav nav-tabs horizontal-menu custom-scrollable-tabs" role="tablist">
                <li class="nav-item active"><a href="@Url.Action("Create", "Vehicles")">@Loc.NewVehicle</a></li>
                <li class="nav-item"><a href="@Url.Action("Index", "Vehicles")">@Loc.MenuVehicles</a></li>
            </ul>
        </nav>
        <div class="row buttons-tabbed">
            @Html.Partial("_FormButtons", new FormButtonsViewModel
                   {
                       BackUrl = Url.Action("Index", "Vehicles"),
                       SaveButtonGroup = new FormButtonGroup
                       {
                           Buttons = new List<FormButton>
               {
                   new FormButton { OnClick = "return submitForm('false', 'vehicleSubmit')" }
               }
                       },
                       CreateButtonGroup = new FormButtonGroup
                       {
                           IsButtonName = true,
                           ButtonName = Loc.AddVehicle,
                           Buttons = new List<FormButton>
               {
                   new FormButton { OnClick = "return submitForm('true', 'vehicleSubmit')" }
               }
                       }

                   })
        </div>
        <div class="tab-content">
                @using (Html.BeginForm(ActionMethod, "Vehicles", null, FormMethod.Post))
                {
                    <input id="vehicleSubmit" type="submit" hidden />
                    <div class="row">
                        <div class="ibox-content">
                            @Html.HiddenFor(m => m.InventNum)
                            @Html.HiddenFor(m => m.IsFixedAsset)
                            @Html.HiddenFor(m => m.IsCompanyCar)
                            @Html.HiddenFor(m => m.IsSupportVehicle)
                            @Html.HiddenFor(m => m.CreatedDate)
                            @Html.Hidden("redirectToCreate", "false")

                            <div class="row form-group m-b-xs">
                                <div class="col-lg-4">
                                    <div class="col-lg-4">
                                        @Html.Label(Loc.IsActive, new { @class = "control-label m-t-xs custom-label" })
                                    </div>
                                    <div class="col-lg-8">
                                        @Html.CheckBox("IsActive", Model.IsActive, new { @class = "form-control js-switch" })
                                    </div>
                                </div>
                            </div>

                            <div class="row form-group m-b-xs">
                                <div class="col-lg-4">
                                    <div class="col-lg-4">
                                        @Html.Label(Loc.Name, new { @class = "control-label m-t-xs custom-label" })
                                    </div>
                                    <div class="col-lg-8">
                                        @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control", @minlength = "5", @autocomplete = "off", @placeholder = Loc.Name } })
                                        @Html.ValidationMessageFor(m => m.Name, "", new { @class = "text-danger" })
                                    </div>
                                </div>
                            </div>

                            <div class="row form-group m-b-xs">
                                <div class="col-lg-4">
                                    <div class="col-lg-4">
                                        @Html.Label(Loc.CarRegNo, new { @class = "control-label m-t-xs custom-label" })
                                    </div>
                                    <div class="col-lg-8">
                                        @Html.EditorFor(model => model.CarRegNo, new { htmlAttributes = new { @class = "form-control", @placeholder = Loc.CarRegNo, @autocomplete = "off" } })
                                        @Html.ValidationMessageFor(m => m.CarRegNo, "", new { @class = "text-danger" })
                                    </div>
                                </div>
                            </div>

                            <div class="row form-group m-b-xs">
                                <div class="col-lg-4 ">
                                    <div class="col-lg-4">
                                        @Html.Label(Loc.SupportCar, new { @class = "control-label m-t-xs custom-label" })
                                    </div>
                                    <div class="col-lg-8">
                                        <select name="SuppCarRegNo"
                                                data-placeholder="@Loc.SupportCar"
                                                class="form-control select2withAPI"
                                                data-url=@Url.Action("GetSupportVehicleAsync", "Vehicles")>
                                            <option selected="selected">@Model.SuppCarRegNo</option>
                                        </select>
                                    </div>
                                </div>
                            </div>

                            <div class="row form-group m-b-xs">
                                <div class="col-lg-4">
                                    <div class="col-lg-4">
                                        @Html.Label(Loc.Note, new { @class = "control-label m-t-xs custom-label" })
                                    </div>
                                    <div class="col-lg-8">
                                        @Html.EditorFor(model => model.Note, new { htmlAttributes = new { @class = "form-control", @placeholder = Loc.Note } })
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                }
        </div>
    </div>
        
</div>

@* TODO: remove after refactor *@
@section pageScripts{
    @Scripts.Render("~/bundles/validation")
    <script src="~/Scripts/global-script.js"></script>
}