@using PantheonRA.BackOffice.Enums
@using PantheonRA.WebApi.Contracts.Enums

@model PantheonRA.BackOffice.Models.WorkOrdersGridFilterModel

<div class="wrapper wrapper-content">
    <div class="tabs-container">
        @Html.Partial("_ManufacturingTabNavigation")
        <div class="tab-content">
            <input id="localStorageFiltersFor" value="workOrders" hidden />
            @Html.HiddenFor(model => model.DefaultDecimalPlacesPrice)
            @Html.HiddenFor(model => model.DefaultDecimalPlacesQuantity)
            @Html.HiddenFor(model => model.DefaultDecimalPlacesValue)
            @Html.HiddenFor(model => model.ProductionType)
            @Html.Hidden((string)ViewBag.ProdType)
            <div class="row document-head">

                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-6">
                    <div class="form-group">
                        <label class="control-label">@Loc.SearchFilter</label>
                        @Html.TextBoxFor(model => model.Keywords, new { @id = "Keywords", @class = "form-control search-input localStorageFilter", @placeholder = Loc.Search, autocomplete = "off" })
                    </div>
                </div>

                <div class="col-md-2 col-sm-4 col-xs-6">
                    <div class="form-group">
                        <label class="control-label">@Loc.DocumentType</label>
                        <select id="DocTypes" name="DocTypes" class="form-control selectpicker localStorageFilter" multiple="multiple">
                            <option value="@String.Empty" selected> @Loc.All </option>
                            @foreach (var item in ViewBag.DocumentTypes)
                            {
                                <option value="@item.Id"> @item.Value </option>
                            }
                        </select>

                    </div>
                </div>

                <div class="col-md-2 col-sm-4 col-xs-6">
                    <div class="form-group">
                        <label class="control-label">@Loc.WorkOrderStatus</label>

                        <select id="Status" name="Status" class="form-control selectpicker  localStorageFilter" multiple="multiple">
                            @foreach (var item in ViewBag.StatusLookup)
                            {
                                <option value="@item.Id" @(String.IsNullOrEmpty(item.Id) ? "selected" : string.Empty)>
                                    @item.Name
                                </option>
                            }
                        </select>
                    </div>
                </div>
                <div class="col-md-2 col-sm-4 col-xs-6 @(Model.ProductionType == ProductionType.MF? String.Empty : "hidden" )">
                    <div class="form-group">
                        <label class="control-label">@Loc.WOResource</label>
                        <select id="ResursID" name="ResursID" class="form-control selectpicker  localStorageFilter" multiple="multiple">
                            @foreach (var item in ViewBag.SetResursLookup)
                            {
                                <option value="@item.Value" @(String.IsNullOrEmpty(item.Value) ? "selected" : string.Empty)>
                                    @item.Text
                                </option>
                            }
                        </select>
                    </div>
                </div>
                <div class="col-lg-1 col-sm-2 col-xs-4 dateFilter">
                    <div class="form-group">
                        <label class="control-label">@Loc.DateFrom</label>
                        <div class="input-group">
                            <span class="input-group-addon"><i class="far fa-calendar alt"></i></span>
                            <input class="form-control datepicker  localStorageFilter" id="Filter_DateFrom" name="Filter.DateFrom" type="text"
                                   value="@DateTime.Now.Date.AddMonths(-1).ToString(Loc.DateFormat)">
                        </div>
                    </div>
                </div>
                <div class="col-lg-1 col-sm-2 col-xs-4 dateFilter">
                    <div class="form-group">
                        <label class="control-label">@Loc.DateTo</label>
                        <div class="input-group">
                            <span class="input-group-addon"><i class="far fa-calendar alt"></i></span>
                            <input class="form-control datepicker  localStorageFilter" id="Filter_DateTo" name="Filter.DateTo" type="text"
                                   value="@DateTime.Now.Date.ToString(Loc.DateFormat)">
                        </div>
                    </div>
                </div>
                <div class="col-lg-1 col-sm-2 col-xs-4 @(Model.ProductionType == ProductionType.MF? String.Empty : "hidden" )">
                    <div class="form-group">
                        <label class="control-label">From daily plan</label>
                        <div class="hw-switch-m-l m-t-3">
                            <input type="checkbox" class="js-switch timeRecordsSwitch localStorageFilter" id="data-from-daily-plan" onchange="SetDataFromDP();" />
                        </div>
                    </div>
                </div>
            </div>

            <div class="project-list">
                <table id="mainGrid" data-grid-id="work-orders" data-url="@Url.Action("WorkOrderList", "Manufacturing")" class="cards">
                    <thead style="display:none">
                        <tr>
                            <th width="3%"></th>
                            <th width="15%"></th>
                            <th width="10%"></th>
                            <th width="6%"></th>
                            <th width="8%"></th>
                            <th width="8%"></th>
                        </tr>
                    </thead>
                </table>
            </div>

        </div>
    </div>
</div>

<div id="operPopover">
    <table id="popoverTable" class="table">
    </table>
</div>

<input type="hidden" id="identFilterItem" value="@Loc.Item" />
<input type="hidden" id="identFilterName" value="@Loc.Name" />
<input type="hidden" id="operationStart" value="@Loc.OperationStart" />
<input type="hidden" id="operationPause" value="@Loc.OperationPause" />
<input type="hidden" id="operationContinue" value="@Loc.OperationContinue" />
<input type="hidden" id="operationEnd" value="@Loc.OperationEnd" />
<input type="hidden" id="operRegURL" value="@Url.Action("GetActiveWoExRegOper", "Manufacturing")" />

@section pageScripts{
    @Scripts.Render("~/bundles/manufacturing")
    <script>
        $(document).ready(function () {
            initializeWorkOrders();
        });
    </script>
}
