
<%@page import="LoginDb.DbHandler"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%@page import="java.sql.Connection"%>
<%@page import="DataEntryBean.DepositRateSlabBean"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@page import="java.util.UUID" %>
<%String uuid = UUID.randomUUID().toString();%>
<% try {
%>

<html>
    <head>
        
        <title>Term Deposit Rate Slab</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="${pageContext.request.contextPath}/js/Calendar.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/TableCSSCode.css?pacs=<%=((new java.util.Date()).getTime())%>" />
        <link rel="shortcut icon" href="${pageContext.request.contextPath}/img/favicon.ico?pacs=<%=((new java.util.Date()).getTime())%>" type="image/x-icon" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/styles.css?pacs=<%=((new java.util.Date()).getTime())%>"/>
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/ButtonAndText.css?pacs=<%=((new java.util.Date()).getTime())%>" />
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/info.css?pacs=<%=((new java.util.Date()).getTime())%>" />
        <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-ui-1.10.4.custom/development-bundle/jquery-1.10.2.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <script type="text/javascript" src="/PacsApplication/chromejs/chrome.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <script type="text/javascript" src="/PacsApplication/js/iFrame_killer.js"></script>
        <script>

            function noBack()
            {
                window.history.forward();
                if($('#displayFlag').val() != "Y"){
	                    $('select#checkOption').change();
	                }
            }
            function selectproduct(width, height, pCode, iCat) {


                if (window.innerWidth) {
                    LeftPosition = (window.innerWidth - width) / 2;
                    TopPosition = ((window.innerHeight - height) / 2) - 20;
                }
                else {
                    LeftPosition = (parseInt(window.screen.width) - width) / 2;
                    TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
                }
                attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
                    height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
                    TopPosition + '';
                var screenName = "DepositRateSlab.jsp";
                var  lovKey="PickUPProduct";
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationDepositLOV.jsp?pCode=' + pCode + '&iCat=' + iCat + '&screenName=' + screenName+'&lovKey='+lovKey, 'PickUPProduct', attr);
                popWin.focus();
            }

            function selectproductAmend(width, height, pCode, iCat) {


                if (window.innerWidth) {
                    LeftPosition = (window.innerWidth - width) / 2;
                    TopPosition = ((window.innerHeight - height) / 2) - 20;
                }
                else {
                    LeftPosition = (parseInt(window.screen.width) - width) / 2;
                    TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
                }
                attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
                    height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
                    TopPosition + '';
                var screenName = "DepositRateSlab.jsp";
                var  lovKey="PickUPProductAmend";
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationDepositLOV.jsp?pCode=' + pCode + '&iCat=' + iCat + '&screenName=' + screenName+'&lovKey='+lovKey, 'PickUPProduct', attr);
                popWin.focus();
            }
            function selectproductAmend2(width, height, pCode, iCat) {


                if (window.innerWidth) {
                    LeftPosition = (window.innerWidth - width) / 2;
                    TopPosition = ((window.innerHeight - height) / 2) - 20;
                }
                else {
                    LeftPosition = (parseInt(window.screen.width) - width) / 2;
                    TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
                }
                attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
                    height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
                    TopPosition + '';
                var screenName = "DepositRateSlab.jsp";
                var  lovKey="PickUPProductAmend2";
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationDepositLOV.jsp?pCode=' + pCode + '&iCat=' + iCat + '&screenName=' + screenName+'&lovKey='+lovKey, 'PickUPProductAmend2', attr);
                popWin.focus();
            }
            
            // to restrict back button
            history.pushState(null, null, location.href);
            window.addEventListener('popstate', function(event) {
                history.pushState(null, null, location.href);
            });

        </script>

    </head>

    <body  onload="noBack()">
        <%          int count = 1;
             int count3 = 1;
             String error_msg = "";
             Object error = request.getAttribute("message");
             if (error != null) {
                 error_msg = error.toString();
             }
        %>

        <%!
            String blankNull(String s) {
                return (s == null) ? "" : s;
            }
        %>

        <%
             String displayFlag = "";
             Object display = request.getAttribute("displayFlag");
             if (display != null) {
                 displayFlag = display.toString();
             }
        %>


        <%
             Object oDepositRateSlabBeanObj = request.getAttribute("oDepositRateSlabBean");
             DepositRateSlabBean oDepositRateSlabBeanHeader = new DepositRateSlabBean();
             if (oDepositRateSlabBeanObj != null) {
                 oDepositRateSlabBeanHeader = (DepositRateSlabBean) request.getAttribute("oDepositRateSlabBean");
             }

             Object alDepositRateSlabBeanObj = request.getAttribute("alDepositRateSlabBean");
             ArrayList<DepositRateSlabBean> alDepositRateSlabBean = new ArrayList<DepositRateSlabBean>();
             DepositRateSlabBean oDepositRateSlabBean = new DepositRateSlabBean();
             if (alDepositRateSlabBeanObj != null) {
                 alDepositRateSlabBean = (ArrayList<DepositRateSlabBean>) request.getAttribute("alDepositRateSlabBean");

             }
        %>

        <jsp:include page="MenuHead_Deposit.jsp" flush="true" />
        <br>

        <fieldset style="border-color: black; background-image: url('/PacsApplication/img/download.jpg'); border-width: 3px">
            <legend style="padding: 8px; border-radius: 20px; background-color: #006600; color: white">Term Deposit Rate Slab</legend>

            <form name="tdRateSlabForm" method="post" action="">

                <%if (!error_msg.equalsIgnoreCase("")) {%>
                <center><div class="info" id="errorMessage"><center><%= error_msg%></center></div></center>
                <% }%>
                <br>
                <br>

                <center style='display:none;'><h3><label style=" font-family: Berlin Sans FB; font-weight:  normal;">Operation Selection:</label>
                        <select id="checkOption" name="checkOption" >
                            <%--<option value="" disabled selected style="display:none;" > --Select-- </option>--%>
                            <%--<option value="create" >Create</option>--%>
                            <option value="amend" >Amend</option>

                        </select>
                    </h3></center>
                

                <div id="create" style="display: none;">
                    <table>
                        	                        <%--<tr><td><h4>Amend Effective Date & Interest Rates</h4></td></tr>--%>

	                        <%--<tr><td><h4>Select Product & Effective Date</h4></td></tr> --%>
                        <tr>
                            <td><lable>Product Code<font color="red" >*</font>:</lable></td>
                        <td><input type="text" readonly id="pCode" name="pCode" ><input type="button" value="Search"  onclick="javascript:selectproduct(850, 200, document.tdRateSlabForm.pCode.value, document.tdRateSlabForm.iCat.value);"/></td>
                        </tr>
                        <tr><td></td></tr>
                        <tr><td></td></tr>
                        <tr>
                            <td><lable>Interest Category<font color="red" >*</font>:</lable></td>
                        <td><input type="text" readonly id="iCat" name="iCat" ><input type="button" value="Search"  onclick="javascript:selectproduct(850, 200, document.tdRateSlabForm.pCode.value, document.tdRateSlabForm.iCat.value);"/></td>
                        </tr>
                        <tr><td><hr></td></tr>
	                        <tr><td><h4>Amend Effective Date & Interest Rates</h4></td></tr>
                        <tr>
                            <td><lable>Effective From Date:</lable></td>
                        <td><input type="text" id="procStartDate" name="procStartDate" readonly="true"> <a href="#" onclick="return getCalendar(getElementById('procStartDate'));"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" border="0" width="25" height="20" /></a></td>
                        </tr>

                        <tr>
                            <td><lable>Effective To Date:</lable></td>
                        <td><input type="text" id="procEndDate" name="procEndDate" readonly="true"> <a href="#" onclick="return getCalendar(document.forms[0].procEndDate);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" border="0" width="25" height="20" /></a></td>
                        </tr>

                        <%--<tr><td><hr></td></tr>--%>
                    </table>

                    <h4>Interest Rate Details</h4>

                    <center>
                        <table class="checkEvents" id="order-list" border="2" width="auto" cellspacing="1" cellpadding="1" style="text-align: center ;overflow-y: scroll; font-size: 15px">
                            <thead class="CSSTableGenerator" >
                                <tr>
                                    <td style=""></td>
                                    <td>Interest Rate(%)</td>
                                    <td >Term From (Days)</td>
                                    <td>Term To (Days)</td>
                                    <td>From Amount</td>
                                    <td>To Amount</td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td><input type="checkbox" name="chckbox<%=count%>" id="chckbox<%=count%>" onclick="checkboxTrue(<%=count%>);" /></td>
                                    <td><input type="text" size="13" style="border:none;" name="inttRate<%=count%>" id="inttRate<%=count%>"/></td>
                                    <td><input type="text" style="border:none;" name="termFrom<%=count%>" id="termFrom<%=count%>" class="noDot"/></td>
                                    <td><input type="text" style="border:none;" name="termTo<%=count%>" id="termTo<%=count%>" class="noDot" /></td>
                                    <td><input type="text" style="border:none;" class="numeric"  name="amountFrom<%=count%>" id="amountFrom<%=count%>"/></td>
                                    <td><input type="text" style="border:none;" class="numeric" name="amountTo<%=count%>" id="amountTo<%=count%>"/></td>


                                </tr>
                            </tbody>
                        </table>

                        <br/><br/>

                    </center>
                    <center>
                        <input type="button" id="addRow" value="Add Row"/>
                        <input type="button" id="deleteRow" value="Delete Row"/>
                        <input type="button"  value="Reset" onclick="javascript:ShowParent()" />
                    </center>


                    <br>
                    <center>
                        <input type="button" value="Submit" onclick="javascript:submitform(tdRateSlabForm)">

                    </center>

                    <br>
                    <br>
                    <label style=" font-family: Berlin Sans FB; font-weight:normal; ">All fields are mandatory</label>
                </div>
                <div id="amend" style="display: none;">
                    <center>
                        <table>
                            <tr>
                                <td>Product Code<font color="red" >*</font>: </td>
                                <td> <input type="text" readonly name="pCodeSearch" id="pCodeSearch" value=""/></td>
                                <td><input type="button" value="Search"  onclick="javascript:selectproductAmend(650, 200, document.tdRateSlabForm.pCodeSearch.value, document.tdRateSlabForm.iCatSearch.value);"/></td>
                            </tr>
                            <tr>
                                <td>Interest Category<font color="red" >*</font>: </td>
                                <td><input type="text" readonly name="iCatSearch" id="iCatSearch" value=""/></td>
                                <td><input type="button" value="Search"  onclick="javascript:selectproductAmend(650, 200, document.tdRateSlabForm.pCodeSearch.value, document.tdRateSlabForm.iCatSearch.value);"/></td>

                            </tr>
                        </table>
                        <br>
                        <center>
                            <input type="button"  value="Submit" onclick="javascript:submitformSearch()" />
                            <input type="button"  value="Reset" onclick="javascript:ShowParent()" /></center>


                    </center><br>
                </div>
                <%if (displayFlag.equalsIgnoreCase("Y")) {%>
                <div id="amend2" >


                    <table>
                        <%--<tr><td><hr></td></tr>
                        <%--<tr><td><h4>Select Product & Effective Date</h4></td></tr>--%>

                        <tr>
                            <td><lable>Product Code :</lable></td>
                        <td><input type="text" readonly id="pCodeAmend" name="pCodeAmend" value="<%=blankNull(oDepositRateSlabBeanHeader.getpCodeSearch())%>" ><input type="button" value="Search"  onclick="javascript:selectproductAmend2(850, 200, document.tdRateSlabForm.pCodeAmend.value, document.tdRateSlabForm.iCatAmend.value);"/></td>

                        </tr>
                        <tr><td></td></tr>
                        <tr><td></td></tr>
                        <tr>
                            <td><lable>Interest Category :</lable></td>
                        <td><input type="text" readonly id="iCatAmend" name="iCatAmend" value="<%=blankNull(oDepositRateSlabBeanHeader.getiCatSearch())%>" ><input type="button" value="Search"  onclick="javascript:selectproductAmend2(850, 200, document.tdRateSlabForm.pCodeAmend.value, document.tdRateSlabForm.iCatAmend.value);"/></td>
                        </tr>

                        <tr><td><hr></td></tr>
	                        <tr><td><h4>Amend Effective Date & Interest Rates</h4></td></tr>

                        <tr>
                            <td><lable>Effective From Date :</lable></td>
                        <td><input type="text" readonly id="procStartDateAmend" name="procStartDateAmend" style="text-align:center;" value="<%=blankNull(oDepositRateSlabBeanHeader.getProcStartDate())%>"> <a href="#" onclick="return getCalendar(getElementById('procStartDateAmend'));"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" border="0" width="25" height="20" /></a></td>
                        </tr>

                        <tr>
                            <td><lable>Effective To Date :</lable></td>
                        <td><input type="text" readonly id="procEndDateAmend" name="procEndDateAmend" style="text-align:center;" value="<%=blankNull(oDepositRateSlabBeanHeader.getProcEndDate())%>"> <a href="#" onclick="return getCalendar(document.forms[0].procEndDateAmend);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" border="0" width="25" height="20" /></a></td>
                        </tr>

                        <%--<tr><td><hr></td></tr>--%>
                    </table>



                    <h4>Interest Rate Details</h4>

                    <center>
                        <table class="checkEvents" id="order-listAmend" border="2" width="auto" cellspacing="1" cellpadding="1" style="text-align: center ;overflow-y: scroll; font-size: 15px" >
                            <%if (blankNull(oDepositRateSlabBeanHeader.getpCodeSearch()).substring(0, 1).equalsIgnoreCase("3")) {%>
                            <thead class="CSSTableGenerator" >
                                <tr>
                                    <td></td>
                                    <td>Interest Rate(%)</td>
                                    <td>Term From (Months)</td>
                                    <td>Term To (Months)</td>
                                    <td>From Amount</td>
                                    <td>To Amount</td>
                                </tr>
                            </thead>
                            <%} else {%>
                            <thead class="CSSTableGenerator" >
                                <tr>
                                    <td></td>
                                    <td>Interest Rate(%)</td>
                                    <td>Term From (Days)</td>
                                    <td>Term To (Days)</td>
                                    <td>From Amount</td>
                                    <td>To Amount</td>
                                </tr>
                            </thead>
                            <%}%>
                            <tbody>

                                <%
                                    oDepositRateSlabBean = new DepositRateSlabBean();
                                    count3 = 0;

                                    for (int i = 0; i < alDepositRateSlabBean.size(); i++) {
                                        oDepositRateSlabBean = alDepositRateSlabBean.get(i);

                                        count3++;

                                %>

                                <tr>
                                    <td><input type="checkbox" name="chckboxAmend<%=count3%>" id="chckboxAmend<%=count3%>" onclick="checkboxTrueAmend(<%=count3%>);" value="<%=blankNull(oDepositRateSlabBean.getSlabTable_id())%>" /></td>
                                    <td><input type="text" size="13" style="border:none;" class="numeric" name="inttRateAmend<%=count3%>" id="inttRateAmend<%=count3%>" value="<%=blankNull(oDepositRateSlabBean.getInttRate())%>"/></td>
                                    <td><input type="text" style="border:none;" name="termFromAmend<%=count3%>" id="termFromAmend<%=count3%>" value="<%=blankNull(oDepositRateSlabBean.getTermFrom())%>" class="noDot" /></td>
                                    <td><input type="text" style="border:none;" name="termToAmend<%=count3%>" id="termToAmend<%=count3%>" value="<%=blankNull(oDepositRateSlabBean.getTermTo())%>" class="noDot" /></td>
                                    <td><input type="text" style="border:none;" class="numeric"  name="amountFromAmend<%=count3%>" id="amountFromAmend<%=count3%>" value="<%=blankNull(oDepositRateSlabBean.getAmountFrom())%>"/></td>
                                    <td><input type="text" style="border:none;" class="numeric" name="amountToAmend<%=count3%>" id="amountToAmend<%=count3%>" value="<%=blankNull(oDepositRateSlabBean.getAmountTo())%>"/></td>
                                    <td style="display:none"><input type="hidden"  name="dep_product_idAmend<%=count3%>" id="dep_product_idAmend<%=count3%>" value="<%=blankNull(oDepositRateSlabBean.getDep_product_id())%>"/></td>
                                    <td style="display:none"><input type="hidden" name="slabTable_id<%=count3%>" id="slabTable_id<%=count3%>" value="<%=blankNull(oDepositRateSlabBean.getSlabTable_id())%>"/></td>
                                    <td style="display:none"><input type="hidden" name="rowStatus<%=count3%>" id="rowStatus<%=count3%>" value="A"/></td>
                                </tr>

                                <%}%>
                            </tbody>
                        </table>

                        <br>
                    </center>
                    <center>
                        <input type="button" id="addRowAmend" value="Add Row"/>
                        <input type="button" id="deleteRowAmend" value="Delete Row"/>
                        <input type="button" value="Reset" onclick="ShowParent();" />

                    </center>

                    <br>
                    <center>
                        <input type="button" value="Update" onclick="javascript:submitformAmend(tdRateSlabForm)">

                    </center>
                    <br>
                    <br>
                    <label style=" font-family: Berlin Sans FB; font-weight:normal; ">All fields are mandatory</label>

                </div>
                <%}%>


                <input type="hidden" name="handle_id" value="" />
                <input type="hidden" name="dep_product_id" value="<%=blankNull(oDepositRateSlabBean.getDep_product_id())%>" />
                <input type="hidden" id="displayFlag" name="displayFlag" value="<%=displayFlag%>"/>

                <input type="hidden" name="rowCounter" id="rowCounter" value="<%=count%>">
                <input type="hidden" name="rowCounterDelete" id="rowCounterDelete" value="<%=count%>">
                <input type="hidden" name="rowCounterAmend" id="rowCounterAmend" value="<%=count3%>">
                <input type="hidden" name="rowCounterDeleteAmend" id="rowCounterDeleteAmend" value="<%=count3%>">
                <input type="hidden" name="deletedRows" id="deletedRows" value=""/>
                <input type="hidden" name="chkboxCounter" id="chkboxCounter" value="0"/>
                <input type="hidden" name="chkboxCounterAmend" id="chkboxCounterAmend" value="0"/>
                <input type="hidden" name="add" id="add" value="0"/>

            </form>
            <script>

                function checkboxTrue(i){
                    if(document.getElementById("chckbox"+i).checked==true){

                        var counter = $("#chkboxCounter").val();
                        counter++;
                        $("#chkboxCounter").val(counter);
                    }

                    else{
                        var counter = $("#chkboxCounter").val();
                        counter--;
                        $("#chkboxCounter").val(counter);
                    }

                }

                function checkboxTrueAmend(i){
                    if(document.getElementById("chckboxAmend"+i).checked==true){
                        var counter = $("#chkboxCounterAmend").val();
                        counter++;
                        $("#chkboxCounterAmend").val(counter);
                    }
                    else{
                        var counter = $("#chkboxCounterAmend").val();
                        counter--;
                        $("#chkboxCounterAmend").val(counter);
                    }
                }

                $("#addRow").click(function () {
                   // var counter = $("#rowCounter").val();
                    counter++;
                    $('#order-list tr:last').after('<tr> <td><input type="checkbox" name="chckbox' + counter + '" id="chckbox' + counter + '" onclick="checkboxTrue(' + counter + ');" /></td><td><input type="text" size="13" style="border:none;" name="inttRate' + counter + '" id="inttRate' + counter + '"/></td><td><input type="text" style="border:none;" name="termFrom' + counter + '" id="termFrom' + counter + '" class="noDot" /></td><td><input type="text" style="border:none;" name="termTo' + counter + '" id="termTo' + counter + '" class="noDot" /></td><td><input type="text" style="border:none;" class="numeric"  name="amountFrom' + counter + '" id="amountFrom' + counter + '"/></td><td><input type="text" style="border:none;" class="numeric" name="amountTo' + counter + '" id="amountTo' + counter + '"/></td> </tr>');
                    $("#rowCounter").val(counter);
                    $("#rowCounterDelete").val(counter);

                });
                $("#deleteRow").click(function () {
                    var len = ($("#order-list tr").length)-1;
                    var chkboxCounter=$("#chkboxCounter").val();
                    var rowcount = $("#rowCounterDelete").val();
                    var counterDelete = rowcount-chkboxCounter;
                    if (counterDelete == 0) {
                        alert("All rows can not be deleted");
                        return false;
                    }
                    else{
                        if (len ==chkboxCounter) {
                            alert("All rows can not be deleted");
                            return false;
                        }

                        $('input:checkbox:checked').closest('tr').remove();
                        $("#rowCounterDelete").val( $("#rowCounter").val());
                        chkboxCounter=0;
                        $("#chkboxCounter").val(chkboxCounter);
                    }
                });

                $("#addRowAmend").click(function () {
                    //var counter = $("#rowCounterAmend").val();
                    counter++;
                    $('#order-listAmend tr:last').after('<tr> <td><input type="checkbox" name="chckboxAmend' + counter + '" id="chckboxAmend' + counter + '" onclick="checkboxTrueAmend(' + counter + ');" /></td>\n\
                    <td><input type="text" size="13" style="border:none;" name="inttRateAmend' + counter + '" id="inttRateAmend' + counter + '" class="numeric"/></td>\n\
                    <td><input type="text" style="border:none;" name="termFromAmend' + counter + '" id="termFromAmend' + counter + '" class="noDot"/></td>\n\
                    <td><input type="text" style="border:none;" name="termToAmend' + counter + '" id="termToAmend' + counter + '" class="noDot" /></td>\n\
                    <td><input type="text" style="border:none;"  name="amountFromAmend' + counter + '" id="amountFromAmend' + counter + '" class="numeric"/></td>\n\
                    <td><input type="text" style="border:none;" name="amountToAmend' + counter + '" id="amountToAmend' + counter + '" class="numeric"/></td>\n\
                    <td style="display:none"><input type="text"  name="dep_product_idAmend' + counter + '" id="dep_product_idAmend' + counter + '" /></td>\n\
                    <td style="display:none"><input type="text" name="slabTable_id' + counter + '" id="slabTable_id' + counter + '"/></td>\n\
                    <td style="display:none"><input type="hidden" name="rowStatus' + counter + '" id="rowStatus' + counter + '" value="N"/></td>\n\
                    </tr>');
                    $("#rowCounterAmend").val(counter);
                    $("#rowCounterDeleteAmend").val(counter);
                });


                $("#deleteRowAmend").click(function () {
                    var len = ($("#order-listAmend tr").length)-1;
                    var chkboxCounter=$("#chkboxCounterAmend").val();
                    var rowcount = $("#rowCounterDeleteAmend").val();
                    var counterDelete = rowcount-chkboxCounter;
                    if (counterDelete == 0) {
                        alert("All rows can not be deleted");
                        return false;
                    }
                    else{
                        if (len ==chkboxCounter) {
                            alert("All rows can not be deleted");
                            return false;
                        }

                        var selchbox = [];
                        selchbox= getSelectedChbox(tdRateSlabForm);
                        $("#deletedRows").val(selchbox);
                        $('input:checkbox:checked').closest('tr').remove();
                        $("#rowCounterDeleteAmend").val( $("#rowCounterAmend").val());
                        chkboxCounter=0;
                        $("#chkboxCounterAmend").val(chkboxCounter);
                    }
                });


                function getSelectedChbox(tdRateSlabForm) {
                    var selchbox = [];
                    var inpfields = tdRateSlabForm.getElementsByTagName('input');
                    var nr_inpfields = inpfields.length;
                    for(var i=0; i<nr_inpfields; i++) {
                        if(inpfields[i].type == 'checkbox' && inpfields[i].checked == true){
                            if  (inpfields[i].value!=null || inpfields[i].value!="" ){
                                selchbox.push(inpfields[i].value);
                            }
                        }
                    }
                    return selchbox;
                }

                function ShowParent()
                {
                    document.forms[0].action="${pageContext.request.contextPath}/Deposit/DepositRateSlab.jsp";
                    document.forms[0].submit();
                }

                function submitform(tdRateSlabForm)
                {
                    if (checkDiv(tdRateSlabForm))
                    {
                        document.forms[0].handle_id.value = "Create";
                        document.forms[0].action = '/PacsApplication/DepositRateSlabServlet';
                        document.forms[0].submit();
                    }
                }
                function submitformSearch(tdRateSlabForm)
                {
                    if (checkDivSearch(tdRateSlabForm))
                    {
                        document.forms[0].handle_id.value = "Search";
                        document.forms[0].action = '/PacsApplication/DepositRateSlabServlet';
                        document.forms[0].submit();
                    }
                }
                function submitformAmend(tdRateSlabForm)
                {                    
                    if (checkDivAmend(tdRateSlabForm)){
                        document.forms[0].handle_id.value = "Update";
                        document.forms[0].action = '/PacsApplication/DepositRateSlabServlet';
                        tdRateSlabForm.submit();
                    }

                }
                function checkDiv(tdRateSlabForm)
                {
                    if (tdRateSlabForm.dep_product_id.value == "")
                    {
                        alert("Product & Interest category  must be filled.");
                        return false;
                    }
                    if (tdRateSlabForm.pCode.value == "")
                    {
                        alert("Product Code must be filled.");
                        tdRateSlabForm.pCode.focus();
                        return false;
                    }

                    if (tdRateSlabForm.iCat.value == "")
                    {
                        alert("Interest Category must be filled.");
                        tdRateSlabForm.iCat.focus();
                        return false;
                    }

                    if (tdRateSlabForm.procStartDate.value == "")
                    {
                        alert("Effective From-Date must be filled.");
                        tdRateSlabForm.procStartDate.focus();
                        return false;
                    }

                    if (tdRateSlabForm.procEndDate.value == "")
                    {
                        alert("Effective To-Date must be filled.");
                        tdRateSlabForm.procEndDate.focus();
                        return false;
                    }
                    
                    if (checkdate()){
                        var counter = document.forms[0].rowCounter.value;

                        try{
                            for (var i = 1; i <= counter; i++) {
                                var inttRate = document.getElementById("inttRate" + i).value;
                                var termFrom = document.getElementById("termFrom" + i).value;
                                var termTo = document.getElementById("termTo" + i).value;
                                var amountFrom = document.getElementById("amountFrom" + i).value;
                                var amountTo = document.getElementById("amountTo" + i).value;
                                
                                //alert("Rate"+inttRate);
                                
                            if ( inttRate.indexOf('%') == -1 )
                            {
                                if (inttRate == "" || termFrom == "" || termTo == "" || amountFrom == "" ||amountTo =="") {
                                    alert("All Fields are mandatory.");
                                    return false;
                                }
                                if(parseInt(termFrom) > parseInt(termTo)){
                                    
                                    alert("Term From (Days) cannot be greater than Term To (Days).");
                                    return false;
                                }
                                if(parseInt(amountFrom) > parseInt(amountTo)){
                                    alert("From Amount cannot be greater than To Amount.");
                                    return false;
                                }
                            }
                            else
                            {
                                  alert("Please do not enter % in Interest Rate.");
                                  document.getElementById("inttRate" + i).focus();
                                  return false;
                            }

                }
                        }catch(e){
                        
                        }
                    }
                    else{
                        alert("Effective from date cannot be greater than effective to date.");
                        tdRateSlabForm.procStartDate.focus();
                        return false;
                    }

                    return true;
                }
                function checkDivSearch(){
                    if (tdRateSlabForm.dep_product_id.value == "")
                    {
                        alert("Product & Interest category  must be filled.");
                        tdRateSlabForm.pCodeSearch.focus();
                        return false;
                    }
                    if (tdRateSlabForm.pCodeSearch.value == "")
                    {
                        alert("Product Code must be filled.");
                        tdRateSlabForm.pCodeSearch.focus();
                        return false;
                    }

                    if (tdRateSlabForm.iCatSearch.value == "")
                    {
                        alert("Interest Category must be filled.");
                        tdRateSlabForm.iCatSearch.focus();
                        return false;
                    }
                    return true;
                }

                function checkDivAmend(tdRateSlabForm)
                {

                    if (tdRateSlabForm.dep_product_id.value == "")
                    {
                        alert("Product & Interest category  must be filled.");
                        return false;
                    }
                    if (tdRateSlabForm.pCodeAmend.value == "")
                    {
                        alert("Product Code must be filled.");
                        tdRateSlabForm.pCodeAmend.focus();
                        return false;
                    }

                    if (tdRateSlabForm.iCatAmend.value == "")
                    {
                        alert("Interest Category must be filled.");
                        tdRateSlabForm.iCatAmend.focus();
                        return false;
                    }

                    if (tdRateSlabForm.procStartDateAmend.value == "")
                    {
                        alert("Effective From-Date must be filled.");
                        tdRateSlabForm.procStartDateAmend.focus();
                        return false;
                    }

                    if (tdRateSlabForm.procEndDateAmend.value == "")
                    {
                        alert("Effective To-Date must be filled.");
                        tdRateSlabForm.procEndDateAmend.focus();
                        return false;
                    }
                    if(checkdateamend()){
                        var counter = document.forms[0].rowCounterAmend.value;
                        try{
                            for (var i = 1; i <= counter; i++) {
                                var inttRateAmend = document.getElementById("inttRateAmend" + i).value;
                                var termFromAmend = document.getElementById("termFromAmend" + i).value;
                                var termToAmend = document.getElementById("termToAmend" + i).value;
                                var amountFromAmend = document.getElementById("amountFromAmend" + i).value;
                                var amountToAmend = document.getElementById("amountToAmend" + i).value;

                                //alert("Rate"+inttRateAmend);

                            if ( inttRateAmend.indexOf('%') == -1 )
                            {
                                if (inttRateAmend == "" || termFromAmend == "" || termToAmend == "" || amountFromAmend == "" || amountToAmend == "") {
                                    alert("All Fields are mandatory.");
                                    return false;
                                }
                                if(parseInt(termFromAmend) > parseInt(termToAmend)){
                                    alert("Term From (Days) cannot be greater than Term To (Days).");
                                    return false;
                                }
                                if(parseInt(amountFromAmend) > parseInt(amountToAmend)){
                                    alert("From Amount cannot be greater than To Amount.");
                                    return false;
                                }
                            }
                            else
                            {
                                  alert("Please do not enter % in Interest Rate.");
                                  document.getElementById("inttRateAmend").focus();
                                  return false;
                            }
                            }

                        }catch(e){

                        }
                    }
                    else{
                        alert("Effective From-Date cannot be greater than Effective To-Date.");
                        tdRateSlabForm.procStartDate.focus();
                        return false;
                    }
                    
                    return true;
                }

                function checkdate()
                {
                    var s1 = document.getElementById("procStartDate").value;
                    var s2 = document.getElementById("procEndDate").value;
                    var dateParts1 = s1.split("/");
                    var dateParts2 = s2.split("/");

                    var dateObject1 = new Date(dateParts1[2], dateParts1[1] - 1, dateParts1[0]);
                    var dateObject2 = new Date(dateParts2[2], dateParts2[1] - 1, dateParts2[0]);

                    if (dateObject1>dateObject2){
                        return false;
                    }
                    return true;
                }

                function checkdateamend()
                {
                    var s1 = document.getElementById("procStartDateAmend").value;
                    var s2 = document.getElementById("procEndDateAmend").value;
                    var dateParts1 = s1.split("/");
                    var dateParts2 = s2.split("/");

                    var dateObject1 = new Date(dateParts1[2], dateParts1[1] - 1, dateParts1[0]);
                    var dateObject2 = new Date(dateParts2[2], dateParts2[1] - 1, dateParts2[0]);

                    if (dateObject1>dateObject2){

                        return false;
                    }

                    return true;

                }

                $(document).ready(function () {
                    $('select#checkOption').change(function () {
                        $('#amend2').hide();
                        var shouldEnable = $(this).val();
                        switch(shouldEnable)
                        {
                            case 'create':
                                $('#create').show();
                                $('#amend').hide();
                                break;

                            case 'amend':
                                $('#create').hide();
                                $('#amend').show();
                                break;
                            default:
                                $('#create').hide();
                                $('#amend').hide();
                                break;
                        }


                    });
                });

                $('.checkEvents').on('keydown',':input.numeric[type="text"]', function() {
                    if (event.shiftKey == true) {
                        event.preventDefault();
                    }

                    if ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 46 || event.keyCode == 190) {

                    } else {
                        event.preventDefault();
                    }

                    if($(this).val().indexOf('.') !== -1 && event.keyCode == 190)
                    { event.preventDefault();}
                           
                });

                $('.checkEvents').on('keydown',':input.noDot[type="text"]', function(event) {
                    
                    if (event.shiftKey == true) {
                        event.preventDefault();
                    }

                    if ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 37 || event.keyCode == 39  ) {

                    } else {
                        event.preventDefault();
                    }

                    if($(this).val().indexOf('.') !== -1 && event.keyCode == 190)
                    {event.preventDefault();}
                });

            </script>
        </fieldset>
    </body>
</html>
<% 	} catch (Exception e) {
               
            }
%>

