<%-- 
    Document   : accountAmendSTB
    Created on : Dec 11, 2018, 6:00:55 PM
    Author     : 1242938
--%>

<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.util.Date"%>
<%@page import="LoginDb.DbHandler"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.UUID" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%String uuid = UUID.randomUUID().toString();%>
<% try {
%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Account Amendmend</title>
        <link rel="shortcut icon" href="${pageContext.request.contextPath}/img/favicon.ico" type="image/x-icon" />
        <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())%>" />
        <script src="${pageContext.request.contextPath}/js/Calendar.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <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>

        <style>
            .beforeAccSrch {
                display: none;
            }
        </style>
    </head>
    <body  onload="noBack()">
        <script type="text/javascript">
            function noBack()
            {
                window.history.forward();
            }

            function ShowParent()
            {
                document.forms[0].action="${pageContext.request.contextPath}/accountAmendSTB.jsp";
                document.forms[0].submit();
            }
            function popup_Acc(width, height, Acc) {
                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 = "accountAmendSTB.jsp";
                var  lovKey="AccSrch"
                popWin = open('${pageContext.request.contextPath}/CommonSearchInfoLOVNew.jsp?Acc=' + Acc + '&screenName=' + screenName+'&lovKey='+lovKey, 'AccSearch', attr);
                popWin.focus();

            }
            function submitform(){

                //alert();
                if(validateForm()){
                    document.accountAmend.action = '/PacsApplication/AccountServletSTB';
                    document.accountAmend.submit();
                }
            }
            function validateForm(){
                if($('#newLimit').val() == ""){
                    alert("New limit amount cannot be blank");
                    return false;
                }
                if($('#intCat').val().substr(0, 1) == "2")
                {
                    if($('#newExpDate').val() == ""){
                        alert("New expiry date cannot be blank");
                        return false;
                    }
                    var a = $('#dbDate').val();
                    var chkdate = document.getElementById("newExpDate").value;
                    var edate = chkdate.split("/");
                    var spdate = new Date(a.substring(6,10),a.substring(3,5) - 1,a.substring(0, 2));
                    var sdd = spdate.getDate();
                    var smm = spdate.getMonth();
                    var syyyy = spdate.getFullYear()-0;
                    var today = new Date(syyyy,smm,sdd).getTime();
                    var e_date = new Date(edate[2],edate[1]-1,edate[0]).getTime();
                    if(e_date <= today)
                    {
                        alert("Limit expiry date cannot be less than or equal to today's date");
                        return false;
                    }
                }
                return true;
            }
            
            // to restrict back button
            history.pushState(null, null, location.href);
            window.addEventListener('popstate', function(event) {
                history.pushState(null, null, location.href);
            });

        </script>

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

        <%
             int count = 1;
             String error_msg = "";
             Object error = request.getAttribute("message");
             if (error != null) {
                 error_msg = error.toString();
             }
             String sysDt = new String();
             Connection connection = null;
             ResultSet rs = null;
             Statement statement = null;
             connection = DbHandler.getDBConnection();
             try {
                 statement = connection.createStatement();
                 rs = statement.executeQuery("select to_char(SYSTEM_DATE,'DD/MM/YYYY') from system_date");
                 while (rs.next()) {
                     sysDt = rs.getString(1);
                 }
                // statement.close();
                // connection.close();
             } catch (Exception e) {
                System.out.println("Error occurred during processing.");
            } finally {
                try {
                    if(statement !=null)
                        statement.close();
                    if (connection != null)
                    connection.close();

            } catch (Exception e) {               
               System.out.println("Error Occurred during connection close.");
            }

            }
        %>

        <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">Account Limit Update</legend>
            <form name="accountAmend" id="accountAmend" action="" method="post">
                <%if (!error_msg.equalsIgnoreCase("")) {%>
                <center><div class="info" id="errorMessage"><center><%= error_msg%></center></div></center>
                <% }%>

                <br><br>

                <center>
                    <table>
                        <tbody>
                            <tr>
                                <td></td>
                                <td>Account Number:</td>
                                <td><input type="text" name="accNo" id="accNo" value=""/></td>
                                <td><input type="button" value="Search" onclick="javascript:popup_Acc(500,300,$('#accNo').val());"/></td>
                            </tr>

                            <tr></tr>
                            <tr></tr>
                            <tr class="beforeAccSrch"><td colspan="5"><hr></td></tr>
                            <tr class="beforeAccSrch">
                                <td>Pacs ID:</td>
                                <td><input type="text" name="pacsId_PACS" id="pacsId_PACS" readonly/></td>
                                <td>Pacs Name:</td>
                                <td><input type="text" name="pacsName" id="pacsName" value="" readonly/></td>

                            </tr>
                            <tr class="beforeAccSrch"></tr>
                            <tr class="beforeAccSrch">
                                <td>CIF Number:</td>
                                <td><input type="text" name="cifNo" id="cifNo" value="" readonly/></td>
                                <td>Customer Name:</td>
                                <td><input type="text" name="custName" id="custName" value="" readonly/></td>

                            </tr>
                            <tr class="beforeAccSrch"></tr>
                            <tr class="beforeAccSrch">
                                <td>Limit/Sanction Amt:</td>
                                <td><input type="text" name="limit" id="limit" value="" readonly/></td>
                                <td>Available Balance:</td>
                                <td><input type="text" name="availBal" id="availBal" value="" readonly/></td>

                            </tr>
                            <tr class="beforeAccSrch"></tr>
                            <tr class="beforeAccSrch">
                                <td>Priciple Outstanding:</td>
                                <td><input type="text" name="prinOust" id="prinOust" value="" readonly/></td>
                                <td>Interest Outstanding:</td>
                                <td><input type="text" name="intOust" id="intOust" value="" readonly/></td>
                            </tr>
                            <tr class="beforeAccSrch"></tr>
                            <tr class="beforeAccSrch">
                                <td>Penal Interest:</td>
                                <td><input type="text" name="penalInt" id="penalInt" value="" readonly/></td>
                                <td>Loan Due Date:</td>
                                <td><input type="text" name="expDate" id="expDate" value="" readonly/></td>
                            </tr>
                            <tr class="beforeAccSrch"></tr>
                            <tr class="beforeAccSrch"><td colspan="5"><hr></td></tr>
                            <tr class="beforeAccSrch">
                                <td></td>
                                <td>New Limit/Sanction Amt:</td>
                                <td><input type="number" name="newLimit" id="newLimit" value=""  /></td>

                            </tr>
                            <tr class="beforeAccSrch"></tr>
                            <tr class="beforeAccSrch"><td colspan="5"></td></tr>
                            <tr class="beforeAccSrch">
                                <td></td>
                                <td>New Loan Due Date:</td>
                                <td><input type="text" name="newExpDate" id="newExpDate" readonly/><a href="#" onclick="return getCalendar(document.forms[0].newExpDate);"/><img src="img/calendar.gif" name="imgr" border="0" width="15" height="20" /></td>
                            </tr>

                        </tbody>

                    </table>
                    <br>
                    <input type="button" value="Submit" id="Submit" onclick="submitform()"/>
                    <input type="button" value="Reset" id="Reset" onclick="ShowParent();" />
                    <input type="hidden" name="dbDate" id="dbDate" value="<%=sysDt%>" />
                    <input type="hidden" value="" id="intCat" name="intCat" />
                </center>
            </form>
        </fieldset>
    </body>
</html>
<% 	} catch (Exception e) {
          
            }
%>