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

@model PaWoEx

<div class="wrapper wrapper-content">
    <div class="tabs-container">
        @Html.Partial("_ProcessingTabNavigation")
        <div class="tab-content">
            <input id="localStorageFiltersFor" value="workOrdersMobile" hidden />
            @Html.HiddenFor(model => model.AcKey)
            @Html.HiddenFor(model => model.WoExDecPlacesProd)

            <div class="divided-content">

                <div class="divided-content-main divided-content-full no-padding">

                    <div class="row document-head d-head-m-b-0" style="margin-left:0px !important; margin-right:0px !important;">
                        <div class="col-xs-4 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" id="acKeyDisplay" disabled="disabled" type="text" value=" @Model.KeyView">
                            </div>
                        </div>
                        <div class=" document-head-disabled-input @(ViewBag.ItemType == "S"?"col-xs-4":"col-xs-8")">
                            <div class="form-group">
                                @Html.Label(Loc.Product, new { @class = "control-label" })
                                <input type="text" disabled="disabled" class="form-control" style="overflow:hidden;text-overflow:ellipsis" id="ident" value="@Model.Ident - @Model.Name" />
                            </div>
                        </div>
                        <div class="col-xs-4 document-head-disabled-input selectResurs @(ViewBag.ItemType == "S"?String.Empty:"hidden")">
                            <div class="form-group">
                                @Html.Label(Loc.WOResource, new { @class = "control-label" })
                                <input type="text" readonly="readonly" class="form-control localStorageFilter" id="ResursID" name="ResursID" value="@Loc.All" />
                            </div>
                        </div>
                    </div>

                    <div class="document-list-no-footer">
                        <table id="mainGridProcessing" data-grid-id="work-order-items" data-url="@Url.Action("WorkOrderItemList", "Manufacturing")" class="card">
                            <thead style="display:none">
                            </thead>
                        </table>
                    </div>

                </div>

                <div class="divided-content-side">
                    <div class="tabs-container">
                        <ul class="nav nav-tabs horizontal-menu" id="tabNav">
                            <li class="active divided-tab-1" id="homeTab">
                                <a id="tabCaption" data-toggle="tab" href="#item-options" class="local-tab">
                                    <span>@Loc.AdditionalSettings</span>
                                    <i class="far fa-times pull-right fa-lg text-muted btn-close-side-panel"></i>
                                </a>

                            </li>
                        </ul>
                    </div>
                    <div class="tab-content" id="sideNavBar">
                        <div id="item-options" class="tab-pane">
                            <div class="form-horizontal additonal-options">

                                <div class="row border-bottom p-l-10" id="work-history">
                                    <a data-toggle="tab" href="#work-reg-history">
                                        <h3 class="text-default"><i class="fas fa-history text-primary p-r-sm"></i>@Loc.WorkHistory</h3>
                                    </a>
                                </div>

                            </div>
                        </div>

                        <div id="work-reg-history" class="tab-pane m-l-n-sm m-r-n-sm">
                            <table id="woExOperWork" data-grid-id="WoExOperWork" data-url="@Url.Action("WoExOperWork", "Manufacturing")" class="table-responsive">
                                <thead>
                                    <tr>
                                        <th>@Loc.Worker</th>
                                        <th>@Loc.Key</th>
                                        <th>@Loc.Product/@Loc.Operation</th>
                                        <th>@Loc.Planned</th>
                                        <th>@Loc.Status</th>
                                    </tr>
                                </thead>
                            </table>
                        </div>

                        <div id="resurs" class="tab-pane additonal-options m-l-n-sm m-r-n-sm" 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>

                        <button type="button" class="btn btn-rounded btn-back btn-close-side-panel">
                            <i class="fas fa-chevron-left"></i>
                        </button>
                        <button type="button" class="btn btn-rounded btn-back btn-back-to-menu hidden">
                            <i class="fas fa-chevron-left"></i>
                        </button>

                    </div>
                </div>

            </div>
        </div>

        <a href="@Url.Action("Index", "Manufacturing", new { type = ViewBag.ProdType })" id="back" class="btn btn-light btn-rounded btn-back">
            <i class="fas fa-chevron-left"></i>
        </a>


        <div class="cont-right" style="right:0px;">

            <a href="@Url.Action("Receive", "Manufacturing", new { @id = Model.AcKey, type = ViewBag.ProdType })"
               id="receiving" role="button"
               class="btn pull-right btn-primary btn-rounded m-l-sm">
                <i class="fa fa-dolly"></i><span class="m-l-xs">@Loc.Receive</span>
            </a>

            <button id="options" type="button" class="btn pull-right btn-rounded @(ViewBag.ItemType == "S"?String.Empty:"hidden")">
                <i class="fas fa-ellipsis-h"></i>
            </button>
        </div>


    </div>
</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") {
                initializeWorkOrderOperationsMobile();
            }
            else {
                initializeWorkOrderMaterialsMobile();
            }

        });
    </script>

}
