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

<%@ Register Src="../UserControls/TA_uc_OrgLevelFilter_Updated.ascx" TagName="TA_uc_OrgLevel_Filter"
    TagPrefix="uc1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ContentPlaceHolderID="BodyContentPH" ID="conLeaveAnalysisReport" runat="server">

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

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

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

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

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

    <script language="javascript" type="text/javascript">
        function ConvertStringMonthToInt(month) {
            var mon = month;
            switch (mon) {
                case "Jan":
                    mon = "01";
                    break;
                case "Feb":
                    mon = "02";
                    break;
                case "Mar":
                    mon = "03";
                    break;
                case "Apr":
                    mon = "04";
                    break;
                case "May":
                    mon = "05";
                    break;
                case "Jun":
                    mon = "06";
                    break;
                case "Jul":
                    mon = "07";
                    break;
                case "Aug":
                    mon = "08";
                    break;
                case "Sep":
                    mon = "09";
                    break;
                case "Oct":
                    mon = "10";
                    break;
                case "Nov":
                    mon = "11";
                    break;
                case "Dec":
                    mon = "12";
                    break;
            }
            return mon;
        }

        function ValidateDateWithCurrentDate(Year1, Year2, Month1, Month2, Date1, Date2) {
            var IsValid = "";

            if (Year1 > Year2) {
                IsValid = "false";
            }
            if (Year1 == Year2) {
                if (Month1 > Month2) {
                    IsValid = "false";
                }
                if (Month1 == Month2) {
                    if (Date1 > Date2) {
                        IsValid = "false";
                    }
                }
            }

            if (IsValid == "false") {
                alert("The date exceeds current date");
                document.getElementById("<%= txtEntryDate.ClientID%>").focus();
                return false;
            }
            else {
                return true;
            }
        }

        function ValidateDate() {
            if (document.getElementById("<%= txtEntryDate.ClientID %>").value != "") {
                //validation for MM/dd/YYYY format
                if (document.getElementById('ctl00_BodyContentPHRpt_Hidden1').value == '%m/%d/%Y') {
                    var date1 = document.getElementById("<%= txtEntryDate.ClientID%>").value;
            var date1Month = date1.substring(0, 2);
            var date1Date = date1.substring(3, 5);
            var date1Year = date1.substring(6, date1.length);
        }

                //validation for dd/MM/YYYY format
        if (document.getElementById('ctl00_BodyContentPHRpt_Hidden1').value == '%d/%m/%Y') {
            var date1 = document.getElementById("<%= txtEntryDate.ClientID%>").value;
            var date1Month = date1.substring(3, 5);
            var date1Date = date1.substring(0, 2);
            var date1Year = date1.substring(6, date1.length);
        }

                //validation for dd-MMM-YYYY format
        if (document.getElementById('ctl00_BodyContentPHRpt_Hidden1').value == '%d-%b-%Y') {
            var date1 = document.getElementById("<%= txtEntryDate.ClientID%>").value;
            var mon = date1.substring(3, 6);
            mon = ConvertStringMonthToInt(mon);
            var date1Month = mon;
            //var date1Month = Month(mon);
            var date1Date = date1.substring(0, 2);
            var date1Year = date1.substring(7, date1.length);
        }

        var today = new Date();
        CurrentYear = today.getFullYear();//Gets the current year.
        var month_names = new Array("Jan", "Feb", "Mar",
         "Apr", "May", "Jun", "Jul", "Aug", "Sep",
         "Oct", "Nov", "Dec");
        CurrentMonth = today.getMonth();//Gets the current month.
        CurrentMonth = month_names[CurrentMonth];
        CurrentDate = today.getDate(); //Gets the current date.
        var ReturnValue = ValidateDateWithCurrentDate(date1Year, CurrentYear, date1Month, ConvertStringMonthToInt(CurrentMonth), date1Date, CurrentDate);
        if (ReturnValue == false) {
            return false;
        }
    }
    else {
        alert("Entry date is required");
        return false;
    }
}

    </script>

    <script type="text/javascript">

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

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

        });
    </script>

    <div class="content-header" id="conHeader" runat="server">
        <h1 style="background-image: url(../dist/img/swipe-icon.png); background-repeat: no-repeat; padding-left: 35px">
            <asp:Label ID="lblLeaveAnalysisReport" 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-sm-2">
                    <div class="inr-fil-text">
                        <asp:Label ID="lblFilter" runat="server" Text="Filters"></asp:Label>
                        <asp:Label ID="Label1" runat="server" Visible="false"></asp:Label>
                        <input id="Hidden3" type="hidden" value='<% Response.Write(Convert.ToString(Session["IDateFormat"])); %>' />
                    </div>
                </div>
                <div class="clearfix">
                </div>
            </div>
        </div>
        <div id="collapseOne">
            <div class="emp-filter">
                <div class="form-horizontal">
                    <asp:HiddenField ID="Hidden1" runat="server" />
                    <div id="divEmployeeDetails" runat="server">
                        <div class="row form-group">
                            <div class="col-md-2">
                                <asp:Label ID="lblEmployeeName" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox ID="txtEmployeeName" runat="server" CssClass="form-control"></asp:TextBox>
                                <cc1:AutoCompleteExtender ID="acEmployeeName" runat="server" CompletionSetCount="10"
                                    CompletionListItemCssClass="item" CompletionListHighlightedItemCssClass="AutocompleteCSS"
                                    CompletionInterval="10" Enabled="true" MinimumPrefixLength="1" TargetControlID="txtEmployeeName"
                                    ServicePath="../WebServices/AutoCompleteExtender.asmx" ServiceMethod="GetEmployeeNameForReports"
                                    CompletionListCssClass="autocomplete_completionListElement" FirstRowSelected="true">
                                </cc1:AutoCompleteExtender>
                            </div>
                            <div class="col-md-1">
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lblEmployeeId" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox ID="txtEmployeeId" runat="server" CssClass="form-control"></asp:TextBox>
                                <cc1:AutoCompleteExtender ID="acEmployeeId" runat="server" CompletionSetCount="10"
                                    CompletionListItemCssClass="item" CompletionListHighlightedItemCssClass="AutocompleteCSS"
                                    CompletionInterval="10" Enabled="true" MinimumPrefixLength="1" TargetControlID="txtEmployeeId"
                                    ServicePath="../WebServices/AutoCompleteExtender.asmx" ServiceMethod="GetEmployeeIdForReports"
                                    CompletionListCssClass="autocomplete_completionListElement" FirstRowSelected="true">
                                </cc1:AutoCompleteExtender>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-2">
                                <asp:Label ID="lblEmpCategory" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:DropDownList ID="ddlEmpCatagory" runat="server" CssClass="form-control select2"
                                    AppendDataBoundItems="true">
                                    <asp:ListItem Value="0" Selected="True">-Select-</asp:ListItem>
                                </asp:DropDownList>
                            </div>
                            <div class="col-md-1">
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lblEmpType" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:DropDownList ID="ddlEmpType" runat="server" CssClass="form-control select2"
                                    AppendDataBoundItems="true">
                                    <asp:ListItem Value="0" Selected="True">-Select-</asp:ListItem>
                                </asp:DropDownList>
                            </div>
                        </div>
                    </div>
                    <div class="row form-group">
                        <div class="col-md-2">
                            <asp:Label ID="lblTimePeriod" runat="server"></asp:Label>
                            -
                            <asp:Label ID="lblFrom" runat="server"></asp:Label>
                        </div>
                        <div class="col-md-3">
                            <asp:TextBox onpaste="return true" ID="txtFromDate" runat="server" Width="150px"
                                CssClass="form-control" onCut="return false" onDrop="return false" MaxLength="11"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="reqFromDate" runat="server" ControlToValidate="txtFromDate"
                                Display="None" EnableClientScript="False" ErrorMessage="Please select FromDate"></asp:RequiredFieldValidator>
                        </div>
                        <div class="col-md-1">
                        </div>
                        <div class="col-md-2">
                            <asp:Label ID="lblTo" runat="server"></asp:Label>
                        </div>
                        <div class="col-md-3">
                            <asp:TextBox onpaste="return true" ID="txtToDate" runat="server" Width="150px" CssClass="form-control"
                                onCut="return false" onDrop="return false" MaxLength="11"></asp:TextBox>
                            <asp:CustomValidator ID="cus_ComToDate" runat="server" EnableClientScript="False"
                                OnServerValidate="CompareDate" ErrorMessage="Select valid date compare with Fromdate"
                                Display="None"></asp:CustomValidator>
                            <asp:RequiredFieldValidator ID="reqToDate" runat="server" ControlToValidate="txtToDate"
                                Display="None" EnableClientScript="False" ErrorMessage="Please select ToDate"></asp:RequiredFieldValidator>
                        </div>
                    </div>
                    <div class="row">
                        <div class="row">
                            <div class="line16">
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <asp:PlaceHolder ID="PlaceHolderLeaveApplication" runat="server">
                                <uc1:TA_uc_OrgLevel_Filter ID="TA_uc_OrgLevel_Filter1" runat="server" />
                            </asp:PlaceHolder>
                        </div>
                    </div>
                    <div class="row form-group">
                        <div class="col-md-2">
                            <asp:Label ID="lblIntimationType" runat="server"></asp:Label>
                        </div>
                        <div class="col-md-3">
                            <asp:CheckBox ID="chkPlannedLeave" runat="server" CssClass="checkbox checkbox-primary" />
                        </div>
                        <div class="col-md-3">
                            <asp:CheckBox ID="chkUnPlannedLeaveWI" runat="server" CssClass="checkbox checkbox-primary" />
                        </div>
                        <div class="col-md-3">
                            <asp:CheckBox ID="chkUnPlannedLeaveWOI" runat="server" CssClass="checkbox checkbox-primary" />
                        </div>
                    </div>
                    <div class="row form-group">
                        <div class="col-md-2">
                            <asp:Label ID="Label2" runat="server" Text="Month"></asp:Label>
                        </div>
                        <div class="col-md-3">
                            <asp:DropDownList ID="ddlMonth" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlMonth_SelectedIndexChanged"
                                CssClass="form-control select2">
                            </asp:DropDownList>
                        </div>
                        <div class="col-md-1">
                        </div>
                        <div class="col-md-2">
                            <asp:Label ID="Label3" runat="server" Text="Year"></asp:Label>
                        </div>
                        <div class="col-md-3">
                            <asp:DropDownList ID="ddlYear" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlYear_SelectedIndexChanged"
                                CssClass="form-control select2">
                            </asp:DropDownList>
                        </div>
                    </div>
                    <div class="row form-group" id="trView" runat="server">
                        <div class="col-md-5">
                        </div>
                        <div class="col-md-6">
                            <div class="pull-right-button">
                                <asp:LinkButton ID="btn_View" CssClass="btn save-btn fa-eye" runat="server" OnClick="btn_View_Click"
                                    OnClientClick="return DateEntryValidation()" />
                            </div>
                        </div>
                    </div>
                    <div class="row form-group">
                        <div class="col-md-11" style="overflow: auto; padding-bottom: 10px;">
                            <asp:GridView ID="grdRemarks" OnRowCommand="grdRemarks_RowCommand" OnRowDataBound="grdRemarks_RowDataBound"
                                Width="100%" runat="server" AutoGenerateColumns="false" CssClass="table das-table1"
                                DataSourceID="ObjectDataSource1" BorderColor="white" BorderWidth="1px">
                                <Columns>
                                    <asp:TemplateField HeaderText="Date">
                                        <ItemTemplate>
                                            <asp:Label ID="lblDate" Text='<%# Bind("DateIns") %>' runat="server">
                                            </asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Notes">
                                        <ItemTemplate>
                                            <asp:Label ID="lblNotes" Text='<%# Bind("Notes")%>' runat="server" ></asp:Label>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:TextBox ID="txtNotes" runat="server" Height="100px" Rows="10" Text='<%# Bind("Notes")%>'
                                                TextMode="MultiLine" Width="90%"></asp:TextBox>
                                            <asp:Label ID="lblId" Text='<%# Bind("Id") %>' runat="server" Style="display: none">
                                            </asp:Label>
                                        </EditItemTemplate>
                                    </asp:TemplateField>
                                    <%--<asp:TemplateField HeaderText="Id" Visible="true"> 
                                        <ItemTemplate>
                                            &nbsp;&nbsp;
                                            <asp:Label ID="lblId" Text='<%# Bind("Id") %>' runat="server">
                                            </asp:Label>                                           
                                        </ItemTemplate>
                                       
                                        <ItemStyle HorizontalAlign="Center" />
                                    </asp:TemplateField>--%>
                                    <asp:CommandField ShowEditButton="True" />
                                    <asp:TemplateField HeaderText="Select">
                                        <ItemTemplate>
                                            <asp:LinkButton ID="LinkButton1" OnClientClick="return confirm('Are you sure to Delete?');return false;"
                                                CommandArgument='<%# Eval("Id") %>' CommandName="Del" runat="server">
                                        Delete</asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <HeaderStyle CssClass="empheader" />
                                <RowStyle Height="30px" CssClass="table-bg" BorderColor="#C5DFFC" />
                                <PagerStyle Font-Overline="False" HorizontalAlign="Right" CssClass="GridPager" />
                                <AlternatingRowStyle BackColor="white" />
                            </asp:GridView>
                            <%----%>
                            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" UpdateMethod="UpdateLeaveAnalysisNotes"
                                OnUpdated="ObjectDataSource1_Updated" SelectMethod="SelectLeaveAnalysisNotes"
                                TypeName="GetReports">
                                <UpdateParameters>
                                    <asp:Parameter Name="strOpr" DefaultValue="U" Type="String" />
                                    <asp:Parameter Name="Id" Type="Int32" />
                                    <asp:Parameter Name="Notes" Type="String" />
                                    <asp:SessionParameter Name="iEmpID" SessionField="EmpAutoID" />
                                </UpdateParameters>
                                <SelectParameters>
                                    <%--<asp:ControlParameter ControlID="txtFromDate" Name="strDate" />--%>
                                    <asp:SessionParameter Name="strDate" SessionField="Date" />
                                </SelectParameters>
                            </asp:ObjectDataSource>
                        </div>
                    </div>
                    <div class="row form-group">
                        <div class="col-md-2">
                            Add New Remarks :
                        </div>
                        <div class="col-md-9">
                            <asp:TextBox ID="txtRemarks" TextMode="MultiLine" Width="100%" Height="100px" Rows="10"
                                CssClass="form-control" runat="server"></asp:TextBox>
                        </div>
                    </div>
                    <div class="row form-group">
                        <div class="col-md-2">
                            <asp:Label ID="lblEntryDate" runat="server" Text="Entry Date"></asp:Label>
                        </div>
                        <%-- <asp:TextBox ID="txtEntryDate" runat="server" CssClass="textbox_4" onCut="return false"
                                            onDrop="return false" onkeydown="return key_press_nokey(this)" onkeypress="return false;"
                                            onpaste="return true">
                                        </asp:TextBox>--%>
                        <div class="col-md-3">
                            <asp:TextBox onpaste="return true" ID="txtEntryDate" runat="server" Width="150px"
                                CssClass="form-control man-dat" onCut="return false" onDrop="return false" MaxLength="11"></asp:TextBox>

                            <script type="text/javascript">

                                var rangeDemoFormat = document.getElementById('ctl00_BodyContentPHRpt_Hidden1').value;
                                var rangeDemoConv = new AnyTime.Converter({ format: rangeDemoFormat }); if (rangeDemoFormat == '%d-%b-%Y') { var Earlier = "01-Jan-1900"; var Final = "31-Dec-9999"; } else { var Earlier = "01/01/1900"; var Final = "12/31/9999"; }
                                $("#ctl00_BodyContentPHRpt_txtEntryDate").AnyTime_picker({ earliest: Earlier, format: rangeDemoFormat, latest: Final });
                            </script>

                        </div>
                        <div class="col-md-1">
                        </div>
                        <div class="col-md-2">
                        </div>
                        <div class="col-md-3">
                            <div class="pull-right-button">
                                <asp:LinkButton ID="btnSave" CssClass="btn save-btn fa-floppy-o" Text="  Save Notes"
                                    runat="server" OnClientClick="return ValidateDate()" OnClick="btnSave_Click" />
                                <asp:ValidationSummary ID="ValidationSummary1" ShowMessageBox="false" ShowSummary="true"
                                    runat="server" />
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script language="javascript" 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';
        var EntervalidDateandTime = 'Please enter valid Date and Time';
        var Invalidvalueforhours = 'Invalid value for hours:';
        var Invalidvalueforminites = 'Invalid value for minutes:';
        var MaxLength = "Maximum length is ";
        var FromDate = "Enter Valid From Date";
        var ToDate = "Enter Valid To Date";

        function SetAlertMessages(fromdate, enterToDate) {

            FromDate = fromdate;
            ToDate = enterToDate;
        }



        function DateEntryValidation() {
            var rangeDemoFormat = document.getElementById('ctl00_BodyContentPHRpt_Hidden1').value;
            var rangeDemoConv = new AnyTime.Converter({ format: rangeDemoFormat }); if (rangeDemoFormat == '%d-%b-%Y') { var Earlier = "01-Jan-1900"; var Final = "31-Dec-9999"; } else { var Earlier = "01/01/1900"; var Final = "12/31/9999"; }
            $("#ctl00_BodyContentPHRpt_txtFromDate").AnyTime_noPicker();
            $("#ctl00_BodyContentPHRpt_txtFromDate").AnyTime_picker({ earliest: Earlier, format: rangeDemoFormat, latest: Final });
            $("#ctl00_BodyContentPHRpt_txtToDate").AnyTime_noPicker();
            $("#ctl00_BodyContentPHRpt_txtToDate").AnyTime_picker({ earliest: Earlier, format: rangeDemoFormat, latest: Final });
            if (document.aspnetForm.ctl00_BodyContentPHRpt_txtFromDate.value != '') {
                var weekDay = document.aspnetForm.ctl00_BodyContentPHRpt_txtFromDate;
                var DateFormat = document.getElementById('ctl00_BodyContentPHRpt_Hidden1').value;

                if (checkDate(weekDay, DateFormat, Monthfourdigit, Datefourdigit, Invalidyearentry, Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours, Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime, ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, EntervalidDateandTime, Invalidvalueforhours, Invalidvalueforminites)
         ) {
                    if (document.aspnetForm.ctl00_BodyContentPHRpt_txtToDate.value != '') {
                        var weekDay = document.aspnetForm.ctl00_BodyContentPHRpt_txtToDate;
                        var DateFormat = document.getElementById('ctl00_BodyContentPHRpt_Hidden1').value;

                        if (checkDate(weekDay, DateFormat, Monthfourdigit, Datefourdigit, Invalidyearentry, Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours, Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime, ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, EntervalidDateandTime, Invalidvalueforhours, Invalidvalueforminites)
         ) {
                        }
                        else {
                            return false;
                        }
                    }
                    else {
                        alert(ToDate);

                        return false;
                    }
                }
                else {
                    return false;
                }
            }
            else {
                alert(FromDate);

                return false;
            }


        }


    </script>

</asp:Content>
