<%--
    Document   : LoanModify
    Created on : Oct 19, 2016, 3:11:52 PM
    Author     : 986137
--%>

<%@page import="LoginDb.DbHandler"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.util.ArrayList"%>
<%@page import="DataEntryBean.EnquiryBean"%>
<%@page import="java.util.Date"%>


<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="${pageContext.request.contextPath}/jquery-ui-1.10.4.custom/development-bundle/jquery-1.10.2.js"></script>
        <script src="${pageContext.request.contextPath}/js/Calendar.js"></script>
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/TableCSSCode.css" />
        <title>Modify Interest Rate</title>
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/TableCSSCode.css" />
        <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())%>" />
        <link rel="shortcut icon" href="${pageContext.request.contextPath}/img/favicon.ico?pacs=<%=((new java.util.Date()).getTime())%>" type="image/x-icon" />
        <script type="text/javascript">
            function noBack()
            {
                window.history.forward();
            }
            function ShowParent()
            {
                document.forms[0].action="${pageContext.request.contextPath}/Loan/LoanModify.jsp";
                document.forms[0].submit();
            }
            
            $(document).ready(function(){
	                $('#incr_value').on("cut copy paste",function(e) {
	                    e.preventDefault();
	                });
	                $('#pen_incr_value').on("cut copy paste",function(e) {
	                    e.preventDefault();
	                });
	            });

           <%--function accountsubmitform(loanModifyForm)
            {
                if( document.forms[0].accountNo.value == ""  )
                {
                    alert("Please provide Loan Account Number.");
                    loanModifyForm.accountNo.focus();
                    return false;
                }
                if( document.forms[0].incr_value.value == "" )
                {
                    alert("Please provide value in Set New Interest Rate as.");
                    loanModifyForm.incr_value.focus();
                    return false;
                }
                if( document.forms[0].pen_incr_value.value == "") 
                {
                    alert("Please provide value in Set New Penal Interest Rate as.");
                    loanModifyForm.pen_incr_value.focus();
                    return false; 
                }

                document.forms[0].action = '/PacsApplication/ModifyLoanInterestServlet';
                document.forms[0].submit();   
            }--%>

            function validate()
            {
	                var filter = /^[0-9]{17}$/;

	                if($('#accountNo').val() == "") {
	                    alert("Account No cannot be empty");
	                    $('#accountNo').focus();
	                    return false;
	                }

	                if($('#displayFlag').val() != "Y") {
	                    if(!filter.test($('#accountNo').val())){
	                        alert("Account number is incorrect. Please search account number to proceed");
	                        $('#accountNo').focus();
	                        return false;
	                    }
	                }

	                if($('#incr_value').val() == "") {
	                    alert("New interest rate cannot be empty");
	                    $('#incr_value').focus();
	                    return false;
	                }

	                if($('#pen_incr_value').val() == "") {
	                    alert("New penal interest rate cannot be empty");
	                    $('#pen_incr_value').focus();
	                    return false;
	                }

	                return true;
	            }

	           function accountsubmitform(loanModifyForm)
	            {
	                if(validate()){
	                    document.forms[0].action = '/PacsApplication/ModifyLoanInterestServlet';
	                    document.forms[0].submit();
	                }
	            }
            
            function popup_accNo(width, height, accNo) {
                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 = "LoanModify.jsp";
                var  lovKey="LoanAcctSearch"
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationLoanLOV.jsp?loanAcc=' + accNo + '&screenName=' + screenName+'&lovKey='+lovKey, 'LoanAcctSearch', 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()">


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

        <jsp:include page="MenuHead_Loan.jsp" flush="true" />
        <br>
        <%!
            String blankNull(String s) {
                return (s == null) ? "" : s;
            }
        %>

        <%
                    String error_msg = "";
                    String acc_no = "";
	                    Object error = request.getAttribute("message");
	                    if (error != null) {
	                        error_msg = error.toString();
	                    }

	                    error = request.getAttribute("acc_no");
	                    if (error != null) {
	                        acc_no = error.toString();
	                    }
        %>

      


        <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">Modify Interest Rate For Active Loan Accounts</legend>
            <form id="loanModifyForm" name="loanModifyForm" method="post" action="">


                <%if (!error_msg.equalsIgnoreCase("")) {%>
                <center><div class="info" id="errorMessage"><center><%= error_msg%></center></div></center>
                <% }%>
                <br>
                <br>
            <input type="hidden" value="LoanModify" name="screenName" />
            <%if (!(displayFlag.equalsIgnoreCase("Y"))) {%>
                <div id="filterDiv" >
                    <center>
                       <table>
                           <tr>
                              <td style="text-align: right">Loan Account Number<font color="red" >*</font>: </td>
                              <td><input type="text"  maxlength="17" name="accountNo" id="accountNo"  value="<%= blankNull(((String)request.getAttribute("acc_no")))%>" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                              <td><input type="button" value="Search" onclick="javascript:popup_accNo(420, 180, document.loanModifyForm.accountNo.value)"/></td>
                              <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                           </tr>
                       </table>
                    </center>
                           
                   </div><br><br>
              <%}%>
                            
             <%if (displayFlag.equalsIgnoreCase("Y")) {%>
                  <center>
                     <div id="displayDiv" >             
                        <table>
                           <tr>
                              <td style="text-align: right">Loan Account Number: </td>
                              <td><input type="text"  maxlength="17" name="accountNo_read" id="accountNo_read"  value="<%= blankNull(((String)request.getAttribute("acc_no")))%>" style="text-align:right;" readonly/></td>
                              <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                           </tr>
                           <tr>
                              <td style="text-align: right">Active Interest Rate: </td>
                              <td><input type="text"  maxlength="17" name="int_rate" id="int_rate" value="<%= blankNull(((String)request.getAttribute("int_rate")))%>" style="text-align:right;" readonly/></td>
                              <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                           </tr>
                           <tr>
                              <td style="text-align: right">Set New Interest Rate as<font color="red" >*</font>: </td>
                              <td><input type="text"  maxlength="17" name="incr_value" id="incr_value" style="text-align:right;" onkeypress='return event.charCode >= 46 && event.charCode <= 57' /></td>
                              <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                           </tr>
                           <tr>
                              <td style="text-align: right">Active Penal Interest Rate: </td>
                              <td><input type="text"  maxlength="17" name="pen_int_rate" id="pen_int_rate" value="<%= blankNull(((String)request.getAttribute("pen_int_rate")))%>" style="text-align:right;" readonly/></td>
                              <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                           </tr>
                           <tr>
                              <td style="text-align: right">Set New Penal Interest Rate as<font color="red" >*</font>: </td>
                              <td><input type="text"  maxlength="17" name="pen_incr_value" id="pen_incr_value" style="text-align:right;" onkeypress='return event.charCode >= 46 && event.charCode <= 57' /></td>
                              <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                           </tr>

                           <tr><td><br></td></tr>
                        <tr><td><font color="red" >*</font>marked fields are mandatory.</td></tr>
                        </table>
                     </div>
                  </center>
             <%}%>
                  <center>
                     <input type="button" value="Submit" onclick="javascript:accountsubmitform(loanModifyForm)">
                     <input type="button" value="Reset" name="reset" onclick="ShowParent();" />
                     <input type="hidden" id="displayFlag" name="displayFlag" value="<%=displayFlag%>"/>
                  </center>
        </form>
    </fieldset>
  </body>
</html>
