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

<%@ 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">
    <div class="content-header">
        <h1>
            <asp:Label ID="lbl_Header" runat="server"></asp:Label>
        </h1>
        <asp:SiteMapPath ID="site" runat="server" CssClass="breadcrumb" ShowToolTips="true">
            <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">
                        <div class="table-responsive" style="padding-bottom: 10px">
                            <dxGridview:ASPxGridView ID="gdLeaveSanctionView" EnableCallBacks="false" runat="server"
                                ClientInstanceName="gdLeaveSanctionView" AutoGenerateColumns="false" KeyFieldName="LeaveApplication_Id"
                                Width="100%">
                                <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("LeaveApplication_Id") %>' />
                                        </DataItemTemplate>
                                        <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                    </dxGridview:GridViewDataColumn>
                                    <dxGridview:GridViewDataTextColumn FieldName="employeeid" VisibleIndex="1" Width="110px">
                                        <Settings AllowDragDrop="False" />
                                        <DataItemTemplate>
                                            <asp:Label ID="LabelEmp" Style="overflow-y: auto; overflow-x: auto; word-break: break-all; word-wrap: break-word; display: inline-block;"
                                                runat="server"
                                                Text='<%# Eval("employeeid")%>'></asp:Label>
                                        </DataItemTemplate>
                                        <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                    </dxGridview:GridViewDataTextColumn>
                                    <dxGridview:GridViewDataTextColumn Caption="Employee Name" FieldName="Employee_FirstName"
                                        Width="150px" VisibleIndex="2">
                                        <Settings AllowDragDrop="False" />
                                        <DataItemTemplate>
                                            <asp:Label ID="LabelEmp" Style="overflow-y: auto; overflow-x: auto; cursor: pointer; word-break: break-all; word-wrap: break-word; display: inline-block;"
                                                runat="server" Text='<%# Eval("Employee_FirstName")%>'></asp:Label>
                                        </DataItemTemplate>
                                        <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                    </dxGridview:GridViewDataTextColumn>
                                    <dxGridview:GridViewDataTextColumn FieldName="Leave_ApplicationDate" VisibleIndex="3"
                                        Width="200px">
                                        <Settings AllowDragDrop="False" />
                                        <DataItemTemplate>
                                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("Leave_ApplicationDate") %>'></asp:Label>
                                        </DataItemTemplate>
                                        <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                    </dxGridview:GridViewDataTextColumn>
                                    <dxGridview:GridViewDataTextColumn FieldName="Duration" VisibleIndex="4" Width="160px">
                                        <Settings AllowDragDrop="False" />
                                        <DataItemTemplate>
                                            <asp:Label ID="Label3" runat="server" Text='<%# Eval("Duration") %>'></asp:Label>
                                        </DataItemTemplate>
                                        <Settings AllowAutoFilter="False" />
                                        <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                    </dxGridview:GridViewDataTextColumn>
                                    <dxGridview:GridViewDataTextColumn FieldName="Type" VisibleIndex="5" Width="150px">
                                        <Settings AllowDragDrop="False" />
                                        <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                    </dxGridview:GridViewDataTextColumn>
                                    <dxGridview:GridViewDataTextColumn FieldName="Status" VisibleIndex="6" Width="70px">
                                        <Settings AllowDragDrop="False" />
                                        <DataItemTemplate>
                                            <asp:Label ID="Label2" runat="server" Text='<%# Eval("Status") %>'></asp:Label>
                                        </DataItemTemplate>
                                        <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                    </dxGridview:GridViewDataTextColumn>
                                    <dxGridview:GridViewDataColumn HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"
                                        CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center" Width="35px">
                                        <Settings AllowAutoFilter="false" />
                                        <DataItemTemplate>
                                            <a href="TA_UI_Transactions_LeaveSanctionModify.aspx?page=Bulk&LeaveApplication_Id=<%# Eval("LeaveApplication_Id") %>&Status=<%# Eval("Status") %>">
                                                <span class="btn btn-defalut edit-icons"></span></a>
                                        </DataItemTemplate>
                                        <HeaderStyle HorizontalAlign="center" Wrap="true" CssClass="empheader" />
                                    </dxGridview:GridViewDataColumn>
                                    <dxGridview:GridViewDataTextColumn FieldName="LeaveApplication_Id" VisibleIndex="7"
                                        Visible="false">
                                        <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                    </dxGridview:GridViewDataTextColumn>
                                </Columns>
                                <Settings ShowGroupFooter="VisibleAlways" />
                                <SettingsPager PageSize="10">
                                </SettingsPager>
                                <SettingsText EmptyDataRow="No Records Found" />
                                <Settings ShowFilterRow="true" />
                                <SettingsBehavior SortMode="Value" AllowSort="true" AllowDragDrop="true" />
                                <Styles AlternatingRow-CssClass="table-bg">
                                </Styles>
                            </dxGridview:ASPxGridView>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="pull-right-button">
                            <asp:LinkButton ID="btnSave" runat="server" Text="Sanction" CssClass="btn save-btn fa-floppy-o"
                                OnClick="btnSave_Click" />
                            <asp:LinkButton ID="btnBack" runat="server" CssClass="btn save-btn fa-angle-left"
                                OnClick="btnBack_Click" />
                            <asp:HiddenField ID="hdnLeaveApplicationId" runat="server" />
                            <asp:HiddenField ID="hdnSelectRow" runat="server" />
                            <asp:HiddenField ID="hdnGetAllid" runat="server" />
                        </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 < gdLeaveSanctionView.pageRowCount; i++) {
                if (document.getElementById('ctl00_BodyContentPH_gdLeaveSanctionView_cell' + (i + gdLeaveSanctionView.visibleStartIndex) + '_0_chkSelect').disabled == false) {
                    document.getElementById('ctl00_BodyContentPH_gdLeaveSanctionView_cell' + (i + gdLeaveSanctionView.visibleStartIndex) + '_0_chkSelect').checked = true;
                    var hdnUserId = document.getElementById('ctl00_BodyContentPH_gdLeaveSanctionView_cell' + (i + gdLeaveSanctionView.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 < gdLeaveSanctionView.pageRowCount; i++) {
                document.getElementById('ctl00_BodyContentPH_gdLeaveSanctionView_cell' + (i + gdLeaveSanctionView.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 < gdLeaveSanctionView.pageRowCount; i++) {
                if (document.getElementById('ctl00_BodyContentPH_gdLeaveSanctionView_cell' + (i + gdLeaveSanctionView.visibleStartIndex) + '_0_chkSelect').checked)
                    varTotalCheckedCount = varTotalCheckedCount + 1;
                else
                    break;
            }
            if (varTotalCheckedCount == gdLeaveSanctionView.pageRowCount)
                document.getElementById('ctl00_BodyContentPH_gdLeaveSanctionView_header0_chkSelectAll').checked = true;
            else
                document.getElementById('ctl00_BodyContentPH_gdLeaveSanctionView_header0_chkSelectAll').checked = false;
        }
        else {
            if (Array.contains(removeId, hdnUserId)) {
                Array.remove(removeId, hdnUserId);
            }
            hdnSelectRow.value = removeId;

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

    </script>

</asp:Content>
