@using PAW.Contracts.Enums
@using System.Configuration
@model PantheonRA.Contracts.DataContracts.CompanyInfoData
@{
    ViewBag.Title = Loc.CompanyInfo;
    bool isLocalizationRS = Loc.CurrentLocalization == Localization.Code.RS;
}

<div class="tabs-container">
    @Html.Partial("~/Views/Company/_CompanySettingsTabNavigation.cshtml")

    <div class="tab-content">
        <form action="@Url.Action("Edit", "Company")" enctype="multipart/form-data">
            <div class="row buttons-tabbed">
                @if (!PantheonRA.BackOffice.CurrentUser.HasGranules())
                {
                    <button type="submit" class="btn btn-success pull-right">
                        <i class="fa fa-save m-r-xs"></i> @Loc.Save
                    </button>
                    <button id="checkFiscalServerConnectivityBtn" type="button" class="btn btn-primary btn-outline pull-right collapsable-form-button" onclick="checkFiscalServerConnectivity()">
                        <i class="fa fa-wifi" title="@Loc.CheckServiceAvailability"></i><span class="hidden-xs hidden-sm m-l-xs">@Loc.CheckServiceAvailability</span>
                    </button>
                    <button id="checkFiscalServerConnectivityBtn" type="button" class="btn btn-primary btn-outline pull-right collapsable-form-button" onclick="openImportWorkflowDefinitionsModal()">
                        <i class="fa fa-paper-plane" title="@Loc.ImportWorkflowDefinition"></i><span class="hidden-xs hidden-sm m-l-xs">@Loc.ImportWorkflowDefinition</span>
                    </button>

                }
            </div>
            <div class="divided-content clearfix">
                <div class="divided-content-main divided-content-full">

                    <div class="row stacked-content">
                        <div class="col-lg-4 col-sm-12">
                            <div class="row m-t">
                                <div class="col-sm-12">
                                    <div>
                                        <h3>
                                            @Loc.CompanyInfo
                                            @if (!PantheonRA.BackOffice.CurrentUser.HasGranules())
                                            {
                                                <span class="pull-right"><i class="edit-form-button fa fa-pencil clickable-icon" title="@Loc.Edit"></i></span>
                                            }
                                        </h3>
                                    </div>
                                    <div>
                                        <table class="full-width">
                                            <tr>
                                                <td colspan="2">
                                                    <img class="form-display-element" style="max-width:100%" src="@(!string.IsNullOrEmpty(Model.CompanyLogo) ? "data:image/png;base64, " + Model.CompanyLogo : "")" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2">
                                                    <div class="form-edit-element">
                                                        <input name="LogoFile" id="LogoFile" type="file" class="dropify" data-allowed-file-extensions="png jpg jpeg" />
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="align-middle">
                                                    <div class="m-t-sm">
                                                        <strong>@Loc.CompanyName</strong>
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="m-t-sm">
                                                        <span class="form-display-element">
                                                            @Model.CompanyId
                                                        </span>
                                                        <div class="form-edit-element">
                                                            @Html.HiddenFor(model => model.CompanyId)
                                                            @Html.TextBox("Company", Model.CompanyId,
                                                            HtmlAttributesHelper.CreateInputAttributes("form-control typeahead_3 typeahead_wide",
                                                            null, false, Loc.EnterPartner, true,
                                                            new { dataUrl = Url.Action("SearchPartners", "Company") }))
                                                        </div>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="align-middle">
                                                    <div class="m-t-sm">
                                                        <strong>@Loc.IsCompanyVat</strong>
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="m-t-sm">
                                                        @Html.HiddenFor(model => model.IsCompanyVat)
                                                        <span class="form-display-element">@Html.CheckBox("IsTaxPayer", Model.IsCompanyVat, new { @class = "form-control js-switch js-switch-small company-js-switch", @id = "IsCompanyVatDisplaySwitch", @disabled = "disabled" })</span>
                                                        <span class="form-edit-element">@Html.CheckBox("IsTaxPayer", Model.IsCompanyVat, new { @class = "form-control js-switch js-switch-small company-js-switch", @id = "IsCompanyVatSwitch" })</span>
                                                    </div>
                                                </td>
                                            </tr>
                                        </table>

                                        <table class="full-width">
                                            <tr>
                                                <td class="align-middle"><div class="m-t-sm"><strong>@Loc.DocumentNoteThreeRows</strong></div></td>
                                            </tr>
                                            <tr>
                                                <td colspan="2">
                                                    <div class="form-display-element textArea">
                                                        <textarea class="form-control" rows="3" disabled>@Model.CompanyPrtTextA</textarea>
                                                    </div>
                                                    <div class="form-edit-element">
                                                        @Html.TextAreaFor(model => model.CompanyPrtTextA,
                                                        HtmlAttributesHelper.CreateInputAttributes("form-control",
                                                        "CompanyPrtTextA", false, string.Empty, true, new { @rows = "3" }))
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="align-middle"><div class="m-t-sm"><strong>@Loc.DocumentNoteSixRows</strong></div></td>
                                            </tr>
                                            <tr>
                                                <td colspan="2">
                                                    <div class="form-display-element textArea">
                                                        <textarea class="form-control" rows="6" disabled>@Model.CompanyPrtTextB</textarea>
                                                    </div>
                                                    <div class="form-edit-element">
                                                        @Html.TextAreaFor(model => model.CompanyPrtTextB,
                                                        HtmlAttributesHelper.CreateInputAttributes("form-control",
                                                        "CompanyPrtTextB", false, string.Empty, true, new { @rows = "6" }))
                                                    </div>
                                                </td>
                                            </tr>
                                            @if (!PantheonRA.BackOffice.CurrentUser.IsDemo)
                                            {
                                                <tr>
                                                    <td colspan="2">
                                                        <div class="form-group google-api-key">
                                                            <label class="col-md-3 control-label" for="GoogleApiKey">@Loc.GoogleApiKey</label>
                                                            <div class="col-md-9">
                                                                <input autocomplete="off" class="form-control" id="GoogleApiKey" name="GoogleApiKey" type="text" value="@Model.GoogleApiKey">
                                                            </div>
                                                        </div>
                                                    </td>
                                                </tr>
                                            }
                                            @if (isLocalizationRS)
                                            {
                                                <tr>
                                                    <td colspan="2">
                                                        <div class="form-group gtin-ident">
                                                            <label class="col-md-3 control-label" for="FiscalGtin">@Loc.GtinIdent</label>
                                                            <div class="col-md-5">
                                                                <select class="form-control custom-select custom-select-open" id="FiscalGtin" name="FiscalGtin">
                                                                    <option value="" @(Model.FiscalGtin == 1 || Model.FiscalGtin == null ? "selected" : "")></option>
                                                                    <option value="2" @(Model.FiscalGtin == 2 ? "selected" : "")>@Loc.GtinIdent2</option>
                                                                    <option value="3" @(Model.FiscalGtin == 3 ? "selected" : "")>@Loc.GtinIdent3</option>
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </td>
                                                </tr>
                                            }
                                            <tr>
                                                <td colspan="2">
                                                    <div class="pull-right form-edit-element m-t-sm">
                                                        <button type="button" class="cancel-button btn btn-sm btn-outline btn-primary">@Loc.Cancel</button>
                                                        <button type="submit" class="btn btn-sm btn-success"><i class="fas fa-save"></i> @Loc.Save</button>
                                                    </div>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>

                                </div>
                            </div>

                        </div>
                        <div class="col-lg-4 col-md-6 col-sm-12">
                            <div class="row m-t">
                                <div class="col-sm-12">
                                    <div class="form-group">
                                        <h3 class="m-l-sm">@Loc.LicenceInfo</h3>
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-12">
                                            <div class="clearfix">
                                                <table class="display-table">
                                                    <tr>
                                                        <td style="min-width:150px"><strong>@Loc.RegisteredUser</strong><span class="visible-xs">@Model.Licence.RegisteredUser</span></td>
                                                        <td><span class="hidden-xs">@Model.Licence.RegisteredUser</span></td>
                                                    </tr>
                                                    <tr>
                                                        <td><strong>@Loc.SerialNumber</strong><span class="visible-xs">@Model.Licence.SerialNumber</span></td>
                                                        <td><span class="hidden-xs">@Model.Licence.SerialNumber</span></td>
                                                    </tr>
                                                    <tr>
                                                        <td><strong>@Loc.License</strong></td>
                                                        <td><span>@PantheonRA.BackOffice.Licensing.LicCount(PantheonRA.BackOffice.CurrentUser.DomainName) / @PantheonRA.BackOffice.Licensing.LicTotal(PantheonRA.BackOffice.CurrentUser.DomainName)</span></td>
                                                    </tr>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row m-t">
                                <div class="col-sm-12">
                                    <div class="form-group">
                                        <h3 class="m-l-sm">@Loc.VersionInfo</h3>
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-12">
                                            <div class="clearfix">
                                                <table class="display-table">
                                                    <tr>
                                                        <td><strong>@Loc.VersionWeb</strong><span class="visible-xs">@Model.WebBuildVersion  rev. @Model.WebBuildRevision</span></td>
                                                        <td><span class="hidden-xs">@Model.WebBuildVersion  rev. @Model.WebBuildRevision</span></td>
                                                    </tr>
                                                    <tr>
                                                        <td><strong>@Loc.VersionDB</strong><span class="visible-xs">@Model.DbBuildVersion rev. @Model.Revision</span></td>
                                                        <td><span class="hidden-xs">@Model.DbBuildVersion  rev. @Model.Revision</span></td>
                                                    </tr>
                                                    <tr>
                                                        <td><strong>@Loc.Database</strong><span class="visible-xs">@Model.DatabaseName</span></td>
                                                        <td><span class="hidden-xs">@Model.DatabaseName</span></td>
                                                    </tr>
                                                    <tr>
                                                        <td><strong>@Loc.Legislation</strong><span class="visible-xs">@Model.Legislation</span></td>
                                                        <td><span class="hidden-xs">@Model.Legislation</span></td>
                                                    </tr>
                                                    <tr>
                                                        <td><strong>@Loc.CollationDB</strong><span class="visible-xs">@Model.CollationDb</span></td>
                                                        <td><span class="hidden-xs">@Model.CollationDb</span></td>
                                                    </tr>
                                                    <tr>
                                                        <td><strong>@Loc.CollationServer</strong><span class="visible-xs">@Model.CollationServer</span></td>
                                                        <td><span class="hidden-xs">@Model.CollationServer</span></td>
                                                    </tr>
                                                    @if (PantheonRA.BackOffice.CurrentUser.UserName.Trim() == "AD")
                                                    {
                                                        <tr>
                                                            <td><strong>@Loc.PaasVersion</strong><span class="visible-xs">@PantheonRA.BackOffice.CurrentUser.PaasVersion</span></td>
                                                            <td><span class="hidden-xs">@PantheonRA.BackOffice.CurrentUser.PaasVersion</span></td>
                                                        </tr>
                                                        <tr>
                                                            <td><strong>@Loc.PaasLocalization</strong><span class="visible-xs">@PantheonRA.BackOffice.CurrentUser.PaasLocalization</span></td>
                                                            <td><span class="hidden-xs">@PantheonRA.BackOffice.CurrentUser.PaasLocalization</span></td>
                                                        </tr>
                                                        <tr>
                                                            <td><strong>@Loc.PaasIP</strong><span class="visible-xs">@PantheonRA.BackOffice.CurrentUser.PaasIP</span></td>
                                                            <td><span class="hidden-xs">@PantheonRA.BackOffice.CurrentUser.PaasIP</span></td>
                                                        </tr>
                                                    }
                                                    @if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.RS)
                                                    {
                                                        @*TODO: display real version when available*@
                                                        <tr>
                                                            <td><strong>@Loc.ESIRVersion</strong><span class="visible-xs">@ConfigurationManager.AppSettings.Get("ESIRVersion")/DataLab SR d.o.o.</span></td>
                                                            <td><span class="hidden-xs">@ConfigurationManager.AppSettings.Get("ESIRVersion"), DataLab SR d.o.o.</span></td>
                                                        </tr>
                                                    }
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        @if (!PantheonRA.BackOffice.CurrentUser.HasGranules() &&
                            (!Localization.IsInFiscalPrinterLocalization(PantheonRA.BackOffice.CurrentUser.DatabaseLocalization, PantheonRA.BackOffice.CurrentUser.IsInServerFiscalization) || PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.RS))
                        {
                            <div class="col-lg-4 col-md-6 col-sm-12">
                                <div class="row m-t">
                                    <div class="col-sm-12">
                                        <div class="row">
                                            <div class="col-xs-12 m-b-md">
                                                @if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.RS ? PantheonRA.BackOffice.CurrentUser.IsInServerFiscalization : true)
                                                {
                                                    <div>
                                                        <h3 class="m-l-sm">@Loc.FiscalCertificate</h3>
                                                    </div>
                                                    <div class="flat alert alert-sm clearfix" style="padding-left:0;">
                                                        <div class="pull-left" style="padding-left:5px;">
                                                            @if (Model.CertificateInfo != null)
                                                            {
                                                                <div class="certificate-icon">
                                                                    <img src="~/Content/Redesign/Icons/Trademark/certificate-yes.svg" />
                                                                </div>
                                                            }
                                                            else
                                                            {
                                                                <div class="certificate-icon-locked">
                                                                    <img src="~/Content/Redesign/Icons/Trademark/certificate-no.svg" />
                                                                </div>
                                                            }
                                                        </div>
                                                        <div class="pull-left padding-top-10" style="width:calc(100% - 67px); max-width:100%">
                                                            @if (Model.CertificateInfo != null)
                                                            {
                                                                <div class="form-group">
                                                                    <p class="alert-title col-xs-12">@Loc.YouHaveCertificate</p>
                                                                </div>
                                                                @*<p>@string.Format(Loc.CertificateValidUntil, Model.CertificateInfo.SerialNumber, Model.CertificateInfo.Expiry.ToString(Loc.DateTimeFormat))</p>*@
                                                                <div class="form-group padding-top-10">
                                                                    <label class="col-xs-5">@Loc.Certificate</label>
                                                                    <div class="col-xs-7">
                                                                        <label>@Model.CertificateInfo.SerialNumber</label>
                                                                    </div>
                                                                </div>

                                                                <div class="form-group">
                                                                    <label class="col-xs-5">@Loc.ValidUntil</label>
                                                                    <div class="col-xs-7">
                                                                        <label>@Model.CertificateInfo.Expiry.ToString(Loc.DateTimeFormat)</label>
                                                                    </div>
                                                                </div>
                                                            }
                                                            else
                                                            {
                                                                <div class="col-xs-12">
                                                                    <p class="alert-title">@Loc.FiscalizationCertificateMissing</p>
                                                                    <p>@Loc.InOrderToPrintOutBillsYouMustUploadCertificate</p>
                                                                </div>
                                                            }
                                                        </div>
                                                    </div>

                                                    <div>
                                                        @if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.RS)
                                                        {
                                                            <a href="@Url.Action("Index", "Certificate")" class="btn btn-primary m-l-sm allow-redirect">
                                                                @Loc.EditCertificates
                                                            </a>
                                                        }
                                                        else
                                                        {
                                                            <a href="@Url.Action("Upload", "Certificate")" class="btn btn-primary m-l-sm allow-redirect">
                                                                @(Model.CertificateInfo != null ? Loc.UploadNewCertificate : Loc.UploadCertificate)
                                                            </a>
                                                        }
                                                    </div>

                                                    if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.RS)
                                                    {
                                                        <hr class="hr-dashed" />
                                                    }
                                                }

                                                @if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.RS)
                                                {
                                                    <div>
                                                        <h3 class="m-l-sm">@Loc.Fiscalization</h3>
                                                    </div>
                                                    <div>
                                                        <div class="form-group">
                                                            <label class="col-xs-4 control-label padding-top-10 nowrap-text" title="@Loc.StartDate">@Loc.StartDate</label>
                                                            <div class="col-xs-8">
                                                                <div class="input-group">
                                                                    <span class="input-group-addon"><i class="far fa-calendar alt"></i></span>
                                                                    <input class="form-control" disabled value="@(Model.FiscalDateNew.HasValue ? Model.FiscalDateNew.Value.ToString(Loc.DateFormat) + " " + Loc.NewFiscalizationName : (Model.FiscalDate.HasValue ? Model.FiscalDate.Value.ToString(Loc.DateFormat) + " " + Loc.OldFiscalizationName : "/"))" />
                                                                    <input type="hidden" id="FiscalDate" name="FiscalDate" value="@(Model.FiscalDate.HasValue ? Model.FiscalDate.Value.ToString(Loc.DateFormat) : string.Empty)" />
                                                                    <input type="hidden" id="FiscalDateNew" name="FiscalDateNew" value="@(Model.FiscalDateNew.HasValue ? Model.FiscalDateNew.Value.ToString(Loc.DateFormat) : string.Empty)" />
                                                                    <span class="input-group-addon">
                                                                        <button type="button" class="btn btn-ghost btn-xs padding-bottom-none" onclick="openFiscalDateModal($('#FiscalDate'), $('#FiscalDateNew'), '@Loc.FiscalizationStartDate', ['@Loc.StartDate', '@Loc.FiscalizationType'], ['@Loc.OldFiscalizationName', '@Loc.NewFiscalizationName']);">
                                                                            <i class="fas fa-pencil-alt"></i>
                                                                        </button>
                                                                    </span>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        @if (!PantheonRA.BackOffice.CurrentUser.IsDemo && (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.RS ? PantheonRA.BackOffice.CurrentUser.IsInServerFiscalization : false))
                                                        {
                                                            <div class="form-group">
                                                                <label class="col-xs-4 control-label padding-top-10 nowrap-text" title="@Loc.Links">@Loc.Links</label>
                                                                <div class="col-xs-8">
                                                                    <div class="input-group">
                                                                        <input id="FiscalServer" readonly name="FiscalServer" class="form-control" value="@Model.FiscalServer" title="@Model.FiscalServer, @Model.FiscalTaxServer, @Model.FiscalCheckConnectionServer" autocomplete="off" onclick="$(this).closest('.input-group').find('button').trigger('click'); $(this).blur();" />
                                                                        @Html.HiddenFor(model => model.FiscalTaxServer)
                                                                        @Html.HiddenFor(model => model.FiscalCheckConnectionServer)
                                                                        <span class="input-group-addon">
                                                                            <button type="button" class="btn btn-ghost btn-xs padding-bottom-none" onclick="openServerDataModal($('#FiscalServer'), $('#FiscalTaxServer'), $('#FiscalCheckConnectionServer'), '@Loc.Links', ['@Loc.TypeShort', '@Loc.Link'], ['@Loc.FiscalServer', '@Loc.TaxServer', '@Loc.CheckConnectionServer']);">
                                                                                <i class="fas fa-pencil-alt"></i>
                                                                            </button>
                                                                        </span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        }
                                                        else
                                                        {
                                                            @Html.HiddenFor(model => model.FiscalServer)
                                                            @Html.HiddenFor(model => model.FiscalTaxServer)
                                                            @Html.HiddenFor(model => model.FiscalCheckConnectionServer)
                                                        }
                                                    </div>
                                                }
                                                else if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.SI
                                                    || PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.HR
                                                    || PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.ME)
                                                {
                                                    <div class="form-group @(PantheonRA.BackOffice.CurrentUser.IsDemo ? "hidden" : "")">
                                                        <label class="col-xs-4 control-label padding-top-10 nowrap-text" title="@Loc.Server">@Loc.Server</label>
                                                        <div class="col-xs-8">
                                                            <input id="FiscalServer" name="FiscalServer" class="form-control" value="@Model.FiscalServer" title="@Model.FiscalServer" autocomplete="off" />
                                                        </div>
                                                    </div>
                                                }
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        }
                    </div>
                </div>
            </div>
        </form>
    </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="YesLoc" value="@Loc.Yes" />
<input type="hidden" id="NoLoc" value="@Loc.No" />
<input type="hidden" id="OkLoc" value="@Loc.OK" />
<input type="hidden" id="DragAndDropOrClick" value="@Loc.UploadImageMessage" />
<input type="hidden" id="Remove" value="@Loc.Remove" />
<input type="hidden" id="GeneralErrorMessage" value="@Loc.GeneralError" />
<input type="hidden" id="WrongImageFormat" value="@Loc.WrongImageFormat" />
<input type="hidden" id="ConnectionCheckSuccessLoc" value="@Loc.ConnectionCheckSuccess" />
<input type="hidden" id="ConnectionCheckFailedLoc" value="@Loc.ConnectionCheckFailed" />
<input type="hidden" id="ErrorHappenedWhileCheckingFiscalServiceConnectivityLoc" value="@Loc.ErrorHappenedWhileCheckingFiscalServiceConnectivity" />
<input type="hidden" id="UrlCheckFiscalServiceConnectivity" value="@Url.Action("_CheckFiscalServiceConnectivity", "CompanyUnits")" />

@section pageScripts{
    @Scripts.Render("~/bundles/admin")
    <script>
        $(document).ready(function () {
            initializeCompanyCompany();
        });

        function openImportWorkflowDefinitionsModal() {
            let tableTitles = ['@Loc.Name', '@Loc.Note', '@Loc.BuildNUmber'];
                let tableDataNames = ["Name", "Note", "BuildNo"];
            let localization = {
                importType: "@Loc.ImportType",
                forCountry: "@Loc.ForCountry",
                dowloadFromServer: "@Loc.DownloadFromServer",
                importIntoCodebook: "@Loc.ImportIntoCodebook",
                importTypeAdding: "@Loc.ImportTypeAdding",
                importTypeAddEdit: "@Loc.ImportTypeAddEdit",
                yesNo: "@Loc.Yes/@Loc.No"
            };

            openImportCodebookModal("@Loc.ImportWorkflowDefinition", tableTitles, tableDataNames,
                '@Url.Action("GetImportWorkflowDefinitions", "WorkflowDefinitions")',
                '@Url.Action("ImportWorkflowDefinitions", "WorkflowDefinitions")',
                '@SiteHelpAttributeHelper.GetHelpUrl(PantheonRA.BackOffice.Enums.HelpIds.ImportWorkflowDefinitions)',
                localization,
                '@PantheonRA.BackOffice.CurrentUser.Localization',
                function () {
                    $.fn.dataTable.reload($('#grid-data'));
                },
                function (data) {
                    data.group = $(".codebook-group").val();
                },
                "<div class='col-sm-5 m-t-xs'><label>@Loc.Group</label><select class='form-control codebook-group' style='display:inline-block;width:auto'></select></div>",
                function (data) {
                    if (data.WorkflowDefinitionGroup && $(".codebook-group").children().length === 0) {
                        for (let i = 0; i < data.WorkflowDefinitionGroup.length; i++) {
                            let definitionGroup = data.WorkflowDefinitionGroup[i];
                            $(".codebook-group").append("<option value='" + (definitionGroup.Group === null ? "" : definitionGroup.Group) + "'>" + (definitionGroup.Name === null ? "" : definitionGroup.Name) + "</option>");
                        }
                    }
                }
            );
        }
    </script>
}