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

<%--<%@ Register Src="../UserControls/TA_uc_OrgLevel_Filter.ascx" TagName="TA_uc_OrgLevel_Filter"
    TagPrefix="uc1" %>--%>
<%-- <%@ Register Src="../UserControls/TA_uc_OrgLevel_Filter_Modify.ascx" TagName="TA_uc_OrgLevel_Filter"
    TagPrefix="uc1" %>--%>
<%@ Register Src="../UserControls/TA_uc_OrgLevelFilter_Updated.ascx" TagName="TA_uc_OrgLevel_Filter"
    TagPrefix="uc1" %>
<asp:Content ContentPlaceHolderID="BodyContentPH" ID="con_MonClosAdd" runat="server">
    <!--[if gt IE 5.5]>
	<link rel="stylesheet" type="text/css" href="../css/anytimeIE.css" />
 <![endif]-->

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

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

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

    <script>
        $(function () {
            $('#ctl00_BodyContentPH_txt_StartDate').datetimepicker({ format: document.getElementById('ctl00_BodyContentPH_hdn_DateFormat').value }
            );
        });
        $(function () {
            $('#ctl00_BodyContentPH_txt_EndDate').datetimepicker({ format: document.getElementById('ctl00_BodyContentPH_hdn_DateFormat').value }
            );
        });
        $(function () {
            $('#ctl00_BodyContentPH_txt_ClosedDate').datetimepicker({ format: document.getElementById('ctl00_BodyContentPH_hdn_DateFormat').value }
            );
        });
    </script>

    <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:';
        function SetAlertCheckDate(monthfourdigit, datefourdigit, invalidyearentry, invalidmonthentry, invaliddateentry, dateformatDDMONYYYY, entertime, valueforhours, invalidvalueforminutes, invalidtimeformat, entervalidDateandTime, validdatemonthMMDDYYHHMM, validdatemonthMMDDYYHHMMTT, entervalidDateandTime, invalidvalueforhours, invalidvalueforminites) {
            Monthfourdigit = monthfourdigit;
            Datefourdigit = datefourdigit;
            Invalidyearentry = invalidyearentry;
            Invalidmonthentry = invalidmonthentry;
            Invaliddateentry = invaliddateentry;
            DateformatDDMONYYYY = dateformatDDMONYYYY;
            Entertime = Entertime;
            Valueforhours = valueforhours;
            Invalidvalueforminutes = invalidvalueforminutes;
            Invalidtimeformat = invalidtimeformat;
            EntervalidDateandTime = entervalidDateandTime;
            ValiddatemonthMMDDYYHHMM = validdatemonthMMDDYYHHMM;
            ValiddatemonthMMDDYYHHMMTT = validdatemonthMMDDYYHHMMTT;
            EntervalidDateandTime = entervalidDateandTime;
            Invalidvalueforhours = invalidvalueforhours;
            Invalidvalueforminites = invalidvalueforminites;
        }
        var SelectCompany = "Select Company";
        var SelectMonth = "Select Month";
        var SelectYear = "Select Year";
        var SelectStartDate = "Select Start Date";
        var SelectEndDate = "Select End Date";
        var SelectClosureDate = "Select Closed Date";
        var SelectCorrectYear = "Select Correct Year in Start date";
        var SelectCorrectMonth = "Select Correct Month in Start date";
        var SelectCorrectYearinEndDate = "Select Correct Year in End date";
        var SelectCorrectMonthinEndDate = "Select Correct Month in End date";
        var ConfirmSave = "Are you sure to, Save?";
        var StartDate = "Enter Start Date.";
        var EndDate = "Enter End Date.";
        var ClosedDate = "Enter Closed Date.";
        function SetAlertMessages(selectCompany, selectMonth, selectYear, selectStartDate, selectEndDate, selectClosureDate, selectCorrectYear, selectCorrectMonth, selectCorrectYearinEndDate, selectCorrectMonthinEndDate, confirmSave, startDate, endDate, closedDate) {
            SelectCompany = selectCompany;
            SelectMonth = selectMonth;
            SelectYear = selectYear;
            SelectStartDate = selectStartDate;
            SelectEndDate = selectEndDate;
            SelectClosureDate = selectClosureDate;
            SelectCorrectYear = selectCorrectYear;
            SelectCorrectMonth = selectCorrectMonth;
            SelectCorrectYearinEndDate = selectCorrectYearinEndDate;
            SelectCorrectMonthinEndDate = selectCorrectMonthinEndDate;
            ConfirmSave = confirmSave;
            StartDate = startDate;
            EndDate = endDate;
            ClosedDate = closedDate;
        }
        function dateValidation() {
            var DateFormat = document.getElementById("ctl00_BodyContentPH_hdn_DateFormat").value;
            var startDate = document.aspnetForm.ctl00_BodyContentPH_txt_StartDate.value;
            var endDate = document.aspnetForm.ctl00_BodyContentPH_txt_EndDate.value;
            //    var closedDate= document.aspnetForm.ctl00_BodyContentPH_txt_ClosedDate.value;
            if (document.aspnetForm.ctl00_BodyContentPH_ddlCompany.value == 0) {
                alert(SelectCompany);
                document.aspnetForm.ctl00_BodyContentPH_ddlCompany.focus();
                return false;
            }
            else if (document.aspnetForm.ctl00_BodyContentPH_ddl_Month.value == "-Select-") {
                alert(SelectMonth);
                document.aspnetForm.ctl00_BodyContentPH_ddl_Month.focus();
                return false;
            }
            else if (document.aspnetForm.ctl00_BodyContentPH_ddl_Year.value == "-Select-") {
                alert(SelectYear);
                document.aspnetForm.ctl00_BodyContentPH_ddl_Year.focus();
                return false;
            }
            else if (startDate == "") {
                alert(SelectStartDate);
                document.aspnetForm.ctl00_BodyContentPH_txt_StartDate.focus();
                return false;
            }
            else if (endDate == "") {
                alert(SelectEndDate);
                document.aspnetForm.ctl00_BodyContentPH_txt_EndDate.focus();
                return false;
            }
            //    else if(closedDate == "")
            //    {
            //        alert(SelectClosureDate);
            //       document.aspnetForm.ctl00_BodyContentPH_txt_ClosedDate.focus();
            //       return false;
            //    }    
            if (startDate != "" || endDate != "") {
                var Startmon, Startdate, Startyear;
                var Endmon, Enddate, Endyear;        //var Closedmon,Closeddate,Closedyear;
                Startyear = startDate.substring((startDate.length - 4), startDate.length);
                Endyear = endDate.substring((endDate.length - 4), endDate.length);
                //Closedyear = closedDate.substring((closedDate.length - 4),closedDate.length);
                if (DateFormat == "MM/DD/YYYY") {
                    Startmon = startDate.substring(0, 2);
                    Startdate = startDate.substring(3, 5);
                    Endmon = endDate.substring(0, 2);
                    Enddate = endDate.substring(3, 5);
                    //          Closedmon = closedDate.substring(0,2);
                    //          Closeddate = closedDate.substring(3,5);
                }
                else if (DateFormat == "DD/MM/YYYY") {
                    Startdate = startDate.substring(0, 2);
                    Startmon = startDate.substring(3, 5);
                    Enddate = endDate.substring(0, 2);
                    Endmon = endDate.substring(3, 5);
                    //          Closedmon = closedDate.substring(3,5);
                    //          Closeddate = closedDate.substring(0,2);
                }
                else if (DateFormat == "DD-MMM-YYYY") {
                    Startdate = startDate.substring(0, 2);
                    Startmon = Month(startDate.substring(3, 6));
                    Enddate = endDate.substring(0, 2);
                    Endmon = Month(endDate.substring(3, 6));
                    //          Closeddate = closedDate.substring(0,2);
                    //          Closedmon = Month(closedDate.substring(3,6));
                }
                var index = document.aspnetForm.ctl00_BodyContentPH_ddl_Month.selectedIndex;
                var month = document.aspnetForm.ctl00_BodyContentPH_ddl_Month.options[index].value;
                var index1 = document.aspnetForm.ctl00_BodyContentPH_ddl_Year.selectedIndex;
                var year = document.aspnetForm.ctl00_BodyContentPH_ddl_Year.options[index1].value;
                if (DateEntryValidation() == false) {
                    return false;
                }
                if (startDate != "") {
                    if (Startyear != year) {
                        alert(SelectCorrectYear);
                        return false;
                    }
                    else if (Startmon != month) {
                        if (Startmon > month) {
                            alert(SelectCorrectMonth);
                            return false;
                        }
                    }
                }
                if (endDate != "") {
                    if (Endyear != year) {
                        alert(SelectCorrectYearinEndDate);
                        return false;
                    }
                    else if (Endmon != month) {
                        {
                            alert(SelectCorrectMonthinEndDate);
                            return false;
                        }
                    }
                }
                return confirm(ConfirmSave);
            }
        }
        function DateEntryValidation() {
            if (document.aspnetForm.ctl00_BodyContentPH_txt_StartDate.value != '') {
                var weekDay = document.aspnetForm.ctl00_BodyContentPH_txt_StartDate;
                var DateFormat = document.getElementById('ctl00_BodyContentPH_hdn_DateFormat').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(StartDate);
                return false;
            }
            if (document.aspnetForm.ctl00_BodyContentPH_txt_EndDate.value != '') {
                var weekDay = document.aspnetForm.ctl00_BodyContentPH_txt_EndDate;
                var DateFormat = document.getElementById('ctl00_BodyContentPH_hdn_DateFormat').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(EndDate);
                return false;
            }
            //     if(document.aspnetForm.ctl00_BodyContentPH_txt_ClosedDate.value!='')
            //    {
            //          
            //       var weekDay=document.aspnetForm.ctl00_BodyContentPH_txt_ClosedDate;
            //       var DateFormat = document.getElementById('ctl00_BodyContentPH_hdn_DateFormat').value;
            //      
            //       if(checkDate(weekDay,DateFormat,Monthfourdigit,Invalidyearentry,Invalidmonthentry,Invaliddateentry,DateformatDDMONYYYY,Entertime,Valueforhours,Invalidvalueforminutes,Invalidtimeformat,EntervalidDateandTime,ValiddatemonthMMDDYYHHMM,ValiddatemonthMMDDYYHHMMTT,EntervalidDateandTime,Invalidvalueforhours,Invalidvalueforminites))
            //       {
            //       }
            //       else
            //       {
            //         return false;
            //       }
            //    }
            //    else
            //    {
            //        alert(ClosedDate);
            //     return false;
            //    }
            return true;
        }
    </script>

    <script language="javascript" type="text/javascript">
        function Month(Mon) {
            var Month;
            switch (Mon) {
                case "Jan":
                    Month = 1;
                    break;
                case "Feb":
                    Month = 2;
                    break;
                case "Mar":
                    Month = 3;
                    break;
                case "Apr": Month = 4;
                    break;
                case "May": Month = 5;
                    break;
                case "Jun": Month = 6;
                    break;
                case "Jul": Month = 7;
                    break;
                case "Aug": Month = 8;
                    break;
                case "Sep": Month = 9;
                    break;
                case "Oct": Month = 10;
                    break;
                case "Nov": Month = 11;
                    break;
                case "Dec": Month = 12;
                    break;
            }
            return (Month);
        }
    </script>

    <div class="content-header">
        <h1 style="background-image: url(../dist/img/month-Close.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">
        <div class="row" style="color: Red; display: none">
            <div class="col-md-12">
                <span class="fa fa-asterisk"></span>

                <asp:Label ID="lbl_Error" runat="server"></asp:Label>
            </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 style="color: Red">|</span><span style="padding-left: 10px; padding-right: 10px">
                                <asp:Label ID="lbl_IndicatesMandatoryFields" runat="server"></asp:Label>
                                (5 No.)</span>
                        </h6>
                    </div>
                </div>
                <div class="clearfix">
                </div>
            </div>
        </div>
        <div class="emp-filter">
            <div class="form-horizontal">
                <div class="row">
                    <div class="col-md-12">
                        <div class="form-group">
                            <div class="col-md-2">
                                <asp:HiddenField ID="hdn_DateFormat" runat="server" />
                                <asp:Label ID="lblCompany" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:DropDownList ID="ddlCompany" runat="server" AppendDataBoundItems="true" CssClass="form-control select2 Man-dat">
                                    <asp:ListItem Text="-Select-" Value="0"></asp:ListItem>
                                </asp:DropDownList>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-2">
                                <asp:Label ID="lbl_Month" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:DropDownList ID="ddl_Month" CssClass="form-control select2 Man-dat" runat="server">
                                    <asp:ListItem Value="-Select-" Text="-Select-"></asp:ListItem>
                                    <asp:ListItem Value="01" Text="January"></asp:ListItem>
                                    <asp:ListItem Value="02" Text="February"></asp:ListItem>
                                    <asp:ListItem Value="03" Text="March"></asp:ListItem>
                                    <asp:ListItem Value="04" Text="April"></asp:ListItem>
                                    <asp:ListItem Value="05" Text="May"></asp:ListItem>
                                    <asp:ListItem Value="06" Text="June"></asp:ListItem>
                                    <asp:ListItem Value="07" Text="July"></asp:ListItem>
                                    <asp:ListItem Value="08" Text="August"></asp:ListItem>
                                    <asp:ListItem Value="09" Text="September"></asp:ListItem>
                                    <asp:ListItem Value="10" Text="October"></asp:ListItem>
                                    <asp:ListItem Value="11" Text="November"></asp:ListItem>
                                    <asp:ListItem Value="12" Text="December"></asp:ListItem>
                                </asp:DropDownList>
                            </div>
                            <div class="col-md-1">
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lbl_Year" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:DropDownList ID="ddl_Year" CssClass="form-control select2 Man-dat" runat="server">
                                    <asp:ListItem Text="-Select-" Value="-Select-"></asp:ListItem>
                                </asp:DropDownList>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-2">
                                <asp:Label ID="lbl_StartDate" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txt_StartDate" runat="server" CssClass="form-control man-dat"
                                    onCut="return false" onDrop="return false"></asp:TextBox>
                            </div>
                            <div class="col-md-1">
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lbl_EndDate" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txt_EndDate" runat="server" CssClass="form-control man-dat"
                                    onCut="return false" onDrop="return false"></asp:TextBox>
                            </div>
                        </div>
                        <div class="form-group" style="display: none;">
                            <div class="col-md-2">
                                <asp:Label ID="lbl_ClosedDate" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txt_ClosedDate" runat="server" CssClass="form-control man-dat"
                                    onCut="return false" onDrop="return false"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-5">
                            </div>
                            <div class="col-md-6">
                                <div class="pull-right-button">
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="ddl_Month"
                                        ErrorMessage="Select Month" InitialValue="-Select-" SetFocusOnError="True">*</asp:RequiredFieldValidator>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="ddl_Year"
                                        ErrorMessage="Select Year" InitialValue="-Select-" SetFocusOnError="True">*</asp:RequiredFieldValidator>
                                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True"
                                        ShowSummary="False" />
                                    <asp:LinkButton ID="btn_Save" CssClass="btn add-btn fa-floppy-o" runat="server" OnClick="btn_Save_Click"
                                        OnClientClick="return dateValidation();" />
                                    <asp:LinkButton ID="btn_Cancel" CssClass="btn save-btn fa-angle-left" runat="server"
                                        CausesValidation="false" OnClick="btn_Cancel_Click" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</asp:Content>
