<%@ control language="VB" autoeventwireup="false" inherits="RCC_System_AccessControl_CC_SessionManagement, MachSol.MachPanel.Web" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="EM" %>
<%@ Register Src="~/Template/GVPager.ascx" TagName="Pager" TagPrefix="EM" %>



<asp:Button ID="Btn_RefreshTab" CssClass="RefreshTab" runat="server" Style="display: none;" />
<EM:TabContainer ID="TC_SessionMgt" runat="server" OnClientActiveTabChanged="loadTabPanel">
    <EM:TabPanel ID="Tab_SessionSettings" runat="server" HeaderText='<%$ Resources:Content,strSettings%>'>
        <ContentTemplate>
            <asp:Button ID="Btn_Tab0" runat="server" Style="display: none;" />
            <asp:Panel ID="Pnl_TabContent0" runat="server">
                <div class="card" id="DivSessionSettings" runat="server">
                    <div class="header">
                        <h3>
                            <asp:Literal ID="lbl_title" runat="server" Text="<%$ Resources:Content,strSessionSettings%>" EnableViewState="false"></asp:Literal>
                        </h3>
                    </div>
                    <div class="body">

                        <div class="row">
                            <div class="col-sm-4 col-xs-12 row-label">
                                <label>
                                    <asp:Literal ID="Literal7" runat="server" Text="<%$ Resources:Content,strInActiveUser%>" />:
                                </label>
                            </div>
                            <div class="col-sm-1 col-xs-12">
                                <div class="form-group">
                                    <asp:CheckBox ID="ChBx_InActiveuserAfter" runat="server" Text=" " />
                                </div>
                            </div>
                            <div class="col-sm-2 col-xs-12 hide" id="DivInActiveuserAfterDdl">
                                <div class="form-group">
                                    <asp:DropDownList ID="Ddl_InActiveuserAfter" runat="server">
                                        <asp:ListItem Text="10 Min" Value="10"></asp:ListItem>
                                        <asp:ListItem Text="20 Min" Value="20"></asp:ListItem>
                                        <asp:ListItem Text="30 Min" Value="30"></asp:ListItem>
                                        <asp:ListItem Text="1 Hr" Value="60"></asp:ListItem>
                                        <asp:ListItem Text="2 Hr" Value="120"></asp:ListItem>
                                        <asp:ListItem Text="3 Hr" Value="180"></asp:ListItem>
                                        <asp:ListItem Text="4 Hr" Value="240"></asp:ListItem>
                                        <asp:ListItem Text="5 Hr" Value="300"></asp:ListItem>
                                        <asp:ListItem Text="10 Hr" Value="600"></asp:ListItem>
                                        <asp:ListItem Text="16 Hr" Value="960"></asp:ListItem>
                                        <asp:ListItem Text="20 Hr" Value="1200"></asp:ListItem>
                                        <asp:ListItem Text="24 Hr" Value="1440"></asp:ListItem>
                                    </asp:DropDownList>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-sm-4 col-xs-12 row-label">
                                <label>
                                    <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:Content,strMaintainSessionHistoryFor%>" />:
                                </label>
                            </div>
                            <div class="col-sm-1 col-xs-12">
                                <div class="form-group">
                                    <asp:CheckBox ID="ChBx_MaintainSessionHistory" runat="server" Text=" " />
                                </div>
                            </div>
                            <div class="col-sm-2 col-xs-12 hide" id="DivMaintainSessionDdl">
                                <div class="form-group">
                                    <asp:DropDownList ID="Ddl_MaintainSessionHistoryFor" runat="server">
                                        <asp:ListItem Text="7" Value="7"></asp:ListItem>
                                        <asp:ListItem Text="10" Value="10"></asp:ListItem>
                                        <asp:ListItem Text="15" Value="15"></asp:ListItem>
                                        <asp:ListItem Text="30" Value="30"></asp:ListItem>
                                        <asp:ListItem Text="45" Value="45"></asp:ListItem>
                                        <asp:ListItem Text="60" Value="60"></asp:ListItem>
                                        <asp:ListItem Text="90" Value="90"></asp:ListItem>
                                    </asp:DropDownList>
                                </div>
                            </div>
                            <div class="col-sm-2 col-xs-12 hide" id="DivDays">
                                <label>
                                    <asp:Literal ID="Literal3" runat="server" Text="<%$ Resources:Content,strDays%>" />
                                </label>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-sm-4 col-xs-12 row-label">
                                <label>
                                    <asp:Literal ID="Literal2" runat="server" Text="<%$ Resources:Content,strLimitActiveSessionsPerAccount %>" />:
                                </label>
                            </div>
                            <div class="col-sm-1 col-xs-12">
                                <div class="form-group">
                                    <asp:CheckBox ID="ChBx_ActiveSessionsPerAccount" runat="server" Text=" " />
                                </div>
                            </div>
                            <div class="col-sm-2  col-xs-12 hide" id="DivActiveSessionsddl">
                                <div class="form-group">
                                    <asp:DropDownList ID="Ddl_ActiveSessionsPerAccount" runat="server">
                                    </asp:DropDownList>
                                </div>
                            </div>
                        </div>

                          <div class="row">
                            <div class="col-sm-4 col-xs-12 row-label">
                                <label>
                                    <asp:Literal ID="Literal5" runat="server" Text="<%$ Resources:Content,strkillAllSessionsOnPasswordChange %>" />:
                                </label>
                            </div>
                            <div class="col-sm-1 col-xs-12">
                                <div class="form-group">
                                    <asp:CheckBox ID="ChBx_killSessionsOnPasswordChange" runat="server" Text=" " />
                                </div>
                            </div>                             
                        </div>


                        <div class="row  clearfix">
                            <div class="col-sm-3 col-xs-12">
                                <asp:Button ID="Btn_Save" runat="server" Text="<%$Resources:Content,strUpdate%>" class="btn btn-primary waves-effect btnAction" />
                            </div>
                            <div class="col-sm-9 col-xs-12">
                            </div>
                        </div>


                    </div>

                </div>
            </asp:Panel>
        </ContentTemplate>
    </EM:TabPanel>
    <EM:TabPanel ID="Tab_SessionsDetail" runat="server" HeaderText='<%$ Resources:Content,strSessions%>'>
        <ContentTemplate>
            <asp:Button ID="Btn_Tab1" runat="server" Style="display: none;" />
            <asp:Panel ID="Pnl_TabContent1" runat="server">

                <div class="row Div_OpsRow" id="Div_OpsRow" runat="server">
                    <div class="col-xs-12">

                        <div class="card" id="tbl_Operations" runat="server">
                            <div class="header">
                                <h3>
                                    <asp:Literal ID="Literal4" runat="server" Text="<%$ Resources:Content,GN00001320%>" EnableViewState="false" />
                                </h3>
                            </div>
                            <div class="body">

                                <asp:Button ID="Btn_KillSessions" runat="server" Text="<%$ Resources:Content,strKillSessions%>" class="btn btn-primary waves-effect btnAction" />
                                <asp:Button ID="Btn_DeleteSessions" runat="server" Text="<%$ Resources:Content,strDeleteSessions%>" SkinID="cancelButton" class="btn btn-primary waves-effect btnAction" />

                            </div>
                        </div>
                    </div>
                </div>

                <asp:Panel ID="pnlAccountSearch" runat="server" DefaultButton="Btn_SrchSession">
                    <div class="row">
                        <div class="panel-group search-panel" id="AS_Sessions" role="tablist" aria-multiselectable="true">
                            <div class="col-xs-12" role="tab" id="SH_Sessions">
                                <div class="card">
                                    <div class="header" role="button" data-toggle="collapse" data-parent="#AS_ClientList" href="#<%= CSB_Sessions.ClientID %>" aria-expanded="true" aria-controls="SH_ClientList">
                                        <h3>
                                            <%= Resources.Content.GN0000395%>
                                        </h3>
                                    </div>
                                    <div id="CSB_Sessions" runat="server" class="body panel-collapse collapse" role="tabpanel" aria-labelledby="SH_ClientList" aria-expanded="false">
                                        <div class="row">
                                            <div class="col-md-3 col-sm-6 col-xs-12" runat="server" id="td_DDL_Owner">
                                                <div class="form-group form-float">
                                                    <asp:DropDownList ID="DDL_Owner" runat="server" onchange="setOwnerCookie(this)"></asp:DropDownList>
                                                </div>
                                            </div>


                                            <div class="col-md-3 col-sm-6 col-xs-12" id="Accountsrch" runat="server">
                                                <div class="form-group form-float">
                                                    <div class="form-line">
                                                        <asp:TextBox ID="TxBx_Account" runat="server"></asp:TextBox>
                                                        <asp:Label ID="Label8" runat="server" EnableViewState="false" Text="<%$ Resources:Content,strAccount%>" class="form-label"></asp:Label>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-3 col-sm-6 col-xs-12">
                                                <div class="form-group form-float">
                                                    <asp:DropDownList ID="DDL_SessionStatus" runat="server">
                                                        <asp:ListItem Text="<%$ Resources:Content,strAllSessions%>" Value="-1"></asp:ListItem>
                                                        <asp:ListItem Text="<%$ Resources:Content,strActive%>" Value="0"></asp:ListItem>
                                                        <asp:ListItem Text="<%$ Resources:Content,strExpired%>" Value="1"></asp:ListItem>
                                                    </asp:DropDownList>
                                                </div>
                                            </div>
                                            <div class="col-md-3 col-sm-6 col-xs-12"  runat="server">
                                                <div class="form-group form-float">
                                                    <div class="form-line">
                                                        <asp:TextBox ID="TxBx_Detail" runat="server"></asp:TextBox>
                                                        <asp:Label ID="Label2" runat="server" EnableViewState="false" Text="<%$ Resources:Content,strDetails%>" class="form-label"></asp:Label>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="clearfix" id="DivClearfix" runat="server"></div>

                                            <div class="col-md-3 col-sm-6 col-xs-12">
                                                <%= Resources.Content.GN0000685%>:
                                                    <div class="form-group display-date-input">
                                                        <div class="form-line">
                                                            <asp:TextBox ID="TxBx_DateAfter" runat="server"></asp:TextBox>
                                                        </div>
                                                    </div>

                                                <i runat="server" id="A_DRangeAfter" class="material-icons icon-calendar col-calendar"></i>
                                                <EM:CalendarExtender ID="CE_DRangeAfter" runat="server" TargetControlID="TxBx_DateAfter"
                                                    Format="<%# System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern %>" PopupButtonID="A_DRangeAfter" CssClass="date__calendar">
                                                </EM:CalendarExtender>
                                            </div>


                                            <div class="col-md-3 col-sm-6 col-xs-12">
                                                <%= Resources.Content.GN0000690%>:
                                                    <div class="form-group display-date-input">
                                                        <div class="form-line">
                                                            <asp:TextBox ID="TxBx_DateBefore" runat="server"></asp:TextBox>
                                                        </div>
                                                    </div>

                                                <i runat="server" id="A_DRangeBefore" class="material-icons icon-calendar col-calendar"></i>
                                                <EM:CalendarExtender ID="CE_DRangeBefore" runat="server" TargetControlID="TxBx_DateBefore"
                                                    Format="<%# System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern %>" PopupButtonID="A_DRangeBefore" CssClass="date__calendar">
                                                </EM:CalendarExtender>
                                            </div>


                                        </div>
                                        <div class="row">
                                            <div class="col-md-3 col-sm-6 col-xs-12">

                                                <asp:Button ID="Btn_SrchSession" class="btn btn-primary waves-effect" runat="server" Text="<%$ Resources:Content,GN0000391%>" />
                                                <asp:Button ID="Btn_Clear" Visible="false" class="btn btn-primary waves-effect" runat="server" Text="<%$ Resources:Content,String289 %>" />

                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </asp:Panel>



                <div class="row">
                    <div class="col-xs-12">
                        <asp:GridView CssClass="table table-bordered table-striped table-hover" AllowSorting="true" EmptyDataText="<%$ Resources:Content, GN00001375 %>"
                            ID="GV_SessionList" AllowPaging="true" runat="server" AutoGenerateColumns="false" DataKeyNames="SessionId,LoginId,Account,StartDateTimeUtc,CustomerId,CompanyId">

                            <Columns>

                                <asp:TemplateField HeaderText='<%$ Resources:Content,GN0000370 %>' HeaderStyle-CssClass="col-xs-1" ItemStyle-CssClass="col-xs-1">
                                    <HeaderTemplate>
                                        <asp:CheckBox CssClass="option-menu" runat="server" ID="ChkBx_All" onclick="SetCheckedHeader(this.checked, this, 'All');"
                                            Text=" " />
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <asp:CheckBox ID="ChkBx_All" runat="server" onclick="SetCheckedHeader(this.checked, this,'1');" Text=" " CssClass="option-menu" />
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText='<%$ Resources:Content,strAccount%>'
                                    HeaderStyle-CssClass="col-xs-3 hidden-xs" ItemStyle-CssClass="col-xs-3 hidden-xs">
                                    <ItemTemplate>
                                        <asp:HyperLink ID="Lb_Account" runat="server">
                                        </asp:HyperLink>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="<%$ Resources:Content,Detail%>"
                                    HeaderStyle-CssClass="col-xs-4" ItemStyle-CssClass="col-xs-4">
                                    <ItemTemplate>


                                        <table class="table small">
                                            <tbody>

                                                <%--<tr>
                                                        <td class="col-xs-5 row-label">
                                                            <asp:Label ID="Label2" runat="server" Text="<%$ Resources:Content,String408%>" EnableViewState="false"></asp:Label>:                                                          
                                                        </td>
                                                        <td class="col-xs-8">
                                                            <asp:Label ID="LB_AccountType" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.AccountType")%>'></asp:Label>
                                                        </td>
                                                    </tr>--%>
                                                <%--<tr id="trLabel" runat="server">
                                                        <td class="col-xs-5 row-label">
                                                            <asp:Label ID="lbl_LabelColon" runat="server" Text="<%$ Resources:Content,StrIP%>" EnableViewState="false"></asp:Label>
                                                        </td>
                                                        <td class="col-xs-8">
                                                            <asp:Label ID="Lbl_IP" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.IP")%>'></asp:Label>
                                                        </td>
                                                    </tr>--%>
                                                <tr>
                                                    <td class="col-xs-3 row-label">
                                                        <asp:Label ID="Label3" runat="server" Text="<%$ Resources:Content,strBrowserAndOs%>" EnableViewState="false"></asp:Label>:                                                          
                                                    </td>
                                                    <td class="col-xs-8">
                                                        <asp:Label ID="Lbl_IPBrowser" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.BrowserInfo")%>'></asp:Label>
                                                    </td>
                                                </tr>

                                                <tr>
                                                    <td class="col-xs-4 row-label">
                                                        <asp:Label ID="Label1" runat="server" Text="<%$ Resources:Content,strStartAt%>" EnableViewState="false"></asp:Label>:                                                          
                                                    </td>
                                                    <td class="col-xs-8">
                                                        <asp:Label ID="Lbl_StartDate" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.StartDateTimeUtc")%>'></asp:Label>
                                                    </td>
                                                </tr>

                                                <tr>
                                                    <td class="col-xs-4 row-label">
                                                        <asp:Label ID="Label6" runat="server" Text="<%$ Resources:Content,strEndAt%>" EnableViewState="false"></asp:Label>:                                                          
                                                    </td>
                                                    <td class="col-xs-8">
                                                        <asp:Label ID="Lbl_EndDate" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.EndDateTimeUtc")%>'></asp:Label>
                                                    </td>
                                                </tr>

                                            </tbody>
                                        </table>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText='<%$ Resources:Content,SPT002811%>'
                                    HeaderStyle-CssClass="col-xs-1 hidden-xs" ItemStyle-CssClass="col-xs-1 hidden-xs">
                                    <ItemTemplate>
                                        <asp:HyperLink ID="Lb_Owner" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.OwnerName")%>'>
                                        </asp:HyperLink>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderStyle-CssClass="col-xs-1" ItemStyle-CssClass="col-xs-1" HeaderText="<%$ Resources:Content,String385%>">
                                    <ItemTemplate>
                                        <asp:Label ID="LB_Status" CommandName="Status" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Status")%>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="<%$ Resources:Content,GN0000360%>" HeaderStyle-CssClass="col-xs-1">
                                    <ItemTemplate>
                                        <asp:LinkButton class="btn btn-primary waves-effect btnAction" ID="LB_KillSession" CommandArgument='<%#DataBinder.Eval(Container, "DataItem.LoginId")%>' CommandName="KillSession" runat="server" Text='<%$ Resources:Content,strKillSession%>'></asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>

                            <%--PagerTemplate Start--%>
                            <PagerTemplate>
                                <EM:Pager ID="Pager1" runat="server" />
                            </PagerTemplate>
                            <%--PagerTemplate End--%>
                        </asp:GridView>

                    </div>
                </div>


            </asp:Panel>
        </ContentTemplate>
    </EM:TabPanel>

</EM:TabContainer>



<script>
    function handleIsEanbled() {
        // console.log('handleIsEanbled');
        if ($get('<%= ChBx_InActiveuserAfter.ClientID %>').checked)
            $('#DivInActiveuserAfterDdl').removeClass('hide');
        else
            $('#DivInActiveuserAfterDdl').addClass('hide');

        if ($get('<%= ChBx_MaintainSessionHistory.ClientID %>').checked) {
            $('#DivMaintainSessionDdl').removeClass('hide');
            $('#DivDays').removeClass('hide');
        }
        else {
            $('#DivMaintainSessionDdl').addClass('hide');
            $('#DivDays').addClass('hide');
        }
        if ($get('<%= ChBx_ActiveSessionsPerAccount.ClientID %>').checked)
            $('#DivActiveSessionsddl').removeClass('hide');
        else
            $('#DivActiveSessionsddl').addClass('hide');

    }

    setTimeout(handleIsEanbled, 500);
    $('#<%= ChBx_InActiveuserAfter.ClientID %>').on('change', (e) => { console.log(e); handleIsEanbled(); });

    $('#<%= ChBx_MaintainSessionHistory.ClientID %>').on('change', (e) => { console.log(e); handleIsEanbled(); });

    $('#<%= ChBx_ActiveSessionsPerAccount.ClientID %>').on('change', (e) => { console.log(e); handleIsEanbled(); });
</script>

