@using PantheonRA.WebApi.Contracts.Enums

@model PantheonRA.BackOffice.Models.WorkOrdersGridFilterModel

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

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

        <div class="tab-content">

            <div class="row buttons-tabbed @(!_isMobile ? "hidden" : "")">
                <div style="padding-top:5px;">
                    <input class="form-control search-input" name="Keywords" type="text" placeholder="@Loc.Search" autocomplete="off">
                </div>
            </div>

            <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 @(_isMobile?"hidden":"") " 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" 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">
                            @foreach (var item in ViewBag.DocumentTypes)
                            {
                                <option value="@item.Id">@item.Value</option>
                            }
                        </select>

                    </div>
                </div>
                <div class="col-xs-2 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 localStorageFilter" multiple="multiple" title="@Loc.All">
                            @foreach (var item in ViewBag.StatusLookup)
                            {
                                if (!String.IsNullOrEmpty(item.Id))
                                {
                                    <option value="@item.Id">
                                        @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)
                            {
                                if (!String.IsNullOrEmpty(item.Value))
                                {
                                    <option value="@item.Value">
                                        @(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="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="DateTo" type="text" value="@DateTime.Now.Date.ToString(Loc.DateFormat)">
                        </div>
                    </div>
                </div>
                <div class="col-lg-2 col-sm-4 col-xs-6 @(ViewBag.ProdType == ProductionType.SE ? "hidden" : String.Empty)">
                    <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 role="button" class="btn clear-filters text-default" title="@Loc.Clear">
                            <i class="fas fa-broom fa-lg"></i>
                        </a>
                    </div>
                </div>
            </div>

            <div class="project-list @(_isMobile?"hidden":"")">
                <div class="document-list m-l-n-sm">
                    <table id="mainGrid" 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="pull-right fa-lg"></span>
                                </button>
                            }
                        </div>
                    </div>
                </div>
            </div>

            <div class="divided-content @(!_isMobile?"hidden":"")">
                <div class="divided-content-main divided-content-full no-padding">
                    <div class="document-list-no-footer">
                    </div>
                </div>

                <div class="divided-content-side">
                    <div class="tabs-container">
                        <ul class="nav nav-tabs horizontal-menu">
                            <li class="active divided-tab-1"><a data-toggle="tab" href="#filters" class="local-tab">@Loc.SearchFilter</a></li>
                        </ul>
                    </div>
                    <div class="tab-content" id="filtersTabs">
                        <div id="filters" class="tab-pane fade in active" style="margin-bottom:100px">
                            <div class="form-horizontal m-t-sm">

                                <div class="col-xs-12 p-xxs">
                                    <a data-toggle="tab" href="#doc-types">
                                        <div class="card card-filter">
                                            <div class="card-header">
                                                <h4 class="card-title text-default">@Loc.DocumentType</h4>
                                            </div>
                                            <div class="card-body p-l-10">
                                                <div class="input-group">
                                                    <span id="doc-type-list" class="text-default h4">@Loc.All</span>
                                                </div>

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

                                <div class="col-xs-12 p-xxs">
                                    <a data-toggle="tab" href="#status">
                                        <div class="card card-filter">
                                            <div class="card-header">
                                                <h4 class="card-title text-default">@Loc.WorkOrderStatus</h4>
                                            </div>
                                            <div class="card-body p-l-10">
                                                <div class="input-group">
                                                    <span id="status-list" class="text-default h4">@Loc.All</span>
                                                </div>

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

                                <div class="col-xs-12 p-xxs @hideForSE">
                                    <a data-toggle="tab" href="#resurs">
                                        <div class="card card-filter">
                                            <div class="card-header">
                                                <h4 class="card-title text-default">@Loc.WOResource</h4>
                                            </div>
                                            <div class="card-body p-l-10">
                                                <div class="input-group">
                                                    <span id="res-list" class="text-default h4">@Loc.All</span>
                                                </div>

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

                                <div class="col-xs-6 p-xxs">
                                    <div class="card card-filter">
                                        <div class="card-header">
                                            <h3 class="card-title">@Loc.DateFrom</h3>
                                        </div>
                                        <div class="card-body">
                                            <input class="form-control text-center col-xs-12 localStorageFilter fa-lg" id="mDateFrom" type="date" value="@DateTime.Now.Date.AddMonths(-8).ToString("yyyy-MM-dd")">
                                        </div>
                                    </div>
                                </div>

                                <div class="col-xs-6 p-xxs">
                                    <div class="card card-filter">
                                        <div class="card-header">
                                            <h3 class="card-title">@Loc.DateTo</h3>
                                        </div>
                                        <div class="card-body">
                                            <input class="form-control text-center col-xs-12 localStorageFilter fa-lg" id="mDateTo" type="date" value="@DateTime.Now.Date.ToString("yyyy-MM-dd")">
                                        </div>
                                    </div>
                                </div>

                                <div class="col-xs-12  p-xxs @(ViewBag.ProdType == ProductionType.SE ? "hidden" : String.Empty)">
                                    <div class="card card-filter">
                                        <div class="card-header">
                                            <h3 class="card-title">@Loc.DataFromDailyPlan</h3>
                                        </div>
                                        <div class="card-body">
                                            <div class="text-center">
                                                <input type="checkbox" class="js-switch timeRecordsSwitch localStorageFilter" id="data-from-daily-plan" />
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>

                        <div id="doc-types" class="tab-pane additonal-options m-l-n-sm m-r-n-sm" data-control="#DocTypes">

                            @foreach (var item in ViewBag.DocumentTypes)
                            {
                                <div class="border-bottom p-l-10 filter-list-item" data-value="@item.Id" data-display="@item.Value">
                                    <a data-toggle="tab">
                                        <h3 class="text-default" data-toggle="tab">
                                            @item.Value
                                            <i class="fa text-primary p-r-sm pull-right"></i>
                                        </h3>
                                    </a>
                                </div>
                            }

                        </div>

                        <div id="status" class="tab-pane additonal-options m-l-n-sm m-r-n-sm" data-control="#Status">
                            @foreach (var item in ViewBag.StatusLookup)
                            {
                                if (!String.IsNullOrEmpty(item.Id))
                                {
                                    <div class="border-bottom p-l-10 filter-list-item" data-value="@item.Id" data-display="@item.Name">
                                        <a data-toggle="tab">
                                            <h3 class="text-default" data-toggle="tab">
                                                @item.Name
                                                <i class="fa text-primary p-r-sm pull-right"></i>
                                            </h3>
                                        </a>
                                    </div>
                                }
                            }
                        </div>

                        <div id="resurs" class="tab-pane additonal-options m-l-n-sm m-r-n-sm @hideForSE" style="padding-bottom:100px" data-control="#ResursID">
                            @foreach (var item in ViewBag.SetResursLookup)
                            {
                                if (!String.IsNullOrEmpty(item.Value))
                                {
                                    <div class="border-bottom p-l-10 filter-list-item" data-value="@item.Value" data-display="@item.Value">
                                        <a data-toggle="tab">
                                            <h3 class="text-default" data-toggle="tab">
                                                @item.Value - @item.Text
                                                <i class="fa text-primary p-r-sm pull-right"></i>
                                            </h3>
                                        </a>
                                    </div>
                                }
                            }
                        </div>

                        <a id="back" role="button" class="btn btn-rounded btn-light btn-back">
                            <i class="fas fa-chevron-left"></i>
                        </a>

                        <div class="cont-right">
                            <button id="apply" type="button" class="btn btn-success pull-right btn-rounded margin-left-10">
                                <i class="fas fa-check"></i><span class="m-l-xs">@Loc.Confirm</span>
                            </button>
                            <button type="button" class="btn clear-filters pull-right btn-rounded">
                                <i class="fas fa-broom"></i>
                            </button>

                        </div>

                    </div>
                </div>

            </div>

        </div>

    </div>


    <div class="cont-right @(!_isMobile?"hidden":"")">
        <button id="filter" type="button" class="btn btn-success pull-right btn-rounded margin-left-10">
            <i class="fas fa-filter"></i><span class="m-l-xs">@Loc.SearchFilter</span>
        </button>
    </div>

</div>

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

@section pageScripts{
    @Scripts.Render("~/bundles/manufacturing")

    <script>
            $(document).ready(function () {
                initWorkOrders({
                    identFilterItem: '@Loc.Item',
                    identFilterName: '@Loc.Name',
                    operationStart: '@Loc.OperationStart',
                    operationPause: '@Loc.OperationPause',
                    operationContinue: '@Loc.OperationContinue',
                    operationEnd: '@Loc.OperationEnd',
                    workRegistration: '@Loc.WorkRegistration',
                    materialsForOperation: '@Loc.MaterialsForOperation'
                },
                    {
                        operRegURL: '@Url.Action("GetActiveWoExRegOper", "Manufacturing")'
                    },
                    {
                        isMobile:'@_isMobile'
                    }
                );
            });
    </script>


}
