@using PantheonRA.BackOffice.Models;
@using PantheonRA.BackOffice;

@model PantheonRA.WebApi.Contracts.PaWoExItem

@{
    ViewBag.Title = Loc.WOEditOperation;
    ViewBag.AcKey = Model.AcKey;
    ViewBag.AnNo = Model.AnNo;
    ViewBag.Date = Model.Date;
    ViewBag.UM = Model.UM;
}

@using (Html.BeginForm(null, null, FormMethod.Post, new { @id = "workOrderEditOper", enctype = "multipart/form-data" }))
{

    <div class="wrapper wrapper-content">
        <div class="tabs-container">

            @Html.Partial("~/Views/Shared/_TabNavigation.cshtml", new TabNavigationViewModel
       {
           Tabs = new List<NavigationtabViewModel>
                {
                    new NavigationtabViewModel(Loc.WOProcessing_CompletedWork, Url.Action("EditOper", "Manufacturing",
                        new { key = Model.AcKey, no = Model.AnNo, type = ViewBag.ProdType}), Html.IsActive("EditOper", "Manufacturing"),
                        !PantheonRA.BackOffice.CurrentUser.CanAccess(PantheonRA.WebApi.Contracts.Enums.Permissions.PRODUCTION))
                }
       })


            <div class="tab-content">
                <div class="row buttons-tabbed">

                    @Html.Partial("_FormButtons", new FormButtonsViewModel
                    {
                        BackUrl = Url.Action("CompletWork", "Manufacturing", new { @key = Model.AcKey, type = ViewBag.ProdType }),
                        ConfirmButtonGroup = new FormButtonGroup
                        {
                            Buttons = new List<FormButton>
                                     {
                                         new FormButton {
                                             Text = Loc.Confirm,
                                             Icon = "fa fa-dolly",
                                             OnClick = "saveOperation(true);"
                                         }
                                     }
                        }
                    })
                </div>

                @Html.HiddenFor(model => model.AcKey)
                @Html.HiddenFor(model => model.AnNo)
                @Html.HiddenFor(model => model.Ident)
                @Html.HiddenFor(model => model.UM)
                @Html.HiddenFor(model => model.PlanQty)
                @Html.HiddenFor(model => model.Qty)
                @Html.HiddenFor(model => model.QId)
                @Html.HiddenFor(model => model.WoEx.PlanQty)

                <div class="row document-head">

                    <div class="col-lg-2 col-md-3 col-sm-3 col-xs-8 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-sm-2 col-xs-4 document-head-disabled-input">
                        <div class="form-group">
                            @Html.LabelFor(model => model.AnNo, Loc.Position, new { @class = "control-label m-t-xs" })
                            @Html.TextBoxFor(model => model.AnNo, new { @id = "no", @class = "form-control", @readonly = "readonly", @placeholder = Loc.Position })
                        </div>
                    </div>
                    <div class="col-sm-3 col-xs-6 document-head-disabled-input">
                        <div class="form-group">
                            @Html.LabelFor(model => model.Ident, Loc.Operation, new { @class = "control-label m-t-xs" })
                            @Html.TextBoxFor(model => model.Ident, new { @id = "ident", @class = "form-control", @readonly = "readonly", @placeholder = Loc.Operation })
                        </div>
                    </div>
                    <div class="col-sm-2 col-xs-6 dateFilter">
                        <div class="form-group">
                            <label class="control-label">@Loc.Date</label>
                            <div class="input-group">
                                <span class="input-group-addon"><i class="far fa-calendar alt"></i></span>
                                @Html.TextBoxFor(model => model.Date, new { @id = "date", @class = "form-control datepicker", @type = "text", @Value = @DateTime.Now.Date.ToString(Loc.DateFormat) })
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-2 col-xs-12">
                        <div class="form-group">
                            <label class="control-label">@Loc.Worker</label>
                            <select id="selectWorker"
                                    name="Worker"
                                    required
                                    class="form-control"
                                    allow-clear="true"
                                    data-placeholder="@Loc.Worker"
                                    data-dropdown-height="300">
                                <option value="" selected="selected"></option>
                                @foreach (var item in ViewBag.Workers)
                                {
                                    <option value="@item.Id" data-name="@item.Name" @(CurrentUser.DisplayName == item.Name ? "selected" : string.Empty)>
                                        @item.Name
                                    </option>
                                }

                            </select>
                        </div>
                    </div>

                </div>

                <div class="divided-content" style="overflow: auto">
                    <div class="divided-content-main divided-content-full">
                        <div class="form-horizontal">
                            @Html.Partial("~/Views/Manufacturing/_OperResourcesFormPartial.cshtml", Model.WoExItemResources)
                        </div>
                    </div>
                </div>
            </div>

        </div>

    </div>
};


<input type="hidden" id="receiveURL" value="@Url.Action("ConfirmOper", "Manufacturing")" />
<input type="hidden" id="buttonText" value="@Loc.OK" />
<input type="hidden" id="succesText" value="@Loc.SuccessWorkMsg" />
<input type="hidden" id="requiedQty" value="@Loc.RequiredInput @Loc.Quantity" />
<input type="hidden" id="requiedWorker" value="@Loc.RequiredInput @Loc.Worker" />

@section pageScripts{

    @Scripts.Render("~/bundles/manufacturing")
}
