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

<%--<%@ Register Src="../UserControls/TA_uc_OrgLevel_Filter.ascx" TagName="TA_uc_OrgLevel_Filter"
    TagPrefix="uc1" %>--%>
<%@ Register Src="../UserControls/TA_uc_OrgLevelFilter_Updated.ascx" TagName="TA_uc_OrgLevel_Filter"
    TagPrefix="uc1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="ConLeavePermissionAdd" ContentPlaceHolderID="BodyContentPH" runat="Server">
    <link href="../css/ProgressBar.css" rel="stylesheet" type="text/css" />

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

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

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

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

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

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

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

    <script src="../plugins/datepicker/bootstrap-datepicker.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script>
        var sessionDateValue = '<%= Session["IDateFormat"] %>';
        var sessionTimeValue = '<%= Session["ITimeFormat"] %>';
        var sessionDateAndTimeValue = sessionDateValue + ' ' + sessionTimeValue;
        $(function () {
            $('#ctl00_BodyContentPH_TxtPermissionDate').datetimepicker({ format: document.getElementById('ctl00_BodyContentPH_Hidden1').value }
            );
        });
        //$(function () {
        //    $('#ctl00_BodyContentPH_txt_StartTime').datetimepicker({ format: sessionDateAndTimeValue }
        //    );
        //});
        //$(function () {
        //    $('#ctl00_BodyContentPH_txt_EndTime').datetimepicker({ format: sessionDateAndTimeValue }
        //    );
        //});
    </script>
    <script type="text/javascript">


        $(document).ready(function () {
            $("#ctl00_BodyContentPH_txt_StartTime").keydown(function (e) {
                e.preventDefault();
            });
            $("#ctl00_BodyContentPH_txt_EndTime").keydown(function (e) {
                e.preventDefault();
            });
            $("#ctl00_BodyContentPH_txt_NumberOfHours").keydown(function (e) {
                e.preventDefault();
            });
            $('#linkClose').click(function () {
                $('#divError').hide('fade');
            });
        });
        $(function () {
            $("#ctl00_BodyContentPH_txt_EmployeeId").change(function () {
                if ($("#ctl00_BodyContentPH_TxtPermissionDate").val().length > 0) {
                    $("#ctl00_BodyContentPH_TxtPermissionDate").val('');
                    //Reference GridView Table.
                    var table = $("[id*=tblEmployee]");
                    table.empty();

                    $("#ctl00_BodyContentPH_txt_StartTime").val('');
                    $("#ctl00_BodyContentPH_txt_EndTime").val('');
                    $("#ctl00_BodyContentPH_txt_NumberOfHours").val('');
                    $("#tdRemainNoOfHours").val('');
                    $('#divErrorText').text('');
                    $('#divError').hide();
                }
            });

            $("#ctl00_BodyContentPH_TxtPermissionDate").blur(function () {

                if (CheckDateShiftDate(this, SelectEmployee, SelectvalidPermissionDate, SelectvalidPermissionFromDateandTime, SelectvalidPermissionToDateandTime, Selectvalidyear, Permissionshouldnotbeappliedbeforedateofjoining, PermissionHoursfallsonWeeklyOffGlobalHoliday, SelectValidPermissionHours, ShiftNotAllocated, PermissionHoursdoesnotfallinsidetheshift, PermissionHoursfallwiththeshiftbreaktimes, PermissionHoursShouldNotInNegativeHours, PermissionHoursNotdefinedforthisemployee, MaxNumberofInstancespermonthExceeds)) {
                    if ($("#ctl00_BodyContentPH_hdnEmployeeId").val().length > 0) {
                        if ($("#ctl00_BodyContentPH_TxtPermissionDate").val().length > 0) {
                            var obj = {};
                            if ($('#ctl00_BodyContentPH_divEmployees').is(':visible')) {

                                obj.empid = $("#ctl00_BodyContentPH_lbl_EmployeeID").text();
                            }
                            else {
                                obj.empid = $.trim($("[id*=ctl00_BodyContentPH_txt_EmployeeId]").val());

                            }
                            //alert(obj.empid);
                            obj.permissionDate = document.aspnetForm.ctl00_BodyContentPH_TxtPermissionDate.value;
                            $.ajax({
                                type: "POST",
                                url: "TA_UI_Transactions_PermissionAdd_Eastman.aspx/PermissionDetails",
                                data: JSON.stringify(obj),
                                contentType: "application/json; charset=utf-8",
                                dataType: "json",
                                success: OnSuccess,
                                failure: function (r) {
                                    alert(r.d);
                                },
                                error: function (response) {
                                    alert("error");
                                    alert(r.d);
                                }
                            });



                        }
                        else {
                            //Reference GridView Table.
                            var table = $("[id*=tblEmployee]");
                            table.empty();
                            $("#ctl00_BodyContentPH_txt_StartTime").val('');
                            $("#ctl00_BodyContentPH_txt_EndTime").val('');
                            $("#ctl00_BodyContentPH_txt_NumberOfHours").val('');
                            $("#tdRemainNoOfHours").val('');

                        }
                    }
                }
                else {
                    var table = $("[id*=tblEmployee]");
                    table.empty();
                    $("#ctl00_BodyContentPH_txt_StartTime").val('');
                    $("#ctl00_BodyContentPH_txt_EndTime").val('');
                    $("#ctl00_BodyContentPH_txt_NumberOfHours").val('');
                    $("#tdRemainNoOfHours").val('');
                    if ($("#ctl00_BodyContentPH_TxtPermissionDate").val().length > 0) {
                        $('#divErrorText').text("Select an employee");
                        $('#divError').show('fade');
                    }
                    else {
                        $('#divErrorText').text('');
                        $('#divError').hide();
                    }
                }
            });

        });


        function OnSuccess(r) {
            //Parse the XML and extract the records.
            var EmppermissionDetails = $($.parseXML(r.d)).find("Table");

            //Reference GridView Table.
            var table = $("[id*=tblEmployee]");
            table.empty();
            var trHTML = "<table id='tblpermissiondetails' class='table das-table1'><thead><tr><th class='empheader GridColumn50' scope='col'>Date</th><th class='empheader GridColumn50' scope='col'>In Time</th><th class='empheader GridColumn50' scope='col'>Late Hours</th><th class='empheader GridColumn50' scope='col'>Reason</th><th class='empheader GridColumn50' scope='col'>Received Date</th><th class='empheader GridColumn50' scope='col'>Status</th></tr></thead><tbody>"
            var i = 1;
            $.each(EmppermissionDetails, function () {

                if ($(this).find("Permission_Date").text() == $("#ctl00_BodyContentPH_TxtPermissionDate").val()) {
                    trHTML += '<tr class="alert alert-danger"><td><label id=lblDate' + i + '>' + $(this).find("Permission_Date").text() + '</td><td>'
                        + $(this).find("Permission_ToTime").text() + '</td><td>' + $(this).find("No_Of_Hours").text() + '</td><td>' + $(this).find("Permission_Reason").text() + '</td><td>' + $(this).find("Permission_AppliedDate").text() + '</td><td>' + $(this).find("Permission_Status").text() + '</td></tr>';
                }
                else {
                    trHTML += '<tr><td><label id=lblDate' + i + '>' + $(this).find("Permission_Date").text() + '</label></td><td>'
                        + $(this).find("Permission_ToTime").text() + '</td><td>' + $(this).find("No_Of_Hours").text() + '</td><td style="width:400px;">' + $(this).find("Permission_Reason").text() + '</td><td>' + $(this).find("Permission_AppliedDate").text() + '</td><td>' + $(this).find("Permission_Status").text() + '</td></tr>';
                }
                i += 1;
            });
            $('#tblEmployee').append(trHTML);
            var Emp_SelectDateDetails = $($.parseXML(r.d)).find("Table1");
            $.each(Emp_SelectDateDetails, function () {
                if ($(this).find('Isavailable').text() == "1") {
                    $('#divErrorText').text("Permission Already applied for this date. See the preview table");
                    $('#divError').show('fade');
                    $("#ctl00_BodyContentPH_btn_add").css('display', "none");
                    return false;
                }
                else {
                    if (($(this).find('ShiftStartTime').text() != "" && $(this).find('ShiftStartTime').text() != "00:00")
                    && ($(this).find('intime').text() != "" && $(this).find('intime').text() != "00:00")
                        && ($(this).find('Differences').text() != "" && $(this).find('Differences').text() != "00:00")) {
                        $("#ctl00_BodyContentPH_txt_StartTime").val($(this).find('ShiftStartTime').text());
                        $("#ctl00_BodyContentPH_txt_EndTime").val($(this).find("intime").text());
                        $("#ctl00_BodyContentPH_txt_NumberOfHours").val($(this).find("Differences").text());
                        $("#ctl00_BodyContentPH_btn_add").attr('disabled', false);
                        $('#divErrorText').text('');
                        $('#divError').hide();
                        $("#ctl00_BodyContentPH_btn_add").css('display', "");
                    }
                    else {
                        $('#divErrorText').text("Punches are not available for the selected date / attendance is absent / Late In hours will be zero.So you can't enter permission for this date");
                        $('#divError').show('fade');
                        $("#ctl00_BodyContentPH_btn_add").css('display', "none");
                        $("#ctl00_BodyContentPH_txt_StartTime").val('');
                        $("#ctl00_BodyContentPH_txt_EndTime").val('');
                        $("#ctl00_BodyContentPH_txt_NumberOfHours").val('');
                        $("#tdRemainNoOfHours").val('');
                        return false;
                    }
                }
            });
        }
    </script>
    <script type="text/javascript">

        //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';
        //Added by Manjula.P on 15-Feb-2014 for getting dd/MM/yyyy format datetime
        var ValiddateDateDDMMYYHHMM = 'Please enter valid Date and Time MM/dd/yyyy HH:mm';
        var ValiddateDateDDMMYYHHMMTT = '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 NoRecord = "No Records";
        var ErrorinRetriv = "Error in retriving details";

        var Select = "-Select-";
        var MaxLength = "Maximum length is ";
        function Emp(noRecords, errorinRetrive, select) {
            NoRecord = noRecords;
            ErrorinRetrive = errorinRetrive;
            Select = select;
        }
        function MaxLengthh(maxLength) {

            MaxLength = maxLength;
        }

        function SetAlertCheckDate(monthfourdigit, datefourdigit, invalidyearentry, invalidmonthentry, invaliddateentry, dateformatDDMONYYYY, entertime, valueforhours, invalidvalueforminutes, invalidtimeformat, entervalidDateandTime, validdatemonthMMDDYYHHMM, validdatemonthMMDDYYHHMMTT, validdateDateDDMMYYHHMM, validdateDateDDMMYYHHMMTT, 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;
            //Added by Manjula.P on 15-Feb-2014
            ValiddateDateDDMMYYHHMM = validdateDateDDMMYYHHMM;
            ValiddateDateDDMMYYHHMMTT = validdateDateDDMMYYHHMMTT;
            //**********************************
            EntervalidDateandTime = entervalidDateandTime;
            Invalidvalueforhours = invalidvalueforhours;
            Invalidvalueforminites = invalidvalueforminites;
        }

        var FillPermissinDate = "Select Shift Date";
        var FillStarDate = "Select Start Time";
        var FillEndDate = "Select End Time";
        var FillReason = " Enter the Reason";
        var permissionEmpty = "Number of Hours Applied Should Not Be Empty / Zero.Click Calculate Hours";
        var SelEmployee = "Select an Employee";
        var ConfirmSave = "Are you sure to, Save?";
        var FillStarEndDate = "Select Start and End Time";
        var SelectEmployee = "Select Employee";
        var SelectvalidPermissionDate = "Select valid Permission Date";
        var SelectvalidPermissionFromDateandTime = "Select valid Permission From Date and Time";
        var SelectvalidPermissionToDateandTime = "Select valid Permission To Date and Time";
        var Selectvalidyear = "Select valid year";
        var Permissionshouldnotbeappliedbeforedateofjoining = "Permission should not be applied before date of joining";
        var PermissionHoursfallsonWeeklyOffGlobalHoliday = "Permission Hours falls on Weekly Off / Global Holiday";
        var SelectValidPermissionHours = "Select Valid Permission Hours";
        var ShiftNotAllocated = "Shift Not Allocated";
        var PermissionHoursdoesnotfallinsidetheshift = "Permission Hours does not fall inside the shift";
        var PermissionHoursfallwiththeshiftbreaktimes = "Permission Hours fall with the shift break times"
        var PermissionHoursShouldNotInNegativeHours = "Permission Hours Should Not In Negative Hours";
        var PermissionHoursNotdefinedforthisemployee = "Permission Hours Not defined for this employee";
        var MaxNumberofInstancespermonthExceeds = "Max Number of Instances per month Exceeds";

        function SetAlertMessages(permissiondtae, StarDtae, EndDate, Reason, permissionEmpty, selEmployee, ConfirmSavedeatils, FillStarEnddate) {

            FillPermissinDate = permissiondtae;
            FillStarDate = StarDtae;
            FillEndDate = EndDate;
            FillReason = Reason;
            PermissionEmpty = permissionEmpty;
            SelEmployee = selEmployee;
            ConfirmSave = ConfirmSavedeatils;
            FillStarEndDate = FillStarEnddate;
        }

        function SetAlertMessagesAjax_Permission
      (
       selectEmployee,
       selectvalidPermissionDate,
       selectvalidPermissionFromDateandTime,
       selectvalidPermissionToDateandTime,
       selectvalidyear,
       permissionshouldnotbeappliedbeforedateofjoining,
       permissionHoursfallsonWeeklyOffGlobalHoliday,
       selectValidPermissionHours,
       shiftNotAllocated,
       permissionHoursdoesnotfallinsidetheshift,
       permissionHoursfallwiththeshiftbreaktimes,
       permissionHoursShouldNotInNegativeHours,
       permissionHoursNotdefinedforthisemployee,
       maxNumberofInstancespermonthExceeds
      ) {
            SelectEmployee = selectEmployee;
            SelectvalidPermissionDate = selectvalidPermissionDate;
            SelectvalidPermissionFromDateandTime = selectvalidPermissionFromDateandTime;
            SelectvalidPermissionToDateandTime = selectvalidPermissionToDateandTime;
            Selectvalidyear = selectvalidyear;
            Permissionshouldnotbeappliedbeforedateofjoining = permissionshouldnotbeappliedbeforedateofjoining;
            PermissionHoursfallsonWeeklyOffGlobalHoliday = permissionHoursfallsonWeeklyOffGlobalHoliday;
            SelectValidPermissionHours = selectValidPermissionHours;
            ShiftNotAllocated = shiftNotAllocated;
            PermissionHoursdoesnotfallinsidetheshift = permissionHoursdoesnotfallinsidetheshift;
            PermissionHoursfallwiththeshiftbreaktimes = permissionHoursfallwiththeshiftbreaktimes;
            PermissionHoursShouldNotInNegativeHours = permissionHoursShouldNotInNegativeHours;
            PermissionHoursNotdefinedforthisemployee = permissionHoursNotdefinedforthisemployee;
            MaxNumberofInstancespermonthExceeds = maxNumberofInstancespermonthExceeds;
        }

        function ClearPermissionHrs() {
            document.aspnetForm.ctl00_BodyContentPH_txt_NumberOfHours.value = "";
        }

        function CheckDateShiftDate(current, SelectEmployee, SelectvalidPermissionDate, SelectvalidPermissionFromDateandTime, SelectvalidPermissionToDateandTime, Selectvalidyear, Permissionshouldnotbeappliedbeforedateofjoining, PermissionHoursfallsonWeeklyOffGlobalHoliday, SelectValidPermissionHours, ShiftNotAllocated, PermissionHoursdoesnotfallinsidetheshift, PermissionHoursfallwiththeshiftbreaktimes, PermissionHoursShouldNotInNegativeHours, PermissionHoursNotdefinedforthisemployee, MaxNumberofInstancespermonthExceeds) {
            if (document.getElementById('ctl00_BodyContentPH_hdnEmployeeId').value == "") {
                $('#divErrorText').text("Punches are not available for the selected date.So you can't enter permission for this date");
                $('#divError').show('fade');
                $("#ctl00_BodyContentPH_txt_StartTime").val('');
                $("#ctl00_BodyContentPH_txt_EndTime").val('');
                $("#ctl00_BodyContentPH_txt_NumberOfHours").val('');
                $("#tdRemainNoOfHours").val('');
                return false;
            }
            else {

                var DateFormat = document.getElementById('ctl00_BodyContentPH_Hidden1').value;
                var PermissionDate = document.aspnetForm.ctl00_BodyContentPH_TxtPermissionDate;
                if (document.aspnetForm.ctl00_BodyContentPH_TxtPermissionDate.value != "") {
                    if (checkDate(PermissionDate, DateFormat, Monthfourdigit, Datefourdigit, Invalidyearentry, Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours, Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime, ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, EntervalidDateandTime, Invalidvalueforhours, Invalidvalueforminites)) {
                        //assignEmployeeIdPermission(current, SelectEmployee, SelectvalidPermissionDate, SelectvalidPermissionFromDateandTime, SelectvalidPermissionToDateandTime, Selectvalidyear, Permissionshouldnotbeappliedbeforedateofjoining, PermissionHoursfallsonWeeklyOffGlobalHoliday, SelectValidPermissionHours, ShiftNotAllocated, PermissionHoursdoesnotfallinsidetheshift, PermissionHoursfallwiththeshiftbreaktimes, PermissionHoursShouldNotInNegativeHours, PermissionHoursNotdefinedforthisemployee, MaxNumberofInstancespermonthExceeds);
                        return true;
                    }
                    else {
                        return false;
                    }
                }
                else {
                    return false;
                }
            }
        }
        function CheckDatesAndNumberOfDays() {
            var rangeDemoFormat = document.getElementById('ctl00_BodyContentPH_Hidden1').value;
            var rangeDemoFormats = document.getElementById('ctl00_BodyContentPH_Hidden1').value + " " + document.getElementById('ctl00_BodyContentPH_Hidden2').value;

            var DateFormat = document.getElementById('ctl00_BodyContentPH_Hidden1').value;
            var TimeFormat = document.getElementById('ctl00_BodyContentPH_Hidden2').value;
            var PermissionDate = document.aspnetForm.ctl00_BodyContentPH_TxtPermissionDate;
            if (document.aspnetForm.ctl00_BodyContentPH_TxtPermissionDate.value != "") {
                if (checkDate(PermissionDate, DateFormat, Monthfourdigit, Datefourdigit, Invalidyearentry, Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours, Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime, ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, EntervalidDateandTime, Invalidvalueforhours, Invalidvalueforminites)) {
                    if (document.aspnetForm.ctl00_BodyContentPH_txt_StartTime.value != "") {
                        var FromDateTime = document.aspnetForm.ctl00_BodyContentPH_txt_StartTime;
                        if (checkDateAndTime(FromDateTime, DateFormat, TimeFormat, Monthfourdigit, Datefourdigit, Invalidyearentry, Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours, Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime, ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, ValiddateDateDDMMYYHHMM, ValiddateDateDDMMYYHHMMTT, EntervalidDateandTime, Invalidvalueforhours, Invalidvalueforminites)) {
                            if (document.aspnetForm.ctl00_BodyContentPH_txt_EndTime.value != "") {
                                var ToDateTime = document.aspnetForm.ctl00_BodyContentPH_txt_EndTime;
                                if (checkDateAndTime(ToDateTime, DateFormat, TimeFormat, Monthfourdigit, Datefourdigit, Invalidyearentry, Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours, Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime, ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, ValiddateDateDDMMYYHHMM, ValiddateDateDDMMYYHHMMTT, EntervalidDateandTime, Invalidvalueforhours, Invalidvalueforminites)) {
                                    NumberOfHours(SelectEmployee, SelectvalidPermissionDate, SelectvalidPermissionFromDateandTime, SelectvalidPermissionToDateandTime, Selectvalidyear, Permissionshouldnotbeappliedbeforedateofjoining, PermissionHoursfallsonWeeklyOffGlobalHoliday, SelectValidPermissionHours, ShiftNotAllocated, PermissionHoursdoesnotfallinsidetheshift, PermissionHoursfallwiththeshiftbreaktimes, PermissionHoursShouldNotInNegativeHours, PermissionHoursNotdefinedforthisemployee, MaxNumberofInstancespermonthExceeds);
                                }
                                else {
                                    return false;
                                }
                            }
                            else {
                                return false;
                            }
                        }
                        else {
                            return false;
                        }
                    }
                    else {
                        return false;
                    }
                }
                else {
                    return false;
                }
            }
            else {
                return false;
            }
            //document.getElementById('ctl00_BodyContentPH_CustomValidator1').innerText="";
            //        document.getElementById('ctl00_BodyContentPH_CustomValidator2').innerText="";
            //        document.getElementById('ctl00_BodyContentPH_CustomValidator3').innerText="";        
            return false;
        }

        function Validation() {
            var rangeDemoFormat = document.getElementById('ctl00_BodyContentPH_Hidden1').value;


            var rangeDemoFormats = document.getElementById('ctl00_BodyContentPH_Hidden1').value + " " + document.getElementById('ctl00_BodyContentPH_Hidden2').value;

            document.getElementById('ctl00_BodyContentPH_hdnNoOfHours').value = document.aspnetForm.ctl00_BodyContentPH_txt_NumberOfHours.value;
            if (document.getElementById('ctl00_BodyContentPH_hdnEmployeeId').value == "") {
                alert(SelEmployee);
                return false;
            }
            if (document.aspnetForm.ctl00_BodyContentPH_TxtPermissionDate.value == "") {
                alert(FillPermissinDate);
                return false;
            }
            else if (document.aspnetForm.ctl00_BodyContentPH_txt_StartTime.value == "" && document.aspnetForm.ctl00_BodyContentPH_txt_EndTime.value == "") {
                alert(FillStarEndDate);
                return false;
            }
            else if (document.aspnetForm.ctl00_BodyContentPH_txt_StartTime.value == "") {
                alert(FillStarDate);
                return false;
            }
            else if (document.aspnetForm.ctl00_BodyContentPH_txt_EndTime.value == "") {
                alert(FillEndDate);
                return false;
            }
            else if (trim(document.aspnetForm.ctl00_BodyContentPH_txtReason.value) == "") {
                alert(FillReason);
                document.aspnetForm.ctl00_BodyContentPH_txtReason.focus();
                return false;
            }
            else if (document.aspnetForm.ctl00_BodyContentPH_txt_NumberOfHours.value == "") {
                alert(PermissionEmpty);
                return false;
            }
            else if (document.aspnetForm.ctl00_BodyContentPH_txt_NumberOfHours.value == "00:00") {
                alert(PermissionEmpty);
                return false;
            }

            else {
                if (confirm(ConfirmSave) == true) {

                    return true;
                }
                else {
                    return false;
                }

            }
        }

        function assignEmployeeId(empid, SelectEmployee, SelectvalidPermissionDate, SelectvalidPermissionFromDateandTime, SelectvalidPermissionToDateandTime, Selectvalidyear, Permissionshouldnotbeappliedbeforedateofjoining, PermissionHoursfallsonWeeklyOffGlobalHoliday, SelectValidPermissionHours, ShiftNotAllocated, PermissionHoursdoesnotfallinsidetheshift, PermissionHoursfallwiththeshiftbreaktimes, PermissionHoursShouldNotInNegativeHours, PermissionHoursNotdefinedforthisemployee, MaxNumberofInstancespermonthExceeds) {
            document.getElementById('ctl00_BodyContentPH_hdnEmployeeId').value = empid.value;

            var permissionDate = document.getElementById('ctl00_BodyContentPH_TxtPermissionDate').value;

            if (permissionDate != "" && empid.value != "-Select-") {
                assignEmployeeIdPermission(permissionDate, SelectEmployee, SelectvalidPermissionDate, SelectvalidPermissionFromDateandTime, SelectvalidPermissionToDateandTime, Selectvalidyear, Permissionshouldnotbeappliedbeforedateofjoining, PermissionHoursfallsonWeeklyOffGlobalHoliday, SelectValidPermissionHours, ShiftNotAllocated, PermissionHoursdoesnotfallinsidetheshift, PermissionHoursfallwiththeshiftbreaktimes, PermissionHoursShouldNotInNegativeHours, PermissionHoursNotdefinedforthisemployee, MaxNumberofInstancespermonthExceeds);
            }

            if (empid.value == "-Select-" || empid.value == "") {
                document.getElementById('ctl00_BodyContentPH_hdnEmployeeId').value = "";
                document.getElementById('ctl00_BodyContentPH_hdnRemainNoOfHours').value = "00:00";
                document.getElementById('tdRemainNoOfHours').innerHTML = "00:00";
                document.getElementById('ctl00_BodyContentPH_txt_NumberOfHours').value = "";
            }


            //alert(empid);  
            //document.getElementById('ctl00_BodyContentPH_ddl_Type').focus();
        }




    </script>


    <div class="content-header">
        <h1 style="background-image: url('../dist/img/permission.png'); background-repeat: no-repeat; padding-left: 35px">
            <asp:Label ID="lbl_HeaderPermission" runat="server"></asp:Label>
        </h1>
        <asp:SiteMapPath ID="site" runat="server" CssClass="breadcrumb">
            <NodeStyle CssClass="active" />
        </asp:SiteMapPath>
    </div>
    <div class="content">
        <div class="inr-ftr">
            <div class="row">
                <div class="col-md-12">
                    <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>
                                (7 No.)</span>
                        </h6>
                    </div>
                </div>
                <div class="clearfix">
                </div>
            </div>
        </div>
        <asp:UpdatePanel ID="upLeave" runat="server">
            <ContentTemplate>
                <asp:Panel ID="pnlProgress" runat="server" Style="display: none;">
                    <asp:Panel ID="pnlLoading" runat="server" HorizontalAlign="center">
                        <div class="InsideProgressBar">
                            <div class="row" style="margin-top: 10px">
                                <img src="../dist/img/logo-Progress.png" />
                            </div>
                            <div class="row" style="min-width: 280px">
                                <img src="../dist/img/default.gif" style="width: 100px" />
                            </div>
                            <div class="row" style="margin-bottom: 10px">
                                <asp:Label ID="lblLoading" runat="server" ForeColor="black" Style="text-align: center"
                                    Font-Bold="true" Font-Size="12px" Font-Italic="true" Font-Family="Arial" Text="Please Wait..."></asp:Label>
                            </div>
                            <div class="clear clearfix">
                            </div>
                        </div>
                    </asp:Panel>
                </asp:Panel>
                <asp:HiddenField ID="hdnProgress" runat="server" />
                <cc1:ModalPopupExtender ID="popupProgress" runat="server" TargetControlID="hdnProgress"
                    BackgroundCssClass="ModalPopup" PopupControlID="pnlProgress" BehaviorID="popupProgress">
                </cc1:ModalPopupExtender>
            </ContentTemplate>
            <Triggers>
                <asp:PostBackTrigger ControlID="btn_add" />
            </Triggers>
        </asp:UpdatePanel>
        <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: 100px">
                    <div class="modal-header">
                        <button type="button" id="closemodal" class="close" data-dismiss="modal" style="border-radius: 50px;">
                            &times;</button>
                        <h4 class="modal-title" style="padding-bottom: 10px">
                            <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="500px"
                            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="emp-filter">
            <div class="form-horizontal">
                <div class="row">
                    <div id="books"></div>
                    <div class="col-md-12">
                        <div id="divAdmin" runat="server" class="pull-left-button">
                            <div class="row form-group">
                                <div class="col-md-2  col-sm-2">
                                    <asp:Label ID="lblEmpId" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-3  col-sm-3">
                                    <div class="input-group input-group-sm">
                                        <asp:TextBox ID="txt_EmployeeId" runat="server" CssClass="form-control man-dat" MaxLength="15"
                                            onblur="EmpName('Permission');" onkeypress="return chkMaxLen(event,this,15);"></asp:TextBox>
                                        <span class="input-group-btn">
                                            <asp:LinkButton ID="btn_Search" Text="Search" data-toggle="modal" data-target="#myModal"
                                                CssClass="btn save-btn fa-search" runat="server" OnClientClick="return OpenWindowShiftExchange('txt_EmployeeId','PermissionApplication');" />
                                        </span>
                                    </div>
                                </div>
                                <div class="col-md-2 col-md-offset-1  col-sm-2">
                                    <asp:Label ID="lblEmployeeName" Text="Employee Name" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-3  col-sm-3">
                                    <asp:TextBox ID="txt_Name" runat="server" CssClass="form-control" ReadOnly="True"></asp:TextBox>
                                </div>
                            </div>
                        </div>
                        <div id="divEmployees" runat="server">
                            <div class="row form-group">
                                <div class="col-md-2 col-sm-2">
                                    <asp:Label ID="lbl_EmployeeID1" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-3 col-sm-3">
                                    <asp:Label ID="lbl_EmployeeID" runat="server" CssClass="form-control"></asp:Label>
                                </div>
                                <div class="col-md-2 col-md-offset-1 col-sm-2">
                                    <asp:Label ID="lbl_EmployeeName1" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-3 col-sm-3">
                                    <asp:Label ID="lbl_EmployeeName" runat="server" CssClass="form-control"></asp:Label>
                                </div>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-2 col-sm-2">
                                <asp:Label ID="lbl_PermissionApplicationDate1" runat="server"></asp:Label>
                                <asp:HiddenField ID="Hidden1" runat="server" />
                                <asp:HiddenField ID="Hidden2" runat="server" />
                                <asp:HiddenField ID="hdnNoOfHours" runat="server" />
                            </div>
                            <div class="col-md-3  col-sm-3">
                                <asp:Label ID="lbl_PermissionApplicationDate" runat="server" CssClass="form-control"></asp:Label>
                            </div>
                            <%--<div class="col-md-1   col-sm-0">
                            </div>--%>
                            <div class="col-md-2 col-md-offset-1 col-sm-2">
                                <asp:Label ID="lbl_PermissionDate" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3  col-sm-3">
                                <asp:TextBox onpaste="return true" ID="TxtPermissionDate" runat="server" CssClass="form-control man-dat"
                                    EnableViewState="False"
                                    onCut="return false" onDrop="return false"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-2 col-sm-2">
                                <asp:Label ID="lbl_PermisssionTime" runat="server" Visible="false"></asp:Label>
                                <asp:Label ID="lbl_StartTime" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3 col-sm-3">
                                <asp:TextBox onpaste="return true"
                                    ID="txt_StartTime" runat="server" onkeypress="return false" CssClass="form-control man-dat" onCut="return false"
                                    onDrop="return false" onchange="return ClearPermissionHrs();"></asp:TextBox>
                            </div>
                            <div class="col-md-2 col-md-offset-1 col-sm-2">
                                <asp:Label ID="lbl_EndTime" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3 col-sm-3">
                                <asp:TextBox onpaste="return true"
                                    ID="txt_EndTime" runat="server" onkeypress="return false" CssClass="form-control man-dat visible" onCut="return false"
                                    onDrop="return false" onchange="return ClearPermissionHrs();"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-2  col-sm-2" style="display: none">
                                <asp:Label ID="lbl_RemainingNumberofHours" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3  col-sm-3" style="display: none">
                                <div class="form-control man-dat" id="tdRemainNoOfHours" style="height: 28px">
                                    <asp:Label ID="lblRemainNoOfHours" runat="server" Enabled="false">
                                    </asp:Label>
                                </div>
                            </div>
                            <div class="col-md-2 col-sm-2">
                                <asp:Label ID="lbl_NumberofHoursapplied" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3  col-sm-3">

                                <asp:TextBox onpaste="return true" ID="txt_NumberOfHours" runat="server" CssClass="form-control man-dat"
                                    MaxLength="8" onCut="return false" onDrop="return false" onkeydown="return key_press_nokey(event)"
                                    onkeypress="return key_press_nokey(event)"></asp:TextBox>
                                <span class="input-group-btn" style="display: none">
                                    <asp:LinkButton ID="btn_CalculateHrs" runat="server" CssClass="btn save-btn fa-calculator"
                                        OnClientClick="return CheckDatesAndNumberOfDays();" Text="Calculate Hours" UseSubmitBehavior="False" />
                                </span>
                            </div>
                            <div class="col-md-2 col-md-offset-1 col-sm-2">
                                <asp:Label ID="lbl_Reason" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3  col-sm-3">
                                <asp:TextBox ID="txtReason" runat="server" CssClass="form-control man-dat"
                                    MaxLength="250" onkeypress="return chkMaxLen(event,this,250,MaxLength);" TextMode="MultiLine"
                                    onCut="return false" onDrop="return false" Style="resize: none;"></asp:TextBox>
                            </div>
                        </div>
                        <div id="divError" class="alert alert-danger collapse">
                            <a id="linkClose" href="#" class="close">&times;</a>
                            <div id="divErrorText"></div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-12">
                                <div id="tblEmployee"></div>
                            </div>
                        </div>

                        <div class="row form-group" style="display: none">
                            <div class="col-md-2">
                                <asp:Label ID="lblApprovalCC" runat="server" Text="Cc Mail Ids"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox ID="txtApprovalCC" runat="server" CssClass="textbox_4" OnKeyPress="return false"
                                    Width="240px" Height="40px" TextMode="MultiLine"></asp:TextBox>
                                <asp:Button ID="btnApprovalCC" runat="server" CssClass="but" Text="Cc..." Width="28px"
                                    OnClientClick="javascript:return openPopupMailCc();" />
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-6 col-md-offset-5  col-sm-6 col-sm-offset-4">
                                <div class="pull-right-button">
                                    <asp:LinkButton ID="btn_add" CssClass="btn save-btn fa-floppy-o" runat="server" OnClick="btn_add_Click"
                                        OnClientClick="if(!Validation()) return false;" />
                                    <asp:LinkButton ID="btn_cancel" CssClass="btn save-btn fa-angle-left" runat="server"
                                        CausesValidation="False" OnClick="btn_cancel_Click" />
                                </div>
                            </div>
                        </div>
                        <asp:HiddenField ID="PolicyExistsEmployees" runat="server" />
                        <input id="hdnEmployeeId" runat="server" type="hidden" />
                        <input id="hdnRemainNoOfHours" runat="server" type="hidden" />
                        <input id="hdnNegativeValue" runat="server" type="hidden" />
                        <div class="col-md-3" style="color: Red; display: none">
                            <span class="fa fa-asterisk"></span>
                            <asp:Label ID="lbl_Error" runat="server" Style="color: #ff0000"></asp:Label>
                        </div>
                    </div>

                </div>
            </div>
        </div>
        <br />
        <div class="panel panel-info">
            <div class="panel-heading" style="padding: 10px;">Some Basic Information</div>
            <div class="panel-body" style="padding: 15px;color:red">
                Below scenarios, it wont allow the users to enter permissions,
            </div>
            <ul class="list-group">

                <li class="list-group-item">1. Punches are not available on the selected duration.</li>
                <li class="list-group-item">2. Attendance has been updated as absent.</li>
                <li class="list-group-item">3. If the logs are not processed by system.</li>
                <li class="list-group-item">4. Weekly Off and Holiday days.</li>
                <li class="list-group-item">5. Late Hours is not available days.</li>
                <li class="list-group-item">6. If staff shift & Shift exemption category employee is applied half day leave and got approved, he needs to enter to office before 2.30 PM, otherwise the system will update the attendance as absent.</li>
            </ul>
        </div>
    </div>

</asp:Content>
