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

@model PantheonRA.WebApi.Contracts.PaWoExItem

@{
    Model.ProdType = ViewBag.ProdType;
}


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

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

            @Html.Partial("_ProcessingTabNavigation")

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

                    @Html.Partial("_FormButtons", new FormButtonsViewModel
               {
                   BackUrl = Url.Action("IssueMat", "Manufacturing", new { @key = Model.AcKey, type = ViewBag.ProdType }),
                   ConfirmButtonGroup = new FormButtonGroup
                   {
                       Buttons = new List<FormButton>
                            {
                                new FormButton { Text = Loc.Confirm,
                                                 Icon = "fa fa-dolly",
                                                 Class =  Model.IssueFinished == "Y" ? "hidden" : string.Empty,
                                                 OnClick = "saveMaterial();"
                                }
                            }
                   }

               })


                </div>
                @Html.HiddenFor(model => model.AcKey)
                @Html.HiddenFor(model => model.AnNo)
                @Html.HiddenFor(model => model.WoExDecPlacesMate)
                @Html.HiddenFor(model => model.ProdType)
                @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.MaterialEnum, new { @class = "control-label m-t-xs" })
                            @Html.TextBoxFor(model => model.Ident, new { @id = "ident", @class = "form-control", @readonly = "readonly", @placeholder = Loc.Material })
                        </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" style="overflow: auto">
                    <div class="divided-content-main divided-content-full">
                        <div class="form-horizontal" style="margin:0px 15px">
                            <div class="row">
                                <div class="form-group">
                                    @Html.LabelFor(model => model.Qty, Loc.Quantity, 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.WoExDecPlacesMate" placeholder="0" class="form-control numberInput" />
                                            <span class="input-group-addon">/@String.Format("{0:0.##}", Model.RestQtyCalc) @Model.UM</span>
                                        </div>
                                        @Html.ValidationMessageFor(model => model.Qty, "", new { @class = "text-danger" })
                                    </div>
                                </div>
                                <div class="form-group" style="@((ViewBag.ProdType == ProductionType.MF)?"display:block":"display:none")">
                                    @Html.LabelFor(model => model.ScrapQty, Loc.WOScrap, 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="scrapQty" name="ScrapQty" step="@Model.WoExDecPlacesMate" placeholder="0" class="form-control numberInput" />
                                            <span class="input-group-addon">/@String.Format("{0:0.##}", Model.RestScrapQtyCalc) @Model.UM</span>
                                        </div>
                                        @Html.ValidationMessageFor(model => model.ScrapQty, "", new { @class = "text-danger" })
                                    </div>
                                </div>

                                <div class="form-group">
                                    @Html.LabelFor(model => model.WasteQty, Loc.WOWaste, 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="wasteQty" name="WasteQty" step="@Model.WoExDecPlacesMate" placeholder="0" class="form-control numberInput" />
                                            <span class="input-group-addon">/@String.Format("{0:0.##}", Model.RestWasteQtyCalc) @Model.UM</span>
                                        </div>
                                        @Html.ValidationMessageFor(model => model.WasteQty, "", new { @class = "text-danger" })
                                    </div>
                                </div>

                                <div class="form-group">
                                    @Html.LabelFor(model => model.Note, Loc.Note, new { @class = "col-lg-1 col-sm-2 col-md-2 control-label" })
                                    <div class="col-lg-3 col-sm-4 col-md-4">
                                        <textarea id="note" name="Note" class="form-control text-left"></textarea>
                                    </div>
                                </div>
                                <hr class="hr-dashed" />

                                <div class="form-group">
                                    @Html.LabelFor(model => model.Picture, Loc.Picture, new { @class = "col-lg-1 col-sm-2 col-md-2 control-label" })
                                    <div class="col-lg-3 col-sm-4 col-md-4">
                                        @Html.Image(ImageHelper.GetImageThumbnail(Model.Picture, 500), "alt", new { id = "image", @class = "col-xs-8" })
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
};


<input type="hidden" id="receiveURL" value="@Url.Action("ConfirmMat", "Manufacturing")" />
<input type="hidden" id="buttonText" value="@Loc.OK" />
<input type="hidden" id="succesText" value="@Loc.SuccessIssueMsg" />
<input type="hidden" id="requiedQty" value="@Loc.RequiredInput @Loc.Quantity" />
<input type="hidden" id="productionTypeMF" value="@ProductionType.MF" />
<input type="hidden" id="productionTypeSE" value="@ProductionType.SE" />
<input type="hidden" id="manufacturingExampleMF" value="@SiteHelpAttributeHelper.GetHelpUrl(HelpIds.ManufacturingExampleMF)" />
<input type="hidden" id="manufacturingExampleSE" value="@SiteHelpAttributeHelper.GetHelpUrl(HelpIds.ManufacturingExampleSE)" />

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

    <script src="~/Scripts/custom/global-helpers.js"></script>
    <script>
        if ($("#Picture").val() == "") {
            $("#image").attr('src', noImage);
        }
    </script>

}
