@using PantheonRA.WebApi.Contracts.Enums

@{
    var hideForSE = ViewBag.ProdType == ProductionType.SE ? "hidden" : String.Empty;
}

<div class="wrapper wrapper-content">
    <div class="tabs-container">
        @Html.Partial("_ManufacturingTabNavigation")
        <div class="tab-content">
            <input id="localStorageFiltersFor" value="workOrderList" hidden />
            <input id="sortColumn" value="AdTimeIns" hidden />
            <input id="sortOrder" value="DESC" hidden />
            @Html.Hidden("ProdType", ((string)ViewBag.ProdType))
            <div class="row document-head" style="margin-bottom:5px !important">

                <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>
                        <input class="form-control search-input" id="Keywords" name="Keywords" type="text" placeholder="@Loc.Search" autocomplete="off">
                    </div>
                </div>

                <div class="col-md-2 col-sm-4 col-xs-6">
                    <div class="form-group">
                        <a class="control-label text-default sortField" data-sort-column="AcDocType">
                            <i class="far hidden"></i>@Loc.DocumentType
                        </a>
                        <select id="DocTypes" name="DocTypes" class="form-control selectpicker localStorageFilter" data-live-search="true" multiple="multiple" title="@Loc.All">
                            <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 hidden">
                    <div class="form-group">
                        <a class="control-label text-default sortField" data-sort-column="AcStatusMF">
                            <i class="far hidden"></i>@Loc.WorkOrderStatus
                        </a>
                        <select id="Status" name="Status" class="form-control selectpicker" multiple="multiple" title="@Loc.All">
                            @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 @hideForSE">
                    <div class="form-group">
                        <label class="control-label">@Loc.WOResource</label>
                        <select id="ResursID" name="ResursID" class="form-control selectpicker localStorageFilter" data-live-search="true" multiple="multiple" title="@Loc.All">
                            @foreach (var item in ViewBag.SetResursLookup)
                            {
                                <option value="@item.Value" @(String.IsNullOrEmpty(item.Value) ? "selected" : string.Empty)>
                                    @((String.IsNullOrEmpty(item.Value)? String.Empty : item.Value + " - ") + item.Text)
                                </option>
                            }
                        </select>
                    </div>
                </div>
                <div class="col-sm-2 col-xs-3 dateFilter">
                    <div class="form-group">
                        <a class="control-label text-default sortField" data-sort-column="AdDate">
                            <i class="far hidden"></i>@Loc.DateFrom
                        </a>
                        <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-sm-2 col-xs-3 dateFilter">
                    <div class="form-group">
                        <a class="control-label text-default sortField" data-sort-column="AdDate">
                            <i class="far hidden"></i>@Loc.DateTo
                        </a>
                        <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-2 col-sm-4 col-xs-6 @hideForSE">
                    <div class="col-xs-10">
                        <div class="form-group">
                            <label class="control-label">@Loc.DataFromDailyPlan</label>
                            <div class="hw-switch-m-l m-t-3">
                                <input type="checkbox" class="js-switch timeRecordsSwitch" id="data-from-daily-plan" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-2" style="height: 65px; border-left: 1px solid #ddd;padding:15px 0;">
                        <a id="clear" role="button" class="btn text-default" title="@Loc.Clear">
                            <i class="fas fa-broom fa-lg"></i>
                        </a>
                    </div>
                </div>
            </div>

            <div class="project-list">
                <div class="document-list">
                    <table id="mainGrid" data-grid-id="work-orders" data-url="@Url.Action("WorkOrderList", "Manufacturing")" class="card">
                    </table>
                </div>

                <div class="row document-footer document-footer-sm">
                    <div>

                        <div class="btn-toolbar btn-status-bar m-t-xs" role="toolbar">
                            @foreach (var item in ViewBag.StatusLookup)
                            {
                                <button class="btn" id="@(String.IsNullOrEmpty(@item.Id)? "X" : item.Id)" style="color: @item.Display">
                                    <span>@item.Name</span>
                                    <span class="fa-lg"></span>
                                </button>

                            }

                        </div>

                    </div>
                </div>

            </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="workRegistration" value="@Loc.WorkRegistration" />
<input type="hidden" id="materialsForOperation" value="@Loc.MaterialsForOperation" />

<input type="hidden" id="operRegURL" value="@Url.Action("GetActiveWoExRegOper", "Manufacturing")" />

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

