<%--
    Document   : LoanProductCreation
    Created on : Sep 19, 2016, 8:03:41 PM
    Author     : 986137
--%>

<%@page import="DataEntryBean.LoanProductCreationBean" %>
<%@page import="java.sql.SQLException"%>
<%@page import="LoginDb.DbHandler"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Loan Product Creation</title>
        <script src="${pageContext.request.contextPath}/js/Calendar.js"></script>
        <link rel="shortcut icon" href="${pageContext.request.contextPath}/img/favicon.ico" type="image/x-icon" />
        <script src="${pageContext.request.contextPath}/jquery-ui-1.10.4.custom/development-bundle/jquery-1.10.2.js"></script>
        <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 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>
    </head>
    <body onload="noBack()">
        <script type="text/javascript">
            function noBack()
            {
                window.history.forward();
            }


            function checkCreateDiv(loanProductCreation)
            {
                if (loanProductCreation.productname.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.productname.focus();
                    return false;
                }
                if (loanProductCreation.productdescription.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.productdescription.focus();
                    return false;
                }
                if (loanProductCreation.productcode.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.productcode.focus();
                    return false;
                }
                if (loanProductCreation.inttcategory.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.inttcategory.focus();
                    return false;
                }
                if (loanProductCreation.intcatdescription.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.intcatdescription.focus();
                    return false;
                }
                if (loanProductCreation.segmentCode.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.segmentCode.focus();
                    return false;
                }

                if (loanProductCreation.glCodeInttReceivable.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.glCodeInttReceivable.focus();
                    return false;
                }
                if (loanProductCreation.glCodeInttReceived.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.glCodeInttReceived.focus();
                    return false;
                }
                if (loanProductCreation.debitComp1.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.debitComp1.focus();
                    return false;
                }
                if (loanProductCreation.debitComp2.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.debitComp2.focus();
                    return false;
                }
                if (loanProductCreation.status.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.status.focus();
                    return false;
                }



                if (loanProductCreation.intrate.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.intrate.focus();
                    return false;
                }
                if (loanProductCreation.inttmethod.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.inttmethod.focus();
                    return false;
                }
                if (loanProductCreation.inttfrequency.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.inttfrequency.focus();
                    return false;
                }
                if (loanProductCreation.inttcapfrequency.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.inttcapfrequency.focus();
                    return false;
                }

                if (loanProductCreation.pen_intt_rt.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.pen_intt_rt.focus();
                    return false;
                }
                if (loanProductCreation.pen_intt_method.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.pen_intt_method.focus();
                    return false;
                }
                if (loanProductCreation.pen_inttcapfrequency.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.pen_inttcapfrequency.focus();
                    return false;
                }

                if (loanProductCreation.minDisbrs.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.minDisbrs.focus();
                    return false;
                }
                if (loanProductCreation.maxDisbrs.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.maxDisbrs.focus();
                    return false;
                }
                if (loanProductCreation.minRepay.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.minRepay.focus();
                    return false;
                }
                if (loanProductCreation.maxRepay.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.maxRepay.focus();
                    return false;
                }
                if (loanProductCreation.minTerm.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.minTerm.focus();
                    return false;
                }
                if (loanProductCreation.maxTerm.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.maxTerm.focus();
                    return false;
                }
                if (loanProductCreation.minSancAmt.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.minSancAmt.focus();
                    return false;
                }
                if (loanProductCreation.maxSancAmt.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.maxSancAmt.focus();
                    return false;
                }
                if (loanProductCreation.effectDate.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.effectDate.focus();
                    return false;
                }
                if (loanProductCreation.penGracePr.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.penGracePr.focus();
                    return false;
                }
                if (loanProductCreation.guarantor.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.guarantor.focus();
                    return false;
                }
                if (loanProductCreation.security.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.security.focus();
                    return false;
                }
                if (loanProductCreation.loanType.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.loanType.focus();
                    return false;
                }

                if (loanProductCreation.loanType.value == "N" || loanProductCreation.loanType.value == "C")
                {
                    if (loanProductCreation.repayFrequency.value == "M" || loanProductCreation.repayFrequency.value == "Y" || loanProductCreation.repayFrequency.value == "Q" || loanProductCreation.repayFrequency.value == "H")
                    {
                        alert("!! Repayment frequency should be NONE for negotiable & Cash-Crdeit Loans !!");
                        loanProductCreation.repayFrequency.focus();
                        return false;
                    }
                }

                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.productcode.value))
                {
                    alert("!! ProductType could only contain numbers !!");
                    loanProductCreation.productcode.focus();
                    return false;
                }

                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.inttcategory.value))
                {
                    alert("!! INTT Category could only contain numbers !!");
                    loanProductCreation.inttcategory.focus();
                    return false;
                }

                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.intrate.value))
                {
                    alert("!! Interest could only contain numbers !!");
                    loanProductCreation.intrate.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.pen_intt_rt.value))
                {
                    alert("!! Penalty Interest Rate could only contain numbers !!");
                    loanProductCreation.pen_intt_rt.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.debitComp1.value))
                {
                    alert("!! Debit Comp1 could only contain numbers !!");
                    loanProductCreation.debitComp1.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.debitComp2.value))
                {
                    alert("!! Debit Comp2 could only contain numbers !!");
                    loanProductCreation.debitComp2.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.minDisbrs.value))
                {
                    alert("!! Minimum Disbursement Amount could only contain numbers !!");
                    loanProductCreation.minDisbrs.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.maxDisbrs.value))
                {
                    alert("!! Maximum Disbursement Amount could only contain numbers !!");
                    loanProductCreation.maxDisbrs.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.minRepay.value))
                {
                    alert("!! Minimum Repayment Amount could only contain numbers !!");
                    loanProductCreation.minRepay.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.maxRepay.value))
                {
                    alert("!! Maximum Repayment Amount could only contain numbers !!");
                    loanProductCreation.maxRepay.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.minSancAmt.value))
                {
                    alert("!! Minimum Sanctioned Amount could only contain numbers !!");
                    loanProductCreation.minSancAmt.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.maxSancAmt.value))
                {
                    alert("!! Maximum Sanctioned Amount could only contain numbers !!");
                    loanProductCreation.maxSancAmt.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.minTerm.value))
                {
                    alert("!! Minimum Term Amount could only contain numbers !!");
                    loanProductCreation.minTerm.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.maxTerm.value))
                {
                    alert("!! Maximum Term Amount could only contain numbers !!");
                    loanProductCreation.maxTerm.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.penGracePr.value))
                {
                    alert("!! Penalty Grace Period could only contain Days !!");
                    loanProductCreation.penGracePr.focus();
                    return false;
                }


                if (loanProductCreation.repayFrequency.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.repayFrequency.focus();
                    return false;
                }


                return true;
            }


            function checkUpdateDiv(loanProductCreation)
            {
                if (loanProductCreation.productnameAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.productnameAmend.focus();
                    return false;
                }
                if (loanProductCreation.productdescriptionAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.productdescriptionAmend.focus();
                    return false;
                }
                if (loanProductCreation.productcodeAmend.value == "")
                {
                    alert("!! All fields must be filled !!");

                    loanProductCreation.productcodeAmend.focus();
                    return false;
                }
                if (loanProductCreation.inttcategoryAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.inttcategoryAmend.focus();
                    return false;
                }
                if (loanProductCreation.intcatdescriptionAmend.value == "")
                {
                    alert("!! All fields must be filled !!");

                    loanProductCreation.intcatdescriptionAmend.focus();
                    return false;
                }
                if (loanProductCreation.segmentCodeAmend.value == "")
                {
                    alert("!! All fields must be filled !!");

                    loanProductCreation.segmentCodeAmend.focus();
                    return false;
                }
                if (loanProductCreation.statusAmend.value == "")
                {
                    alert("!! All fields must be filled !!");

                    loanProductCreation.statusAmend.focus();
                    return false;
                }
                if (loanProductCreation.effectDateAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.effectDateAmend.focus();
                    return false;
                }


                if (loanProductCreation.intrateAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.intrateAmend.focus();
                    return false;
                }
                if (loanProductCreation.inttmethodAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.inttmethodAmend.focus();
                    return false;
                }
                if (loanProductCreation.inttfrequencyAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.inttfrequencyAmend.focus();
                    return false;
                }
                if (loanProductCreation.inttcapfrequencyAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.inttcapfrequencyAmend.focus();
                    return false;
                }


                if (loanProductCreation.glCodeInttReceivableAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.glCodeInttReceivableAmend.focus();
                    return false;
                }
                if (loanProductCreation.glCodeInttReceivedAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.glCodeInttReceivedAmend.focus();
                    return false;
                }

                if (loanProductCreation.debitComp1Amend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.debitComp1Amend.focus();
                    return false;
                }
                if (loanProductCreation.debitComp2Amend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.debitComp2Amend.focus();
                    return false;
                }

                if (loanProductCreation.pen_intt_rtAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.pen_intt_rtAmend.focus();
                    return false;
                }
                if (loanProductCreation.pen_intt_methodAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.pen_intt_methodAmend.focus();
                    return false;
                }
                if (loanProductCreation.pen_inttcapfrequencyAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.pen_inttcapfrequencyAmend.focus();
                    return false;
                }

                if (loanProductCreation.minDisbrsAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.minDisbrsAmend.focus();
                    return false;
                }
                if (loanProductCreation.maxDisbrsAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.maxDisbrsAmend.focus();
                    return false;
                }
                if (loanProductCreation.minRepayAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.minRepayAmend.focus();
                    return false;
                }
                if (loanProductCreation.maxRepayAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.maxRepayAmend.focus();
                    return false;
                }
                if (loanProductCreation.minTermAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.minTermAmend.focus();
                    return false;
                }
                if (loanProductCreation.maxTermAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.maxTermAmend.focus();
                    return false;
                }
                if (loanProductCreation.minSancAmtAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.minSancAmtAmend.focus();
                    return false;
                }
                if (loanProductCreation.maxSancAmtAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.maxSancAmtAmend.focus();
                    return false;
                }

                if (loanProductCreation.penGracePrAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.penGracePrAmend.focus();
                    return false;
                }
                if (loanProductCreation.guarantorAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.guarantorAmend.focus();
                    return false;
                }
                if (loanProductCreation.securityAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.securityAmend.focus();
                    return false;
                }
                if (loanProductCreation.loanTypeAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.loanTypeAmend.focus();
                    return false;
                }



                if (loanProductCreation.loanTypeAmend.value == "N" || loanProductCreation.loanTypeAmend.value == "C")
                {
                    if (loanProductCreation.repayFrequencyAmend.value == "M" || loanProductCreation.repayFrequencyAmend.value == "Y" || loanProductCreation.repayFrequencyAmend.value == "Q" || loanProductCreation.repayFrequencyAmend.value == "H")
                    {
                        alert("!! Repayment frequency should be NONE for Negotiable & Cash-Crdeit Loans !!");
                        loanProductCreation.repayFrequencyAmend.focus();
                        return false;
                    }
                }

                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.intrateAmend.value))
                {
                    alert("!! intrate could only contain numbers !!");
                    loanProductCreation.intrateAmend.focus();
                    return false;
                }

                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.debitComp1Amend.value))
                {
                    alert("!! Debit Comp1 could only contain numbers !!");
                    loanProductCreation.debitComp1Amend.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.debitComp2Amend.value))
                {
                    alert("!! Debit Comp2 could only contain numbers !!");
                    loanProductCreation.debitComp2Amend.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.pen_intt_rtAmend.value))
                {
                    alert("!! Debit Comp2 could only contain numbers !!");
                    loanProductCreation.pen_intt_rtAmend.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.minDisbrsAmend.value))
                {
                    alert("!! Minimum Disbursement Amount could only contain numbers !!");
                    loanProductCreation.minDisbrsAmend.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.maxDisbrsAmend.value))
                {
                    alert("!! Maximum Disbursement Amount could only contain numbers !!");
                    loanProductCreation.maxDisbrsAmend.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.minRepayAmend.value))
                {
                    alert("!! Minimum Repayment Amount could only contain numbers !!");
                    loanProductCreation.minRepayAmend.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.maxRepayAmend.value))
                {
                    alert("!! Maximum Repayment Amount could only contain numbers !!");
                    loanProductCreation.maxRepayAmend.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.minSancAmtAmend.value))
                {
                    alert("!! Minimum Sanctioned Amount could only contain numbers !!");
                    loanProductCreation.minSancAmtAmend.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.maxSancAmtAmend.value))
                {
                    alert("!! Maximum Sanctioned Amount could only contain numbers !!");
                    loanProductCreation.maxSancAmtAmend.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.minTermAmend.value))
                {
                    alert("!! Minimum Term Amount could only contain numbers !!");
                    loanProductCreation.minTermAmend.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.maxTermAmend.value))
                {
                    alert("!! Maximum Term Amount could only contain numbers !!");
                    loanProductCreation.maxTermAmend.focus();
                    return false;
                }
                re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
                if (!re.test(loanProductCreation.penGracePrAmend.value))
                {
                    alert("!! Penalty Grace Period could only contain Days !!");
                    loanProductCreation.penGracePrAmend.focus();
                    return false;
                }

                if (loanProductCreation.repayFrequencyAmend.value == "")
                {
                    alert("!! All fields must be filled !!");
                    loanProductCreation.penGracePr.focus();
                    return false;
                }

                return true;
            }

            function submitform(loanProductCreation)
            {
                if (checkCreateDiv(loanProductCreation))
                {
                    document.forms[0].handle_id.value = "Create";
                    document.forms[0].action = '/PacsApplication/LoanProductCreationServlet';
                    document.forms[0].submit();
                }

            }

            function updateform(loanProductCreation)
            {

                if (checkUpdateDiv(loanProductCreation))
                {
                    document.forms[0].handle_id.value = "Update";
                    loanProductCreation.submit();
                }

            }
            function checksearch(loanProductCreation){
                if (loanProductCreation.productcodeSearch.value == "" )
                {
                    alert("!! Please enter Product Code !!");
                    loanProductCreation.productcodeSearch.focus();
                    return false;
                }
                if (loanProductCreation.intcatSearch.value == "" )
                {
                    alert("!! Please enter Interest Category !!");
                    loanProductCreation.intcatSearch.focus();
                    return false;
                }
                return true;
            }
            function searchProduct() {
                if (checksearch(loanProductCreation))
                {

                    document.forms[0].handle_id.value = "Search";
                    document.forms[0].action = '/PacsApplication/LoanProductCreationServlet';
                    document.forms[0].submit();

                }
            }


            function checkop()
            {
                if (document.getElementById("checkOption").value == "create")
                {
                    document.getElementById('create').style.display = 'block';
                    document.getElementById('amend').style.display = 'none';
                    document.getElementById('amend2').style.display = 'none';



                }
                if (document.getElementById("checkOption").value == "amend")
                {
                    document.getElementById('amend').style.display = 'block';
                    document.getElementById('create').style.display = 'none';
                    document.getElementById('amend2').style.display = 'none';
                }
            }


            function popup_Product(width, height, pCode,iCode) {
                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 = "LoanProductCreation.jsp";
                var  lovKey="ParameterPdAmend";
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationLoanLOV.jsp?productcodeSearch=' + pCode + '&intcatSearch=' + iCode + '&screenName=' + screenName+'&lovKey='+lovKey, 'ParameterPdAmend', attr);
                popWin.focus();

            }

            function popup_InttPayBalGL(width, height) {
                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 = "LoanProductCreation.jsp";
                var  lovKey="glCodeInttPAYABLESearchLOVKey";
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationLoanLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey, 'glCodeInttPAYABLESearchLOVKey', attr);
                popWin.focus();

            }

            function popup_InttPayBalGLAmend(width, height) {
                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 = "LoanProductCreation.jsp";
                var  lovKey="glCodeInttPAYABLESearchLOVKeyAmend";
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationLoanLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey, 'glCodeInttPAYABLESearchLOVKeyAmend', attr);
                popWin.focus();

            }

            function popup_InttPaidBalGL(width, height) {
                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 = "LoanProductCreation.jsp";
                var  lovKey="glCodeInttPAIDSearchLOVKey";
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationLoanLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey, 'glCodeInttPAIDSearchLOVKey', attr);
                popWin.focus();

            }

            function popup_InttPaidBalGLAmend(width, height) {
                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 = "LoanProductCreation.jsp";
                var  lovKey="glCodeInttPAIDSearchLOVKeyAmend";
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationLoanLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey, 'glCodeInttPAIDSearchLOVKeyAmend', 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>
        <jsp:include page="MenuHead_Loan.jsp" flush="true" />
        <br>

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

        <%
                    Object LoanProductCreationBeanobj = request.getAttribute("oLoanProductCreationBeanObj");
                    LoanProductCreationBean oLoanProductCreationBean = new LoanProductCreationBean();
                    if (LoanProductCreationBeanobj != null) {
                        oLoanProductCreationBean = (LoanProductCreationBean) request.getAttribute("oLoanProductCreationBeanObj");

                    }
        %>

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

        <%
                    String displayFlag = "";
                    Object display = request.getAttribute("displayFlag");
                    if (display != null) {
                        displayFlag = display.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">LOAN PRODUCT OPERATION</legend>

            <form name="loanProductCreation" id="loanProductCreation" method="post" action="">

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

                <center><lable style=" font-family: Berlin Sans FB; font-weight:  normal;">Operation Selection</lable>
                    <select id="checkOption" onchange="checkop()" name="checkOption" id="checkOption">
                        <option value="" disabled selected style="display:none;" >--select--</option>
                        <option value="create" >Create</option>
                        <option value="amend" >Amend</option>

                    </select>
                </center>
                <br>

                <div id="create" style="display:none;">
                   
                    <table>
                        <tbody>

                            <tr>
                                <td>Product Name:</td>
                                <td><input type="text"  name="productname" id="productname" size="20" /></td>
                            </tr>
                            <tr>
                                <td>Product Description:</td>
                                <td><input type="text"  name="productdescription" id="productdescription" size="20" /></td>
                            </tr>
                            <tr>
                                <td>Product Code:</td>
                                <td><input type="text"  name="productcode" id="productcode" maxlength="4" size="10"  /></td>
                            </tr>
                            <tr>
                                <td>INTT Category:</td>
                                <td><input type="text"  name="inttcategory" id="inttcategory" maxlength="4" size="10" /></td>
                            </tr>
                            <tr>
                                <td>INTCAT Description:</td>
                                <td><input type="text"  name="intcatdescription" id="intcatdescription" size="15" /></td>
                            </tr>
                            <tr>
                                <td>Segment Code:</td>
                                <td>
                                    <select id="segmentCode" name="segmentCode">
                                        <option value="" disabled selected style="display:none;">--Select--</option>
                                        <option value="0706">0706:INDIVIDUAL</option>
                                        <option value="0306">0306:STAFF</option>
                                        <option value="5003">5003:SENIOR CITIZEN</option>
                                        <option value="5010">5010:SHG</option>
                                        <option value="5000">5000:BANKS</option>
                                        <option value="5009">5009:INSTITUTIONS</option>
                                        <option value="5050">5050:OTHERS</option>
                                        <option value="5007">5007:SOCIETY</option>
                                        <option value="5011">5011:GOV/SEMI GOV</option>
                                        <option value="5012">5012:PACS</option>
                                        <option value="5013">5013:UCB</option>
                                        <option value="5014">5014:SCB</option>
                                        <option value="5015">5015:CCB</option>
                                    </select>
                                </td>

                            </tr>
                            <tr style="display:none">
                                <td>GL Code:</td>
                                <td>
                                    <select name="glCode" id="glCode" >
                                        <option value="" disabled selected style="display:none;">--Select--</option>
                                        <%
                                                    Connection connection = null;
                                                    ResultSet rs = null;
                                                    Statement statement = null;
                                                    connection = DbHandler.getDBConnection();
                                                    try {
                                                        statement = connection.createStatement();
                                                        rs = statement.executeQuery("select gl_code,gl_name,id from gl_product");
                                                        while (rs.next()) {%>
                                        <option value="<%=rs.getString(3)%>"><%=rs.getString(1) + ":" + rs.getString(2)%></option>
                                        <%}
                                                       // 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.");
            }

            }
                                        %>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>Interest Receivable GL Code:</td>
                                <td><input type="text" readonly name="glCodeInttReceivableShow" id="glCodeInttReceivableShow" />
                                    <input type="hidden" name="glCodeInttReceivable" id="glCodeInttReceivable" />
                                    <input type="button" name="glCodeInttReceivableButton" id="glCodeInttReceivableButton" value="Search" onclick="javascript:popup_InttPayBalGL(420, 280);"/>

                                </td>
                            </tr>
                            <tr>
                                <td>Interest Received GL Code:</td>
                                <td><input type="text" readonly name="glCodeInttReceivedShow" id="glCodeInttReceivedShow" />
                                    <input type="hidden"  name="glCodeInttReceived" id="glCodeInttReceived" />
                                    <input type="button" name="glCodeInttReceivedButton" id="glCodeInttReceivedButton" value="Search" onclick="javascript:popup_InttPaidBalGL(420, 280);"/>

                                </td>
                            </tr>

                            <tr>
                                <td>Debit Comp1:</td>
                                <td><input type="text"  name="debitComp1" id="debitComp1" size="15" /></td>
                            </tr>
                            <tr>
                                <td>Debit Comp2:</td>
                                <td><input type="text"  name="debitComp2" id="debitComp2" size="15" /></td>
                            </tr>
                            <tr>
                                <td>Status:</td>
                                <td><select name="status" id="status" >
                                        <option value="" disabled selected style="display:none;">--Select--</option>
                                        <option value="A">Active</option>
                                        <option value="I">Inactive</option>

                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>INTT Rate:</td>
                                <td><input type="text" name="intrate" id="intrate" maxlength="5" size="4" /></td>
                            </tr>
                            <tr>
                                <td>INTT Method: </td>
                                <td>
                                    <select name="inttmethod" id="inttmethod">
                                        <option value="" disabled selected style="display:none;">--Select--</option>
                                        <option value="S">Simple</option>
                                        <option value="C">Compound</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>INTT Frequency: </td>
                                <td>
                                    <select name="inttfrequency" id="inttfrequency" >
                                        <option value="" disabled selected style="display:none;">--Select--</option>
                                        <option value="D">Daily</option>
                                        <option value="M">Monthly</option>
                                        <option value="Q">Quaterly</option>
                                        <option value="H">Half-Yearly</option>
                                        <option value="Y">Yearly</option>


                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>INTT Capitalization Frequency: </td>
                                <td>
                                    <select name="inttcapfrequency" id="inttcapfrequency" >
                                        <option value="" disabled selected style="display:none;">--Select--</option>
                                        <option value="D">Daily</option>
                                        <option value="M">Monthly</option>
                                        <option value="Q">Quaterly</option>
                                        <option value="H">Half-Yearly</option>
                                        <option value="Y">Yearly</option>


                                    </select>
                                </td>
                            </tr>



                            <tr>
                                <td>Penalty Interest Rate:</td>
                                <td><input type="text" name="pen_intt_rt" id="pen_intt_rt" size="4" maxlength="5" /></td>
                            </tr>
                            <tr>
                                <td>Penalty Interest Method:</td>
                                <td>
                                    <select name="pen_intt_method" id="pen_intt_method">
                                        <option value="" disabled selected style="display:none;">--Select--</option>
                                        <option value="S">Simple</option>
                                        <option value="C">Compound</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>Penalty Interest Frequency: </td>
                                <td>
                                    <select name="pen_inttcapfrequency" id="pen_inttcapfrequency" >
                                        <option value="" disabled selected style="display:none;">--Select--</option>
                                        <option value="D">Daily</option>
                                        <option value="M">Monthly</option>
                                        <option value="Q">Quaterly</option>
                                        <option value="H">Half-Yearly</option>
                                        <option value="Y">Yearly</option>


                                    </select>
                                </td>
                            </tr>

                            <tr>
                                <td>MIN Disbursement:</td>
                                <td><input type="text"  name="minDisbrs" id="minDisbrs" maxlength="10"  size="10"/></td>
                            </tr>
                            <tr>
                                <td>MAX Disbursement:</td>
                                <td><input type="text"  name="maxDisbrs" id="maxDisbrs" size="10" maxlength="10" /></td>
                            </tr>
                            <tr>
                                <td>MIN Repayment:</td>
                                <td><input type="text"  name="minRepay" id="minRepay"  size="10" maxlength="10"/></td>
                            </tr>
                            <tr>
                                <td>MAX Repayment:</td>
                                <td><input type="text"  name="maxRepay" id="maxRepay" size="10" maxlength="10" /></td>
                            </tr>

                            <tr>
                                <td>Repayment Frequency: </td>
                                <td>
                                    <select name="repayFrequency" id="repayFrequency" >
                                        <option value="" disabled selected style="display:none;">--Select--</option>
                                        <option value="M">Monthly</option>
                                        <option value="Q">Quaterly</option>
                                        <option value="H">Half-Yearly</option>
                                        <option value="Y">Yearly</option>
                                        <option value="N">NONE</option>

                                    </select>
                                </td>
                            </tr>


                            <tr>
                                <td>MIN Term:</td>
                                <td><input type="text"  name="minTerm" id="minTerm"  size="10" maxlength="10"/></td>
                            </tr>
                            <tr>
                                <td>MAX Term:</td>
                                <td><input type="text"  name="maxTerm" id="maxTerm" size="10" maxlength="10" /></td>
                            </tr>
                            <tr>
                                <td>MIN Sanctioned Amount:</td>
                                <td><input type="text"  name="minSancAmt" id="minSancAmt"  size="10" maxlength="10"/></td>
                            </tr>
                            <tr>
                                <td>MAX Sanctioned Amount:</td>
                                <td><input type="text"  name="maxSancAmt" id="maxSancAmt" size="10" maxlength="10" /></td>
                            </tr>
                            <tr>
                                <td><lable>Effect Date :</lable></td>
                        <td><input type="text" id="effectDate" name="effectDate" readonly="true"><a href="#" onclick="return getCalendar(getElementById('effectDate'));"><img src="${pageContext.request.contextPath}/img/calendar.gif" name="imgr" border="0" width="15" height="20" /></a></td>
                        </tr>
                        <tr>
                            <td>Penalty Grace Period(days):</td>
                            <td><input type="text"  name="penGracePr" id="penGracePr"  size="3"/></td>
                        </tr>
                        <tr>
                            <td>Guarantor Required:</td>
                            <td><select name="guarantor" id="guarantor" >
                                    <option value="" disabled selected style="display:none;">--Select--</option>
                                    <option value="Y">Yes</option>
                                    <option value="N">No</option>

                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>Security Required:</td>
                            <td><select name="security" id="security" >
                                    <option value="" disabled selected style="display:none;">--Select--</option>
                                    <option value="Y">Yes</option>
                                    <option value="N">No</option>

                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>Loan Type:</td>
                            <td><select name="loanType" id="loanType" >
                                    <option value="" disabled selected style="display:none;">--Select--</option>
                                    <option value="E">EMI</option>
                                    <option value="N">NEGOTIABLE</option>
                                    <option value="C">Cash-Credit</option>

                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>Head of A/c Type:</td>
                            <td><select name="headAccType" id="headAccType" >
                                    <option value="" disabled selected style="display:none;">--Select--</option>
                                    <option value="1">1: Liabilities</option>
                                    <option value="2">2: Asset</option>
                                    <option value="3">3: Purchase</option>
                                    <option value="4">4: Sell</option>
                                    <option value="5">5: Income</option>
                                    <option value="6">6: Expenditure</option>

                                </select>
                            </td>
                        </tr>

                        </tbody>
                    </table>

                     <br><br>
                    
                    <center>
                        <input type="button" value="Submit" onclick="javascript:submitform(loanProductCreation)">
                        <input type="reset" value="Reset" name="reset" />
                    </center>
                    <p style=" font-family: Berlin Sans FB; font-weight:  normal;"> All fields are mandatory </p>

                </div>


                <div id="amend" style="display: none;">
                    <center>
                        <label style=" font-family: Berlin Sans FB; font-weight:  normal;">Enter Product Code: </label>
                        <input type="text" name="productcodeSearch" id="productcodeSearch"/>&nbsp;&nbsp;&nbsp;
                        <label style=" font-family: Berlin Sans FB; font-weight:  normal;">Enter INTT Category: </label>
                        <input type="text" name="intcatSearch" id="intcatSearch"/><input type="button"  value="Search" onclick="javascript:popup_Product(220, 180, document.loanProductCreation.productcodeSearch.value,document.loanProductCreation.intcatSearch.value)" />
                        <br><br>
                        <input type="button"  value="Submit" onclick="javascript:searchProduct()" />
                    </center><br>
                </div>

                <%if (displayFlag.equalsIgnoreCase("Y")) {%>

                <div id="amend2" >
                    <center>
                     <table border="2" cellspacing="1" cellpadding="1" style="text-align: left ;overflow-y: scroll; font-size: 15px; width: 50%;" >
                        <tbody>
                            <tr>
                                <td>Product Name:</td>
                                <td><input type="text"  name="productnameAmend" id="productnameAmend" size="20" value="<%=blankNull(oLoanProductCreationBean.getProductname())%>" /></td>
                            </tr>
                            <tr>
                                <td>Product Description:</td>
                                <td><input type="text" readonly="true"  name="productdescriptionAmend" id="productdescriptionAmend" size="20" value="<%=blankNull(oLoanProductCreationBean.getProductdescription())%>"/></td>
                            </tr>
                            <tr>
                                <td>Product Code:</td>
                                <td><input type="text" readonly="true"  name="productcodeAmend" id="productcodeAmend" maxlength="4" size="10"  value="<%=blankNull(oLoanProductCreationBean.getProductcode())%>" /></td>
                            </tr>
                            <tr>
                                <td>INTT Category:</td>
                                <td><input type="text" readonly="true"  name="inttcategoryAmend" id="inttcategoryAmend" maxlength="4" size="10" value="<%=blankNull(oLoanProductCreationBean.getInttcategory())%>"/></td>
                            </tr>
                            <tr>
                                <td>INTCAT Description:</td>
                                <td><input type="text" readonly="true"  name="intcatdescriptionAmend" id="intcatdescriptionAmend" size="15" value="<%=blankNull(oLoanProductCreationBean.getIntcatdescription())%>" /></td>
                            </tr>
                            <tr>
                                <td>Segment Code:</td>
                                <td><select id="segmentCodeAmend" name="segmentCodeAmend" id="segmentCodeAmend" >
                                        <option value="" disabled selected style="display:none;" <%if (oLoanProductCreationBean.getSegmentCode().equals("")) {%> selected <%}%>>--Select--</option>
                                        <option value="0706" <%if (oLoanProductCreationBean.getSegmentCode().equals("0706")) {%> selected <%}%>>0706:INDIVIDUAL</option>
                                        <option value="0306" <%if (oLoanProductCreationBean.getSegmentCode().equals("0306")) {%> selected <%}%>>0306:STAFF</option>
                                        <option value="5003" <%if (oLoanProductCreationBean.getSegmentCode().equals("5003")) {%> selected <%}%>>5003:SENIOR CITIZEN</option>
                                        <option value="5010" <%if (oLoanProductCreationBean.getSegmentCode().equals("5010")) {%> selected <%}%>>5010:SHG</option>
                                        <option value="5000" <%if (oLoanProductCreationBean.getSegmentCode().equals("5000")) {%> selected <%}%>>5000:BANKS</option>
                                        <option value="5009" <%if (oLoanProductCreationBean.getSegmentCode().equals("5009")) {%> selected <%}%>>5009:INSTITUTIONS</option>
                                        <option value="5050" <%if (oLoanProductCreationBean.getSegmentCode().equals("5050")) {%> selected <%}%>>5050:OTHERS</option>
                                        <option value="5007" <%if (oLoanProductCreationBean.getSegmentCode().equals("5007")) {%> selected <%}%>>5007:SOCIETY</option>
                                        <option value="5011" <%if (oLoanProductCreationBean.getSegmentCode().equals("5011")) {%> selected <%}%>>5011:GOV/SEMI GOV</option>
                                        <option value="5012" <%if (oLoanProductCreationBean.getSegmentCode().equals("5012")) {%> selected <%}%>>5012:PACS</option>
                                        <option value="5013" <%if (oLoanProductCreationBean.getSegmentCode().equals("5013")) {%> selected <%}%>>5013:UCB</option>
                                        <option value="5014" <%if (oLoanProductCreationBean.getSegmentCode().equals("5014")) {%> selected <%}%>>5014:SCB</option>
                                        <option value="5015" <%if (oLoanProductCreationBean.getSegmentCode().equals("5015")) {%> selected <%}%>>5015:CCB</option>
                                    </select>
                                </td>
                            </tr>
                            <tr style="display:none">
                                <td>GL Code:</td>
                                <td>
                                    <select name="glCodeAmend" id="glcodeAmend" >
                                        <option value="" disabled selected style="display:none;" <%if (oLoanProductCreationBean.getGlCode().equals("")) {%> selected <%}%>>--Select--</option>
                                        <%
                                            connection = DbHandler.getDBConnection();
                                            try {
                                                statement = connection.createStatement();
                                                rs = statement.executeQuery("select distinct(gl_code),gl_name,id from gl_product where id='" + oLoanProductCreationBean.getGlCode() + "'");
                                        %>
                                        <option value="<%=oLoanProductCreationBean.getGlCode()%>" selected ><%while (rs.next()) {%>
                                            <%=rs.getString(1) + ":" + rs.getString(2)%>
                                            <%}%></option>
                                            <%
                                                   // 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.");
            }

            }
                                            %>
                                            <%
                                                connection = DbHandler.getDBConnection();
                                                try {
                                                    statement = connection.createStatement();
                                                    rs = statement.executeQuery("select distinct(gl_code),gl_name,id from gl_product");
                                                    while (rs.next()) {%>
                                        <option value="<%=rs.getString(3)%>"><%=rs.getString(1) + ":" + rs.getString(2)%></option>
                                        <%}
                                               // 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.");
            }

            }
                                        %>
                                    </select>
                                </td>
                            </tr>

                            <tr>
                                <td>Interest Receivable GL Code:</td>
                                <td>
                                    <% String InttPAYABLE_Amend = "";
                                        String InttPAYABLE_AmendID = "";
                                        Connection connection1 = null;
                                        ResultSet rs1 = null;
                                        Statement statement1 = null;
                                        connection1 = DbHandler.getDBConnection();
                                        try {
                                            statement1 = connection1.createStatement();
                                            rs1 = statement1.executeQuery("select distinct(gl_code) as gl_code,gl_name,id from gl_product where id='" + oLoanProductCreationBean.getGlCodeInttReceivable() + "'");
                                            while (rs1.next()) {
                                                InttPAYABLE_Amend = rs1.getString("gl_code") + ":" + rs1.getString("gl_name");
                                                InttPAYABLE_AmendID = rs1.getString("id");
                                            }

                                           // statement1.close();
                                           // connection1.close();
                                        } catch (Exception e) {
                System.out.println("Error occurred during processing.");
            } finally {
                try {
                    if(statement1 !=null)
                        statement1.close();
                    if (connection1 != null)
                    connection1.close();

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

            }
                                    %>
                                    <input type="text" size="" readonly name="glCodeInttReceivableAmendShow" id="glCodeInttReceivableAmendShow" value="<%=InttPAYABLE_Amend%>" />
                                    <input type="hidden" style="display:none" name="glCodeInttReceivableAmend" id="glCodeInttReceivableAmend" value="<%=InttPAYABLE_AmendID%>" />


                                    <input type="button" name="Amend2" id="Amend2" value="Search" onclick="javascript:popup_InttPayBalGLAmend(420, 280);"/>
                                </td>
                            </tr>
                            <tr>
                                <td>Interest Received GL Code:</td>
                                <td>
                                    <% String glCodeInttPAID_AmendShow = "";
                                        String glCodeInttPAID_Amend = "";
                                        Connection connection2 = null;
                                        ResultSet rs2 = null;
                                        Statement statement2 = null;
                                        connection2 = DbHandler.getDBConnection();
                                        try {
                                            statement2 = connection2.createStatement();
                                            rs2 = statement2.executeQuery("select distinct(gl_code) as gl_code,gl_name,id from gl_product where id='" + oLoanProductCreationBean.getGlCodeInttReceived() + "'");
                                            while (rs2.next()) {
                                                glCodeInttPAID_AmendShow = rs2.getString("gl_code") + ":" + rs2.getString("gl_name");
                                                glCodeInttPAID_Amend = rs2.getString("id");
                                            }

                                           // statement2.close();
                                           // connection2.close();
                                        } catch (Exception e) {
                System.out.println("Error occurred during processing.");
            } finally {
                try {
                    if(statement2 !=null)
                        statement2.close();
                    if (connection2 != null)
                    connection2.close();

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

            }
                                    %>
                                    <input type="text" readonly name="glCodeInttReceivedAmendShow" id="glCodeInttReceivedAmendShow" value="<%=glCodeInttPAID_AmendShow%>" />
                                    <input type="hidden" style="display:none" name="glCodeInttReceivedAmend" id="glCodeInttReceivedAmend" value="<%=glCodeInttPAID_Amend%>" />


                                    <input type="button" name="Amend3" id="Amend3" value="Search" onclick="javascript:popup_InttPaidBalGLAmend(420, 280);"/>
                                </td>
                            </tr>
                            <tr>
                                <td>Debit Comp1:</td>
                                <td><input type="text"  name="debitComp1Amend" id="debitComp1Amend" size="15" value="<%=blankNull(oLoanProductCreationBean.getDebitComp1())%>"/></td>
                            </tr>
                            <tr>
                                <td>Debit Comp2:</td>
                                <td><input type="text"  name="debitComp2Amend" id="debitComp2Amend" size="15" value="<%=blankNull(oLoanProductCreationBean.getDebitComp2())%>"/></td>
                            </tr>
                            <tr>
                                <td>Status:</td>
                                <td><select name="statusAmend" id="statusAmend"  readonly="true" >
                                        <option value="" disabled selected style="display:none;" <%if (oLoanProductCreationBean.getStatus().equals("")) {%> selected <%}%>>--Select--</option>
                                        <option value="A" <%if (oLoanProductCreationBean.getStatus().equals("A")) {%> selected <%}%>>Active</option>
                                        <option value="I" <%if (oLoanProductCreationBean.getStatus().equals("I")) {%> selected <%}%>>Inactive</option>

                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>INTT Rate:</td>
                                <td><input type="text" size="10" maxlength="5"  name="intrateAmend" id="intrateAmend" value="<%=blankNull(oLoanProductCreationBean.getIntrate())%>" /></td>
                            </tr>
                            <tr>
                                <td>INTT Method: </td>
                                <td>
                                    <select name="inttmethodAmend" id="inttmethodAmend" >
                                        <option value="" disabled selected style="display:none;" <%if (oLoanProductCreationBean.getInttmethod().equals("")) {%> selected <%}%>>--Select--</option>
                                        <option value="S" <%if (oLoanProductCreationBean.getInttmethod().equals("S")) {%> selected <%}%>>Simple</option>
                                        <option value="C" <%if (oLoanProductCreationBean.getInttmethod().equals("C")) {%> selected <%}%>>Compound</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>INTT Frequency: </td>
                                <td>
                                    <select name="inttfrequencyAmend" id="inttfrequencyAmend" >
                                        <option value="" disabled selected style="display:none;" <%if (oLoanProductCreationBean.getInttfrequency().equals("")) {%> selected <%}%>>--Select--</option>
                                        <option value="D" <%if (oLoanProductCreationBean.getInttfrequency().equals("D")) {%> selected <%}%>>Daily</option>
                                        <option value="M" <%if (oLoanProductCreationBean.getInttfrequency().equals("M")) {%> selected <%}%>>Monthly</option>
                                        <option value="Q" <%if (oLoanProductCreationBean.getInttfrequency().equals("Q")) {%> selected <%}%>>Quaterly</option>
                                        <option value="H" <%if (oLoanProductCreationBean.getInttfrequency().equals("H")) {%> selected <%}%>>Half-Yearly</option>
                                        <option value="Y" <%if (oLoanProductCreationBean.getInttfrequency().equals("Y")) {%> selected <%}%>>Yearly</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>INTT Capitalization Frequency: </td>
                                <td>
                                    <select name="inttcapfrequencyAmend" id="inttcapfrequencyAmend" >
                                        <option value="" disabled selected style="display:none;" <%if (oLoanProductCreationBean.getInttcapfrequency().equals("")) {%> selected <%}%>>--Select--</option>
                                        <option value="D" <%if (oLoanProductCreationBean.getInttcapfrequency().equals("D")) {%> selected <%}%>>Daily</option>
                                        <option value="M" <%if (oLoanProductCreationBean.getInttcapfrequency().equals("M")) {%> selected <%}%>>Monthly</option>
                                        <option value="Q" <%if (oLoanProductCreationBean.getInttcapfrequency().equals("Q")) {%> selected <%}%>>Quaterly</option>
                                        <option value="H" <%if (oLoanProductCreationBean.getInttcapfrequency().equals("H")) {%> selected <%}%>>Half-Yearly</option>
                                        <option value="Y" <%if (oLoanProductCreationBean.getInttcapfrequency().equals("Y")) {%> selected <%}%>>Yearly</option>
                                    </select>
                                </td>
                            </tr>

                            <tr>
                                <td>Penalty Interest Rate:</td>
                                <td><input type="text" name="pen_intt_rtAmend" id="pen_intt_rtAmend" maxlength="5" size="4" value="<%=blankNull(oLoanProductCreationBean.getPen_intt_rt())%>" /></td>
                            </tr>
                            <tr>
                                <td>Penalty Interest Method:</td>
                                <td>
                                    <select name="pen_intt_methodAmend" id="pen_intt_methodAmend">
                                        <option value="" disabled selected style="display:none;" <%if (oLoanProductCreationBean.getPen_intt_method().equals("")) {%> selected <%}%>>--Select--</option>
                                        <option value="S" <%if (oLoanProductCreationBean.getPen_intt_method().equals("S")) {%> selected <%}%>>Simple</option>
                                        <option value="C" <%if (oLoanProductCreationBean.getPen_intt_method().equals("C")) {%> selected <%}%>>Compound</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>Penalty Interest Frequency: </td>
                                <td>
                                    <select name="pen_inttcapfrequencyAmend" id="pen_inttcapfrequencyAmend" >
                                        <option value="" disabled selected style="display:none;" <%if (oLoanProductCreationBean.getPen_inttcapfrequency().equals("")) {%> selected <%}%>>--Select--</option>
                                        <option value="D" <%if (oLoanProductCreationBean.getPen_inttcapfrequency().equals("D")) {%> selected <%}%>>Daily</option>
                                        <option value="M" <%if (oLoanProductCreationBean.getPen_inttcapfrequency().equals("M")) {%> selected <%}%>>Monthly</option>
                                        <option value="Q" <%if (oLoanProductCreationBean.getPen_inttcapfrequency().equals("Q")) {%> selected <%}%>>Quaterly</option>
                                        <option value="H" <%if (oLoanProductCreationBean.getPen_inttcapfrequency().equals("H")) {%> selected <%}%>>Half-Yearly</option>
                                        <option value="Y" <%if (oLoanProductCreationBean.getPen_inttcapfrequency().equals("Y")) {%> selected <%}%>>Yearly</option>


                                    </select>
                                </td>
                            </tr>

                            <tr>
                                <td>MIN Disbursement:</td>
                                <td><input type="text"  name="minDisbrsAmend" id="minDisbrsAmend" maxlength="10"  size="10" value="<%=blankNull(oLoanProductCreationBean.getMinDisbrs())%>"/></td>
                            </tr>
                            <tr>
                                <td>MAX Disbursement:</td>
                                <td><input type="text"  name="maxDisbrsAmend" id="maxDisbrsAmend" maxlength="10" size="10" value="<%=blankNull(oLoanProductCreationBean.getMaxDisbrs())%>" /></td>
                            </tr>
                            <tr>
                                <td>MIN Repayment:</td>
                                <td><input type="text"  name="minRepayAmend" id="minRepayAmend" maxlength="10"  size="10" value="<%=blankNull(oLoanProductCreationBean.getMinRepay())%>"/></td>
                            </tr>
                            <tr>
                                <td>MAX Repayment:</td>
                                <td><input type="text"  name="maxRepayAmend" id="maxRepayAmend" maxlength="10" size="10" value="<%=blankNull(oLoanProductCreationBean.getMaxRepay())%>" /></td>
                            </tr>

                            <tr>
                                <td>Repayment Frequency: </td>
                                <td>
                                    <select name="repayFrequencyAmend" id="repayFrequencyAmend" >
                                        <option value="" disabled selected style="display:none;">--Select--</option>
                                        <option value="M"<%if (oLoanProductCreationBean.getRepayFrequency().equals("M")) {%> selected <%}%>>Monthly</option>
                                        <option value="Q"<%if (oLoanProductCreationBean.getRepayFrequency().equals("Q")) {%> selected <%}%>>Quaterly</option>
                                        <option value="H"<%if (oLoanProductCreationBean.getRepayFrequency().equals("H")) {%> selected <%}%>>Half-Yearly</option>
                                        <option value="Y"<%if (oLoanProductCreationBean.getRepayFrequency().equals("Y")) {%> selected <%}%>>Yearly</option>
                                        <option value="N"<%if (oLoanProductCreationBean.getRepayFrequency().equals("N")) {%> selected <%}%>>NONE</option>

                                    </select>
                                </td>
                            </tr>

                            <tr>
                                <td>MIN Term:</td>
                                <td><input type="text"  name="minTermAmend" id="minTermAmend" maxlength="10"  size="10" value="<%=blankNull(oLoanProductCreationBean.getMinTerm())%>"/></td>
                            </tr>
                            <tr>
                                <td>MAX Term:</td>
                                <td><input type="text"  name="maxTermAmend" id="maxTermAmend" maxlength="10" size="10" value="<%=blankNull(oLoanProductCreationBean.getMaxTerm())%>" /></td>
                            </tr>
                            <tr>
                                <td>MIN Sanctioned Amount:</td>
                                <td><input type="text"  name="minSancAmtAmend" id="minSancAmtAmend" maxlength="10"  size="10" value="<%=blankNull(oLoanProductCreationBean.getMinSancAmt())%>"/></td>
                            </tr>
                            <tr>
                                <td>MAX Sanctioned Amount:</td>
                                <td><input type="text"  name="maxSancAmtAmend" id="maxSancAmtAmend" maxlength="10" size="10" value="<%=blankNull(oLoanProductCreationBean.getMaxSancAmt())%>"/></td>
                            </tr>
                            <tr>
                                <td><lable>Effect Date :</lable></td>
                        <td><input type="text" readonly="true" id="effectDateAmend" name="effectDateAmend" value="<%=blankNull(oLoanProductCreationBean.getEffectDate())%>"><a href="#" onclick="return getCalendar(getElementById('effectDateAmend'));"><img src="${pageContext.request.contextPath}/img/calendar.gif" name="imgr" border="0" width="15" height="20" /></a></td>
                        </tr>
                        <tr>
                            <td>Penalty Grace Period(days):</td>
                            <td><input type="text"  name="penGracePrAmend" id="penGracePrAmend" maxlength="3"  size="3" value="<%=blankNull(oLoanProductCreationBean.getPenGracePr())%>"/></td>
                        </tr>
                        <tr>
                            <td>Guarantor Required:</td>
                            <td><select name="guarantorAmend" id="guarantorAmend" >
                                    <option value="" disabled selected style="display:none;" <%if (oLoanProductCreationBean.getGuarantor().equals("")) {%> selected <%}%>>--Select--</option>
                                    <option value="Y" <%if (oLoanProductCreationBean.getGuarantor().equals("Y")) {%> selected <%}%>>Yes</option>
                                    <option value="N" <%if (oLoanProductCreationBean.getGuarantor().equals("N")) {%> selected <%}%>>No</option>

                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>Security Required:</td>
                            <td><select name="securityAmend" id="securityAmend" >
                                    <option value="" disabled selected style="display:none;" <%if (oLoanProductCreationBean.getSecurity().equals("")) {%> selected <%}%>>--Select--</option>
                                    <option value="Y" <%if (oLoanProductCreationBean.getSecurity().equals("Y")) {%> selected <%}%>>Yes</option>
                                    <option value="N" <%if (oLoanProductCreationBean.getSecurity().equals("N")) {%> selected <%}%>>No</option>

                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>Loan Type:</td>
                            <td><select name="loanTypeAmend" id="loanTypeAmend" >
                                    <option value="" disabled <%if (blankNull(oLoanProductCreationBean.getLoanType()).equals("")) {%> selected <%}%>>--Select--</option>
                                    <option value="E" <%if (blankNull(oLoanProductCreationBean.getLoanType()).equals("E")) {%> selected <%}%>>EMI</option>
                                    <option value="N" <%if (blankNull(oLoanProductCreationBean.getLoanType()).equals("N")) {%> selected <%}%>>NEGOTIABLE</option>
                                    <option value="C" <%if (blankNull(oLoanProductCreationBean.getLoanType()).equals("C")) {%> selected <%}%>>Cash-Credit</option>

                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>Head of A/c Type:</td>
                            <td><select name="headAccTypeAmend" id="headAccTypeAmend" >
                                    <option value="" disabled <%if (blankNull(oLoanProductCreationBean.getHeadAccType()).equals("")) {%> selected <%}%>>--Select--</option>
                                    <option value="1" <%if (blankNull(oLoanProductCreationBean.getHeadAccType()).equals("1")) {%> selected <%}%>>1: Liabilities</option>
                                    <option value="2" <%if (blankNull(oLoanProductCreationBean.getHeadAccType()).equals("2")) {%> selected <%}%>>2: Asset</option>
                                    <option value="3" <%if (blankNull(oLoanProductCreationBean.getHeadAccType()).equals("3")) {%> selected <%}%>>3: Purchase</option>
                                    <option value="4" <%if (blankNull(oLoanProductCreationBean.getHeadAccType()).equals("4")) {%> selected <%}%>>4: Sell</option>
                                    <option value="5" <%if (blankNull(oLoanProductCreationBean.getHeadAccType()).equals("5")) {%> selected <%}%>>5: Income</option>
                                    <option value="6" <%if (blankNull(oLoanProductCreationBean.getHeadAccType()).equals("6")) {%> selected <%}%>>6: Expenditure</option>
                                </select>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <br><br>
                    </center>
                    <input type="hidden" name="dep_product_id" value="<%=blankNull(oLoanProductCreationBean.getLoanPd_id())%>"/>
                    <center>
                        <input type="button" value="Update" onclick="javascript:updateform(loanProductCreation)">
                    </center>
                    <p style=" font-family: Berlin Sans FB; font-weight:  normal;"> All fields are mandatory </p>
                </div>
                <%}%>



                <input type="hidden" name="handle_id" value="" />
            </form>
        </fieldset>
        <script>
            function resetForm($form) {
                $form.find(':input[type="text"], select, textarea').val('');
                //$form.find('input:radio, input:checkbox').removeAttr('checked').removeAttr('selected');
            }

            // to call, use:
            //resetForm($('#loanProductCreation')); // by id, recommended

            $(document).ready(function () {
                $('select#loanType').change(function () {
                    var loanType  = $(this).val();
                    switch(loanType)
                    {
                        case 'N':
                            $('#repayFrequency').val('N');
                            break;
                        case 'C':
                            $('#repayFrequency').val('N');
                            break;
                        default:
                            $('#repayFrequency').val('');
                            break;
                    }
                });

                $('select#loanTypeAmend').change(function () {
                    var loanType  = $(this).val();
                    switch(loanType)
                    {
                        case 'N':
                            $('#repayFrequencyAmend').val('N');
                            break;
                        case 'C':
                            $('#repayFrequencyAmend').val('N');
                            break;
                        default:
                            $('#repayFrequencyAmend').val('');
                            break;
                    }
                });
            });
        </script>
    </body>
</html>
