@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">
            @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-md-2 col-sm-4 col-xs-6">
                    <div class="form-group">
                        @Html.LabelFor(model => model.DocType, Loc.DocumentType, new { @class = "control-label" })
                        @Html.DropDownList("DocTypes",
                                        new SelectList(ViewBag.DocumentTypes != null ? ViewBag.DocumentTypes : new List<string>(), "Id", "Value"), Loc.All,
                                        HtmlAttributesHelper.CreateInputAttributes("form-control selectpicker", "DocTypes", false, Loc.DocumentType, true,
                                                                                    new { @multiple = "multiple", data_live_search = "true", @title = Loc.DocumentType }))
                    </div>
                </div>

                <div class="col-lg-2 col-md-3 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" multiple="multiple" place>
                            @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-lg-2 col-md-3 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" 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-2 col-md-3 col-sm-4 col-xs-6">
                    <div class="form-group typeahead-ident-filter">
                        @Html.Label(Loc.Product, new { @class = "control-label" })
                        <input type="text" class="typeahead_3 form-control" id="IdentFilterSearch" dataUrl="@Url.Action("SearchIdents", "SetItem")"
                               placeholder="@Loc.EnterIdentProduct" autocomplete="off" />
                    </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" id="Filter_DateFrom" name="Filter.DateFrom" type="text"
                                   value="@DateTime.Now.Date.AddYears(-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" id="Filter_DateTo" name="Filter.DateTo" type="text"
                                   value="@DateTime.Now.Date.ToString(Loc.DateFormat)">
                        </div>
                    </div>
                </div>
                <div class="col-md-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" 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>

<input type="hidden" id="identFilterItem" value="@Loc.Item" />
<input type="hidden" id="identFilterName" value="@Loc.Name" />

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

}
