@using PantheonRA.BackOffice.Models

@model PantheonRA.WebApi.Contracts.PaWoExItem

@{
    Model.ProdType = ViewBag.ProdType;
}


@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.PAW_TRANSFER))
                }
            })

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

                    @Html.Partial("_FormButtons", new FormButtonsViewModel
                    {
                        BackUrl = Url.Action("CompletWork", "Manufacturing", new { @id = 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.ProdType)
                @Html.HiddenFor(model => model.WoEx.UM)
                @Html.HiddenFor(model => model.WoEx.PlanQty)

                <div class="row document-head">

                    <div class="col-lg-2 col-md-3 col-sm-4 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-md-2 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-md-3 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-md-2 col-sm-3 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>

                <div class="divided-content">
                    <div class="divided-content-main divided-content-full">
                        <div class="form-horizontal">
                            <div class="row">

                                <div class="form-group">
                                    @Html.LabelFor(m => m.WoExItemWorkSE.Worker, Loc.Worker, new { @class = "col-lg-1 col-sm-2 col-md-2 control-label" })
                                    <div class="col-lg-3 col-sm-4 col-md-4">
                                        <div>
                                            <select id="selectWorker"
                                                    name="WoExItemWorkSE.Worker"
                                                    required
                                                    class="form-control"
                                                    allow-clear="true"
                                                    data-placeholder="@Loc.Worker"
                                                    data-dropdown-height="300">
                                                <option value="" data-name=""></option>
                                                @foreach (var item in ViewBag.Workers)
                                                {
                                                    <option value="@item.Id" data-name="@item.Name">
                                                        @item.Name
                                                    </option>
                                                }

                                            </select>
                                        </div>
                                        @Html.ValidationMessageFor(model => model.WoExItemWorkSE.Worker, "", new { @class = "text-danger" })
                                    </div>
                                </div>
                                <div class="form-group">
                                    @Html.LabelFor(model => model.Qty, Loc.UsedTime, new { @class = "col-lg-1 col-sm-2 col-md-2 control-label" })
                                    <div class="col-lg-3 col-sm-4 col-md-4">
                                        <div class="input-group">
                                            <input type="text" id="qty" name="Qty" step="@Model.WoExDecPlacesOper" placeholder="0" required class="form-control numberInput" autocomplete="off" />
                                            <span class="input-group-addon">/@Decimal.Round(Model.RestQtyCalc, Model.WoExDecPlacesOper) @Model.UM</span>
                                        </div>
                                        @Html.ValidationMessageFor(model => model.Qty, "", new { @class = "text-danger" })
                                    </div>
                                </div>

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

            </div>
        </div>
    </div>
};


<div class="modal inmodal fade" id="errorModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-body">
                <span id="errorModalMessage"></span>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="">@Loc.OK</button>
            </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")
    @Scripts.Render("~/bundles/custom")
}
