<%@ Page Language="c#" MaintainScrollPositionOnPostback="true" CodeBehind="CustomerAdministration.aspx.cs" AutoEventWireup="True" Inherits="eDocument.Server.Administrator.Consumer.CustomerAdministration" MasterPageFile="~/Site.Master" %>

<%@ Register TagPrefix="uc2" TagName="AdditionalModules" Src="~/Consumer/AdditionalModules.ascx" %>
<%@ Register TagPrefix="uc1" TagName="CultureChooser" Src="~/CultureChooser.ascx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
    <style type="text/css">
        .Hide {
            display: none;
        }
    </style>

    <div class="skjema-admin__page-pre-title">
        Organisasjon og brukere
    </div>
    <h1 class="skjema-admin__page-title mt-0 skjema-admin__mb-40">
        Kundeadministrasjon
    </h1>
    
    <p class="skjema-admin__mb-40 skjema-admin__fs-18">
        Administrer opsjoner og kataloger for 
        <asp:Label CssClass="skjema-admin__italic" runat="server" id="lblCustomerName" />.
    </p>

    <h2 class="skjema-admin__underline-title">
        Driftsmodell
    </h2>

    <div class="skjema-admin__mb-40">
        <asp:Label
            ID="Label8"
            CssClass="skjema-admin__page__label skjema-admin__page__label--small"
            runat="server">
                Velg driftsmodell *
        </asp:Label>

        <asp:RadioButtonList ID="rblInstallationType"
            runat="server"
            AutoPostBack="True"
            OnSelectedIndexChanged="rblInstallationType_OnSelectedIndexChanged"
            CssClass="skjema-admin__form__radio">
            <asp:ListItem Value="cloud">Skytjeneste</asp:ListItem>
            <asp:ListItem Value="onprem">Lokal</asp:ListItem>
        </asp:RadioButtonList>

        <asp:RequiredFieldValidator
            ForeColor="Red"
            ID="RequiredFieldValidator3"
            runat="server"
            Display="Dynamic"
            ControlToValidate="rblInstallationType"
            ErrorMessage="Du må velge driftsmodell.">
        </asp:RequiredFieldValidator>
    </div>

    <h2 class="skjema-admin__underline-title">
        Språk
    </h2>
    <div class="skjema-admin__mb-40">
        <div class="d-flex">
            <asp:Label ID="Label36" class="skjema-admin__page__label" runat="server" Width="455px">
                Tilgjengelig språk
            </asp:Label>

            <label class="skjema-admin__page__label">
                Valgte språk
            </label>
        </div>

        

        <div class="skjema-admin__table__dual-select">
            <uc1:CultureChooser ID="CultureChooser1" runat="server" />
        </div>
    </div>

    <h3 class="skjema-admin__underline-title">
        Moduler
    </h3>

    <div class="skjema-admin__mb-40">
        <%--        <label class="skjema-admin__page__label">
            Tillegsmoduler
        </label>--%>
        <div class="skjema-admin__form__checkbox">
            <uc2:AdditionalModules ID="additionalModules" runat="server" />
        </div>
    </div>

    <h3 class="skjema-admin__underline-title">Lisensdetaljer
    </h3>

    <div class="skjema-admin__mb-40">
        <asp:Label ID="Label23" CssClass="skjema-admin__page__label" runat="server">
            Aktiv lisens
        </asp:Label>
        <asp:CheckBox ID="checkIsActiveLicense" runat="server" Width="450px" MaxLength="300" />
    </div>

    <div class="skjema-admin__mb-40" id="divLicenseKey" runat="server">
        <asp:Label ID="Label1912" CssClass="skjema-admin__page__label" runat="server">
            Lisensnøkkel *
        </asp:Label>
        <asp:TextBox Enabled="False" CssClass="skjema-admin__page__text" ID="txtLicenseKey" runat="server" Width="450px" MaxLength="300" />
        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ForeColor="Red" runat="server" Display="Dynamic" ControlToValidate="txtLicenseKey" ErrorMessage="Du må angi en lisensnøkkel." />
    </div>

    <div class="skjema-admin__mb-40" id="divMachineName" runat="server">
        <asp:Label ID="Label12" CssClass="skjema-admin__page__label" runat="server">
                    Lisens aktivert for maskin 
        </asp:Label>
        <asp:TextBox Enabled="False" CssClass="skjema-admin__page__text" ID="txtMachineName" runat="server" Width="450px" MaxLength="300" /><br />
        <asp:Button Text="Fjern binding mot maskin" runat="server" ID="btnClearLicenseMachineName" OnClick="btnClearLicenseMachineName_OnClick" />
    </div>
    
    <div class="skjema-admin__mb-40" id="divMaxDesigners2" runat="server" visible="False">
        <br>
        <asp:Label ID="Label1" CssClass="skjema-admin__page__label" runat="server">
            Designer - Antall lisenser *
        </asp:Label>
        <asp:TextBox TextMode="Number" CssClass="skjema-admin__page__text" ID="txtLicenseMaxDesigner2AdminUserCount"  Width="100px" runat="server" MaxLength="300" />
        <asp:RequiredFieldValidator
            ID="RequiredFieldValidator1"
            ForeColor="Red"
            runat="server"
            Display="Dynamic"
            ControlToValidate="txtLicenseMaxDesigner2AdminUserCount" 
            ErrorMessage="Må oppgis">
        </asp:RequiredFieldValidator>
    </div>

    <div class="skjema-admin__mb-40" id="divMaxOrgs" runat="server" visible="False">
        <asp:Label ID="Label11" CssClass="skjema-admin__page__label" runat="server">
                Max antall organisasjoner *
        </asp:Label>
        <asp:TextBox TextMode="Number" CssClass="skjema-admin__page__text" ID="txtLicenseMaxOrganizationCount" Text="1" runat="server" MaxLength="300" />
        <asp:RequiredFieldValidator
            ID="RequiredFieldValidator5"
            ForeColor="Red"
            runat="server"
            Display="Dynamic"
            ControlToValidate="txtLicenseMaxOrganizationCount"
            ErrorMessage="Må oppgis">
        </asp:RequiredFieldValidator>
    </div>

    <div class="skjema-admin__mb-40">
        <asp:Label
            ID="Label17"
            CssClass="skjema-admin__page__label"
            runat="server">
                Max antall admin-brukere *
        </asp:Label>
        <asp:TextBox
            CssClass="skjema-admin__page__text" TextMode="Number"
            ID="txtLicenseMaxAdminUserCount"
            Text="1"
            Width="100px"
            runat="server"
            MaxLength="300">
        </asp:TextBox>
        <asp:RequiredFieldValidator
            ID="RequiredFieldValidator6"
            runat="server"
            ForeColor="Red"
            Display="Dynamic"
            ControlToValidate="txtLicenseMaxAdminUserCount"
            ErrorMessage="Må oppgis">
        </asp:RequiredFieldValidator>
    </div>

    <div class="skjema-admin__mb-40">
        <asp:Label
            ID="Label20"
            CssClass="skjema-admin__page__label"
            runat="server">
                Max antall skjemaredaktører *
        </asp:Label>
        <asp:TextBox
            CssClass="skjema-admin__page__text"
            ID="txtLicenseMaxDesignerAdminUserCount" TextMode="Number"
            Text="1"
            Width="100px"
            runat="server"
            MaxLength="300">
        </asp:TextBox>
        <asp:RequiredFieldValidator
            ID="RequiredFieldValidator8"
            runat="server"
            ForeColor="Red"
            Display="Dynamic"
            ControlToValidate="txtLicenseMaxDesignerAdminUserCount"
            ErrorMessage="Må oppgis">
        </asp:RequiredFieldValidator>
    </div>

    <div class="skjema-admin__mb-40">
        <asp:Label
            ID="Label21" TextMode="Number"
            CssClass="skjema-admin__page__label"
            runat="server">
                Max antall saksbehandlere *
        </asp:Label>
        <asp:TextBox
            CssClass="skjema-admin__page__text"
            ID="txtLicenseMaxEdocCaseAdminUserCount"
            runat="server"
            Text="1"
            TextMode="Number"
            Width="100px"
            MaxLength="300">
        </asp:TextBox>
        <asp:RequiredFieldValidator
            ID="RequiredFieldValidator9"
            ForeColor="Red"
            runat="server"
            Display="Dynamic"
            ControlToValidate="txtLicenseMaxEdocCaseAdminUserCount"
            ErrorMessage="Må oppgis">
        </asp:RequiredFieldValidator>
    </div>

    <div class="skjema-admin__mb-40">
        <asp:Label
            ID="Label19" TextMode="Number"
            CssClass="skjema-admin__page__label"
            runat="server">
                Max antall aktive skjema *
        </asp:Label>
        <asp:TextBox
            CssClass="skjema-admin__page__text"
            ID="txtLicenseMaxActiveFormsCount"
            Text="1"
            runat="server"
            TextMode="Number"
            Width="100px"
            MaxLength="5">
        </asp:TextBox>
        <asp:RequiredFieldValidator
            ID="RequiredFieldValidator7"
            ForeColor="Red"
            runat="server"
            Display="Dynamic"
            ControlToValidate="txtLicenseMaxActiveFormsCount"
            ErrorMessage="Må oppgis">
        </asp:RequiredFieldValidator>
    </div>

    <h3 class="skjema-admin__underline-title">
        Synlighet
    </h3>

    <div class="skjema-admin__mb-40">
        <asp:Label ID="Label24" CssClass="skjema-admin__page__label" runat="server">
            Tilgang til organisasjon
        </asp:Label>
        <asp:CheckBox ID="checkIsPrivate" Text="Brukere kan ikke be om tilgang til organisasjonen" runat="server" Width="450px" MaxLength="300" />
    </div>

    <h2 class="skjema-admin__underline-title">
        Kataloger
    </h2>

    <asp:GridView
        ID="gvCatalogList"
        runat="server"
        AutoGenerateColumns="False"
        Width="100%"
        Border="0"
        Visible="False"
        CssClass="skjema-admin__table skjema-admin__table--no-table skjema-admin__form__checkbox jsTableCheckAll"
        OnRowDataBound="gvCatalogList_OnRowDataBound">
        <HeaderStyle CssClass="skjema-admin__table__header"></HeaderStyle>
        <Columns>
            <asp:BoundField DataField="Id" HeaderText="Katalog-Id" ItemStyle-CssClass="Hide" HeaderStyle-CssClass="Hide"></asp:BoundField>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:CheckBox ID="chkRow" runat="server" />
                </ItemTemplate>
                <ItemStyle Width="30px" />
            </asp:TemplateField>
            <asp:BoundField DataField="Name" HeaderText="Katalog"></asp:BoundField>
        </Columns>
    </asp:GridView>


    <asp:Panel ID="pnlWarn" Visible="False" runat="server" CssClass="skjema-admin__modal" data-jscomponent="modal">
        <div class="skjema-admin__modal__window">

            <button class="skjema-admin__modal__close" type="button" data-jscomponent="modalClose"></button>

            <asp:Label CssClass="skjema-admin__page__label" Text="OBS: Du har fjernet én eller flere skjemakataloger fra kunden. Hvis du fortsetter, vil kunden miste et eller flere abonnement og innstillinger knyttet til disse." runat="server" />
            
            <div>
                <asp:Button CssClass="skjema-admin__button skjema-admin__button--secondary" runat="server" ID="btnAbortSave" OnClick="btnAbortSave_OnClick" Text="Avbryt" />
            </div>

            <br/>
            <div>
                <asp:Button CssClass="skjema-admin__button skjema-admin__button--primary" runat="server" ID="btnConfirmSave" OnClick="btnConfirmSave_OnClick" Text="Fortsett lagring, jeg er innforstått med at kunden vil miste sine innstillinger" />
            </div>
        </div>
    </asp:Panel>

    <asp:Panel ID="pnlConfirmSave" Visible="False" runat="server" CssClass="skjema-admin__modal" data-jscomponent="modal">
        <div class="skjema-admin__modal__window">

            <button class="skjema-admin__modal__close" type="button" data-jscomponent="modalClose"></button>

            <asp:Label CssClass="skjema-admin__page__label" Text="Endringer er lagret" runat="server" />

            <div>
                <asp:Button CssClass="skjema-admin__button skjema-admin__button--primary" runat="server" ID="btnOk" OnClick="btnOk_OnClick" Text="OK" />
            </div>
        </div>
    </asp:Panel>

    <asp:Label ID="lblMessage" runat="server" ForeColor="Red"></asp:Label>
    <asp:Label ID="lblError" runat="server" ForeColor="Red" Visible="False"></asp:Label>

    <asp:Panel ID="pnlAddTemplatesModalPopup" Visible="False" runat="server" CssClass="skjema-admin__modal" data-jscomponent="modal">
        <div class="skjema-admin__modal__window">

            <button class="skjema-admin__modal__close" type="button" data-jscomponent="modalClose"></button>
            <asp:Label CssClass="skjema-admin__modal__title" Text="Legg til skjema" runat="server" />

            <div class="mb-4">
                Velg skjema som skal legges til
            </div>

            <hr />

            <asp:GridView
                ID="gvTemplateListPopup"
                data-id="gvTemplatesOnCatalog"
                runat="server"
                AutoGenerateColumns="False"
                Width="100%"
                Border="0"
                data-jscomponent="toggleTable"
                CssClass="skjema-admin__table skjema-admin__table--list skjema-admin__table--min-width-1"
                OnRowDataBound="gvTemplateListPopup_OnRowDataBound">
                <HeaderStyle CssClass="skjema-admin__table__header"></HeaderStyle>
                <Columns>
                    <asp:BoundField DataField="templateId" HeaderText="Id" ItemStyle-CssClass="Hide" HeaderStyle-CssClass="Hide" />
                    <asp:TemplateField>
                        <ItemTemplate>
                            <div class="skjema-admin__table__list-td skjema-admin__table__list-td--thin skjema-admin__table__list-td--collapse-panel d-flex justify-content-center">
                                <asp:CheckBox ID="chkRow" CssClass="jsSingleCheck" runat="server" />
                            </div>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <div class="skjema-admin__table__list-td skjema-admin__table__list-td--thin skjema-admin__table__list-td--collapse-panel skjema-admin__nbr">
                                <asp:Label runat="server" Text='<%#Eval("formId")%>'>
                                </asp:Label>
                            </div>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <div class="skjema-admin__table__list-td skjema-admin__table__list-td--thin skjema-admin__table__list-td--collapse-panel">
                                <asp:Label runat="server" Text='<%#Eval("templateName")%>'>
                                </asp:Label>
                            </div>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:HiddenField ID="category" runat="server" Value='<%#Eval("categoryName")%>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>

            <div class="skjema-admin__table__counter mb-5 text-center" data-jscomponent="totalSelected" data-tableid="gvTemplatesOnCatalog">
                0 skjema er valgt.
            </div>

            <div class="text-center">
                <asp:Button CssClass="skjema-admin__button skjema-admin__button--primary" runat="server" ID="btnAddTemplatesSave" OnClick="btnAddTemplatesSave_OnClick" Text="Legg til" Style="min-width: 200px;" />
            </div>
        </div>
    </asp:Panel>

    <h3 class="skjema-admin__page__label">
        Enkeltskjema
    </h3>
    <asp:Repeater ID="repeaterSingleSubscriptions" runat="server">
        <HeaderTemplate>
        </HeaderTemplate>

        <ItemTemplate>
            <div>
                <div class="skjema-admin__rounded-label">
                    <asp:Label ID="FormId" Text='<%# Eval("formId") %>' runat="server"></asp:Label>
                    <asp:Label ID="lblTemplateName" Text='<%# Eval("templateName") %>' runat="server"></asp:Label>

                    <asp:LinkButton
                        Class="skjema-admin__rounded-label__delete-anchor"
                        ID="btnDeleteSubscription"
                        runat="server"
                        CommandArgument='<%# Eval("templateId") %>'
                        OnClick="btnDeleteSubscription_OnClick">
                        <span class="budicon budicon-cross-ui"></span>
                    </asp:LinkButton>
                </div>
            </div>
        </ItemTemplate>
    </asp:Repeater>

    <div class="mb-2 mt-4">
        <div class="skjema-admin__plus-anchor-container">
            <span class="skjema-admin__icon__plus skjema-admin__icon__big-and-bold"></span>
            <asp:LinkButton
                Class="skjema-admin__plus-anchor"
                ID="btnEditSingleTemplates"
                runat="server"
                Text="Legg til enkeltskjema"
                OnClick="btnEditSingleTemplates_Click">
            </asp:LinkButton>
        </div>
    </div>

    <div class="mb-5 skjema-admin__mt-50">
        <asp:Button ID="btnSave" 
            OnClick="btnSave_OnClick" 
            Text="Lagre endringer" 
            CssClass="skjema-admin__button skjema-admin__button--secondary" 
            runat="server" />
    </div>
</asp:Content>
