@model PantheonRA.BackOffice.Models.BaseGridFilterModel
@using PantheonRA.BackOffice.Models
@using PantheonRA.WebApi.Contracts
@{
    ViewBag.Title = @Loc.WorkHourSettings;
}

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

        <div class="row buttons-tabbed">
            @Html.Partial("_FormButtons", new FormButtonsViewModel
            {
                ShowCloseBtn = false,
                CreateButtonGroup = new FormButtonGroup
                {
                    IsActive = true,
                    IsButtonName = true,
                    ButtonName = Loc.AddShift,
                    Buttons = new List<FormButton>
                    {
                        new FormButton { Url = Url.Action("Create", "SetWorkHours") }
                    }
                }
            })
        </div>

        <div id="set-workhours-content" class="divided-content">
            <div class="divided-content-main">
                <div class="row document-head">
                    <div class="col-md-2">
                        <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-10"></div>
                </div>

                <div class="row document-body texts-list project-list">
                    <div class="document-list document-list-no-footer">
                        <table id="set-workhours" data-grid-id="set-workhours" data-url="@Url.Action("ListM", "SetWorkHours")" class="list-table">
                            <thead>
                                <tr>
                                    <th data-url="@Url.Action("Edit", "SetWorkHours")?AcCode=">@Loc.Code</th>
                                    <th>@Loc.Name</th>
                                    <th>@Loc.TaEtBefore</th>
                                    <th>@Loc.TaEtAfter</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
            <div class="divided-content-side">
                @{Html.RenderAction("SideMenu", "SetWorkHours", new { activeId = "2" });}
            </div>
        </div>
    </div>
</div>

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

        $(document).ajaxError(function () {
            location.reload();
        });

        function initializeSetWorkHours() {
            var columns = [
                { data: "AcCode", name: "AcCode", render: $.fn.dataTable.render.link("AcCode"), className: 'dt-body-center' },
                { data: "ShiftType", name: "ShiftType", filtertype: "text" },
                { data: "EtBefore", name: "EtBefore", filtertype: "text" },
                { data: "EtAfter", name: "EtAfter", filtertype: "text" },
            ];

            initializeDataTables('set-workhours', 'Keywords', columns);

            $dataTable = $('#set-workhours');
        }

    </script>
}