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

<%@ Register Src="~/UserControls/TA_uc_OrganizationLevels_Mandatory.ascx" TagName="OrganizationLevel"
    TagPrefix="uc" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register TagPrefix="dxGridview" Namespace="DevExpress.Web" Assembly="DevExpress.Web.v14.2" %>
<asp:Content ID="ConNearestShift" ContentPlaceHolderID="BodyContentPH" runat="Server">
    <!--[if gt IE 5.5]>
	<link rel="stylesheet" type="text/css" href="../css/anytimeIE.css" />
		<link rel="stylesheet" type="text/css" href="../css/ProgressforIE.css" />
 <![endif]-->

    <script type="text/javascript" src="../bootstrap/js/1.4.3/jquery.min.js"></script>

    <script src="../bootstrap/js/1.8.5/jquery-ui.min.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(function () {

            $("#<%= txtEmployeeId.ClientID %>").autocomplete({
                source: function (request, response) {
                    $.getJSON("../AutoCompleteByEmployeeId.ashx?EmpAutoid=" + '<%= Convert.ToString(Session["EmpAutoID"]) %>', {
                        term: extractLast(request.term)
                    }, response);
                },
                search: function () {
                    // custom minLength
                    var term = extractLast(this.value);
                    if (term.length < 1) {
                        return false;
                    }
                },
                focus: function () {
                    // prevent value inserted on focus
                    return false;
                },
                select: function (event, ui) {

                    var terms = split(this.value);
                    // remove the current input
                    terms.pop();
                    // add the selected item
                    terms.push(ui.item.value);
                    // add placeholder to get the comma-and-space at the end
                    terms.push("");
                    this.value = terms.join(",");
                    return false;
                }
            });
            function split(val) {
                return val.split(/,\s*/);
            }
            function extractLast(term) {
                return split(term).pop();
            }
        });

            $(function () {

                $("#<%= txtEmployeeName.ClientID %>").autocomplete({
                    source: function (request, response) {
                        $.getJSON("../AutoCompleteByName.ashx?EmpAutoid=" + '<%= Convert.ToString(Session["EmpAutoID"]) %>', {
                            term: extractLast(request.term)
                        }, response);
                    },
                    search: function () {
                        // custom minLength
                        var term = extractLast(this.value);
                        if (term.length < 1) {
                            return false;
                        }
                    },
                    focus: function () {
                        // prevent value inserted on focus
                        return false;
                    },
                    select: function (event, ui) {

                        var terms = split(this.value);
                        // remove the current input
                        terms.pop();
                        // add the selected item
                        terms.push(ui.item.value);
                        // add placeholder to get the comma-and-space at the end
                        terms.push("");
                        this.value = terms.join(",");
                        return false;
                    }
                });
                function split(val) {
                    return val.split(/,\s*/);
                }
                function extractLast(term) {
                    return split(term).pop();
                }
            });
    </script>

    <script src="../plugins/datepicker/jquery-1.11.1.min.js"></script>

    <script language="javascript" src="../js/jquery.autocomplete.js" type="text/javascript"></script>

    <script src="../plugins/datepicker/bootstrap-datepicker.js"></script>

    <script>

        $(function () {
            $('#ctl00_BodyContentPH_txtFromDate').datetimepicker({ format: document.getElementById('ctl00_BodyContentPH_Hidden1').value }
            );
            $('#ctl00_BodyContentPH_txtToDate').datetimepicker({ format: document.getElementById('ctl00_BodyContentPH_Hidden1').value }
           );
        });

    </script>

    <script type="text/javascript">
        $(document).ready(function () {
            $("#<%=txtEmployeeId.ClientID%>").autocomplete('../AutoCompleteByEmployeeId.ashx?EmpAutoid=' + '<%= Convert.ToString(Session["EmpAutoID"]) %>', {
                multiple: true,
                multipleSeparator: ",",
                width: 180,
                highlight: false,
                scroll: true,
                scrollHeight: 300,
                delay: 10
            });
        });

        $(document).ready(function () {
            $("#<%=txtEmployeeName.ClientID%>").autocomplete('../AutoCompleteByName.ashx?EmpAutoid=' + '<%= Convert.ToString(Session["EmpAutoID"]) %>', {
                multiple: true,
                multipleSeparator: " ,",
                width: 380,
                highlight: false,
                scroll: true,
                scrollHeight: 300,
                delay: 10
            });
        });

    </script>

    <div class="content-header" id="conHeader" runat="server">
        <h1 style="background-image: url(../dist/img/swipe-icon.png); background-repeat: no-repeat; padding-left: 35px">
            <asp:Label ID="lblShiftReport" runat="server"></asp:Label>
            <asp:HiddenField ID="Hidden1" runat="server" />
            <asp:HiddenField ID="Hidden2" runat="server" />
            <asp:HiddenField ID="hdnReportFilters" runat="server" />
            <asp:HiddenField ID="hdnReportType1" runat="server" />
            <asp:HiddenField ID="hdnCompanyId1" runat="server" />
        </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 class="inr-fil-text">
                        <asp:Label ID="lblFilter" runat="server" Text="Filters"></asp:Label>
                        <asp:Label ID="Label1" runat="server" Visible="false"></asp:Label>
                        <input id="Hidden3" type="hidden" value='<% Response.Write(Convert.ToString(Session["IDateFormat"])); %>' />
                    </div>
                </div>
                <div class="clearfix">
                </div>
            </div>
        </div>
        <div id="collapseOne">
            <div class="emp-filter">
                <div class="form-horizontal">
                    <div id="divEmployeeDetails" runat="server">
                        <div class="row form-group">
                            <div class="col-md-2">

                                <asp:Label ID="lblEmployeeName" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txtEmployeeName" runat="server" CssClass="form-control"
                                    Style="resize: none;" TextMode="multiLine"></asp:TextBox>
                            </div>
                            <div class="col-md-1">
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lblEmployeeId" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txtEmployeeId" runat="server" CssClass="form-control"
                                    Style="resize: none;" TextMode="multiLine"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-2">
                                <asp:Label ID="lblEmpCategory" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:DropDownList ID="ddlEmpCatagory" runat="server" CssClass="form-control select2"
                                    AppendDataBoundItems="true">
                                    <asp:ListItem Value="0" Selected="True" Text="-Select-"></asp:ListItem>
                                </asp:DropDownList>
                            </div>
                            <div class="col-md-1">
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lblEmpType" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:DropDownList ID="ddlEmpType" runat="server" CssClass="form-control select2"
                                    AppendDataBoundItems="true">
                                    <asp:ListItem Value="0" Selected="True" Text="-Select-"></asp:ListItem>
                                </asp:DropDownList>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-2">
                                <asp:Label ID="lblDesignation" runat="server" Text="Designation"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:DropDownList ID="ddlDesignation" runat="server" CssClass="form-control select2"
                                    AppendDataBoundItems="true">
                                    <asp:ListItem Value="0" Selected="True" Text="All"></asp:ListItem>
                                </asp:DropDownList>
                            </div>
                            <div class="col-md-1">
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lblGender" runat="server" Text="Gender"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:DropDownList ID="ddlGender" runat="server" CssClass="form-control select2">
                                    <asp:ListItem Value="Both" Text="Both"></asp:ListItem>
                                    <asp:ListItem Value="Male" Text="Male"></asp:ListItem>
                                    <asp:ListItem Value="Female" Text="Female"></asp:ListItem>
                                </asp:DropDownList>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-2">
                                <asp:Label ID="lblTimePeriod" runat="server"></asp:Label>
                                -
                                <asp:Label ID="lblFrom" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txtFromDate" runat="server" CssClass="form-control"
                                    onCut="return false" onDrop="return false" MaxLength="11"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="reqFromDate" runat="server" ControlToValidate="txtFromDate"
                                    Display="None" EnableClientScript="False" ErrorMessage="Please select FromDate"></asp:RequiredFieldValidator>
                                <asp:CustomValidator ID="cus_FromDate" runat="server" EnableClientScript="False"
                                    OnServerValidate="ValidateFromDate" ErrorMessage="Select valid From Date" Display="None"></asp:CustomValidator>
                            </div>
                            <div class="col-md-1">
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lblTo" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txtToDate" runat="server" CssClass="form-control"
                                    onCut="return false" onDrop="return false" MaxLength="11"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="reqToDate" runat="server" ControlToValidate="txtToDate"
                                    Display="None" EnableClientScript="False" ErrorMessage="Please select ToDate"></asp:RequiredFieldValidator>
                                <asp:CustomValidator ID="cus_ToDate" OnServerValidate="ValidateToDate" runat="server"
                                    EnableClientScript="False" ErrorMessage="Select valid To Date" Display="None"></asp:CustomValidator>
                                <asp:CustomValidator ID="cus_ComToDate" runat="server" EnableClientScript="False"
                                    OnServerValidate="CompareDate" ErrorMessage="Select valid date compare with Fromdate"
                                    Display="None"></asp:CustomValidator>
                            </div>
                        </div>
                        <!-- This line add Karthick -->
                        <div class="row form-group">
                            <div class="col-md-2">
                                <asp:Label ID="lblShift" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:DropDownList ID="ddlShift" runat="server" CssClass="form-control select2">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ddlShift"
                                    Display="None" ErrorMessage="Select Shift"></asp:RequiredFieldValidator>
                            </div>
                            <div class="col-md-1">
                            </div>
                            <div class="col-md-2">
                            </div>
                            <div class="col-md-3">
                            </div>
                        </div>
                        <!-- End -->
                    </div>
                    <div class="clearfix">
                    </div>
                    <div class="row">
                        <div class="row">
                            <div class="line16">
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <asp:UpdatePanel ID="upOrgLevel" runat="server" UpdateMode="Conditional">
                                <ContentTemplate>
                                    <asp:PlaceHolder ID="PlaceHolderShift" runat="server">
                                        <uc:OrganizationLevel ID="ucOrganizationLevel" runat="server" />
                                    </asp:PlaceHolder>
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </div>
                    </div>
                    <div class="row form-group" id="trView" runat="server">
                        <div class="col-md-5">
                        </div>
                        <div class="col-md-6">
                            <div class="pull-right-button">
                                <asp:LinkButton ID="btn_View" CssClass="btn save-btn fa-eye" runat="server"
                                    OnClientClick="return DateEntryValidation()" OnClick="btn_View_Click" />

                            </div>
                        </div>
                    </div>
                    <div class="clearfix">
                    </div>
                    <div id="divNearestShift" runat="server" style="display: none">
                        <div class="row form-group" style="color: red">
                            <div class="col-md-4">
                                <asp:Label ID="lblASIT" runat="server" Style="color: red"></asp:Label>

                            </div>
                            <div class="col-md-4">
                                <asp:Label ID="lblSST" runat="server" Style="color: red"></asp:Label>
                            </div>
                            <div class="col-md-4">
                                <asp:Label ID="lblNMS" runat="server" Style="color: red"></asp:Label>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="table-responsive" style="padding-bottom: 10px; overflow: auto;">
                                    <asp:HiddenField ID="hdnSelectRow" runat="server" />
                                    <asp:HiddenField ID="hdnGetAllid" runat="server" />
                                    <dxGridview:ASPxGridView ID="grdNearestShift" EnableCallBacks="false" runat="server" 
                                        ClientInstanceName="grdNearestShift" AutoGenerateColumns="false"
                                        OnHtmlRowCreated="grdNearestShift_HtmlRowCreated" Width="100%" KeyFieldName="AutoID"
                                        Style="width: 100%; empty-cells: show; table-layout: fixed; overflow: hidden;">
                                        <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("AutoID") %>' />
                                                </DataItemTemplate>
                                                <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                            </dxGridview:GridViewDataColumn>
                                            <dxGridview:GridViewDataTextColumn FieldName="id" VisibleIndex="1" Width="90px">
                                                <DataItemTemplate>
                                                    <asp:Label ID="lblEmpid" runat="server" Text='<%# Eval("id") %>'></asp:Label>
                                                </DataItemTemplate>
                                                <Settings AllowAutoFilter="False" />
                                                <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                            </dxGridview:GridViewDataTextColumn>
                                            <dxGridview:GridViewDataTextColumn FieldName="Name" VisibleIndex="2" Width="200px">
                                                <DataItemTemplate>
                                                    <asp:Label ID="lblEmpname" runat="server" Text='<%# Eval("Name") %>' Style="overflow-y: auto; overflow-x: auto; cursor: pointer; word-break: break-all; word-wrap: break-word; display: inline-block;"></asp:Label>
                                                </DataItemTemplate>
                                                <Settings AllowAutoFilter="False" />
                                                <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                            </dxGridview:GridViewDataTextColumn>
                                            <dxGridview:GridViewDataTextColumn FieldName="Date" VisibleIndex="3" Width="100px">
                                                <DataItemTemplate>
                                                    <asp:Label ID="lblShiftDate" runat="server" Text='<%# Eval("Date") %>'></asp:Label>
                                                </DataItemTemplate>
                                                <Settings AllowAutoFilter="False" />
                                                <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                            </dxGridview:GridViewDataTextColumn>
                                            <dxGridview:GridViewDataTextColumn FieldName="ActualShiftIn" VisibleIndex="4" Width="70px">
                                                <DataItemTemplate>
                                                    <asp:Label ID="lblActualShiftIn" runat="server" Text='<%# Eval("ActualShiftIn") %>' Style="width: 100px"></asp:Label>
                                                </DataItemTemplate>
                                                <Settings AllowAutoFilter="False" />
                                                <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                            </dxGridview:GridViewDataTextColumn>
                                            <dxGridview:GridViewDataTextColumn FieldName="AllocatedShift" VisibleIndex="5" Width="80px">
                                                <DataItemTemplate>
                                                    <asp:Label ID="lblAllocatedShift" runat="server" Text='<%# Eval("AllocatedShift") %>'></asp:Label>
                                                </DataItemTemplate>
                                                <Settings AllowAutoFilter="False" />
                                                <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                            </dxGridview:GridViewDataTextColumn>
                                            <dxGridview:GridViewDataTextColumn FieldName="NearestShift" VisibleIndex="6" Width="184px">
                                                <DataItemTemplate>
                                                    <asp:Label ID="lblNearestShift" runat="server" Text='<%# Eval("NearestShift") %>'
                                                        Style="overflow-y: auto; overflow-x: auto; cursor: pointer; word-break: break-all; width: 180px; word-wrap: break-word; display: inline-block;"></asp:Label>
                                                </DataItemTemplate>
                                                <Settings AllowAutoFilter="False" />
                                                <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                            </dxGridview:GridViewDataTextColumn>
                                            <dxGridview:GridViewDataTextColumn FieldName="ShiftID" VisibleIndex="7" Width="200px">
                                                <DataItemTemplate>
                                                    <asp:DropDownList ID="ddlshift" runat="server" CssClass="form-control" Style="width: 150px">
                                                    </asp:DropDownList>
                                                </DataItemTemplate>
                                                <Settings AllowAutoFilter="False" />
                                                <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                            </dxGridview:GridViewDataTextColumn>
                                            <dxGridview:GridViewDataTextColumn FieldName="CompanyId" VisibleIndex="8" Visible="false">
                                                <DataItemTemplate>
                                                    <asp:Label ID="lblCompanyId" runat="server" Text='<%# Eval("CompanyId") %>'></asp:Label>
                                                </DataItemTemplate>
                                            </dxGridview:GridViewDataTextColumn>
                                            <dxGridview:GridViewDataTextColumn FieldName="EmployeeAutoID" VisibleIndex="9">
                                                <HeaderStyle CssClass="clumndisplay" />
                                                <CellStyle CssClass="clumndisplay"></CellStyle>
                                                <DataItemTemplate>
                                                    <asp:Label ID="lblEmployeeAutoID" runat="server" Text='<%# Eval("EmployeeAutoID") %>'></asp:Label>
                                                </DataItemTemplate>
                                            </dxGridview:GridViewDataTextColumn>
                                            <dxGridview:GridViewDataTextColumn FieldName="ShiftID" VisibleIndex="10" Visible="false">
                                                <DataItemTemplate>
                                                    <asp:Label ID="lblNearestShiftid" runat="server" Text='<%# Eval("ShiftID") %>'></asp:Label>
                                                </DataItemTemplate>
                                            </dxGridview:GridViewDataTextColumn>
                                            <dxGridview:GridViewDataTextColumn FieldName="Format" VisibleIndex="10" Width="100px">
                                                <DataItemTemplate>
                                                    <asp:Label ID="lblFormat" runat="server" Text='<%# Eval("Format") %>'></asp:Label>
                                                </DataItemTemplate>
                                                <HeaderStyle CssClass="clumndisplay" />
                                                <CellStyle CssClass="clumndisplay"></CellStyle>
                                            </dxGridview:GridViewDataTextColumn>
                                        </Columns>
                                        <Settings ShowVerticalScrollBar="True" VerticalScrollableHeight="460" />
                                        <SettingsPager Mode="ShowAllRecords">                                            
                                        </SettingsPager>
                                        <SettingsText EmptyDataRow="No Records Found" />
                                        <Settings ShowFilterRow="false" />
                                        <SettingsBehavior AllowSort="false" AllowDragDrop="false" />
                                        <Styles AlternatingRow-CssClass="table-bg" Header-Wrap="True">
                                        </Styles>
                                        <%--<ClientSideEvents Init="OnInit" EndCallback="OnEndCallback" />--%>
                                    </dxGridview:ASPxGridView>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="pull-right-button">
                                    <asp:LinkButton ID="btnSave" CssClass="btn save-btn fa-floppy-o" runat="server" Visible="false"
                                        CausesValidation="true" OnClientClick="$find('popupProgress').show();"
                                        OnClick="btnSave_Click" Style="margin-top: 15px" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <style type="text/css">
        .clumndisplay {
            display: none;
        }
    </style>
    <script type="text/javascript" language="javascript">
        //function OnInit(s, e) {

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

        //function OnColumnSorting(s, e) {
        //    AdjustSize();
        //}
        //function AdjustSize() {

        //    var height = Math.max(0, document.documentElement.clientHeight);
        //    var width = Math.max(0, document.documentElement.clientWidth);
        //    grid.SetHeight(height);
        //    grid.setWidth(width);
        //}


        function SelectAllOnThisPage(chkSelectAll) {

            var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
            var hdnSelectAll = document.getElementById('<%= hdnGetAllid.ClientID %>');
            if (chkSelectAll.checked == true) {
                for (var i = 0; i < grdNearestShift.pageRowCount; i++) {
                    if (document.getElementById('ctl00_BodyContentPH_grdNearestShift_cell' + (i + grdNearestShift.visibleStartIndex) + '_0_chkSelect').disabled == false) {
                        document.getElementById('ctl00_BodyContentPH_grdNearestShift_cell' + (i + grdNearestShift.visibleStartIndex) + '_0_chkSelect').checked = true;
                        var hdnUserId = document.getElementById('ctl00_BodyContentPH_grdNearestShift_cell' + (i + grdNearestShift.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 < grdNearestShift.pageRowCount; i++) {
                    document.getElementById('ctl00_BodyContentPH_grdNearestShift_cell' + (i + grdNearestShift.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 < grdNearestShift.pageRowCount; i++) {
                    if (document.getElementById('ctl00_BodyContentPH_grdNearestShift_cell' + (i + grdNearestShift.visibleStartIndex) + '_0_chkSelect').checked)
                        varTotalCheckedCount = varTotalCheckedCount + 1;
                    else
                        break;
                }
                if (varTotalCheckedCount == grdNearestShift.pageRowCount)
                    document.getElementById('ctl00_BodyContentPH_grdNearestShift_header0_chkSelectAll').checked = true;
                else
                    document.getElementById('ctl00_BodyContentPH_grdNearestShift_header0_chkSelectAll').checked = false;
            }
            else {
                if (Array.contains(removeId, hdnUserId)) {
                    Array.remove(removeId, hdnUserId);
                }
                hdnSelectRow.value = removeId;

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

        //values for check date
        var Monthfourdigit = 'Please enter valid date as month, day, and four digit year : Format MM/dd/yyyy.';
        //Adding this line var Datefourdigit='Please enter valid date with correct format dd/MM/yyyy'; as newly
        var Datefourdigit = 'Please enter valid date with correct format dd/MM/yyyy';
        var Invalidyearentry = 'Invalid year entry';
        var Invalidmonthentry = 'Invalid month entry';
        var Invaliddateentry = 'Invalid date entry';
        var DateformatDDMONYYYY = 'Incorrect date format. Enter as DD-MON-YYYY';
        var Entertime = 'Enter time';
        var Valueforhours = 'Invalid value for hours:';
        var Invalidvalueforminutes = 'Invalid value for minutes:';
        var Invalidtimeformat = 'Invalid time format:';
        var EntervalidDateandTime = 'Please enter valid Date and Time';
        var ValiddatemonthMMDDYYHHMM = 'Please enter valid Date and Time MM/dd/yyyy HH:mm';
        var ValiddatemonthMMDDYYHHMMTT = 'Please enter valid Date and Time MM/dd/yyyy hh:mm tt';
        var EntervalidDateandTime = 'Please enter valid Date and Time';
        var Invalidvalueforhours = 'Invalid value for hours:';
        var Invalidvalueforminites = 'Invalid value for minutes:';
        var FromDate = "Enter Valid From Date";
        var MaxLength = "Maximum length is ";


        function MaxLengthh(maxLength) {

            MaxLength = maxLength;
        }


        function SetAlertCheckDate(monthfourdigit, datefourdigit, invalidyearentry, invalidmonthentry, invaliddateentry, dateformatDDMONYYYY, entertime, valueforhours, invalidvalueforminutes, invalidtimeformat, entervalidDateandTime, validdatemonthMMDDYYHHMM, validdatemonthMMDDYYHHMMTT, entervalidDateandTime, invalidvalueforhours, invalidvalueforminites) {
            Monthfourdigit = monthfourdigit;
            Datefourdigit = datefourdigit;
            Invalidyearentry = invalidyearentry;
            Invalidmonthentry = invalidmonthentry;
            Invaliddateentry = invaliddateentry;
            DateformatDDMONYYYY = dateformatDDMONYYYY;
            Entertime = Entertime;
            Valueforhours = valueforhours;
            Invalidvalueforminutes = invalidvalueforminutes;
            Invalidtimeformat = invalidtimeformat;
            EntervalidDateandTime = entervalidDateandTime;
            ValiddatemonthMMDDYYHHMM = validdatemonthMMDDYYHHMM;
            ValiddatemonthMMDDYYHHMMTT = validdatemonthMMDDYYHHMMTT;
            EntervalidDateandTime = entervalidDateandTime;
            Invalidvalueforhours = invalidvalueforhours;
            Invalidvalueforminites = invalidvalueforminites;
        }


        function SetAlertMessages(fromdate) {

            FromDate = fromdate;


        }
        function DateEntryValidation() {
            var FillFromandToDate = "Please enter both the From and To Date";
            var weekDay = document.aspnetForm.ctl00_BodyContentPH_txtFromDate;
            var weekDay2 = document.aspnetForm.ctl00_BodyContentPH_txtToDate;
            var DateFormat = document.getElementById('ctl00_BodyContentPH_Hidden1').value;
            if ((document.getElementById('ctl00_BodyContentPH_txtFromDate').value == '') || (document.getElementById('ctl00_BodyContentPH_txtToDate').value == '')) {
                alert(FillFromandToDate);
                return false;
            }
            if (weekDay.value != '') {
                if (checkDate(weekDay, DateFormat, Monthfourdigit, Datefourdigit, Invalidyearentry, Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours, Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime, ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, EntervalidDateandTime, Invalidvalueforhours, Invalidvalueforminites)) {
                    if (weekDay2.value != '') {
                        if (checkDate(weekDay2, DateFormat, Monthfourdigit, Datefourdigit, Invalidyearentry, Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours, Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime, ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, EntervalidDateandTime, Invalidvalueforhours, Invalidvalueforminites)) {
                        }
                        else {
                            return false;
                        }
                    }
                }
                else {
                    return false;
                }
            }

        }

    </script>
</asp:Content>

