@using PantheonRA.BackOffice;
@using PantheonRA.WebApi.Contracts.Enums;
@using PAW.Contracts.Enums;
@using PantheonRA.BackOffice.Enums;
@model PantheonRA.BackOffice.Models.EmployeesGridFilterModel
@using PantheonRA.BackOffice.Models

@{
    ViewBag.Title = Loc.EmployeesList;
    var currentLoc = Loc.CurrentLocalization;
    var locBA = Localization.Code.BA;
    var locRS = Localization.Code.RS;
    var locMK = Localization.Code.MK;
    var locME = Localization.Code.ME;
    bool isLocBA = Loc.CurrentLocalization == Localization.Code.BA;
    bool isLocRS = Loc.CurrentLocalization == Localization.Code.RS;
    bool isLocMK = Loc.CurrentLocalization == Localization.Code.MK;
    bool isLocME = Loc.CurrentLocalization == Localization.Code.ME;
}

@Html.Hidden("DeleteTitle", Loc.Confirmation)
@Html.Hidden("DeleteWorkerText", Loc.DeleteWorkerText)
@Html.Hidden("DeleteSubjectText", Loc.DeleteSubjectText)
@Html.Hidden("Confirm", Loc.Yes)
@Html.Hidden("Cancel", Loc.No)
@Html.Hidden("TextConfirm", Loc.Confirm)
@Html.Hidden("CurrentLoc", currentLoc)
@Html.Hidden("LocBA", locBA)
@Html.Hidden("LocRS", locRS)
@Html.Hidden("LocMK", locMK)
@Html.Hidden("LocME", locME)


<div class="wrapper wrapper-content">
    <div class="tabs-container">
        @Html.Partial("_EmployeesTabNavigation")

        <div class="row buttons-tabbed employees-buttons">
            @if (CurrentUser.CanAccess(Permissions.EMPLOYEES))
            {
                <div>
                    @Html.Partial("_FormButtons", new FormButtonsViewModel
                    {
                      ShowCloseBtn = false,
                      BackUrl = Url.Action("Index", "Employees"),
                      CreateButtonGroup = new FormButtonGroup
                      {
                          IsActive = true,
                          IsButtonName = true,
                          ButtonName = Loc.NewEmployee,
                          Buttons = new List<FormButton>
                          {
                              new FormButton { Url = Url.Action("Create", "Employees") }
                          }
                      },
                      DeleteButtonGroup = new FormButtonGroup
                      {
                          IsActive = false,
                          Buttons = new List<FormButton>
                          {
                              new FormButton { OnClick = string.Format("DeleteEmployee('{0}')", Url.Action("Delete", "Employees")) }
                          }
                      }
                   })
                </div>
            }
        </div>

        <div class="mobile-scroll-wrapper">
            <div class="row document-head">
                <div class="col-md-2 col-sm-12">
                    <div class="form-group">
                        <label class="control-label">@Loc.SearchFilter</label>
                        @Html.TextBoxFor(model => model.Keywords, new { @id = "Keywords", @class = "form-control search-input", @placeholder = Loc.Search, autocomplete = "off" })
                    </div>
                </div>
                <div class="col-md-2 col-xs-6">
                    <div class="form-group selectpicker-dropdown">
                        @Html.LabelFor(model => model.EmployeesFilterData.EmploymentStatuses, Loc.EmploymentStatus, new { @class = "control-label" })
                        @Html.DropDownListFor(model => model.EmployeesFilterData.EmploymentStatuses,
                            new SelectList(Model.EmployeesFilterData.EmploymentStatuses, "Name", "Name"), Loc.All,
                            HtmlAttributesHelper.CreateInputAttributes("form-control selectpicker",
                                "EmploymentStatuses", false, Loc.EmploymentStatus, true, new { @multiple = "multiple", data_live_search = "true", @title = Loc.All }))
                    </div>
                </div>
                <div class="col-md-2 col-xs-6">
                    <div class="form-group selectpicker-dropdown">
                        @Html.LabelFor(model => model.EmployeesFilterData.WorkingPlaces, Loc.WorkingPlace, new { @class = "control-label" })
                        @Html.DropDownListFor(model => model.EmployeesFilterData.WorkingPlaces,
                            new SelectList(Model.EmployeesFilterData.WorkingPlaces, "Name", "Name"), Loc.All,
                            HtmlAttributesHelper.CreateInputAttributes("form-control selectpicker",
                                "WorkingPlaces", false, Loc.WorkingPlace, true, new { @multiple = "multiple", data_live_search = "true", @title = Loc.All }))
                    </div>
                </div>
                <div class="col-md-2 col-xs-6">
                    <div class="form-group selectpicker-dropdown">
                        @Html.LabelFor(model => model.EmployeesFilterData.Departments, Loc.Department, new { @class = "control-label" })
                        @Html.DropDownListFor(model => model.EmployeesFilterData.Departments,
                            new SelectList(Model.EmployeesFilterData.Departments, "Name", "Name"), Loc.All,
                            HtmlAttributesHelper.CreateInputAttributes("form-control selectpicker",
                                "Departments", false, Loc.Department, true, new { @multiple = "multiple", data_live_search = "true", @title = Loc.All }))
                    </div>
                </div>
                <div class="col-md-2 col-xs-6">
                    <div class="form-group selectpicker-dropdown">
                        <label class="control-label">@Loc.Status</label>
                        <select id="WorkingStatuses"
                                name="WorkingStatuses"
                                class="form-control selectpicker"
                                title="@Loc.All"
                                multiple>
                            <option value="@ActiveStatus.Active">@Loc.Active</option>
                            <option value="@ActiveStatus.Inactive">@Loc.Inactive</option>
                        </select>
                    </div>
                </div>
                <div class="col-md-2 hidden-sm hidden-xs"></div>
            </div>

            <div class="project-list mobile-content">
                <div class="employees-list document-list-no-footer width-99">
                    <table id="mainGrid" data-grid-id="employees" data-url="@Url.Action("EmployeesList", "Employees")" class="list-table">
                        <thead>
                            <tr>
                                <th class="dt-head-center"></th>
                                <th></th>
                                <th data-url="@Url.Action("Edit", "Employees")?id=">@Loc.Code</th>
                                <th>@Loc.LastnameAndFirstname</th>
                                <th>@Loc.Department</th>
                                <th>@Loc.Job</th>
                                <th>@Loc.Address</th>
                                <th>@Loc.Post</th>
                                <th class="@((isLocBA || isLocRS || isLocMK || isLocME) ? "hidden" : string.Empty)">@Loc.GridVatNumber</th>
                                <th>@Loc.RegistrationNumberShort</th>
                                <th class="dt-head-center">@Loc.Status</th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

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