@model PantheonRA.BackOffice.Models.SetItemCreateViewModel
@using PantheonRA.BackOffice.Models
@using PantheonRA.BackOffice.Enums
@{
    ViewBag.Title = string.IsNullOrEmpty(Model.ProductEditData.Id) ? Loc.CreateNewProduct : Loc.EditProduct;
}

<div class="tabs-container product-content">
    @Html.Partial("~/Views/Products/_CodeListTabNavigation.cshtml")
    <div class="tab-content">
        <div class="row buttons-tabbed">
            <button onclick="onDeleteProduct()" class="btn btn-primary btn-primary btn-outline @(Model.IsEdit ? string.Empty : " hidden")" title="@Loc.Delete">
                <i class="far fa-trash-alt"></i><span class="bold visible-lg-inline m-l-xs">@Loc.Delete</span>
            </button>

            <a href="@Url.Action("Create", "Products")" class="btn btn-primary btn-primary btn-outline" title="@Loc.CreateNewProduct">
                <i class="fa fa-plus"></i><span class="bold visible-lg-inline m-l-xs">@Loc.New</span>
            </a>

            <div id="importContractPricesContainer" class="btn-group dropdown hidden">
                <button type="button"
                        id="importContractPricesButton"
                        class="btn btn-primary btn-outline printDropdown"
                        onClick="importProductContractPricesClick()"
                        title="@Loc.ImportContractPrices">
                    <i class="fas fa-cloud-upload-alt"></i><span class="visible-lg-inline visible-md-inline m-l-xs">@Loc.ImportContractPrices</span>
                </button>
                <button type="button" class="btn btn-primary btn-outline dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                    <li>
                        <a href="@Url.Action("DownloadProductsContractPriceImportTemplate", "Products")" class="btn btn-primary btn-outline" title="@Loc.DownloadImportTemplate">
                            <span>@Loc.DownloadImportTemplate</span>
                        </a>
                    </li>
                    <li>
                        <a id="importProductContractPricesButton" onClick="importProductContractPricesClick()" class="btn btn-primary btn-outline" title="@Loc.ImportProducts">
                            <span>@Loc.ImportContractPrices</span>
                        </a>
                    </li>
                </ul>
            </div>

            @if (Model.Type == ProductsMenuType.BasicInfo
                || Model.Type == ProductsMenuType.Packaging)
            {
                @Html.Partial("_FormButtons", new FormButtonsViewModel
                {
                    BackUrl = Url.Action("Index", "Products"),
                    SaveButtonGroup = new FormButtonGroup
                    {
                        Buttons = new List<FormButton>
                        {
                            new FormButton { Text = Loc.Save, Icon = "fa fa-save fa-lg", IsSubmit = true, OnClick="submitSaveProduct()" }
                        }
                    }
                })
            }
            else
            {
                @Html.Partial("_FormButtons", new FormButtonsViewModel
                {
                    BackUrl = Url.Action("Index", "Products"),
                })
            }
        </div>

        <div class="divided-content">
            <div class="divided-content-main">
                @if (Model.Type == ProductsMenuType.BasicInfo)
                {
                    Html.RenderPartial("~/Views/Products/_CreateProductFormPartial.cshtml", Model);
                }
                else if (Model.Type == ProductsMenuType.ContractPriceList)
                {
                    Html.RenderPartial("~/Views/Products/_ContractPriceList.cshtml", Model);
                }
                else if (Model.Type == ProductsMenuType.SerialNumbers)
                {
                    Html.RenderPartial("~/Views/Products/_SerialNumbers.cshtml", Model);
                }
                else if (Model.Type == ProductsMenuType.Packaging)
                {
                    Html.RenderPartial("~/Views/Products/_Packaging.cshtml", Model);
                }
            </div>
            <div class="divided-content-side" style="min-height: 88vh">
                @{Html.RenderAction("SideMenu", "Products", new { activeTitle = Model.Title, id = Model.Id, description = Model.ProductEditData != null ? Model.ProductEditData.Name : string.Empty });}
            </div>
        </div>
    </div>
</div>

<input type="hidden" value="@Url.Action("ImportProducts", "Products")" id="importProductsUrl" />
<input type="hidden" value="@Url.Action("ImportProductContractPrices", "Products")" id="importProductsContractPricesUrl" />
<input type="hidden" id="createProductUrl" value="@Url.Action("Create", "Products")" />
<input type="hidden" id="editProductUrl" value="@Url.Action("Edit", "Products")" />
<input type="hidden" id="productsIndex" value="@Url.Action("Index", "Products")" />
<input type="hidden" id="ConfirmDeleteLoc" value="@Loc.ConfirmDeleteMessage" />
<input type="hidden" id="DeleteProductUrl" value="@Url.Action("Remove", "Products")" />
<input type="hidden" id="YesLoc" value="@Loc.Yes" />
<input type="hidden" id="NoLoc" value="@Loc.No" />
<input type="hidden" id="ConfirmLoc" value="@Loc.Confirm" />
<input type="hidden" id="ProductAlreadyInUseLoc" value="@Loc.ProductAlreadyInUse" />

@section pageScripts{
    @Scripts.Render("~/bundles/product")
    <script>
        $(document).ready(function () {
            try {
                initializeProductsEdit();
            } catch (e) { }
        });
    </script>
}