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

@model PaWoEx

<div class="tabs-container">
    @Html.Partial("_ProcessingTabNavigation")
    <div class="row buttons-tabbed">
        @Html.Partial("_FormButtons", new FormButtonsViewModel
            {
                BackUrl = Url.Action("Index", "Manufacturing", new { type = ViewBag.ProdType })
            })
        <a href="@Url.Action("Receive", "Manufacturing", new { @id = Model.AcKey, type = ViewBag.ProdType })" 
           id="receiveButton" 
           class="btn btn-success  pull-right @(Model.ReceiveFinished == "Y"? "hidden":"") " 
           title="@Loc.Receive">
            <i class="fa fa-dolly"></i><span class="bold hidden-xs m-l-xs">@Loc.Receive</span>
        </a>
    </div>
    <input id="localStorageFiltersFor" value="workOrderList" hidden />
    @Html.HiddenFor(model => model.AcKey)
    <div class="row document-head" style="margin-bottom:5px !important">
        <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6 document-head-disabled-input">
            <div class="form-group">
                @Html.LabelFor(model => model.AcKey, Loc.Number, new { @class = "control-label m-t-xs" })
                <input class="form-control text-center " id="acKeyDisplay" disabled="disabled" type="text" value=" @Model.KeyView">
            </div>
        </div>
        <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6 document-head-disabled-input">
            <div class="form-group typeahead-ident-filter">
                @Html.Label(Loc.Product, new { @class = "control-label" })
                <input type="hidden" id="productPlaceholder" title="@Loc.Product" />
                <input type="text" disabled="disabled" class="typeahead_3 form-control" id="IdentFilterSearch" dataUrl="@Url.Action("SearchIdents", "SetItem")"
                       placeholder="@Loc.EnterIdentProduct" autocomplete="off" value="@Model.Ident" />
            </div>
        </div>
        <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6 @(ViewBag.ProdType == ProductionType.MF && @ViewBag.ItemType == "S" ? 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" title="@Loc.All">
                    @foreach (var item in ViewBag.SetResursLookup)
                    {
                        <option value="@item.Value" @(String.IsNullOrEmpty(item.Value) ? "selected" : string.Empty)>
                            @item.Text
                        </option>
                    }
                </select>
            </div>
        </div>

    </div>
    <div class="project-list  m-l-n-sm">
        <table id="mainGridProcessing" data-grid-id="work-order-items" data-url="@Url.Action("WorkOrderItemList", "Manufacturing")" class="card cardDailyPlan">
            <thead style="display:none">
            </thead>
        </table>
    </div>
</div>

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

<input type="hidden" id="itemType" value="@ViewBag.ItemType" />
<input type="hidden" id="prodType" value="@ViewBag.ProdType" />
<input type="hidden" id="operationCaption" value="@Loc.Operation" />
<input type="hidden" id="materialCaption" value="@Loc.MaterialEnum" />
<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="operMatURL" value="@Url.Action("MaterialsForOperationList", "Manufacturing")" />
<input type="hidden" id="operRegURL" value="@Url.Action("GetActiveWoExRegOper", "Manufacturing")" />

@section pageScripts{
    @Scripts.Render("~/bundles/manufacturing")
    <script>
        $(document).ready(function () {
            if ($("#itemType").val() === "S") {
                initializeWorkOrderOperations();
            }
            else {
                initializeWorkOrderMaterials();
            }
        });
    </script>

}
