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

<%@ Register TagPrefix="dxGridview" Namespace="DevExpress.Web" Assembly="DevExpress.Web.v14.2" %>
<%@ Register Assembly="DevExpress.Web.v14.2" Namespace="DevExpress.Web"
    TagPrefix="devxEditors" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="BodyContentPH" runat="Server">
    <div class="content-header">
        <h1 style="background-image: url('../dist/img/lve-san.png'); background-repeat: no-repeat; padding-left: 35px">
            <asp:Label ID="lbl_Header" runat="server" Text="OnDuty Sanction"></asp:Label>
        </h1>
        <asp:SiteMapPath ID="site" runat="server" CssClass="breadcrumb">
            <NodeStyle CssClass="active" />
        </asp:SiteMapPath>
    </div>
    <div class="content">
        <div class="inr-ftr">
            <div class="row">
                <div class="col-sm-2">
                </div>
                <div class="col-sm-2 col-sm-offset-8" style="height: 36px">
                    <div class="pull-right">
                    </div>
                </div>
                <div class="clearfix">
                </div>
            </div>
        </div>
        <asp:UpdatePanel ID="upLeave" runat="server">
            <ContentTemplate>
                <asp:Panel ID="pnlProgress" runat="server" Style="display: none;">
                    <asp:Panel ID="pnlLoading" runat="server" HorizontalAlign="center">
                        <div class="InsideProgressBar">
                            <div class="row" style="margin-top: 10px">
                                <img src="../dist/img/logo-Progress.png" />
                            </div>
                            <div class="row" style="min-width: 280px">
                                <img src="../dist/img/default.gif" style="width: 100px" />
                            </div>
                            <div class="row" style="margin-bottom: 10px">
                                <asp:Label ID="lblLoading" runat="server" ForeColor="black" Style="text-align: center"
                                    Font-Bold="true" Font-Size="12px" Font-Italic="true" Font-Family="Arial" Text="Please Wait..."></asp:Label>
                            </div>
                            <div class="clear clearfix">
                            </div>
                        </div>
                    </asp:Panel>
                </asp:Panel>
                <asp:HiddenField ID="hdnProgress" runat="server" />
                <cc1:ModalPopupExtender ID="popupProgress" runat="server" TargetControlID="hdnProgress"
                    BackgroundCssClass="ModalPopup" PopupControlID="pnlProgress" BehaviorID="popupProgress">
                </cc1:ModalPopupExtender>
            </ContentTemplate>
            <Triggers>
                <asp:PostBackTrigger ControlID="btnApprove" />
                <asp:PostBackTrigger ControlID="btnForward" />
                <asp:PostBackTrigger ControlID="btnBack" />
            </Triggers>
        </asp:UpdatePanel>
        <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">
                            <asp:HiddenField ID="hdnSelectRow" runat="server" />
                            <asp:HiddenField ID="hdnGetAllid" runat="server" />
                            <asp:HiddenField ID="hdnLeaveApplicationId" runat="server" />
                            <dxGridview:ASPxGridView ID="gdOndutySanctionViewBulk" EnableCallBacks="false" runat="server"
                                ClientInstanceName="gdOndutySanctionViewBulk" AutoGenerateColumns="false" 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="SelectAllOnThisPageOnduty(this)" />
                                        </HeaderTemplate>
                                        <DataItemTemplate>
                                            <input id="chkSelect" runat="server" type="checkbox" onclick="SelectOnRowOnduty(this)"
                                                accesskey='<%# Eval("Onduty_ID") %>' />
                                        </DataItemTemplate>
                                        <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                    </dxGridview:GridViewDataColumn>
                                    <dxGridview:GridViewDataTextColumn FieldName="Employee_Code_Id" Caption="Employee Id"
                                        VisibleIndex="1" Width="90px">
                                        <DataItemTemplate>
                                            <asp:Label ID="lbl_EmployeeId" Text='<%# Eval("Employee_Code_Id") %>' runat="server"></asp:Label>
                                        </DataItemTemplate>
                                        <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                    </dxGridview:GridViewDataTextColumn>
                                    <dxGridview:GridViewDataTextColumn Caption="Employee Name" FieldName="Employee_FirstName"
                                        VisibleIndex="2" Width="110px">
                                        <Settings AllowDragDrop="False" />
                                        <DataItemTemplate>
                                            <asp:Label ID="lbl_EmpName" Text='<%# Eval("Employee_FirstName") %>' runat="server"
                                                Style="overflow-y: auto; overflow-x: auto; word-break: break-all; word-wrap: break-word; cursor: pointer; display: inline-block;"></asp:Label>
                                        </DataItemTemplate>
                                        <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                    </dxGridview:GridViewDataTextColumn>
                                    <dxGridview:GridViewDataTextColumn Caption="Shift Date" FieldName="shiftDate" VisibleIndex="3"
                                        Width="80px">
                                        <Settings AllowDragDrop="False" />
                                        <DataItemTemplate>
                                            <asp:Label ID="lbl_shiftDate" Text='<%# Eval("Onduty_EntryDate")%>' runat="server"></asp:Label>
                                        </DataItemTemplate>
                                        <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                    </dxGridview:GridViewDataTextColumn>
                                    <dxGridview:GridViewDataTextColumn Caption="From Date" FieldName="ManualTimeEntry_InDate"
                                        Width="80px" VisibleIndex="4">
                                        <Settings AllowDragDrop="False" />
                                        <DataItemTemplate>
                                            <asp:Label ID="lbl_InDate" Text='<%# Eval("Onduty_FromDate") %>' runat="server"></asp:Label></a>
                                        </DataItemTemplate>
                                        <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                    </dxGridview:GridViewDataTextColumn>
                                    <dxGridview:GridViewDataTextColumn Caption="Start Time" FieldName="ManualTimeEntry_InTime"
                                        VisibleIndex="5" Width="80px">
                                        <Settings AllowDragDrop="False" AllowAutoFilter="False" />
                                        <DataItemTemplate>
                                            <asp:Label ID="lbl_InTime" Text='<%# Eval("Onduty_FromTime") %>' runat="server"></asp:Label></a>
                                        </DataItemTemplate>
                                        <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                    </dxGridview:GridViewDataTextColumn>
                                    <dxGridview:GridViewDataTextColumn Caption="To Date" FieldName="ManualTimeEntry_OutDate"
                                        VisibleIndex="6" Width="80px">
                                        <Settings AllowDragDrop="False" />
                                        <DataItemTemplate>
                                            <asp:Label ID="lbl_OutDate" Text='<%# Eval("Onduty_ToDate") %>' runat="server"></asp:Label>
                                        </DataItemTemplate>
                                        <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                    </dxGridview:GridViewDataTextColumn>
                                    <dxGridview:GridViewDataTextColumn Caption="End Time" FieldName="ManualTimeEntry_OutTime"
                                        VisibleIndex="7" Width="80px">
                                        <Settings AllowDragDrop="False" AllowAutoFilter="False" />
                                        <DataItemTemplate>
                                            <asp:Label ID="lbl_OutTime" Text='<%# Eval("Onduty_ToTime") %>' runat="server"></asp:Label></a>
                                        </DataItemTemplate>
                                        <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                    </dxGridview:GridViewDataTextColumn>
                                    <dxGridview:GridViewDataTextColumn Caption="Status" FieldName="ManualTimeEntry_Status"
                                        VisibleIndex="8" Width="70px">
                                        <Settings AllowDragDrop="False" />
                                        <DataItemTemplate>
                                            <asp:Label ID="lbl_status" Text='<%# Eval("OnDuty_Status")%>' runat="server"></asp:Label>
                                        </DataItemTemplate>
                                        <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                    </dxGridview:GridViewDataTextColumn>
                                    <dxGridview:GridViewDataTextColumn Caption="Reason" FieldName="ManualTimeEntry_Reason"
                                        VisibleIndex="9" Width="120px">
                                        <Settings AllowDragDrop="False" />
                                        <DataItemTemplate>
                                            <asp:Label ID="lbl_reason" Text='<%# Eval("Onduty_Reason")%>' runat="server"></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="40px">
                                        <Settings AllowAutoFilter="false" />
                                        <DataItemTemplate>
                                            <a title='<%# Session["View"] %>' data-placement="top" href='TA_UI_Transactions_OnDutySanctionModify.aspx?ODID=<%# Eval("Onduty_ID") %>'>
                                                <span class="btn btn-defalut edit-icons"></span></a>
                                        </DataItemTemplate>
                                        <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                    </dxGridview:GridViewDataColumn>
                                </Columns>
                                <Settings ShowGroupFooter="VisibleAlways" />
                                <Settings ShowFilterRow="true" />
                                <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 runat="server" id="dvRemarks">
                    <div class="row form-group">
                        <div class="col-md-12">
                            <asp:Label ID="lblRemarks" runat="server" Text="Remarks :"></asp:Label>
                            <asp:TextBox ID="txtRemarks" runat="server" Text="OK" TextMode="MultiLine" CssClass="form-control man-dat"
                                Style="resize: none"></asp:TextBox>
                        </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"
                                Visible="false" />
                            <asp:LinkButton ID="btnForward" Text="FORWARD" OnClientClick="return confirmMsg(this.form);"
                                runat="server" CssClass="btn save-btn fa-angle-double-right" OnClick="btnForward_Click" />
                            <asp:LinkButton ID="btnApprove" Text="APPROVE" OnClientClick="return confirmMsg(this.form);"
                                runat="server" CssClass="btn save-btn fa-thumbs-o-up" OnClick="btnApprove_Click" />
                            <asp:LinkButton ID="btnBack" runat="server" CssClass="btn save-btn fa-angle-left"
                                Text="&nbsp;&nbsp;Back" OnClick="btnBack_Click" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript" language="javascript">
        function SelectAllOnThisPageOnduty(chkSelectAll) {
            var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
            var hdnSelectAll = document.getElementById('<%= hdnGetAllid.ClientID %>');
            if (chkSelectAll.checked == true) {
                for (var i = 0; i < gdOndutySanctionViewBulk.pageRowCount; i++) {
                    if (document.getElementById('ctl00_BodyContentPH_gdOndutySanctionViewBulk_cell' + (i + gdOndutySanctionViewBulk.visibleStartIndex) + '_0_chkSelect').disabled == false) {
                        document.getElementById('ctl00_BodyContentPH_gdOndutySanctionViewBulk_cell' + (i + gdOndutySanctionViewBulk.visibleStartIndex) + '_0_chkSelect').checked = true;
                        var hdnUserId = document.getElementById('ctl00_BodyContentPH_gdOndutySanctionViewBulk_cell' + (i + gdOndutySanctionViewBulk.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 < gdOndutySanctionViewBulk.pageRowCount; i++) {
                document.getElementById('ctl00_BodyContentPH_gdOndutySanctionViewBulk_cell' + (i + gdOndutySanctionViewBulk.visibleStartIndex) + '_0_chkSelect').checked = false;
            }
            hdnSelectRow.value = '';
        }
    }


        function SelectOnRowOnduty(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 < gdOndutySanctionViewBulk.pageRowCount; i++) {
                    if (document.getElementById('ctl00_BodyContentPH_gdOndutySanctionViewBulk_cell' + (i + gdOndutySanctionViewBulk.visibleStartIndex) + '_0_chkSelect').checked)
                        varTotalCheckedCount = varTotalCheckedCount + 1;
                    else
                        break;
                }
                if (varTotalCheckedCount == gdOndutySanctionViewBulk.pageRowCount)
                    document.getElementById('ctl00_BodyContentPH_gdOndutySanctionViewBulk_header0_chkSelectAll').checked = true;
                else
                    document.getElementById('ctl00_BodyContentPH_gdOndutySanctionViewBulk_header0_chkSelectAll').checked = false;
            }
            else {
                if (Array.contains(removeId, hdnUserId)) {
                    Array.remove(removeId, hdnUserId);
                }
                hdnSelectRow.value = removeId;

                document.getElementById('ctl00_BodyContentPH_gdOndutySanctionViewBulk_header0_chkSelectAll').checked = false;
            }
        }
    //Added by Manjula.P on 25-Apr-2014 for Integrating ANGLER into PRODUCT
    function openPopupMailTo() {
        var MailType = "TO";
        popupwindow('GetEmailIdsPopup.aspx?MailType=' + MailType + '', 'Test', 700, 500);
        //            window.open('GetEmailIdsPopup.aspx?MailType=' + MailType + '','Test','height=610,top=200,left=250,width=600');
        return false;
    }
    function openPopupMailCc() {
        var MailType = "CC";
        popupwindow('GetEmailIdsPopup.aspx?MailType=' + MailType + '', 'Test', 700, 500);
        //            window.open('GetEmailIdsPopup.aspx?MailType=' + MailType + '','Test','height=610,top=200,left=250,width=600');
        return false;
    }
    function RedirectionFunction() {
        //alert('Test');
        document.getElementById('ctl00_BodyContentPH_btnBack').click();
    }
    //************************************************************

    function popupwindow(url, title, w, h) {
        var left = (screen.width / 2) - (w / 2);
        var top = (screen.height / 2) - (h / 2);
        return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
    }

    function confirmdelete(frm) {
        var status = "";
        var stausForAll = "";
        var frm = document.forms[0];
        for (i = 0; i < frm.length; i++) {
            if (frm.elements[i].name.indexOf('chkSelectAll') != -1) {
                if (frm.elements[i].checked) {
                    stausForAll = true;
                }
            }
            if (frm.elements[i].name.indexOf('chkSelectAll') == -1) {
                if ((frm.elements[i].name.indexOf('chkSelect')) != -1) {
                    if (frm.elements[i].checked) {
                        status = true;
                    }
                }
            }
        }

        if (stausForAll == true && status == "") {
            alert('No records to delete');
            return false;
        }

        if (status == true) {
            return confirm("Are you sure, to change status?");
        }
        else {
            alert("Select Item(s) to change status.");
            return false;
        }
    }
    </script>

</asp:Content>
