<%@ page language="C#" autoeventwireup="true" inherits="Forms_ScheduleListing, App_Web_phobza4z" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Src="~/UserControls/New_Header.ascx" TagName="Header" TagPrefix="uc1" %>
<%@ Register Src="~/UserControls/New_Footer.ascx" TagName="Footer" TagPrefix="uc2" %>

<%--<%@ Register Assembly="DevExpress.Web.ASPxGridView.v8.2, Version=8.2.10.0, Culture=neutral, PublicKeyToken=9B171C9FD64DA1D1"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v8.2, Version=8.2.10.0, Culture=neutral, PublicKeyToken=9B171C9FD64DA1D1"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v8.2" Namespace="DevExpress.Web.ASPxEditors"
    TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v8.2.Export, Version=8.2.10.0, Culture=neutral, PublicKeyToken=9B171C9FD64DA1D1"
    Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="exp" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v8.2, Version=8.2.10.0, Culture=neutral, PublicKeyToken=9B171C9FD64DA1D1"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>--%>

<%@ Register Assembly="DevExpress.Web.v14.2" Namespace="DevExpress.Web" TagPrefix="dxw" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <meta http-equiv="Page-Enter" content="blendTrans(Duration=0)" />
    <meta http-equiv="Page-Exit" content="blendTrans(Duration=0)" />
    <title>tSense-IoT Scheduling Of Commands</title>
    <link id="reset" runat="server" href="../css/reset.css" rel="stylesheet" type="text/css" />
    <link id="stylesheet2" runat="server" href="../css/stylesheet2.css" rel="stylesheet" type="text/css" />
    <link id="dropdown" runat="server" href="../css/dropdown.css" rel="stylesheet" type="text/css" />
    <link rel="SHORTCUT ICON" href="../images/favicon.ico" />
    <style type="text/css">
        </style>

    <script src="../js/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script language="JavaScript1.2" type="text/javascript" src="../js/myformvalidations.js"></script>
    <script src="../js/wow.min.js"></script>
</head>
<body>
    <div id="container">
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel runat="server" ID="updDriverDetails" UpdateMode="Conditional">
                <ContentTemplate>
                    <!-- Header Starts Here -->
                    <uc1:Header ID="ucHeader" runat="server" />
                    <!-- Nav Ends Here -->
                    <!-- Content Starts Here -->
                    <div id="outer">
                        <div id="inner">
                            <div id="float-wrap">
                                <!-- Main Content Starts Here -->
                                <div id="content">
                                    <div class="content-wrap">
                                        <div id="top-content">
                                            <div id="heading">
                                                <img class="icon" src="../images/configuration-icon.jpg" alt="" />
                                                <h1>
                                                    <asp:Literal ID="lblConfigurationSetupCaption" Text="Configuration" runat="server"></asp:Literal>
                                                </h1>
                                                <asp:LinkButton ID="lnkHomeCaption" runat="server"></asp:LinkButton><span>&gt;</span><span><a
                                                    href="ScheduleListing.aspx"><asp:Label ID="lblMngDriver" Text="Manage Listing"
                                                        runat="server"></asp:Label></a></span>
                                            </div>
                                            <div id="control-box">
                                                <table border="0" cellpadding="0" cellspacing="0" id="control-tbl" width="100%">
                                                    <tr>
                                                        <td>
                                                            <div id="control-btn">
                                                                <table>
                                                                    <tr height="20px">
                                                                        <td></td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:LinkButton ID="lbtnHistory" runat="server" class="btn" Width="120px"
                                                                                PostBackUrl="~/Forms/SchedulingOfCommands.aspx"><span>Command Scheduling</span></asp:LinkButton>
                                                                        </td>
                                                                        <td>
                                                                            <asp:ImageButton ID="ibtnBackToConfig" runat="server" CausesValidation="false" ImageUrl="~/images/btn-back-to-configuration.jpg"
                                                                                PostBackUrl="~/Forms/ConfigurationSetup.aspx" />
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>
                                            <div class="clear clearfix">
                                            </div>
                                        </div>
                                        <div class="clear clearfix">
                                        </div>
                                        <asp:Panel ID="pnlScheduleInputDetails" runat="server">
                                            <div class="form-box">
                                                <h1>
                                                    <span class="icon">
                                                        <%--<img src="../images/driver-scheduling-caption.png" alt="" />--%></span><asp:Label ID="lblCapSchedule"
                                                            Text="Schedule Details" runat="server"></asp:Label></h1>
                                                <table cellspacing="5px" border="0" class="form-tbl" width="100%">
                                                    <tr id="trInputs" runat="server">
                                                        <td></td>
                                                        <td>
                                                            <asp:Label ID="lblFleet" runat="server" Text="Fleet"></asp:Label>
                                                            <asp:Label ID="Label1" runat="server" ForeColor="Red">*</asp:Label>
                                                        </td>
                                                        <td class="dropdown">
                                                            <asp:DropDownList ID="ddlFleet" runat="server" OnSelectedIndexChanged="ddlFleet_SelectedIndexChanged"
                                                                AutoPostBack="true">
                                                            </asp:DropDownList>
                                                        </td>

                                                        <td>
                                                            <asp:Label ID="lblVehicle" runat="server" Text="Vehicle"></asp:Label>
                                                            <asp:Label ID="Label2" runat="server" ForeColor="Red">*</asp:Label>
                                                        </td>
                                                        <td class="dropdown">
                                                            <asp:DropDownList ID="ddlVehicle" runat="server" AutoPostBack="false">
                                                            </asp:DropDownList>
                                                        </td>

                                                        <td>
                                                            <asp:Label ID="lblReptype" runat="server" Text="Interval"></asp:Label>
                                                        </td>
                                                        <td>
                                                            <asp:DropDownList ID="ddlRepType" runat="server" onchange="Intervals();">
                                                                <asp:ListItem Selected="True" Text="Date Range" Value="1"></asp:ListItem>
                                                                <asp:ListItem Text="This Week" Value="2"></asp:ListItem>
                                                                <asp:ListItem Text="Last Week" Value="3"></asp:ListItem>
                                                                <asp:ListItem Text="This Month" Value="4"></asp:ListItem>
                                                                <asp:ListItem Text="Last Month" Value="5"></asp:ListItem>
                                                            </asp:DropDownList>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td></td>
                                                        <td>
                                                            <%-- <img src="../images/calendar-icon.gif" alt="From" />--%>
                                                            <asp:Label ID="lblFromDate" runat="server" Text="From" CssClass="label"></asp:Label>
                                                            <asp:Label ID="Label15" runat="server" ForeColor="Red">*</asp:Label>
                                                        </td>
                                                        <td>
                                                            <asp:TextBox ID="txtFromDate" runat="server" onkeypress="return false" onpaste="return false"></asp:TextBox>
                                                            <cc1:CalendarExtender ID="calFromdate" runat="server" CssClass="cal_Theme1" TargetControlID="txtFromDate"
                                                                Format="dd/MM/yyyy" OnClientDateSelectionChanged="checkDate">
                                                            </cc1:CalendarExtender>
                                                        </td>

                                                        <td>
                                                            <%-- <img src="../images/calendar-icon.gif" alt="To" />--%>
                                                            <asp:Label ID="lblToDate" runat="server" CssClass="label" Text="To"></asp:Label>
                                                            <asp:Label ID="Label9" runat="server" ForeColor="Red">*</asp:Label>
                                                        </td>
                                                        <td>
                                                            <asp:TextBox ID="txtToDate" runat="server" onkeypress="return false" onpaste="return false"
                                                                TabIndex="12"></asp:TextBox>
                                                            <cc1:CalendarExtender ID="calTodate" runat="server" CssClass="cal_Theme1" TargetControlID="txtToDate"
                                                                Format="dd/MM/yyyy" OnClientDateSelectionChanged="CheckGreaterThanFromdate">
                                                            </cc1:CalendarExtender>
                                                        </td>

                                                        <td>
                                                            <asp:Label ID="lblStatus" runat="server" Text="Status"></asp:Label>
                                                        </td>
                                                        <td>
                                                            <asp:DropDownList ID="ddlStatus" runat="server" AutoPostBack="true"
                                                                OnSelectedIndexChanged="ddlStatus_SelectedIndexChanged">
                                                                <asp:ListItem Text="All" Value="All" Selected="True"></asp:ListItem>
                                                                <asp:ListItem Text="Success" Value="Success"></asp:ListItem>
                                                                <asp:ListItem Text="Failed" Value="Failed"></asp:ListItem>
                                                            </asp:DropDownList>
                                                        </td>
                                                        <td>
                                                            <asp:ImageButton ID="btnView" runat="server" OnClientClick="return ValidateScheduleofCommands();"
                                                                OnClick="btnView_Click" ImageUrl="~/images/btn-view-schedules.png" />
                                                        </td>
                                                    </tr>
                                                </table>
                                                <div class="clear clearfix">
                                                </div>
                                            </div>
                                        </asp:Panel>
                                    </div>
                                    <div class="clear clearfix">
                                    </div>

                                    <asp:Panel ID="pnlScheduleDetails" runat="server">
                                        <div class="form-box">
                                            <h1>
                                                <span class="icon">
                                                    <img src="../images/icn-driver-information.gif" alt="" /></span><asp:Label ID="Label7"
                                                        runat="server" Text="Scheduling Details"></asp:Label></h1>
                                        </div>
                                        <div id="grid-dsply">
                                            <dxw:ASPxGridView ID="gvScheduleDetails" ClientInstanceName="gvScheduleDetails" runat="server"
                                                Width="100%" EnableTheming="true" KeyFieldName="ScheduleId" CssFilePath="~/App_Themes/Office2003 Blue/{0}/styles.css"
                                                Settings-ShowFilterRow="true" CssPostfix="Office2003_Blue">
                                                <ClientSideEvents SelectionChanged="function(s, e) { OnGridSelectionChanged(1); }" />
                                                <Settings ShowVerticalScrollBar="true" VerticalScrollableHeight="250" />
                                                <SettingsBehavior ProcessSelectionChangedOnServer="false" />
                                                <Images ImageFolder="~/App_Themes/Office2003 Blue/{0}/">
                                                    <CollapsedButton Height="12px" Url="~/App_Themes/Office2  003 Blue/GridView/gvCollapsedButton.png"
                                                        Width="11px" />
                                                    <ExpandedButton Height="12px" Url="~/App_Themes/Office2003 Blue/GridView/gvExpandedButton.png"
                                                        Width="11px" />
                                                    <DetailCollapsedButton Height="12px" Url="~/App_Themes/Office2003 Blue/GridView/gvCollapsedButton.png"
                                                        Width="11px" />
                                                    <DetailExpandedButton Height="12px" Url="~/App_Themes/Office2003 Blue/GridView/gvExpandedButton.png"
                                                        Width="11px" />
                                                </Images>
                                                <Styles CssFilePath="~/App_Themes/Office2003 Blue/{0}/grid.css" AlternatingRow-Enabled="True"
                                                    CssPostfix="Office2003_Blue">
                                                    <Header ImageSpacing="5px" SortingImageSpacing="5px">
                                                    </Header>
                                                    <LoadingPanel ImageSpacing="10px">
                                                    </LoadingPanel>
                                                    <PagerBottomPanel CssClass="PageFooter">
                                                    </PagerBottomPanel>
                                                    <PagerTopPanel CssClass="PageFooter">
                                                    </PagerTopPanel>
                                                </Styles>
                                                <SettingsPager PrevPageButton-Image-Url="../App_Themes/Office2003 Blue/GridView/pPrev.gif"
                                                    PrevPageButton-Image-UrlDisabled="../App_Themes/Office2003 Blue/GridView/pPrevDisabled.gif"
                                                    NextPageButton-Image-UrlDisabled="../App_Themes/Office2003 Blue/GridView/pNextDisabled.gif"
                                                    NextPageButton-Image-Url="../App_Themes/Office2003 Blue/GridView/pNext.gif" AlwaysShowPager="true">
                                                </SettingsPager>
                                                <Columns>
                                                    <dxw:GridViewDataColumn Caption="VehicleDescription" FieldName="VehicleDescription" Width="10%">
                                                        <HeaderCaptionTemplate>
                                                            <span>
                                                                <%--<img src="../images/icn-address.gif" alt="" align="middle" />&nbsp;--%> 
                                                        Vehicle Name</span>
                                                        </HeaderCaptionTemplate>
                                                    </dxw:GridViewDataColumn>

                                                    <dxw:GridViewDataColumn Caption="BoxCmdOutTypeName" FieldName="BoxCmdOutTypeName" Width="10%">
                                                        <HeaderCaptionTemplate>
                                                            <span>
                                                                <%--<img src="../images/icn-address.gif" alt="" align="middle" />&nbsp; --%>Command 
                                                        Name</span>
                                                        </HeaderCaptionTemplate>
                                                    </dxw:GridViewDataColumn>

                                                    <dxw:GridViewDataColumn Caption="ExecutionType" FieldName="ExecutionType"
                                                        Width="10%">
                                                        <HeaderCaptionTemplate>
                                                            <span>
                                                                <%--<img src="../images/icn-driver-information.gif" alt="" align="top" />&nbsp;--%>Executed 
                                                        Type</span>
                                                        </HeaderCaptionTemplate>
                                                    </dxw:GridViewDataColumn>
                                                    <dxw:GridViewDataColumn Caption="Frequency" FieldName="FrequencyName"
                                                        Width="8%">
                                                        <HeaderCaptionTemplate>
                                                            <span>
                                                                <%--<img src="../images/icn-driver-information.gif" alt="" align="top" />&nbsp;--%>Frequency</span>
                                                        </HeaderCaptionTemplate>
                                                    </dxw:GridViewDataColumn>
                                                    <dxw:GridViewDataColumn Caption="ExecutedOn" FieldName="ExecutionOn"
                                                        Width="16%">
                                                        <HeaderCaptionTemplate>
                                                            <span>
                                                                <%--<img src="../images/icn-driver-information.gif" alt="" align="top" />&nbsp;--%>Executed On</span>
                                                        </HeaderCaptionTemplate>
                                                    </dxw:GridViewDataColumn>
                                                    <dxw:GridViewDataColumn Caption="Tries" FieldName="No.ofRetries"
                                                        Width="6%" CellStyle-HorizontalAlign="Center">
                                                        <HeaderCaptionTemplate>
                                                            <span>
                                                                <%--<img src="../images/icn-driver-information.gif" alt="" align="top" />&nbsp;--%>No.ofTries </span>
                                                        </HeaderCaptionTemplate>
                                                    </dxw:GridViewDataColumn>
                                                    <dxw:GridViewDataColumn Caption="Status" FieldName="commandStatus"
                                                        Width="10%" CellStyle-HorizontalAlign="Center">
                                                        <HeaderCaptionTemplate>
                                                            <span>
                                                                <%--<img src="../images/icn-driver-information.gif" alt="" align="top" />&nbsp;--%>Status
                                                            </span>
                                                        </HeaderCaptionTemplate>
                                                    </dxw:GridViewDataColumn>
                                                </Columns>
                                                <Settings ShowFilterRow="true" ShowFilterRowMenu="True" />
                                                <SettingsText EmptyDataRow="No Schedule details found" />
                                            </dxw:ASPxGridView>
                                        </div>
                                    </asp:Panel>
                                </div>
                            </div>
                            <!-- Main Content Ends Here -->
                            <div id="left">
                            </div>
                            <div class="clear clearfix">
                            </div>
                        </div>
                        <div id="right">
                        </div>
                        <div class="clear clearfix">
                        </div>
                    </div>
                    <%-- </div>--%>
                    <asp:Button ID="btnTest" Text="Test" CssClass="ControlHide" runat="server" />
                </ContentTemplate>
                <Triggers>
                    <asp:PostBackTrigger ControlID="btnTest" />
                </Triggers>
            </asp:UpdatePanel>

            <asp:UpdateProgress ID="uprDataLoading" runat="server" DynamicLayout="True" AssociatedUpdatePanelID="updDriverDetails">
                <ProgressTemplate>
                    <asp:Panel ID="pnlProgress" runat="server" CssClass="processMessage" Style="z-index: 1000;">
                        <center>
                            <br />
                            <img alt="Please Wait ..." src="../images/47.gif" /><br />
                            <br />
                            <asp:Label ID="lbl_msg12" Text="Processing... Please Wait..." runat="server" CssClass="specialdisplay"></asp:Label>
                            <br />
                            <br />
                        </center>
                    </asp:Panel>
                </ProgressTemplate>
            </asp:UpdateProgress>
            <asp:HiddenField ID="hdnTotAmt" runat="server" />

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

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

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

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

            <asp:HiddenField ID="hdnReportOption" runat="server" />

        </form>
        <!-- Content Ends Here -->
    </div>
    <uc2:Footer ID="ucFooter" runat="server" />

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

        //            if ((document.getElementById('txtPartialAMT').value == "") || (parseFloat(document.getElementById('txtPartialAMT').value) > parseFloat(document.getElementById('hdnTotAmt').value))) {
        //                alert("Please enter the amount less than or equal to total amount.");
        //                document.getElementById('txtPartialAMT').style.backgroundColor = 'lightyellow';
        //                document.getElementById('txtPartialAMT').focus();
        //                return false;
        //            }
        //            else {
        //                document.getElementById('txtPartialAMT').style.backgroundColor = 'white';
        //                return true;
        //            }

        //        }
        //        function CheckTotAmt1() {
        //            if (document.getElementById('chkAmtIssued').checked) {
        //                if ((document.getElementById('txtPartialAMT').value == "") || (parseFloat(document.getElementById('txtPartialAMT').value) > parseFloat(document.getElementById('hdnTotAmt').value))) {
        //                    alert("Please enter the amount less than or equal to total amount.");
        //                    document.getElementById('txtPartialAMT').style.backgroundColor = 'lightyellow';
        //                    document.getElementById('txtPartialAMT').focus();
        //                    return false;
        //                }
        //                else {
        //                    document.getElementById('txtPartialAMT').style.backgroundColor = 'white';
        //                    confirm('Are you sure you want to settle the Amount?');
        //                    return true;
        //                }
        //            }
        //            else {
        //                confirm('Are you sure you want to settle the Amount?');
        //                return true;
        //            }
        //        }
        //        function PartialAmt() {
        //            var isAmt = document.getElementById('chkAmtIssued').checked;
        //            document.getElementById('txtPartialAMT').value = "";
        //            if (isAmt) {
        //                document.getElementById('tdParial').style.display = "block";
        //            }
        //            else {
        //                document.getElementById('tdParial').style.display = "none";
        //            }
        //        }
        function ReportOption(control, RowNo, AssignmentId) {
            document.getElementById('hdnReportOption').value = document.getElementById(control).value + "," + RowNo + "," + AssignmentId;
        }
        function Intervals() {
            var interval = document.getElementById('ddlRepType').value;
            var day = new Date().getDay == "0" ? 0 : 1;
            if (interval == "1") {
                document.getElementById('txtFromDate').value = "";
                document.getElementById('txtToDate').value = "";
                document.getElementById('txtFromDate').disabled = false;
                document.getElementById('txtToDate').disabled = false;
            }
            else if (interval == "2") {
                var val = "";
                var days = new Date().getDate() - new Date().getDay();
                var str;
                str = "";
                if (parseInt(days) < 0) {
                    str = String(new Date(new Date().getFullYear(), new Date().getMonth(), 0).getDate() + "/" + new Date().getMonth() + "/" + new Date().getFullYear()).split('/');

                }
                else {
                    str = String((new Date().getDate() - new Date().getDay()) + day + "/" + (new Date().getMonth() + 1) + "/" + new Date().getFullYear()).split('/');
                }

                for (var i = 0; i < str.length; i++) {
                    if (str[i].length < 2) {
                        val = val + "0" + str[i] + "/";
                    }
                    else {
                        if (i == 2)
                            val = val + str[i];
                        else {
                            if (i == 0)
                                if (parseInt(str[i]) < 0) {
                                    val = new Date(new Date().getFullYear(), new Date().getMonth(), 0).getDate() + parseInt(str[i]) + "/" + (new Date().getMonth()) + "/" + new Date().getFullYear();
                                    break;
                                }
                            val = val + str[i] + "/";
                        }
                    }
                }
                document.getElementById('txtFromDate').value = val;
                str = "";
                val = "";
                str = String((new Date().getDate()) + "/" + (new Date().getMonth() + 1) + "/" + new Date().getFullYear()).split('/');
                for (var i = 0; i < str.length; i++) {
                    if (str[i].length < 2) {
                        val = val + "0" + str[i] + "/";
                    }
                    else {
                        if (i == 2)
                            val = val + str[i];
                        else {
                            if (i == 0)
                                if (parseInt(str[i]) < 0) {
                                    val = new Date(new Date().getFullYear(), new Date().getMonth(), 0).getDate() + parseInt(str[i]) + "/" + (new Date().getMonth()) + "/" + new Date().getFullYear();
                                    break;
                                }
                            val = val + str[i] + "/";
                        }
                    }
                }
                document.getElementById('txtToDate').value = val;
                document.getElementById('txtFromDate').disabled = true;
                document.getElementById('txtToDate').disabled = true;
            }
            else if (interval == "3") {
                var d = (new Date().getDate() - (new Date().getDate() + 7));
                var val = "";
                var isNegative = 0;
                str = "";
                str = String((new Date().getDate() - (new Date().getDay() + 7)) + day + "/" + (new Date().getMonth() + 1) + "/" + new Date().getFullYear()).split('/');
                for (var i = 0; i < str.length; i++) {
                    if (str[i].length < 2) {
                        val = val + "0" + str[i] + "/";
                    }
                    else {
                        if (i == 2)
                            val = val + str[i];
                        else {
                            if (i == 0)
                                if (parseInt(str[i]) < 0) {
                                    val = new Date(new Date().getFullYear(), new Date().getMonth(), 0).getDate() + parseInt(str[i]) + "/" + (new Date().getMonth()) + "/" + new Date().getFullYear();
                                    break;
                                }
                            val = val + str[i] + "/";
                        }
                    }
                }
                document.getElementById('txtFromDate').value = val;
                str = "";
                val = "";
                str = String((new Date().getDate() - new Date().getDay()) + "/" + (new Date().getMonth() + 1) + "/" + new Date().getFullYear()).split('/');

                if (str[0] < 7 && str[1] == 1) {
                    var modifieddate = String(document.getElementById('txtFromDate').value).split('/');
                    for (var i = 0; i < modifieddate.length; i++) {
                        if (i == 0) {
                            val = val + modifieddate[i] + "/";
                        }
                        else if (i == 1) {
                            val = val + "12/";
                        }
                        else if (i == 2) {
                            val = val + (parseInt(modifieddate[i]) - 1);
                        }
                    }
                    document.getElementById('txtFromDate').value = val;
                    val = "";
                }

                for (var i = 0; i < str.length; i++) {
                    if (str[i].length < 2) {
                        val = val + "0" + str[i] + "/";
                    }
                    else {
                        if (i == 2)
                            val = val + str[i];
                        else {
                            if (i == 0)
                                if (parseInt(str[i]) < 0) {
                                    val = new Date(new Date().getFullYear(), new Date().getMonth(), 0).getDate() + parseInt(str[i]) + "/" + (new Date().getMonth()) + "/" + new Date().getFullYear();
                                    break;
                                }
                            val = val + str[i] + "/";
                        }
                    }
                }

                document.getElementById('txtToDate').value = val;
                document.getElementById('txtFromDate').disabled = true;
                document.getElementById('txtToDate').disabled = true;
            }
            else if (interval == "4") {
                var month = new Date().getMonth().length > 1 ? (new Date().getMonth() + 1) : "0" + (new Date().getMonth() + 1);
                document.getElementById('txtFromDate').value = "01/" + month + "/" + new Date().getFullYear();
                var d = new Date().getDate().toString().length > 1 ? new Date().getDate() : "0" + new Date().getDate();
                document.getElementById('txtToDate').value = d + "/" + month + "/" + new Date().getFullYear();
                document.getElementById('txtFromDate').disabled = true;
                document.getElementById('txtToDate').disabled = true;
            }
            else if (interval == "5") {
                var lastmonth = new Date().getMonth() == '0' ? '12' : new Date().getMonth();
                var lastyear = new Date().getMonth() == '0' ? (parseInt(new Date().getFullYear()) - 1) : new Date().getFullYear();
                document.getElementById('txtFromDate').value = "01/" + lastmonth + "/" + lastyear;
                document.getElementById('txtToDate').value = new Date(new Date().getFullYear(), new Date().getMonth(), 0).getDate() + "/" + lastmonth + "/" + lastyear;

                document.getElementById('txtFromDate').disabled = true;
                document.getElementById('txtToDate').disabled = true;
            }
        }
        //        function Confirm() {

        //            return confirm('The settlement amount is ' + document.getElementById('hdnTotAmt').value + '.Do you want to issue?');
        //        }
    </script>

</body>
</html>
