<%@ page language="C#" masterpagefile="~/MasterFile/TimeCheck.master" autoeventwireup="true" inherits="Organization_Settings_LoginList, App_Web_3olww1qf" %>

<%@ Register TagPrefix="dxGridview" Namespace="DevExpress.Web" Assembly="DevExpress.Web.v14.2" %>
<%@ Register Assembly="DevExpress.Web.v14.2" Namespace="DevExpress.Web"
    TagPrefix="devxEditors" %>
<asp:Content ID="Content1" ContentPlaceHolderID="BodyContentPH" runat="Server">

    <script type="text/javascript" language="javascript">
        var SureToLogout = "Are you sure, to Logout?";
        var SelectUserIdsToLogout = "Select UserIds To Logout";
        function SetAlertMessages(sureToLogout, selectUserIdsToLogout) {
            SureToLogout = sureToLogout;
            SelectUserIdsToLogout = selectUserIdsToLogout;
        }
    </script>

    <div class="content-header">
        <h1 style="background-image: url(../dist/img/loginlist.png); background-repeat: no-repeat; padding-left: 35px">
            <asp:Label ID="lbl_HeaderLoginList" runat="server"></asp:Label>
        </h1>
        <asp:SiteMapPath ID="site" runat="server" CssClass="breadcrumb">
            <NodeStyle CssClass="active" />
        </asp:SiteMapPath>
    </div>
    <div class="content">
        <div class="emp-filter">
            <div class="form-horizontal">
                <div class="row form-group">
                    <div class="col-md-12" style="overflow: auto; overflow-y: hidden; padding-bottom: 10px;">
                        <asp:HiddenField ID="hdnSelectRow" runat="server" />
                        <asp:HiddenField ID="hdnGetAllid" runat="server" />
                        <dxGridview:ASPxGridView ID="grv_LoginList" EnableCallBacks="false" runat="server"
                            ClientInstanceName="grv_LoginList" AutoGenerateColumns="false" KeyFieldName="chkSelect"
                            Width="100%" OnHtmlRowCreated="grv_LoginList_HtmlRowCreated">
                            <Columns>
                                <dxGridview:GridViewDataColumn VisibleIndex="0" Width="34px" HeaderStyle-VerticalAlign="Middle"
                                    HeaderStyle-HorizontalAlign="Center" CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center">
                                    <Settings AllowAutoFilter="false" />
                                    <HeaderTemplate>
                                        <input id="chkSelectAll" runat="server" type="checkbox" onclick="SelectAllOnThisPage(this)" />
                                    </HeaderTemplate>
                                    <DataItemTemplate>
                                        <input id="chkSelect" runat="server" type="checkbox" onclick="SelectOnRow(this)"
                                            accesskey='<%# Eval("UserId") %>' />
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataColumn>
                                <dxGridview:GridViewDataTextColumn FieldName="ConcurrentUserId" VisibleIndex="0"
                                    Width="200px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblConcurrentUserId" Text='<%# Eval("ConcurrentUserId") %>' runat="server"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataTextColumn FieldName="UserId" VisibleIndex="1" Width="200px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblUserId" runat="server" Text='<%# Eval("UserId") %>'></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataTextColumn FieldName="IpAddress" VisibleIndex="2" Width="150px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblIpAddress" runat="server" Text='<%# Eval("IpAddress") %>'></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataTextColumn FieldName="LoginTime" VisibleIndex="3" Width="140px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblLoginTime" runat="server" Text='<%# Eval("LoginTime") %>'></asp:Label>
                                    </DataItemTemplate>
                                    <Settings AllowAutoFilter="false" />
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataTextColumn FieldName="LoginTime" VisibleIndex="4" Width="100px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblStatus" runat="server" Text='<%# Eval("Status") %>'></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                            </Columns>
                            <SettingsPager PageSize="10">
                            </SettingsPager>
                            <Settings ShowFilterRow="true" />
                            <SettingsBehavior SortMode="Value" AllowSort="true" AllowDragDrop="false" />
                            <Styles AlternatingRow-CssClass="table-bg">
                            </Styles>
                        </dxGridview:ASPxGridView>
                    </div>
                    <div class="col-md-12" style="margin-top: 5px;">
                        <div class="pull-right-button">
                            <asp:LinkButton ID="btn_Logout" CssClass="btn save-btn fa-sign-out" runat="server"
                                OnClick="btn_Logout_Click" OnClientClick="return confirmlogout(this.form,SureToLogout,SelectUserIdsToLogout);" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript" language="javascript">
        function OnInit(s, e) {

            AdjustSize();
        }
        function OnEndCallback(s, e) {
            AdjustSize();
        }

        function AdjustSize() {

            var height = Math.max(0, document.documentElement.clientHeight);
            var width = Math.max(0, document.documentElement.clientWidth);
            grid.SetHeight(height);
        }
        function SelectAllOnThisPage(chkSelectAll) {

            var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
            var hdnSelectAll = document.getElementById('<%= hdnGetAllid.ClientID %>');
            if (chkSelectAll.checked == true) {
                for (var i = 0; i < grv_LoginList.pageRowCount; i++) {
                    if (document.getElementById('ctl00_BodyContentPH_grv_LoginList_cell' + (i + grv_LoginList.visibleStartIndex) + '_0_chkSelect').disabled == false) {
                        document.getElementById('ctl00_BodyContentPH_grv_LoginList_cell' + (i + grv_LoginList.visibleStartIndex) + '_0_chkSelect').checked = true;
                        var hdnUserId = document.getElementById('ctl00_BodyContentPH_grv_LoginList_cell' + (i + grv_LoginList.visibleStartIndex) + '_0_chkSelect').accessKey;
                        var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
                        var removeId = hdnSelectRow.value.split(",");
                        if (hdnUserId != "" && !Array.contains(removeId, hdnUserId)) {
                            if (hdnSelectRow.value != "")
                                hdnSelectRow.value += ",";
                            hdnSelectRow.value += hdnUserId;
                        }
                    }
                }
            }
            else {
                for (var i = 0; i < grv_LoginList.pageRowCount; i++) {
                    document.getElementById('ctl00_BodyContentPH_grv_LoginList_cell' + (i + grv_LoginList.visibleStartIndex) + '_0_chkSelect').checked = false;
                }
                hdnSelectRow.value = '';
            }
        }


        function SelectOnRow(chkOnSelect) {

            var hdnUserId = chkOnSelect.accessKey;
            var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
            var removeId = hdnSelectRow.value.split(",");

            if (chkOnSelect.checked) {
                if (hdnUserId != "" && !Array.contains(removeId, hdnUserId)) {
                    if (hdnSelectRow.value != "")
                        hdnSelectRow.value += ",";
                    hdnSelectRow.value += hdnUserId;
                }

                var varTotalCheckedCount = 0;
                for (var i = 0; i < grv_LoginList.pageRowCount; i++) {
                    if (document.getElementById('ctl00_BodyContentPH_grv_LoginList_cell' + (i + grv_LoginList.visibleStartIndex) + '_0_chkSelect').checked)
                        varTotalCheckedCount = varTotalCheckedCount + 1;
                    else
                        break;
                }
                if (varTotalCheckedCount == grv_LoginList.pageRowCount)
                    document.getElementById('ctl00_BodyContentPH_grv_LoginList_header0_chkSelectAll').checked = true;
                else
                    document.getElementById('ctl00_BodyContentPH_grv_LoginList_header0_chkSelectAll').checked = false;
            }
            else {
                if (Array.contains(removeId, hdnUserId)) {
                    Array.remove(removeId, hdnUserId);
                }
                hdnSelectRow.value = removeId;

                document.getElementById('ctl00_BodyContentPH_grv_LoginList_header0_chkSelectAll').checked = false;
            }
        }

    </script>

</asp:Content>
