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

<%@ Register TagPrefix="dxGridview" Namespace="DevExpress.Web" Assembly="DevExpress.Web.v14.2" %>
<asp:Content ID="conPunchTypesList" ContentPlaceHolderID="BodyContentPH" runat="Server">
    <script type="text/javascript">
        function navi(loc) {
            document.getElementById('ctl00_BodyContentPH_iframePopup').src = loc;
            return false;
        }
        function Delete_Conf() {
            return confirm('Are you sure to Delete ?');
        }
    </script>
    <div class="content-header">
        <h1 style="background-image: url('../dist/img/punch-type.png'); background-repeat: no-repeat; padding-left: 35px">
            <asp:Label ID="lbl_Header" runat="server"></asp:Label>
        </h1>
        <asp:SiteMapPath ID="site" runat="server" CssClass="breadcrumb">
            <NodeStyle CssClass="active" />
        </asp:SiteMapPath>
    </div>
    <div class="content">
        <div class="form-horizontal">
            <div class="border-table new-space" style="margin-top: 0px">
                <div class="row form-group">
                    <%--if we enable property, in mobile view, the scroll bar will come automatically for grid control but not in PC--%>
                    <%--<div class="col-md-12" style="overflow: auto; overflow-y: hidden; padding-bottom: 10px">--%>
                    <div class="col-md-12">
                        <asp:HiddenField ID="hdnSelectRow" runat="server" />
                        <asp:HiddenField ID="hdnGetAllid" runat="server" />
                        <dxGridview:ASPxGridView ID="grv_InOut" runat="server" AutoGenerateColumns="False"
                            EnableCallBacks="false" OnHtmlRowCreated="grv_InOut_HtmlRowCreated" ClientInstanceName="grv_InOut"
                            DataSourceID="ObjectDataSource1" KeyFieldName="PunchType_Id">
                            <Columns>
                                <dxGridview:GridViewDataTextColumn FieldName="PunchType_Id" Visible="false">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblPunchTypeId" runat="server" Text='<%# Eval("PunchType_Id")%>'></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataColumn VisibleIndex="0" Width="30px" HeaderStyle-VerticalAlign="Middle"
                                    HeaderStyle-HorizontalAlign="Center" CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center">
                                    <HeaderTemplate>
                                        <input id="chkSelectAll" runat="server" type="checkbox" onclick="SelectAllOnThisPage(this)" />
                                    </HeaderTemplate>
                                    <DataItemTemplate>
                                        <input id="chkSelect" runat="server" type="checkbox" onclick="SelectOnRow(this)"
                                            disabled='<%#DataBinder.Eval(Container.DataItem,"flag").ToString()=="1" %>' accesskey='<%# Eval("PunchType_Id") %>' />
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataColumn>
                                <dxGridview:GridViewDataTextColumn Caption="Terminal ID" FieldName="Terminal_ReaderID"
                                    VisibleIndex="2" Width="308px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblTerminalId" Text='<%# Eval("Terminal_ReaderID") %>' runat="server"
                                            CssClass="dxlabel">
                                        </asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataTextColumn FieldName="PunchType" VisibleIndex="3" Width="250px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblPunchType" Text='<%# Eval("PunchType") %>' runat="server" CssClass="dxlabel"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataTextColumn FieldName="Value" VisibleIndex="4" Width="250px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblValue" Text='<%# Eval("Value") %>' runat="server" CssClass="dxlabel"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataColumn HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center" VisibleIndex="5"
                                    CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center" Width="40px">
                                    <Settings AllowAutoFilter="false" />
                                    <DataItemTemplate>
                                        <a data-toggle="modal" title='<%# Session["View"] %>' data-placement="top" data-target="#myModal" onclick="return navi('TA_UI_Master_PunchTypes_View.aspx?PunchType_Id=<%# Eval("PunchType_Id") %>')"
                                            href="#"><span class="btn btn-defalut view-icons"></span></a>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataColumn>
                                <dxGridview:GridViewDataColumn HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center" VisibleIndex="6"
                                    CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center" Width="40px">
                                    <Settings AllowAutoFilter="false" />
                                    <DataItemTemplate>
                                        <asp:LinkButton ID="btnEdit" CommandName='<%# Eval("PunchType_Id") %>' OnClick="EditLinkButton_Click"
                                            runat="server" ToolTip='<%# Session["Edit"] %>' data-toggle="tooltip" data-placement="top" CssClass="btn btn-defalut edit-icons"
                                            Style="color: #3C8DBC"></asp:LinkButton>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataColumn>
                                <dxGridview:GridViewDataColumn HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center" VisibleIndex="7"
                                    CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center" Width="40px">
                                    <Settings AllowAutoFilter="false" />
                                    <DataItemTemplate>
                                        <asp:LinkButton ID="btnDelete" runat="server" OnClientClick="return Delete_Conf();"
                                            CommandName='<%# Eval("PunchType_Id") %>' OnClick="btn_delete_Click" ToolTip='<%# Session["Delete"] %>'
                                            data-toggle="tooltip" data-placement="top" CssClass="btn btn-defalut del-icons"
                                            Style="color: Red"></asp:LinkButton>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataColumn>
                            </Columns>
                            <SettingsPager PageSize="10">
                                <PageSizeItemSettings Visible="true" ShowAllItem="true" Items="10,20,50,100,200" />
                            </SettingsPager>
                            <Settings ShowFilterRow="true" ShowFilterRowMenu="true" HorizontalScrollBarMode="Auto" ShowGroupPanel="true" VerticalScrollBarMode="Hidden" VerticalScrollableHeight="400" />
                            <SettingsText EmptyDataRow="No Records Found" />
                            <SettingsBehavior SortMode="Value" AllowSort="true" AllowDragDrop="true" ColumnResizeMode="Control" />
                            <Styles AlternatingRow-CssClass="table-bg">
                            </Styles>
                        </dxGridview:ASPxGridView>
                        <dxGridview:ASPxGridViewExporter ID="ASPxGridViewExporter1" runat="server" GridViewID="grv_InOut">
                            <PageFooter Right="[Page # of Pages #]">
                            </PageFooter>
                        </dxGridview:ASPxGridViewExporter>
                    </div>
                    <div class="col-md-12">
                        <div id="myModal" class="modal modal-default fade" role="dialog">
                            <div class="modal-dialog" style="min-width: 80%;">
                                <div class="modal-content" style="margin-top: 150px">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal" style="border-radius: 50px;">
                                            &times;</button>
                                        <h4 class="modal-title">
                                            <asp:Label ID="lblDataView" runat="server" Text="Data View"></asp:Label>
                                        </h4>
                                    </div>
                                    <div class="modal-body">
                                        <iframe id="iframePopup" runat="server" scrolling="auto" width="100%" height="150px"
                                            style="border-style: none"></iframe>
                                    </div>
                                    <div class="modal-footer" style="display: none">
                                        <button type="button" class="btn btn-primary pull-right" data-dismiss="modal">
                                            Close</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="pull-right-button">
                            <asp:LinkButton ID="btn_add" CssClass="btn add-btn fa-plus" runat="server" OnClick="btn_add_Click"></asp:LinkButton>
                            <asp:LinkButton ID="btnsync" Text="&nbsp;&nbsp;Sync device data" CssClass="btn del-btn fa-refresh"
                                runat="server" OnClick="btnsync_Click" Enabled="false" />
                            <asp:LinkButton ID="btn_Delete" CssClass="btn btn-primary fa fa-trash-o" runat="server"
                                OnClick="btn_Delete_Click" OnClientClick="return confirmdelete(this.form);" Visible="false"></asp:LinkButton>
                            <asp:LinkButton ID="btn_Restore" CssClass="btn btn-primary fa fa-recycle" runat="server"
                                OnClick="btn_Restore_Click" OnClientClick="return RestoreData();" Visible="false"></asp:LinkButton>
                            <asp:HiddenField ID="hdnDeletedData" runat="server" />
                            <asp:LinkButton ID="btn_PermanentDelete" CssClass="btn save-btn fa-trash-o" runat="server"
                                OnClick="btn_PermanentDelete_Click" OnClientClick="return Permanentconfirmdelete(this.form);"></asp:LinkButton>
                            <asp:LinkButton ID="lnktbnexcel" ToolTip="Excel" CommandName="excel" runat="server" CssClass="btn del-btn fa-file-excel-o" OnClick="lnktbnexcel_Click">
                            </asp:LinkButton>
                            <asp:LinkButton ID="lnkbtnpdf" ToolTip="Pdf" CommandName="pdf" runat="server" CssClass="btn del-btn fa-file-pdf-o" OnClick="lnktbnexcel_Click">
                            </asp:LinkButton>
                            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="Select_PunchTypeDetails"
                                TypeName="PunchTypesEventdata">
                                <SelectParameters>
                                    <asp:SessionParameter Name="strUserGroupName" SessionField="UserGroupName" Type="String" />
                                </SelectParameters>
                            </asp:ObjectDataSource>
                        </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_InOut.pageRowCount; i++) {
                    if (document.getElementById('ctl00_BodyContentPH_grv_InOut_cell' + (i + grv_InOut.visibleStartIndex) + '_1_chkSelect').disabled == false) {
                        document.getElementById('ctl00_BodyContentPH_grv_InOut_cell' + (i + grv_InOut.visibleStartIndex) + '_1_chkSelect').checked = true;
                        var hdnUserId = document.getElementById('ctl00_BodyContentPH_grv_InOut_cell' + (i + grv_InOut.visibleStartIndex) + '_1_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_InOut.pageRowCount; i++) {
                    document.getElementById('ctl00_BodyContentPH_grv_InOut_cell' + (i + grv_InOut.visibleStartIndex) + '_1_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;
                var varTotalEnabled = 0;
                for (var i = 0; i < grv_InOut.pageRowCount; i++) {
                    if (document.getElementById('ctl00_BodyContentPH_grv_InOut_cell' + (i + grv_InOut.visibleStartIndex) + '_1_chkSelect').disabled == false) {
                        varTotalEnabled = varTotalEnabled + 1;
                    }
                    if (document.getElementById('ctl00_BodyContentPH_grv_InOut_cell' + (i + grv_InOut.visibleStartIndex) + '_1_chkSelect').checked)
                        varTotalCheckedCount = varTotalCheckedCount + 1;
                }
                if (varTotalCheckedCount == varTotalEnabled)
                    document.getElementById('ctl00_BodyContentPH_grv_InOut_header1_chkSelectAll').checked = true;
                else
                    document.getElementById('ctl00_BodyContentPH_grv_InOut_header1_chkSelectAll').checked = false;
            }
            else {
                if (Array.contains(removeId, hdnUserId)) {
                    Array.remove(removeId, hdnUserId);
                }
                hdnSelectRow.value = removeId;
                document.getElementById('ctl00_BodyContentPH_grv_InOut_header1_chkSelectAll').checked = false;
            }
        }
        var Norecordsavailable = "No records available ";
        var AreyousuretoRestore = "Are you sure to Restore? ";
        var Selecteddataisnotindeletedstatus = "Selected data is not in deleted status ";
        var Selectdatatorestore = "Select data to restore ";
        var Nodeletedrecordsavailable = "No deleted records available ";
        function RestoreAlert(norecordsavailable, areyousuretoRestore, selecteddataisnotindeletedstatus, selectdatatorestore, nodeletedrecordsavailable) {
            Norecordsavailable = norecordsavailable;
            AreyousuretoRestore = areyousuretoRestore;
            Selecteddataisnotindeletedstatus = selecteddataisnotindeletedstatus;
            Selectdatatorestore = selectdatatorestore;
            Nodeletedrecordsavailable = nodeletedrecordsavailable;
        }
        function RestoreData() {
            var rowscount = grv_InOut.pageRowCount;
            if (rowscount == 0) {
                alert(Norecordsavailable);
                return false;
            }
            var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
        var DeleteDataRow = document.getElementById('<%= hdnDeletedData.ClientID %>');
        if (DeleteDataRow.value != '') {
            if (hdnSelectRow.value != '') {
                var selectedRow = new Array();
                selectedRow = hdnSelectRow.value.split(",");
                var deletedRow = new Array();
                deletedRow = DeleteDataRow.value.split(",");
                var Status = false;
                for (var i = 0; i < selectedRow.length; i++) {
                    if (Array.contains(deletedRow, selectedRow[i])) {
                        Status = true;
                    }
                }
                if (Status == true) {
                    return confirm(AreyousuretoRestore);
                }
                else {
                    alert(Selecteddataisnotindeletedstatus);
                    return false;
                }
            }
            else {
                alert(Selectdatatorestore);
                return false;
            }
        }
        else {
            if (hdnSelectRow.value == '') {
                alert(Nodeletedrecordsavailable);
                return false;
            }
            else {
                alert(Selecteddataisnotindeletedstatus);
                return false;
            }
        }
    }
    </script>
</asp:Content>
