@model PantheonRA.WebApi.Contracts.Job
@using PantheonRA.BackOffice.Models

@{
    string ActionMethod = "Create";
    if (!string.IsNullOrEmpty(Model.Name))
    {
        ActionMethod = "Edit";
    }
    var hideOnCreate = string.IsNullOrEmpty(Model.Name) ? "hidden" : string.Empty;
}

@Html.Hidden("ConfirmDeleteMessage", Loc.ConfirmDeleteMessage)
@Html.Hidden("Confirm", Loc.Confirm)
@Html.Hidden("Cancel", Loc.Cancel)
@Html.Hidden("WorkPlaceInUse", Loc.WorkPlaceInUse)
@Html.Hidden("DeleteJob", Url.Action("Delete", "Jobs", new { name = Model.Name }))
@Html.Hidden("JobsUrl", Url.Action("Index", "Jobs"))


<div class="wrapper wrapper-content">
    <div class="tabs-container">
        @Html.Partial("~/Views/Products/_CodeListTabNavigation.cshtml")

        <div class="row buttons-tabbed">
            @Html.Partial("_FormButtons", new FormButtonsViewModel
            {
                BackUrl = Url.Action("Index", "Jobs")
            })

            <button title="@Loc.Save" type="button" onclick="$('#jobForm').submit()"
                    class="btn btn-success pull-right">
                <i class="fa fa-save"></i>
                <span class="visible-lg-inline visible-md-inline">@Loc.Save</span>
            </button>

            <button title="@Loc.Delete" type="button" onclick="deleteJob('@Model.Name')"
                    class="btn btn-primary btn-outline pull-right pull-right @hideOnCreate">
                <i class="far fa-trash-alt"></i>
                <span class="visible-lg-inline visible-md-inline">@Loc.Delete</span>
            </button>

        </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-7 col-lg-5">
                            <div class="row">
                                <div class="col-xs-12">
                                    <h3 class="m-b-md">@Loc.BasicJobInformation</h3>
                                    @using (Html.BeginForm(ActionMethod, "Jobs", null, FormMethod.Post, new { @id = "jobForm" }))
                                    {
                                        @Html.HiddenFor(m => m.Id)

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

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

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

                                        <div class="form-group">
                                            <div class="col-md-4">
                                                @Html.Label("", Loc.ParentWorkPlace, new { @class = "control-label m-t-xs custom-label" })
                                            </div>
                                            <div class="col-md-8">
                                                <select id="NameSuperior"
                                                        name="NameSuperior"
                                                        data-placeholder="@Loc.ParentWorkPlace"
                                                        class="form-control select2withAPI"
                                                        filter-by="Name"
                                                        data-url=@Url.Action("GetDropDownValues", "GlobalHelper", new { apiPath = "/v1/jobs/get-superior-jobs/" })>
                                                    <option selected="selected" value="@Model.NameSuperior">@Model.NameSuperior</option>
                                                </select>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <div class="col-md-4">
                                                @Html.Label(Loc.Department, new { @class = "control-label m-t-xs custom-label" })
                                            </div>
                                            <div class="col-md-8">
                                                <select id="Department"
                                                        name="Department"
                                                        data-placeholder="@Loc.Department"
                                                        class="form-control select2withAPI"
                                                        data-url=@Url.Action("GetDepartments", "Employees")>
                                                    <option selected="selected" value="@Model.Department">@Model.Department</option>
                                                </select>
                                            </div>
                                        </div>

                                    }

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@section pageScripts{
    @Scripts.Render("~/bundles/validation")
    @Scripts.Render("~/bundles/jobs")
    <script src="~/Scripts/global-script.js"></script>
    <script>
        $(document).ready(function () {
            $('#Name').focus();
        });
    </script>
}
