<%@ page language="C#" masterpagefile="~/MasterFile/TimeCheck.master" autoeventwireup="true" enableeventvalidation="false" inherits="Transactions_TA_UI_Transactions_OnDutyAdd, App_Web_kd00jig5" %>

<%@ Register TagPrefix="dxGridview" Namespace="DevExpress.Web" Assembly="DevExpress.Web.v14.2" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="BodyContentPH" runat="Server">
    <!--[if gt IE 5.5]>
	<link rel="stylesheet" type="text/css" href="../css/ProgressforIE.css" />
	<link rel="stylesheet" type="text/css" href="../css/anytimeIE.css" />
<![endif]-->
    <script type="text/javascript" language="javascript">
        function ValidateFileUploader() {
            var array = ['csv'];
            var xyz = document.getElementById('<%= fup_ShiftImport.ClientID %>');
            if (xyz.value != '') {
                var Extension = xyz.value.substring(xyz.value.lastIndexOf('.') + 1).toLowerCase();
                if (array.indexOf(Extension) <= -1) {
                    alert("The Uploaded file is not an CSV file");
                    return false;
                }
            }
            else {
                alert("You have not specified a file");
                return false;
            }
            return true;
        }
        //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 by Manjula.P on 15-Feb-2014
        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 InvalidTime = "Invalid time.";
        var InvalidTimeFormat = "Invalid Time Format";
        var InValidHour = "Invalid time. Hours can not be more than 24.";
        var Invalidtime = "Invalid time. Minute can not be more than 59.";
        var SelTerminal = "Select In Terminal";
        var SelPunchTypes = "Select In PunchTypes";
        var FillIndate = "Fill In Date";
        var FillInTime = "Fill In Time";
        var SelOutTerminal = "Select Out Terminal";
        var RouteName = "Select Route Name";
        //Changed the time validation message by Manjula.P on 17-Feb-2014
        var InTimeCorrectFormat = "Enter Start Time correct Format";
        var OutTimeFormat = "Enter valid time format";
        //**********************************************************  
        var ConfirmSave = "Are you sure to, Save?";
        var FillOutDate = "Fill Out Date";
        var FillOutTime = "Fill Out Time";
        var SelectInDate = "Select InDate";
        var SelecttheRouteName = "Select the Route Name";
        var NoRecords = "No Records";
        var Errorinretrivingdetails = "Error in retriving details";
        var SelectEntranceID = "Select Entrance ID";
        var SelectOutPunchType = "Select Out Punch Type";
        var MaxLength = "Maximum length is ";
        var Select = "-Select-";
        var EntertheEmployeeID = "Enter the Employee ID";
        var SelectShiftDate = "Select OnDuty Date";
        var SelectStartTime = "Select Start Time";
        var SelectEndTime = "Select End Time";
        var EntertheReason = "Enter the Reason";
        var SelectFromDate = "Select From Date";
        var SelectFromsession = "Select From session";
        var SelectToDate = "Select To Date";
        var SelectTosession = "Select To session";
        function ModeOfAllocation() {
            if (document.getElementById('ctl00_BodyContentPH_rbtnManual').checked == true) {
                document.getElementById("ctl00_BodyContentPH_divManual").style.display = "block";
                document.getElementById("ctl00_BodyContentPH_divImport").style.display = "none";
                document.getElementById("div_Employee").style.display = "block";
                document.getElementById("ctl00_BodyContentPH_lblManCount").textContent = "5";
            }
            else if (document.getElementById('ctl00_BodyContentPH_rbtnImport').checked == true) {
                document.getElementById("ctl00_BodyContentPH_divManual").style.display = "none";
                document.getElementById("ctl00_BodyContentPH_divImport").style.display = "block";
                document.getElementById("div_Employee").style.display = "none";
                document.getElementById("ctl00_BodyContentPH_lblManCount").textContent = "1";
            }
            return true;
        }
        function MaxLengthh(maxLength, select) {
            MaxLength = maxLength;
            Select = select;
        }
        function SetAlertCheckDate(monthfourdigit, datefourdigit, invalidyearentry, invalidmonthentry, invaliddateentry, dateformatDDMONYYYY, entertime, valueforhours, invalidvalueforminutes, invalidtimeformat, entervalidDateandTime, validdatemonthMMDDYYHHMM, validdatemonthMMDDYYHHMMTT, entervalidDateandTime, invalidvalueforhours, invalidvalueforminites) {
            Monthfourdigit = monthfourdigit;
            //Added by MAnjula.P on 17-Feb-2014
            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(invalidTime, TimeFormat, HourInvalid, timeInvalid, Terminal, PunchTypes, InDate, InTime, OutTerminal, Route, CorrectFormat, TimeFormat, SaveConfirm, OutDate, OutTime, selectInDate, selecttheRouteName, noRecords, errorinretrivingdetails, selectEntranceID, selectOutPunchType, entertheEmployeeID, selectShiftDate, selectStartTime, selectEndTime, entertheReason, selectFromDate, selectFromsession, selectToDate, selectTosession) {
            InvalidTime = invalidTime;
            InvalidTimeFormat = TimeFormat;
            InValidHour = HourInvalid;
            Invalidtime = timeInvalid;
            SelTerminal = Terminal;
            SelPunchTypes = PunchTypes;
            FillIndate = InDate;
            FillInTime = InTime;
            SelOutTerminal = OutTerminal;
            RouteName = Route;
            InTimeCorrectFormat = CorrectFormat;
            FormatTime = TimeFormat;
            ConfirmSave = SaveConfirm;
            FillOutDate = OutDate;
            FillOutTime = OutTime;
            SelectInDate = selectInDate;
            SelecttheRouteName = selecttheRouteName;
            NoRecords = noRecords;
            Errorinretrivingdetails = errorinretrivingdetails;
            SelectEntranceID = selectEntranceID;
            SelectOutPunchType = selectOutPunchType;
            EntertheEmployeeID = entertheEmployeeID;
            SelectShiftDate = selectShiftDate;
            SelectStartTime = selectStartTime;
            SelectEndTime = selectEndTime;
            EntertheReason = entertheReason;
            SelectFromDate = selectFromDate;
            SelectFromsession = selectFromsession;
            SelectToDate = selectToDate;
            SelectTosession = selectTosession;
        }
        function ValidateTime(inIntime) {
            var keyValue;
            if (window.event) {
                keyValue = window.event.keyCode;
                //         alert(keyValue); 
            }
            else if (inIntime) {
                keyValue = inIntime.which
            }
            else {
                return true;
            }
            if ((keyValue > 47 && keyValue < 58) || (keyValue >= 96 && keyValue <= 105) || (keyValue >= 32 && keyValue <= 40) || (keyValue >= 16 && keyValue <= 20) || (keyValue == 8) || (keyValue == 0) || (keyValue == 46)) {
                var InTime;
                var val = inIntime.value;
                if ((keyValue > 47 && keyValue < 58) || (keyValue >= 96 && keyValue <= 105)) {
                    if (val.length >= 2 && val.length < 5) {
                        if (val.search(":") == -1) {
                            InTime = val.substring(0, 2) + ":" + val.substring(2, 5);
                            inIntime.value = InTime;
                            return (inIntime.value);
                        }
                    }
                    if (val.length > 5) {
                        alert(InvalidTime);
                        insertAtCursor(inIntime, "0", "min");
                        return false;
                    }
                    //              if(val.length > 5)
                    //               {
                    //                   InTime = val.removeAt(6);
                    //                   inIntime.value = InTime;
                    //                   return(inIntime.value);
                    //               }              
                }
                if (keyValue == 0) {
                    if (val.length < 5) {
                        if (val.length == 4) {
                            if (val.search(":") == -1) {
                                InTime = val.substring(0, 2) + ":" + val.substring(2, 5);
                                inIntime.value = InTime;
                                return (inIntime.value);
                            }
                            else {
                                insertAtCursor(inIntime, "0", "first");
                                alert(InvalidTimeFormat);
                                return false;
                            }
                        }
                        else {
                            insertAtCursor(inIntime, "0", "first");
                            alert(InvalidTimeFormat);
                            return false;
                        }
                    }
                    if (val.length >= 2) {
                        var Hourval = val.substring(0, 2);
                        if (Hourval > 24) {
                            alert(InValidHour);
                            insertAtCursor(inIntime, "0", "hrs");
                            return false;
                        }
                        if (val.substring(0, 2) == "24") {
                            inIntime.value = "00" + val.substring(2, 5);
                        }
                        if (val.search(":") == -1) {
                            InTime = val.substring(0, 2) + ":" + val.substring(2, 5);
                            inIntime.value = InTime;
                            return (inIntime.value);
                        }
                    }
                    if (val.length == 5) {
                        var Minuteval = val.substring(3, 5);
                        if (parseFloat(Minuteval) > 59) {
                            alert(Invalidtime);
                            insertAtCursor(inIntime, "0", "min");
                            return false;
                        }
                    }
                }
                if (val.length == 2) {
                    if (val.substring(0, 1) == ":") {
                        InTime = val.substring(1, 2) + ":";
                        inIntime.value = InTime;
                        return (inIntime.value);
                    }
                    else if (val.substring(1, 2) == ":") {
                        InTime = val.substring(0, 1) + ":";
                        inIntime.value = InTime;
                        return (inIntime.value);
                    }
                }
                else {
                    return (inIntime.value);
                }
            }
            else {
                inIntime.value = "";
                return (inIntime.value);
            }
        }
        function insertAtCursor(myField, myValue, myType) {
            //IE support
            if (document.selection) {
                myField.focus();
                sel = document.selection.createRange();
                //    sel.text = myValue;
            }
                //MOZILLA/NETSCAPE support
            else if (myField.selectionStart || myField.selectionStart == '0') {
                var startPos = myField.selectionStart;
                var endPos = myField.selectionEnd;
                myField.value = myField.value.substring(0, startPos)
        //        + myValue
                + myField.value.substring(endPos, myField.value.length);
            } else {
                myField.value += myValue;
            }
            if (myType == "hrs") {
                setCaretPosition(myField, 2);
            }
            if (myType == "min") {
                setCaretPosition(myField, 3);
            }
            if (myType == "first") {
                setCaretPosition(myField, 0);
            }
        }
        function setCaretPosition(ctrl, pos) {
            if (ctrl.setSelectionRange) {
                ctrl.focus();
                ctrl.setSelectionRange(pos, pos);
            }
            else if (ctrl.createTextRange) {
                var range = ctrl.createTextRange();
                range.collapse(true);
                range.moveEnd('character', pos);
                range.moveStart('character', pos);
                range.select();
            }
        }
        function show() {
            if (document.aspnetForm.ctl00_BodyContentPH_rbtSingle.checked == true) {
                document.getElementById("div_Employee").style.display = "block";
                document.getElementById("div_Route").style.display = "none";
                document.getElementById("divGroupEntryType").style.display = "none";
                document.getElementById("divEmployees").style.display = "none";
                document.aspnetForm.ctl00_BodyContentPH_txt_EmployeeId.focus();
            }
            else if (document.aspnetForm.ctl00_BodyContentPH_rbtGroup.checked == true) {
                document.getElementById("divGroupEntryType").style.display = "block";
                document.getElementById("div_Employee").style.display = "none";
                if (document.aspnetForm.ctl00_BodyContentPH_rbtBusLate.checked == true) {
                    document.getElementById("div_Route").style.display = "block";
                    document.getElementById("divEmployees").style.display = "none";
                }
                else if (document.aspnetForm.ctl00_BodyContentPH_rbtOnDuty.checked == true) {
                    document.getElementById("div_Route").style.display = "none";
                    document.getElementById("div_Employee").style.display = "block";
                }
                // document.aspnetForm.ctl00_BodyContentPH_ddlEntranceName.focus();  
            }
        }
        function show1() {
            if (document.aspnetForm.ctl00_BodyContentPH_rbtGroup.checked == true) {
                document.getElementById("divGroupEntryType").style.display = "block";
                document.aspnetForm.ctl00_BodyContentPH_rbtBusLate.checked = true;
                document.getElementById("div_Route").style.display = "block";
                document.getElementById("divEmployees").style.display = "none";
                document.getElementById("div_Employee").style.display = "none";
            }
        }
        function FillInPunchTypeHidden() {
            var InPunchType;
            var InPunchTypeSelectedIndex = document.aspnetForm.ctl00_BodyContentPH_ddlInPunchTypes.selectedIndex;
            InPunchType = document.aspnetForm.ctl00_BodyContentPH_ddlInPunchTypes.options[InPunchTypeSelectedIndex].text;
            // InPunchType = document.aspnetForm.ctl00_BodyContentPH_ddlInPunchTypes.options[InPunchTypeSelectedIndex].value;
            document.aspnetForm.ctl00_BodyContentPH_hdn_InPunchType.value = InPunchType;
        }
        function FillOutPunchTypeHidden() {
            var OutPunchType;
            var OutPunchTypeSelectedIndex = document.aspnetForm.ctl00_BodyContentPH_ddlOutPunchTypes.selectedIndex;
            OutPunchType = document.aspnetForm.ctl00_BodyContentPH_ddlOutPunchTypes.options[OutPunchTypeSelectedIndex].text;
            // OutPunchType = document.aspnetForm.ctl00_BodyContentPH_ddlOutPunchTypes.options[OutPunchTypeSelectedIndex].value;
            document.aspnetForm.ctl00_BodyContentPH_hdn_OutPunchType.value = OutPunchType;
        }
        function ClearInDate() {
            document.aspnetForm.ctl00_BodyContentPH_txt_InDate.value = "";
            return false;
        }
        function ClearInTime() {
            document.aspnetForm.ctl00_BodyContentPH_txt_ShiftIn.value = "";
            return false;
        }
        function ClearOutDate() {
            document.aspnetForm.ctl00_BodyContentPH_txt_OutDate.value = "";
            return false;
        }
        function ClearOutTime() {
            document.aspnetForm.ctl00_BodyContentPH_txt_ShiftOut.value = "";
            return false;
        }
        function ManualEntryValidation() {
            var InTerminals = document.getElementById('ctl00_BodyContentPH_ddlInTerminals').selectedIndex;
            var InPunchTypes = document.getElementById('ctl00_BodyContentPH_ddlInPunchTypes').selectedIndex;
            var DateFormat = document.getElementById('ctl00_BodyContentPH_Hidden1').value;
            var txt_EmployeeId = document.getElementById('ctl00_BodyContentPH_txt_EmployeeId');
            var ddlEntranceName = document.getElementById('ctl00_BodyContentPH_ddlEntranceName');
            var ddlFromSeesion = document.getElementById('ctl00_BodyContentPH_ddl_SessionFrom');
            if (document.getElementById('ctl00_BodyContentPH_rbSingleDayYes').checked == true) {
                var Shiftdate = document.getElementById('ctl00_BodyContentPH_txt_ShiftDate').value;
                var ShiftDay = document.aspnetForm.ctl00_BodyContentPH_txt_ShiftDate;
                //*****************************
                var txt_Reason = document.getElementById('ctl00_BodyContentPH_txt_Reason');
                var ShiftIn = document.getElementById('ctl00_BodyContentPH_txt_ShiftIn').value;
                var ShiftOut = document.getElementById('ctl00_BodyContentPH_txt_ShiftOut').value;
                var weekDay = document.aspnetForm.ctl00_BodyContentPH_txt_ShiftIn;
                var weekDay2 = document.aspnetForm.ctl00_BodyContentPH_txt_ShiftOut;
                //*************************************************
                if (txt_EmployeeId != null) {
                    if (txt_EmployeeId.value.length == 0) {
                        alert(EntertheEmployeeID);
                        return false;
                    }
                }
                if (Shiftdate == "") {
                    alert(SelectShiftDate);
                    return false;
                }
                if (ShiftIn == "") {
                    alert(SelectStartTime);
                    return false;
                }
                if (ShiftOut == "") {
                    alert(SelectEndTime);
                    return false;
                }
                if (txt_Reason.value.trim() == '') {
                    alert(EntertheReason);
                    return false;
                }
                var regExp = "^((([0]?[1-9]|1[0-2])(:|\.)[0-5][0-9]((:|\.)[0-5][0-9])?( )?(AM|am|aM|Am|PM|pm|pM|Pm))|(([0]?[0-9]|1[0-9]|2[0-3])(:|\.)[0-5][0-9]((:|\.)[0-5][0-9])?))$";
                var TimeFormat = document.getElementById('ctl00_BodyContentPH_Hidden2').value;
                var length = 0;
                if (TimeFormat != "LT") {
                    length = 8;
                    regExp = "^(([0]?[0-9]|1[0-9]|2[0-3])(:|\.)[0-5][0-9]((:|\.)[0-5][0-9])?)$";
                }
                else {
                    length = 8;
                    regExp = "^(([0]?[1-9]|1[0-2])(:|\.)[0-5][0-9]((:|\.)[0-5][0-9])?( )?(AM|am|aM|Am|PM|pm|pM|Pm))$";
                }
                if (Shiftdate != "") {
                    if (checkDate(ShiftDay, DateFormat, Monthfourdigit, Datefourdigit, Invalidyearentry, Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours, Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime, ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, EntervalidDateandTime, Invalidvalueforhours, Invalidvalueforminites)) {
                    }
                    else {
                        document.getElementById("<%=txt_ShiftDate.ClientID%>").focus();
                        return false;
                    }
                }
            }
            if (document.getElementById('ctl00_BodyContentPH_rbSingleDayNo').checked == true) {
                var Session1 = document.getElementById('ctl00_BodyContentPH_ddl_SessionFrom').selectedIndex;
                var Session2 = document.getElementById('ctl00_BodyContentPH_ddl_SessionTo').selectedIndex;
                var FromDate = document.getElementById('ctl00_BodyContentPH_txt_InDate').value;
                var ToDate = document.getElementById('ctl00_BodyContentPH_txt_OutDate').value;
                //Added by MAnjula.P on 17-Feb-2014
                var InDay = document.aspnetForm.ctl00_BodyContentPH_txt_InDate;
                var OutDay = document.aspnetForm.ctl00_BodyContentPH_txt_OutDate;
                //****************************
                var txt_Reason = document.getElementById('ctl00_BodyContentPH_txt_Reason');
                if (txt_EmployeeId != null) {
                    if (txt_EmployeeId.value.length == 0) {
                        alert(EntertheEmployeeID);
                        return false;
                    }
                }
                if (FromDate == "") {
                    alert(SelectFromDate);
                    return false;
                }
                if (Session1 == 0) {
                    alert(SelectFromsession);
                    return false;
                }
                if (ToDate == "") {
                    alert(SelectToDate);
                    return false;
                }
                if (Session2 == 0) {
                    alert(SelectTosession);
                    return false;
                }
                if (txt_Reason.value.length == 0) {
                    alert(EntertheReason);
                    return false;
                }
                var rangeDemoFormat = document.getElementById('ctl00_BodyContentPH_Hidden1').value;
                var rangeDemoFormats = document.getElementById('ctl00_BodyContentPH_hiddenTime').value;
                if (document.getElementById('ctl00_BodyContentPH_rbtSingle').checked == true) {
                    if (txt_EmployeeId.value.length == 0) {
                        alert(EntertheEmployeeID);
                        return false;
                    }
                }
                else {
                    if (document.getElementById('ctl00_BodyContentPH_rbtOnDuty').checked == true) {
                        if (txt_EmployeeId.value.length == 0) {
                            alert(EntertheEmployeeID);
                            return false;
                        }
                        //Aded by Manjula.P on 17-Feb-2014
                        if (FromDate != "") {
                            if (checkDate(InDay, DateFormat, Monthfourdigit, Datefourdigit, Invalidyearentry, Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours, Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime, ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, EntervalidDateandTime, Invalidvalueforhours, Invalidvalueforminites)) {
                            }
                            else {
                                document.getElementById("<%=txt_InDate.ClientID%>").focus();
                                return false;
                            }
                        }
                        if (ToDate != "") {
                            if (checkDate(OutDay, DateFormat, Monthfourdigit, Datefourdigit, Invalidyearentry, Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours, Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime, ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, EntervalidDateandTime, Invalidvalueforhours, Invalidvalueforminites)) {
                            }
                            else {
                                document.getElementById("<%=txt_OutDate.ClientID%>").focus();
                                return false;
                            }
                        }
                    }
                }
                if (txt_Reason.value.length == 0) {
                    alert(EntertheReason);
                    return false;
                }
            }
            if (confirm(ConfirmSave) == true) {
                return true;
            }
            else {
                return false;
            }
        }
    </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 language="javascript" src="../js/ShiftExchange.js" type="text/javascript"></script>
    <script language="javascript" src="../js/DateTimeValidation.js" type="text/javascript"></script>
    <script language="javascript" src="../js/EmployeeNameAjax.js" type="text/javascript"></script>
    <script>
        $(function () {
            $('#ctl00_BodyContentPH_txt_ShiftDate').datetimepicker({ format: document.getElementById('ctl00_BodyContentPH_Hidden1').value }
            );
        });
        $(function () {
            $('#ctl00_BodyContentPH_txt_OutDate').datetimepicker({ format: document.getElementById('ctl00_BodyContentPH_Hidden1').value }
            );
        });
        $(function () {
            $('#ctl00_BodyContentPH_txt_InDate').datetimepicker({ format: document.getElementById('ctl00_BodyContentPH_Hidden1').value }
            );

        });
        //$(function () {
        //    $('#ctl00_BodyContentPH_txt_InDate').datetimepicker({
        //        format: document.getElementById('ctl00_BodyContentPH_Hidden1').value,
        //        onSelect: function () {
        //            // Trigger the postback manually when the date is changed
        //            __doPostBack('ctl00$BodyContentPH$txt_InDate', '');
        //        }
        //    });
        //});
        $(function () {
            $('#ctl00_BodyContentPH_txt_ShiftIn').datetimepicker({ format: document.getElementById('ctl00_BodyContentPH_Hidden2').value }
            );
        });
        $(function () {
            $('#ctl00_BodyContentPH_txt_ShiftOut').datetimepicker({ format: document.getElementById('ctl00_BodyContentPH_Hidden2').value }
            );
        });

    </script>
    <script type="text/javascript">
        function datePicker() {
            debugger;
            // Get the value from the txt_InDate TextBox
            var fromDate = document.getElementById('<%= txt_InDate.ClientID %>').value;
            
            // Check if the date value is valid
            if (!fromDate) {
                alert("Please enter a valid InDate.");
                return;
            }

            // Parse InDate to standard format (yyyy/MM/dd)
            var fromDateStandard = convertToStandardFormat(fromDate);
            if (!fromDateStandard) {
                alert("Invalid InDate format. Please enter a valid date.");
                return;
            }

            // Get the YearToDate hidden field value
            var yearToDate = document.getElementById('<%= hdnYearToDate.ClientID %>').value;
            var fromPPValidate=document.getElementById('<%= hdnPPValidateDate.ClientID %>').value;
            if (!yearToDate) {
                alert("YearToDate is not provided.");
                return;
            }

            // Parse YearToDate to standard format
            var yearToDateStandard = convertToStandardFormat(extractDatePart(yearToDate));
            var fromPPValidateStandard = convertToStandardFormat(extractDatePart(fromPPValidate));
            if (!yearToDateStandard) {
                alert("Invalid YearToDate format. Please verify the input.");
                return;
            }

            // Convert fromDateStandard to a Date object
            var toDate = new Date(fromDateStandard);
            var rbPML = document.getElementById('<%= rbPML.ClientID %>');

            if (rbPML.checked) {
                // Calculate ToDate by adding 60 days
                var NumofDays = document.getElementById('<%= hdnNumofWFHDays.ClientID %>').value;
                if (NumofDays==0) {
                    toDate.setDate(toDate.getDate() + 59);
                } else {
                    NumofDays = 59 - NumofDays;
                    toDate.setDate(toDate.getDate() + NumofDays);
                }
            } else {

                // Calculate ToDate by adding 14 days
                debugger;
                //   toDate.setDate(toDate.getDate() + 13);
                if (fromPPValidateStandard > fromDateStandard) {
                    alert('Your Eligible Post Paternity – Work from Home Start date will be ' + formatDate(new Date(fromPPValidateStandard), getDateFormat(fromDate)));
                    return false;
                }

            }

            // Format toDate as "yyyy/MM/dd" explicitly
            var toDateStandard = toDate.getFullYear() + '/' + (toDate.getMonth() + 1).toString().padStart(2, '0') + '/' + toDate.getDate().toString().padStart(2, '0');

            // Now call convertToStandardFormat with the formatted date string
            toDateStandard = convertToStandardFormat(toDateStandard);

            // Ensure toDate does not exceed yearToDateStandard
            if (toDateStandard > yearToDateStandard) {
                toDateStandard = yearToDateStandard;
            }

            // Convert toDate back to the desired format
            var formattedToDate = formatDate(new Date(toDateStandard), getDateFormat(fromDate));

            // Bind ToDate value to the txt_OutDate TextBox
            document.getElementById('<%= txt_OutDate.ClientID %>').value = formattedToDate;
            document.getElementById('<%= hdnOutDate.ClientID %>').value = formattedToDate;
        }

         function ToDateValidateForPP() {
            debugger;
            var FroMDate = document.getElementById('<%= txt_InDate.ClientID %>').value;
             var ToDate = document.getElementById('<%= txt_OutDate.ClientID %>').value;

             var fromDateStandard = convertToStandardFormat(FroMDate);
             var toDateStandard = convertToStandardFormat(ToDate);


             var validateToDate = new Date(fromDateStandard);

             var NumofDays = document.getElementById('<%= hdnNumofWFHDays.ClientID %>').value;

             if (validateToDate != '') {
                 validateToDate.setDate(validateToDate.getDate() + 27);
             }
             var validateToDateStandard = validateToDate.getFullYear() + '/' + (validateToDate.getMonth() + 1).toString().padStart(2, '0') + '/' + validateToDate.getDate().toString().padStart(2, '0');

             // Now call convertToStandardFormat with the formatted date string
             validateToDateStandard = convertToStandardFormat(validateToDateStandard);
             if (validateToDateStandard < toDateStandard ) {
                 alert('As Per Policy only Applicable for Maximum 28 Days');
                 return false;
             }
        }


        function extractDatePart(dateTimeString) {
            // Extract the date part from "MM/DD/YYYY HH:MM:SS AM/PM"
            var parts = dateTimeString.split(" ");
            return parts[0]; // Return "MM/DD/YYYY"
        }

        function convertToStandardFormat(dateString) {
            var date = parseDate(dateString);
            if (!date) return null;

            return formatDate(date, "yyyy/MM/dd");
        }

        function parseDate(dateString) {
            // Handle "dd-MMM-yyyy" format
            var regexDDMMMYYYY = /^\d{2}-[A-Za-z]{3}-\d{4}$/; // dd-MMM-yyyy
            var regexMMDDYYYY = /^\d{2}\/\d{2}\/\d{4}$/; // MM/dd/yyyy
            var regexYYYYMMDD = /^\d{4}\/\d{2}\/\d{2}$/; // yyyy/MM/dd
            var regexDDMMYYYY = /^\d{2}\/\d{2}\/\d{4}$/; // dd/MM/yyyy

            var dateObject;

            // Check if the format matches dd-MMM-yyyy
            if (regexDDMMMYYYY.test(dateString)) {
                var parts = dateString.split('-');
                var day = parts[0];
                var monthName = parts[1];
                var year = parts[2];

                var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
                var monthIndex = months.indexOf(monthName);
                dateObject = new Date(year, monthIndex, day);
            }
                // Check if the format matches MM/dd/yyyy
            else if (regexMMDDYYYY.test(dateString)) {
                var parts = dateString.split('/');
                dateObject = new Date(parts[2], parts[0] - 1, parts[1]);
            }
                // Check if the format matches dd/MM/yyyy
            else if (regexDDMMYYYY.test(dateString)) {
                var parts = dateString.split('/');
                dateObject = new Date(parts[2], parts[1] - 1, parts[0]);
            }
                // Check if the format matches yyyy/MM/dd
            else if (regexYYYYMMDD.test(dateString)) {
                var parts = dateString.split('/');
                dateObject = new Date(parts[0], parts[1] - 1, parts[2]);
            } else {
                console.error("Invalid date format: " + dateString);
                return null;
            }

            // Ensure the date is valid
            if (isNaN(dateObject)) {
                console.error("Invalid date value: " + dateString);
                return null;
            }
            return dateObject;
        }

        function formatDate(date, format) {
            var day = date.getDate().toString().padStart(2, '0');
            var month = (date.getMonth() + 1).toString().padStart(2, '0');
            var year = date.getFullYear();
            var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
            var monthName = monthNames[date.getMonth()];

            if (format === "yyyy/MM/dd") {
                return year + "/" + month + "/" + day;
            } else if (format === "MM/dd/yyyy") {
                return month + "/" + day + "/" + year;
            } else if (format === "dd-MM-yyyy") {
                return day + "-" + monthName + "-" + year;
            } else if (format === "dd/MM/yyyy") {
                return day + "/" + month + "/" + year;
            } else {
                return date.toLocaleDateString(); // Default fallback
            }
        }

        function getDateFormat(referenceDate) {
            if (/\d{2}\/\d{2}\/\d{4}/.test(referenceDate)) {
                return "MM/dd/yyyy";
            } else if (/\d{2}-[A-Za-z]{3}-\d{4}/.test(referenceDate)) {
                return "dd-MM-yyyy";
            } else if (/\d{2}\/\d{2}\/\d{4}/.test(referenceDate)) {
                return "dd/MM/yyyy";
            }
            return "yyyy/MM/dd"; // Default format
        }


       
    </script>
    <div class="content-header">
        <asp:HiddenField ID="hdfStartTime" runat="server" />
        <asp:HiddenField ID="hdfStartEnd" runat="server" />
        <asp:HiddenField ID="hdnAllowMax" Value="2" runat="server" />
        <h1 style="background-image: url('../dist/img/onduty-icons.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">
        <asp:HiddenField ID="Hidden1" runat="server" />
        <asp:HiddenField ID="Hidden2" runat="server" />
        <asp:HiddenField ID="hiddenTime" runat="server" />
        <asp:HiddenField ID="hdnYearStartDate" runat="server" />
        <asp:HiddenField ID="hdnYearToDate" runat="server" />
        <asp:HiddenField ID="hdnNumofWFHDays" runat="server" />
        <asp:HiddenField ID="hdnPPValidateDate" runat="server" />
        <asp:HiddenField ID="limtCount" runat="server" />
        <input id="hdnEmployeeId" type="hidden" runat="server" />
        <input id="hdnEmployeeCodeId" type="hidden" runat="server" />
        
        <asp:HiddenField ID="hdnOutDate" runat="server" />
        <div class="col-md-12" style="color: Red; display: none">
            <asp:Label ID="lbl_Error" runat="server" ForeColor="Red"></asp:Label>
        </div>
        <div id="myModal" class="modal modal-default fade" role="dialog">
            <div class="modal-dialog" style="min-width: 85%;">
                <!-- Modal content-->
                <div class="modal-content" style="margin-top: 50px">
                    <div class="modal-header">
                        <button type="button" id="closemodal" class="close" data-dismiss="modal" style="border-radius: 50px;">
                            &times;</button>
                        <h4 class="modal-title">
                            <asp:Label ID="lblSelectEmployee" runat="server" Text="Select Employee"></asp:Label>
                        </h4>
                    </div>
                    <div class="modal-body">
                        <iframe id="iframePopup" runat="server" scrolling="auto" width="100%" height="700px"
                            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 class="inr-ftr">
            <div class="row">
                <div class="col-sm-2">
                </div>
                <div class="col-sm-2 col-sm-offset-8">
                    <div class="pull-right">
                        <h6>
                            <span><span style="color: Red">|</span><span style="padding-left: 10px; padding-right: 10px"><asp:Label
                                ID="lbl_IndicatesMandatoryFields" runat="server"></asp:Label>
                                (<asp:Label ID="lblManCount" runat="server" Text="5"></asp:Label>
                                No.)</span>
                        </h6>
                    </div>
                </div>
                <div class="clearfix">
                </div>
            </div>
        </div>
        <div class="emp-filter">
            <div class="row">
                <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>
                </asp:UpdatePanel>
                <div class="form-horizontal">
                    <div class="col-md-12 form-group" id="divmode_Allocation" runat="server" style="display: none;">
                        <div class="col-md-12">
                            <div class="row">
                                <div class="col-md-3">
                                    <asp:Label ID="Label1" runat="server" Text="Mode of Entry"></asp:Label>
                                </div>
                                <div class="col-md-4 Pad-left-7px">
                                    <div class="col-md-6">
                                        <asp:RadioButton Text="Manual" ID="rbtnManual" Checked="true" runat="server" GroupName="EntryMode"
                                            CssClass="radioLeave radioLeave-primary" onclick="ModeOfAllocation();" />
                                    </div>
                                    <div class="col-md-6">
                                        <asp:RadioButton Text="Import" ID="rbtnImport" runat="server" GroupName="EntryMode"
                                            CssClass="radioLeave radioLeave-primary" onclick="ModeOfAllocation();" />
                                    </div>
                                </div>
                                <div class="col-md-5">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-12 form-group">
                        <div id="div_Employee" style="display: block">
                            <div class="col-md-12">
                                <div class="form-group" id="trEmployeeID" runat="server">
                                    <div class="col-md-3">
                                        <asp:Label ID="lbl_EmployeeId" runat="server"></asp:Label>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="input-group input-group-sm">
                                            <asp:TextBox onpaste="return true" ID="txt_EmployeeId" runat="server" CssClass="form-control man-dat"
                                                MaxLength="15" onblur="EmpName('Onduty');" onkeypress="return acceptCharsNum_MaxLength(event,this,15,MaxLength);"></asp:TextBox>
                                            <span class="input-group-btn">
                                                <asp:LinkButton ID="btn_Search" data-toggle="modal" data-target="#myModal" CssClass="btn save-btn fa-search"
                                                    runat="server" OnClientClick="return OpenWindowShiftExchange('txt_EmployeeId','Onduty');" />
                                            </span>
                                        </div>
                                    </div>
                                    <div class="col-md-5">
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-3">
                                        <asp:Label ID="lbl_EmployeeName" runat="server"></asp:Label>
                                    </div>
                                    <div class="col-md-3">
                                        <asp:TextBox onpaste="return true" ID="txt_Name" runat="server" CssClass="form-control"
                                            ReadOnly="True"></asp:TextBox>
                                    </div>
                                    <div class="col-md-6">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-12 form-group" id="divManual" runat="server">
                        <div class="col-md-12">
                            <div class="form-group">
                                <div class="col-md-3">
                                    <asp:Label ID="lbl_SingleDay" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-4 Pad-left-7px">
                                    <div class="col-md-6">
                                        <asp:RadioButton ID="rbSingleDayYes" Checked="true" runat="server" AutoPostBack="true"
                                            GroupName="Single Day" OnCheckedChanged="rbSingleDayYes_CheckedChanged" CssClass="radioLeave radioLeave-primary" />
                                    </div>
                                    <div class="col-md-6">
                                        <asp:RadioButton ID="rbSingleDayNo" runat="server" GroupName="Single Day" AutoPostBack="true"
                                            OnCheckedChanged="rbSingleDayNo_CheckedChanged" CssClass="radioLeave radioLeave-primary" />
                                    </div>
                                </div>
                                <div class="col-md-5">
                                </div>
                            </div>
                            <div class="row form-group">
                                <div class="col-md-3">
                                    <asp:Label ID="lbl_OttHoliday" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-4 Pad-left-7px">
                                    <div class="col-md-6">
                                        <asp:RadioButton ID="rbIncludingWeeklyOff" runat="server" GroupName="Weekly Off"
                                            CssClass="radioLeave radioLeave-primary" />
                                    </div>
                                    <div class="col-md-6">
                                        <asp:RadioButton ID="rbExcludingWeeklyOff" Checked="true" runat="server" GroupName="Weekly Off"
                                            CssClass="radioLeave radioLeave-primary" />
                                    </div>
                                </div>
                                <div class="col-md-5">
                                </div>
                            </div>
                            <div class="row form-group" runat="server" id="WFHType" style="display:none;" >
                                <div class="col-md-3">
                                    <asp:Label ID="lblPMLandPPL" runat="server" Text="Select the Type of Work Mode"></asp:Label>
                                </div>
                                <div class="col-md-4 Pad-left-7px">

                                    <div class="col-md-6" runat="server" id="PMWFH" style="display:none;">
                                        <asp:RadioButton ID="rbPML" runat="server" GroupName="PML" Text="PM" AutoPostBack="true"
                                            CssClass="radioLeave radioLeave-primary" OnCheckedChanged="rbPML_CheckedChanged" ToolTip="Post Maternity – Work from Home"/>
                                    </div>
                                    <div class="col-md-6" runat="server" id="PPWFH" style="display:none;">
                                        <asp:RadioButton ID="rbPPL" runat="server" GroupName="PML" Text="PP" AutoPostBack="true"
                                            CssClass="radioLeave radioLeave-primary" OnCheckedChanged="rbPML_CheckedChanged" ToolTip="Post Paternity – Work from Home" />
                                    </div>
                                    <div class="col-md-6" runat="server" id="ODWFH" >
                                        <asp:RadioButton ID="rbNone" Checked="true" runat="server" GroupName="PML" Text="OD"
                                            CssClass="radioLeave radioLeave-primary" />
                                    </div>
                                </div>
                                <div class="col-md-5">
                                </div>
                            </div>
                            <div class="row" style="display: none">
                                <div class="col-md-6">
                                    <asp:Label ID="lbl_TypeOfManualEntry" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-6">
                                    <asp:RadioButton ID="rbtSingle" runat="server" GroupName="EntryType" onclick="show();"
                                        TabIndex="1" />
                                    <asp:RadioButton ID="rbtGroup" runat="server" GroupName="EntryType" onclick="show1();" />
                                </div>
                            </div>
                            <div id="divGroupEntryType" style="display: none">
                                <div class="row" style="display: none">
                                    <div class="col-md-12">
                                        <asp:Label ID="lbl_GroupEntryType" runat="server"></asp:Label>
                                    </div>
                                    <div class="col-md-12">
                                        <asp:RadioButton ID="rbtBusLate" runat="server" GroupName="GroupEntryType" onclick="show();"
                                            Checked="True" CssClass="radio radio-primary" />
                                        <asp:RadioButton ID="rbtOnDuty" runat="server" GroupName="GroupEntryType" onclick="show();"
                                            CssClass="radio radio-primary" />
                                    </div>
                                </div>
                            </div>
                            <div id="divEmployees" style="display: none">
                                <div class="row form-group">
                                    <div class="col-md-2">
                                        <asp:Label ID="lbl_Employees" runat="server"></asp:Label>
                                    </div>
                                    <div class="col-md-3">
                                        <asp:Button ID="btn_ViewEmployees" CssClass="but" runat="server" Width="87px" OnClientClick="return OpenWindow();" />
                                    </div>
                                </div>
                            </div>
                            <div class="row form-group">
                                <div class="col-md-3">
                                    <asp:Label ID="lbl_ManualTimeEntryDate" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-3">
                                    <asp:Label ID="lbl_EntryDate" runat="server" CssClass="form-control"></asp:Label>
                                </div>
                                <div id="tr_ShiftDate" runat="server">
                                    <div class="col-md-3">
                                        <asp:Label ID="lbl_ShiftDate" Text="Shift Date" runat="server"></asp:Label>
                                    </div>
                                    <div class="col-md-3" id="tr_ShiftDate1" runat="server">
                                        <asp:TextBox onpaste="return true" ID="txt_ShiftDate" runat="server" CssClass="form-control man-dat"
                                            onCut="return false" onDrop="return false"></asp:TextBox>
                                        <asp:Button ID="Button1" runat="server" CssClass="but" CausesValidation="False" OnClientClick="return ClearInDate()"
                                            Style="display: none;" />
                                        <asp:CustomValidator ID="CustomValidator2" runat="server" EnableClientScript="False"
                                            OnServerValidate="CheckInDate" SetFocusOnError="True" ControlToValidate="txt_ShiftDate"
                                            Display="None"></asp:CustomValidator>
                                    </div>
                                </div>
                            </div>
                            <div class="row" style="display: none;">
                                <div class="col-md-2">
                                    <asp:Label ID="lbl_EntranceName" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-3">
                                    <asp:DropDownList ID="ddlEntranceName" runat="server" AppendDataBoundItems="True"
                                        CssClass="form-control select2 Man-dat" onchange="return ManualTimeEntryTerminals(SelectEntranceID,NoRecords,Errorinretrivingdetails,Select);">
                                        <asp:ListItem Text="-Select-" Value="-Select-"></asp:ListItem>
                                    </asp:DropDownList>
                                </div>
                            </div>
                            <div class="row" style="color: #5D5D5D">
                                <div id="tr_InTime" runat="server">
                                    <div class="col-md-3">
                                        <asp:Label ID="lbl_InTime" runat="server"></asp:Label>
                                    </div>
                                    <div class="col-md-3">
                                        <asp:TextBox onpaste="return true" ID="txt_ShiftIn" runat="server" CssClass="form-control man-dat"
                                            MaxLength="12" onCut="return false" onDrop="return false"></asp:TextBox>
                                        <asp:Button ID="btn_InTimeClear" runat="server" CssClass="but" CausesValidation="False"
                                            Style="display: none;" />
                                    </div>
                                </div>
                                <div id="tr_OutTime" runat="server">
                                    <div class="col-md-3">
                                        <asp:Label ID="lbl_OutTime" runat="server"></asp:Label>
                                    </div>
                                    <div class="col-md-3">
                                        <asp:TextBox onpaste="return true" ID="txt_ShiftOut" runat="server" CssClass="form-control man-dat"
                                            MaxLength="12" onCut="return false" onDrop="return false"></asp:TextBox>
                                        <asp:Button ID="btn_OutTimeClear" runat="server" CssClass="but" Width="71px" CausesValidation="False"
                                            OnClientClick="return ClearOutTime()" Style="display: none;" />
                                    </div>
                                </div>
                            </div>
                            <div class="row" style="display: none">
                                <div class="col-md-3">
                                    <asp:Label ID="lbl_InTerminal" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-3">
                                    <asp:DropDownList ID="ddlInTerminals" runat="server" CssClass="form-control select2"
                                        onchange="return ManualTimeEntry_InPunchTypes(SelTerminal,NoRecords,Errorinretrivingdetails,Select);">
                                    </asp:DropDownList><input id="hdn_InTerminal" type="hidden" runat="server" />
                                </div>
                            </div>
                            <div style="display: none">
                                <div class="row">
                                    <div class="col-md-12">
                                        <asp:Label ID="lbl_InPunchType" runat="server"></asp:Label>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-12">
                                        <asp:DropDownList ID="ddlInPunchTypes" runat="server" CssClass="form-control select2">
                                        </asp:DropDownList>
                                        <input id="hdn_InPunchType" type="hidden" runat="server" />
                                    </div>
                                </div>
                            </div>
                            <div class="row" style="color: #5D5D5D">
                                <div id="tr_InDate" runat="server">
                                    <div class="col-md-3">
                                        <asp:Label ID="lbl_InDate" runat="server"></asp:Label>
                                    </div>
                                    <div class="col-md-3">
                                        <asp:TextBox onpaste="return true" ID="txt_InDate" runat="server" CssClass="form-control man-dat"
                                            onCut="return false" onDrop="return false" onblur="datePicker();" AutoPostBack="true"></asp:TextBox>
                                        <asp:Button ID="btn_InDateClear" runat="server" CssClass="but" CausesValidation="False"
                                            OnClientClick="return ClearInDate()" Style="display: none;" />
                                        <asp:CustomValidator ID="CustomValidator1" runat="server" EnableClientScript="False"
                                            OnServerValidate="CheckInDate" SetFocusOnError="True" ControlToValidate="txt_InDate"
                                            Display="None"></asp:CustomValidator>
                                    </div>
                                </div>
                                <div id="tr_Start_Session" runat="server">
                                    <div class="col-md-3">
                                        <asp:Label ID="lblSessionstart" Text="From Session" runat="server"></asp:Label>
                                    </div>
                                    <div class="col-md-3">
                                        <asp:DropDownList ID="ddl_SessionFrom" runat="server" CssClass="form-control select2 Man-dat">
                                            <asp:ListItem Text="-Select-" Value="-Select-"></asp:ListItem>
                                            <asp:ListItem Text="First half" Value="First half"></asp:ListItem>
                                            <asp:ListItem Text="Second half" Value="Second half"></asp:ListItem>
                                        </asp:DropDownList>
                                    </div>
                                </div>
                            </div>
                            <div class="row" style="color: #5D5D5D">
                                <div id="tr_OutDate" runat="server" style="padding-top: 15px;">
                                    <div class="col-md-3">
                                        <asp:Label ID="lbl_OutDate" runat="server"></asp:Label>
                                    </div>
                                    <div class="col-md-3">
                                        <asp:TextBox onpaste="return true" ID="txt_OutDate" runat="server" CssClass="form-control man-dat"
                                            onCut="return false" onDrop="return false" onblur="ToDateValidateForPP();"></asp:TextBox>
                                        <asp:Button ID="btn_OutDateClear" runat="server" CssClass="but" Width="70px" CausesValidation="False"
                                            OnClientClick="return ClearOutDate()" Style="display: none;" />
                                        <asp:CustomValidator ID="CustomValidator3" runat="server" Display="None" EnableClientScript="False"
                                            OnServerValidate="CheckOutDate" SetFocusOnError="True" ControlToValidate="txt_OutDate"></asp:CustomValidator>
                                    </div>
                                </div>
                                <div id="tr_End_Session" runat="server">
                                    <div class="col-md-3">
                                        <asp:Label ID="lblSessionEnd" Text="To Session" runat="server"></asp:Label>
                                    </div>
                                    <div class="col-md-3">
                                        <asp:DropDownList ID="ddl_SessionTo" runat="server" CssClass="form-control select2 Man-dat">
                                            <asp:ListItem Text="-Select-" Value="-Select-"></asp:ListItem>
                                            <asp:ListItem Text="First half" Value="First half"></asp:ListItem>
                                            <asp:ListItem Text="Second half" Value="Second half"></asp:ListItem>
                                        </asp:DropDownList>
                                    </div>
                                </div>
                            </div>
                            <div style="display: none">
                                <div class="row">
                                    <div class="col-md-3">
                                        <asp:Label ID="lbl_OutTerminal" runat="server"></asp:Label>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-3">
                                        <asp:DropDownList ID="ddlOutTerminals" runat="server" CssClass="form-control select2"
                                            onchange="return ManualTimeEntry_OutPunchTypes(SelOutTerminal,NoRecords,Errorinretrivingdetails,Select);">
                                        </asp:DropDownList><input id="hdn_OutTerminal" type="hidden" runat="server" />
                                    </div>
                                </div>
                            </div>
                            <div style="display: none">
                                <div class="row">
                                    <div class="col-md-3">
                                        <asp:Label ID="lbl_OutPunchType" runat="server"></asp:Label>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-3">
                                        <asp:DropDownList ID="ddlOutPunchTypes" runat="server" CssClass="form-control select2">
                                        </asp:DropDownList>
                                        <input id="hdn_OutPunchType" type="hidden" runat="server" />
                                    </div>
                                </div>
                            </div>
                            <div class="row form-group" style="margin-top: 15px">
                                <div class="col-md-3">
                                    <asp:Label ID="lbl_Reason" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-3">
                                    <asp:TextBox onpaste="return true" ID="txt_Reason" runat="server" CssClass="form-control man-dat"
                                        MaxLength="250" onCut="return false" onDrop="return false" onkeypress="return chkMaxLen(event,this,250,MaxLength);"
                                        TextMode="MultiLine" Style="resize: none"></asp:TextBox>
                                </div>
                            </div>
                            <div id="div_Route" style="display: none">
                                <div class="row">
                                    <div class="col-md-3">
                                        <asp:Label ID="lbl_RouteName" runat="server"></asp:Label>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-3">
                                        <asp:DropDownList ID="ddlRouteName" runat="server" AppendDataBoundItems="True" CssClass="form-control select2 Man-dat">
                                            <asp:ListItem Text="-Select-" Value="-Select-"></asp:ListItem>
                                        </asp:DropDownList>
                                        <asp:Button ID="btn_View" runat="server" CausesValidation="False" OnClientClick="return Manual_OpenWindow(SelectInDate,SelecttheRouteName);"
                                            CssClass="but" />
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-5">
                                </div>
                                <div class="col-md-7">
                                    <div class="pull-right-button">
                                        <asp:LinkButton ID="btn_Add" CssClass="btn save-btn fa-floppy-o" runat="server" CausesValidation="true"
                                            OnClick="btn_Add_Click" OnClientClick="if(ManualEntryValidation()){ $find('popupProgress').show();return true;}else return false;" />
                                        <asp:LinkButton ID="btn_Cancel" CssClass="btn save-btn fa-angle-left" runat="server"
                                            CausesValidation="False" OnClick="btn_Cancel_Click" />
                                        <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True"
                                            ShowSummary="False" />
                                        <asp:Label ID="lblname" runat="server">
                                        </asp:Label>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-12 form-group" id="divImport" runat="server" style="display: none">
                        <div class="col-md-12">
                            <div class="form-group">
                                <div class="col-md-3">
                                    <asp:Label ID="lblImportFilePath" runat="server" Text="Select CSV File"></asp:Label>
                                </div>
                                <div class="col-md-3">
                                    <asp:FileUpload ID="fup_ShiftImport" runat="server" CssClass="form-control" />
                                </div>
                            </div>
                            <div class="panel panel-info">
                                <div class="panel-heading" style="padding: 10px;">Some Basic Information</div>
                                <ul class="list-group">
                                    <li class="list-group-item">
                                        <asp:Label ID="lblnotes1" runat="server" Text="Do not delete / change any field in the downloaded template file."></asp:Label></li>
                                    <li class="list-group-item">
                                        <asp:Label ID="lblnotes3" runat="server" Text="While importing, check whether the file has been opened or not. If it is opened try an import after closing the file which is minimized in the taskbar"></asp:Label>
                                    </li>
                                    <li class="list-group-item">
                                        <asp:Label ID="lblnotes4" runat="server" Text="Save the file as <B style='color:red;'>.csv</B> format before import."></asp:Label>
                                    </li>
                                    <li class="list-group-item">
                                        <asp:Label ID="lblnotes5" runat="server" Text="<B style='color:red;'>Don't use import option for half day leave availed employee(s)</B>.Use manual option for that employee(s) to enter onduty details."></asp:Label>
                                    </li>
                                    <li class="list-group-item">
                                        <asp:Label ID="lblcon" runat="server" Text="Kindly use <B style='color:red;'>dd-MMM-yyyy</B> format for Manual Time Entry Data Import. Refer the sample data available with in the Downloaded template."></asp:Label>
                                    </li>
                                </ul>
                            </div>
                            <div class="form-group">
                                <div class="col-md-12">
                                    <div class="pull-right-button">
                                        <asp:LinkButton ID="btn_Upload" Text="&nbsp;&nbsp;Upload" CssClass="btn save-btn fa-upload" runat="server" OnClick="btn_Upload_Click"
                                            OnClientClick="javascript:if(ValidateFileUploader()){ $find('popupProgress').show();return true;}else return false;" />
                                        <asp:LinkButton ID="btn_Template" Text="&nbsp;&nbsp;Download Template" CssClass="btn save-btn fa-download" runat="server" OnClick="btn_Template_Click" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="clearfix">
                        </div>
                        <div>
                            <div class="line16">
                            </div>
                        </div>
                        <div class="col-md-12" runat="server" id="grdControl" style="display: none">
                            <div class="form-group">
                                <div class="col-md-6">
                                    <strong>
                                        <asp:Label ID="Label2" runat="server" Text="Un Processed Record"></asp:Label></strong>
                                </div>
                                <div class="col-md-4">
                                    <asp:Label ID="lblInvalidDataCount" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-2 pull-right-button">
                                    <asp:LinkButton ID="lnkbtnRemove" Text="&nbsp;&nbsp;Remove" OnClientClick="javascript:if(confirm('Are you sure to remove data from grid control')){return true}else {return false};" CssClass="btn save-btn fa-remove" runat="server" OnClick="lnkbtnRemove_Click" />
                                </div>
                            </div>
                            <div class="table-responsive" style="padding-bottom: 10px">
                                <dxGridview:ASPxGridView ID="grvImportDetails" EnableCallBacks="false" runat="server"
                                    ClientInstanceName="grvImportDetails" AutoGenerateColumns="false" Width="100%">
                                    <Columns>
                                        <dxGridview:GridViewDataTextColumn Caption="Record Number" FieldName="recordNumber"
                                            VisibleIndex="1" Width="50px">
                                            <DataItemTemplate>
                                                <asp:Label ID="lblrecordNumber" Text='<%# Eval("recordNumber") %>' runat="server"></asp:Label>
                                            </DataItemTemplate>
                                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                        </dxGridview:GridViewDataTextColumn>
                                        <dxGridview:GridViewDataTextColumn Caption="Employee Id" FieldName="Employee_Id"
                                            VisibleIndex="1">
                                            <DataItemTemplate>
                                                <asp:Label ID="lblEmployeeId" Text='<%# Eval("EmployeeId") %>' runat="server"></asp:Label>
                                            </DataItemTemplate>
                                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                        </dxGridview:GridViewDataTextColumn>
                                        <dxGridview:GridViewDataTextColumn Caption="Error Message" FieldName="Err_Msg" VisibleIndex="1">
                                            <DataItemTemplate>
                                                <asp:Label ID="Label3" Text='<%# Eval("Errormessage") %>' runat="server"></asp:Label>
                                            </DataItemTemplate>
                                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                        </dxGridview:GridViewDataTextColumn>
                                    </Columns>
                                    <SettingsText EmptyDataRow="No Records Found" />
                                    <SettingsPager PageSize="10">
                                    </SettingsPager>
                                    <SettingsBehavior AllowSort="false" AllowDragDrop="false" />
                                    <Styles AlternatingRow-CssClass="table-bg">
                                    </Styles>
                                </dxGridview:ASPxGridView>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</asp:Content>
