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

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="manifest" href="@Url.Action("Manifest", "Webapp")" crossorigin="use-credentials" />

    <title>@Loc.WebSiteTitle | @ViewBag.Title</title>
    @Styles.Render("~/Content/inspinia/css")
    <link href="~/Content/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
    <link href="~/Content/plugins/font-awesome-5/css/all.min.css" rel="stylesheet">
    <link href="~/Content/plugins/font-awesome-6/css/regular.min.css" rel="stylesheet">
    <link href="~/Content/plugins/font-awesome-6/css/fontawesome.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,500,600,700&display=swap" rel="stylesheet">
    <link href="~/Content/customStyle.css" rel="stylesheet" />
    <link href="~/Content/inspinia/animate.css" rel="stylesheet">
    <link href="~/Content/jquery.bootgrid.css" rel="stylesheet" />
    <link href="~/Content/plugins/select2/select2.css" rel="stylesheet" />
    <link href="~/Content/plugins/select2/select2-bootstrap.css" rel="stylesheet" />
    <link href="~/Content/plugins/dropify/css/dropify.min.css" rel="stylesheet" />
    <link href="~/Content/plugins/switchery/switchery.css" rel="stylesheet" />
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.10.0/css/bootstrap-datepicker.min.css" rel="stylesheet" />
    <link href="https://code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.css" rel="stylesheet" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.18/css/bootstrap-select.min.css" />
    <link href="~/Content/bootstrap-datetimepicker.css" rel="stylesheet" />
    <link href="https://cdn.datatables.net/v/dt/dt-1.13.8/b-2.4.2/b-html5-2.4.2/cr-1.7.0/fc-4.3.0/fh-3.4.0/r-2.5.0/sc-2.3.0/datatables.min.css" rel="stylesheet">

    @Styles.Render("~/Content/bundles/Redesign")
    @Styles.Render("~/bundles/libStyles")

    @RenderSection("pageCss", false)
</head>
@{
    HttpCookie navigationMenuCookie = CurrentUser.IsAutoTest == false ? Request.Cookies[PantheonRA.BackOffice.Enums.MenuCookie.MenuState] : null;
    string navigationMenuClass = "";

    if (navigationMenuCookie != null)
    {
        navigationMenuClass = navigationMenuCookie.Value == "open" ? "" : "mini-navbar";
    }

    PantheonRA.BackOffice.Authorization.IAuthInfo authInfo = null;
    if (ViewContext.Controller is PantheonRA.BackOffice.Controllers.PawController)
    {
        var controller = ViewContext.Controller as PantheonRA.BackOffice.Controllers.PawController;
        authInfo = controller._authInfo;

        if (authInfo != null && authInfo.HasGranules() && GranulesHelper.GetAllActiveGranules(authInfo).Count == 1)
        {
            bool hasGrTo = authInfo.HasGranule(Granules.TravelOrderGranule);
            bool hasGrDt = authInfo.HasGranule(Granules.DocumentsTasksGranule);
            bool hasGrBi = authInfo.HasGranule(Granules.DashboardGranule);

            navigationMenuClass = hasGrTo || 
                                    (hasGrDt && MainNavigation.RootItem(authInfo).GrantedChildrenCount <= 1) || 
                                    hasGrBi? 
                                    "none-navbar" : "";
        }

        if(authInfo != null)
        {
            <input type="hidden" id="isGDPR" value="@authInfo.IsGDPR().ToString()" />
        }
    }

    HttpCookie themeCookie = Request.Cookies["theme"];
    string theme = themeCookie != null ? themeCookie.Value : null;
}

<body class="@navigationMenuClass theme-@(theme != null ? theme : "trademark")">
    @Scripts.Render("~/Scripts/jquery")

    <!-- Mobile menu -->
    @Html.Partial("_MobileNavigationMenu")

    <!-- Wrapper-->
    <div id="wrapper">

        <!-- Navigation -->
        @Html.Partial("_NavigationAngular")

        <!-- Page wraper -->
        <div id="page-wrapper" class="wrapper-bg">

            <!-- Top Navbar -->
            @Html.Partial("_HeaderNavigationBar")

            <!-- Main view  -->
            @RenderBody()
        </div>
        <!-- End page wrapper-->
    </div>
    <!-- End wrapper-->



    <input type="hidden" id="datatable-noResults" value="@Loc.NoResultFound" />
    <input type="hidden" id="datatable-info" value="@(Loc.Showing + " _START_ " + Loc.To.ToLower() + " _END_ (_TOTAL_)")" />
    <input type="hidden" id="datatable-loading" value="@(Loc.Loading + "...")" />
    <input type="hidden" id="mediaViewer-noPDF" value="@Loc.NoPDFAlert" />
    <input type="hidden" id="mediaViewer-downloadPDF" value="@Loc.DownloadPDF" />
    <input type="hidden" id="mediaViewer-installAdobeReader" value="@Loc.InstallAdobeReader" />
    <input type="hidden" id="siteLocale" value="@Loc.CurrentLocalization.ToString()" />
    <input type="hidden" id="language" value="@Loc.LocalizationCode.ToLower()" />
    <input type="hidden" id="languageDate" value="@PantheonRA.BackOffice.CurrentUser.LocalizationDate" />
    <input type="hidden" id="countryLocale" value="@PantheonRA.BackOffice.CurrentUser.Localization" />
    <input type="hidden" id="i18n" value="@PantheonRA.BackOffice.CurrentUser.Localizationi18n.ToLower()" />
    <input type="hidden" id="filterSubmit" value="@Loc.Submit" />
    <input type="hidden" id="filterCancel" value="@Loc.Cancel" />
    <input type="hidden" id="filterText" value="@Loc.FilterByCondition" />
    <input type="hidden" id="filterSortText" value="@Loc.Sorting" />
    <input type="hidden" id="enumNumberBetween" value="@PantheonRA.WebApi.Contracts.Enums.FilterNumberCriteria.Between" />
    <input type="hidden" id="enumDateBetween" value="@PantheonRA.WebApi.Contracts.Enums.FilterDateTimeCriteria.Between" />
    <input type="hidden" id="itemExcisesUrl" value="@Url.Action("GetItemExcises", "Duty")" />
    <input type="hidden" id="getIdentFxRateUrl" value="@Url.Action("GetIdentFxRate", "Currency")" />
    <input type="hidden" id="siteMenuStatesUrl" value="@Url.Action("MenuState", "Account")" />
    <input type="hidden" id="RepeatAnimationPath" value="@Url.Content("~/Content/Animations/Trademark/Printing.gif")" />
    <input type="hidden" id="LoadingDocumentLoc" value="@Loc.LoadingDocument" />
    <input type="hidden" id="dividedContent-show" value="@Loc.Show" />
    <input type="hidden" id="dividedContent-hide" value="@Loc.Hide" />
    <input type="hidden" id="custom-modal-success" value="@Loc.Information" />
    <input type="hidden" id="custom-modal-alert" value="@Loc.Alert" />
    <input type="hidden" id="custom-modal-question" value="@Loc.Question" />
    <input type="hidden" id="custom-modal-error" value="@Loc.Error" />
    <input type="hidden" id="custom-modal-confirm" value="@Loc.Confirm" />
    <input type="hidden" id="custom-toast-success" value="@Loc.Information" />
    <input type="hidden" id="custom-toast-alert" value="@Loc.Alert" />
    <input type="hidden" id="custom-toast-question" value="@Loc.Question" />
    <input type="hidden" id="custom-toast-error" value="@Loc.Error" />
    <input type="hidden" id="general-error" value="@Loc.GeneralError" />
    <input type="hidden" id="closeLoc" value="@Loc.Close" />
    <input type="hidden" id="yesLoc" value="@Loc.Yes" />
    <input type="hidden" id="noLoc" value="@Loc.No" />
    <input type="hidden" id="checkInstructionsLoc" value="@Loc.CheckInstructions" />
    <input type="hidden" id="dataFilterURL" value="@Url.Action("FiltersList","DataFilter")" />
    @Html.Hidden("SaveTableGrid", Url.Action("SaveTableGrid", "TableGrid"))
    @Html.Hidden("GetTableGrid", Url.Action("GetTableGrid", "TableGrid"))
    @Html.Hidden("SaveLanguage", Url.Action("SaveLanguage", "Users"))
    @Html.Hidden("ShowCalendarUrl", Url.Action("ShowCalendar", "Order"))
    @Html.Hidden("EditTaskUrl", Url.Action("Edit", "Task"))
    @Html.Hidden("GetDocTypeStatusesUrl", Url.Action("GetDocTypeStatuses", "DocumentType"))
    @Html.Hidden("GeneralErrorMessage", string.Format("{0}. ", Loc.GeneralError))
    @Html.Hidden("ResultCouldNotBeLoaded", Loc.ResultCouldNotBeLoaded)
    @Html.Hidden("PleaseDelete", Loc.PleaseDelete)
    @Html.Hidden("Character", Loc.Character)
    @Html.Hidden("PleaseEnter", Loc.PleaseEnter)
    @Html.Hidden("OrMoreCharacters", Loc.OrMoreCharacters)
    @Html.Hidden("LoadingMoreResults", Loc.LoadingMoreResults)
    @Html.Hidden("YouCanOnlySelect", Loc.YouCanOnlySelect)
    @Html.Hidden("Item", Loc.Item)
    @Html.Hidden("NoResultFound", Loc.NoResultFound)
    @Html.Hidden("Searching", Loc.Searching)
    @Html.Hidden("ShowHide", Loc.ShowHide)
    @Html.Hidden("ShowHideColumns", Loc.ShowHideColumns)
    @Html.Hidden("PreparePantheonApi", Url.Action("PreparePantheon", "Account"))
    @Html.Hidden("DateFormat", Loc.DateFormat)
    @Html.Hidden("SelectOptionLoc", Loc.Select)
    @Html.Hidden("GetDocTypeHasPermission", Url.Action("DocTypePermission", "CurrentUser"))
    @Html.Hidden("GetDocTypeHasPermissions", Url.Action("DocTypePermissions", "CurrentUser"))
    @Html.Hidden("IsAutoTest", CurrentUser.IsAutoTest)
    @Html.Hidden("SpecificationLoc", Loc.Specification)
    @Html.Hidden("SerialNumbersLoc", Loc.ProductMenuSerialNumbersTitle)
    @Html.Hidden("NoteLoc", Loc.Note)
    @Html.Hidden("DeleteLoc", Loc.Delete)
    @Html.Hidden("RecalculateWorkBookChartUrl", Url.Action("RecalculateWorkBookChart", "WorkBook"))
    @Html.Hidden("GetSysParamsUrl", Url.Action("GetSysParams", "Settings"))

    @Scripts.Render("~/bundles/libs")

    <script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.5/bluebird.min.js"></script>

    @Scripts.Render("~/plugins/toastr")
    @Scripts.Render("~/inspiniaBundles/bootstrap")
    @Scripts.Render("~/inspiniaPlugins/metsiMenu")
    @Scripts.Render("~/inspiniaPlugins/pace")
    @Scripts.Render("~/inspiniaPlugins/slimScroll")
    @Scripts.Render("~/inspiniaBundles/inspinia")
    @Scripts.Render("~/plugins/bootgrid")
    @Scripts.Render("~/bundles/moment")
    <script src="~/Scripts/moment-with-locales.min.js"></script>

    <script type="text/javascript" src="~/Scripts/plugins/select2/select2.full.js"></script>
    <script type="text/javascript" src="~/Scripts/plugins/select2/select2Custom.js"></script>
    <script src="~/Scripts/plugins/dropify/dropify.min.js"></script>
    <script src="~/Scripts/plugins/select2/select2-helper.js"></script>
    <script src="~/Scripts/plugins/jquery-ui-1.12.1.custom/jquery-ui.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.10.0/js/bootstrap-datepicker.min.js"></script>
    <script type="text/javascript" src="@Url.Content(string.Format("~/Scripts/plugins/datapicker/locales/bootstrap-datepicker.{0}.min.js", PantheonRA.BackOffice.CurrentUser.LocalizationDate.ToLower()))"></script>
    <script type="text/javascript" src="~/Scripts/bootstrap3-typeahead.min.js"></script>
    <script src="~/Scripts/plugins/switchery/switchery.js"></script>
    <script src="https://cdn.datatables.net/v/dt/dt-1.13.8/b-2.4.2/b-html5-2.4.2/cr-1.7.0/fc-4.3.0/fh-3.4.0/r-2.5.0/sc-2.3.0/datatables.min.js"></script>
    <script type="text/javascript" src="~/Scripts/custom/fiscalPrintersHelper.js?v=@ViewContext.Controller.GetType().Assembly.GetName().Version"></script>
    <script type="text/javascript" src="~/Scripts/bootstrap-datetimepicker.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.18/js/bootstrap-select.min.js"></script>
    <script src="https://cdn.datatables.net/fixedcolumns/4.0.0/js/dataTables.fixedColumns.js"></script>
    <script type="text/javascript" src="~/Scripts/plugins/datatable/dataTables.scrollResize.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-scrollTo/2.1.3/jquery.scrollTo.min.js"></script>
    <script type="text/javascript" src="~/Scripts/jquery.ui.touch-punch.js"></script>
    <script src="https://unpkg.com/floatthead"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.1.2/purify.min.js" integrity="sha512-Qv/FE/4VEODlbctXAQe4OHnXmoHiiMitTJv6D/80eCQRviSGZENG4bSOSZ0eE++lRkyuxMxID0Dh90gPkq39Pg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

    @Scripts.Render("~/bundles/purify")
    @Scripts.Render("~/bundles/paw-js")
    @Scripts.Render("~/bundles/custom")

    @* TODO: Add after datepicker refactor *@
    @*<script src="~/Scripts/global-script.js"></script>*@

    @RenderSection("pageScripts", required: false)

    @Html.Partial("_NotificationsPartial")

    @Html.Partial("_FiscalPrinterModals")

    <script type="text/javascript">
        $(document).ajaxError(function (event, jqxhr, settings, thrownError) {
            if (jqxhr.status === 401)
                location.href = "/Account/Login";
        });

        $(document).ready(function () {
            if ($("#noPermissionModul").length === 0 && $("#side-menu > li").length < 3 && $("#side-menu li").length < 4) {
                $("body").removeClass("mini-navbar").addClass("none-navbar");
            }

            if ($("#noPermissionModul").length > 0) {
                $("body").removeClass("none-navbar");
            }

            if ($("#menu-order-calendar-item").length > 0) {
                $.ajax({
                    url: $("#ShowCalendarUrl").val(),
                    type: "GET",
                    success: function (showCalendar) {
                        if (showCalendar) $("#menu-order-calendar-item").removeClass("hidden");
                    }
                });
            }
            var initAion = paw.utils.value.strToBool("@(!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings.Get("AionScriptUrl")))");
            if (initAion) {
                paw.mod.Aion.init({
                    url: "@System.Configuration.ConfigurationManager.AppSettings.Get("AionScriptUrl")",
                    language: "@Loc.AionLanguage"
                }, true);
            }

            if ($('#CloudSupportLoginLink').length > 0) {
                paw.mod.Aion.fetchEncParameter().then(function (enc) {
                    var href = $('#CloudSupportLoginLink').attr('href');
                    href += '&ENC=' + enc;
                    $('#CloudSupportLoginLink').attr('href', href);
                });
            }
        });


    </script>
</body>
</html>
