<%--
    Document   : LoanAccountCreationReadOnly
    Created on : Mar 8, 2016, 1:20:58 PM
    Author     : Tcs Helpdesk10
--%>

<%@page import="LoginDb.DbHandler"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%@page import="java.sql.Connection"%>
<%@page import="DataEntryBean.LoanAccountCreationBean"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Loan Account Creation</title>
        <script src="${pageContext.request.contextPath}/js/Calendar.js"></script>
        <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
        <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 SearchNsc(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 refno = $('#SearchID').val();
                var screenName = "LoanAccountCreationReadOnly.jsp";
                var  lovKey=    "view_collateral"
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationLoanLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey+'&refno='+refno , 'view_collateral', attr);
                popWin.focus();
            }
            function SearchGold(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 refno = $('#SearchID').val();
                var screenName = "LoanAccountCreationReadOnly.jsp";
                var  lovKey=    "view_collateral_Gold"
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationLoanLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey+'&refno='+refno , 'view_collateral_Gold', attr);
                popWin.focus();
            }


            function Approveform(LoanaccCreatFormReadOnly)
            {
                if (document.forms[0].AuthComment.value==""||document.forms[0].AuthComment.value==null){

                    alert("Comments Required");
                    return false;

                }


                if (document.forms[0].sancAmt.value==""||document.forms[0].sancAmt.value==null){

                    alert("Sanctioned Amount must be filled");
                    document.forms[0].sancAmt.focus();
                    return false;

                }


                if (document.forms[0].charges.value==""||document.forms[0].charges.value==null){

                    alert("Charges must be filled");
                    document.forms[0].charges.focus();
                    return false;

                }


                re = /^\d+$/; //this checks whether field contains digits
                if (!re.test(document.forms[0].charges.value))
                {
                    alert("!! Charges could only contain numbers !!");
                    document.forms[0].charges.focus();
                    return false;
                }


                re = /^\d+$/; //this checks whether field contains digits
                if (!re.test(document.forms[0].sancAmt.value))
                {
                    alert("!! Sanctioned Amount could only contain numbers !!");
                    document.forms[0].sancAmt.focus();
                    return false;
                }

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

            }

            function Rform(LoanaccCreatFormReadOnly)
            {
                if (document.forms[0].AuthComment.value==""||document.forms[0].AuthComment.value==null){

                    alert("Comments Required");
                    return false;

                }
                document.forms[0].handle_id.value="RejectAccOpen";
                document.forms[0].action = '/PacsApplication/TransactionAuthorizationServlet';
                document.forms[0].submit();

            }

            // to restrict back button
            history.pushState(null, null, location.href);
            window.addEventListener('popstate', function(event) {
                history.pushState(null, null, location.href);
            });

        </script>


        <%
                    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();
                    }
        %>


        <%
                    Object LoanAccountCreationBeanObj = request.getAttribute("oLoanAccountCreationBean");
                    LoanAccountCreationBean oLoanAccountCreationBean = new LoanAccountCreationBean();

                    if (LoanAccountCreationBeanObj != null) {
                        oLoanAccountCreationBean = (LoanAccountCreationBean) request.getAttribute("oLoanAccountCreationBean");

                    }
        %>

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

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

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

        <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 ACCOUNT AUTHORIZATION</legend>

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

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

                <%if (displayFlag.equalsIgnoreCase("Y")) {%>
                <div id="create" align="left">

                    <table>
                        <tr><td><hr></td></tr>
                        <tr><td><h3>Account Information :</h3></td></tr>
                        <tr>
                            <td><lable>Product Code :</lable></td>
                        <td><input type="text" id="productCodeDetails" name="productCodeDetails" readonly value="<%=blankNull(oLoanAccountCreationBean.getProductCode())%>" ></td>


                        </tr>
                        <tr>
                            <td><lable>Intt Category :</lable></td>
                        <td><input type="text" id="inttCatDetails" name="inttCatDetails" readonly="true" value="<%=blankNull(oLoanAccountCreationBean.getInttCategory())%>"></td>
                        </tr>

                        <tr>
                            <td><lable>Segment Code :</lable></td>
                        <td>
                            <select id="segmentCode" name="segmentCode" disabled>
                                <option value="" disabled selected style="display:none;">--Select--</option>
                                <option value="0706" <%if (oLoanAccountCreationBean.getSegmentCode().equals("0706")) {%> selected <%}%>>0706:INDIVIDUAL</option>
                                <option value="0306" <%if (oLoanAccountCreationBean.getSegmentCode().equals("0306")) {%> selected <%}%>>0306:STAFF</option>
                                <option value="5003" <%if (oLoanAccountCreationBean.getSegmentCode().equals("5003")) {%> selected <%}%>>5003:SENIOR CITIZEN</option>
                                <option value="5010" <%if (oLoanAccountCreationBean.getSegmentCode().equals("5010")) {%> selected <%}%>>5010:SHG</option>
                                <option value="5000" <%if (oLoanAccountCreationBean.getSegmentCode().equals("5000")) {%> selected <%}%>>5000:BANKS</option>
                                <option value="5009" <%if (oLoanAccountCreationBean.getSegmentCode().equals("5009")) {%> selected <%}%>>5009:INSTITUTIONS</option>
                                <option value="5050" <%if (oLoanAccountCreationBean.getSegmentCode().equals("5050")) {%> selected <%}%>>5050:OTHERS</option>
                                <option value="5007" <%if (oLoanAccountCreationBean.getSegmentCode().equals("5007")) {%> selected <%}%>>5007:SOCIETY</option>
                                <option value="5011" <%if (oLoanAccountCreationBean.getSegmentCode().equals("5011")) {%> selected <%}%>>5011:GOV/SEMI GOV</option>
                                <option value="5012" <%if (oLoanAccountCreationBean.getSegmentCode().equals("5012")) {%> selected <%}%>>5012:PACS</option>
                                <option value="5013" <%if (oLoanAccountCreationBean.getSegmentCode().equals("5013")) {%> selected <%}%>>5013:UCB</option>
                                <option value="5014" <%if (oLoanAccountCreationBean.getSegmentCode().equals("5014")) {%> selected <%}%>>5014:SCB</option>
                                <option value="5015" <%if (oLoanAccountCreationBean.getSegmentCode().equals("5015")) {%> selected <%}%>>5015:CCB</option>
                            </select>
                        </td>
                        </tr>
                        <tr>
                            <td><lable>CIF Number :</lable></td>
                        <td><input type="text" id="cifNumber" name="cifNumber" value="<%=blankNull(oLoanAccountCreationBean.getCifNumber())%>" readonly></td>

                        </tr>
                        <tr>
                            <td><lable>Customer Name :</lable></td>
                        <td><input type="text" id="custName" name="custName" value="<%=blankNull(oLoanAccountCreationBean.getCustName())%>" disabled readonly></td>

                        </tr>
                        <tr>
                            <td><lable>Loan Application Amount :</lable></td>
                        <td><input type="text" id="loanappAmt" name="loanappAmt" value="<%=blankNull(oLoanAccountCreationBean.getLoanappAmt())%>" readonly></td>
                        </tr>
                        <tr>
                            <td><lable>Loan Terms(Months) :</lable></td>
                        <td><input type="text" id="loanTerm" name="loanTerm" size="4" value="<%=blankNull(oLoanAccountCreationBean.getLoanTerm())%>" readonly></td>
                        </tr>
                        <tr>
                            <td><lable>Scheme Code :</lable></td>
                        <td>
                            <select id="schemeCode" name="schemeCode" disabled>
                                <option value="" disabled selected style="display:none;">--Select--</option>
                                <option value="1" <%if (oLoanAccountCreationBean.getSchemeCode().equals("1")) {%> selected <%}%>>Urban Development Scheme</option>
                                <option value="2" <%if (oLoanAccountCreationBean.getSchemeCode().equals("2")) {%> selected <%}%>>Women Welfare Scheme</option>
                                <option value="3" <%if (oLoanAccountCreationBean.getSchemeCode().equals("3")) {%> selected <%}%>>Krishan Subidha Yojona</option>
                                <option value="4" <%if (oLoanAccountCreationBean.getSchemeCode().equals("4")) {%> selected <%}%>>Others</option>

                            </select>
                        </td>
                        </tr>
                        <tr>
                            <td><lable>Purpose Code :</lable></td>
                        <td>
                            <select id="purposeCode" name="purposeCode" disabled>
                                <option value="" disabled selected style="display:none;">--Select--</option>
                                <option value="1" <%if (oLoanAccountCreationBean.getPurposeCode().equals("1")) {%> selected <%}%>>Seasonal Crop</option>
                                <option value="2" <%if (oLoanAccountCreationBean.getPurposeCode().equals("2")) {%> selected <%}%>>Regular Crop</option>
                                <option value="3" <%if (oLoanAccountCreationBean.getPurposeCode().equals("3")) {%> selected <%}%>>Other</option>

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

                        <%if (!blankNull(oLoanAccountCreationBean.getCollateralType()).equalsIgnoreCase("") ) {%>

                        <tr><td><hr></td></tr>
                        <tr><td><h3>Collateral Information :</h3></td></tr>
                        <tr>
                            <td><lable>Collateral Type :</lable></td>
                        <td>
                            <select id="collateralType" name="collateralType" disabled>
                                <option value="" disabled style="display:none;">--Select--</option>
                                <option value="L" <%if (oLoanAccountCreationBean.getCollateralType().equals("L")) {%> selected <%}%>>Land</option>
                                <option value="O" <%if (oLoanAccountCreationBean.getCollateralType().equals("G")) {%> selected <%}%>>Gold</option>
                                <option value="O" <%if (oLoanAccountCreationBean.getCollateralType().equals("D")) {%> selected <%}%>>Loan against Deposit</option>
                                <option value="O" <%if (oLoanAccountCreationBean.getCollateralType().equals("K")) {%> selected <%}%>>Loan against NSC/KVP/LIC</option>
                                <option value="O" <%if (oLoanAccountCreationBean.getCollateralType().equals("O")) {%> selected <%}%>>Others</option>
                            </select>
                        </td>
                        <%if(oLoanAccountCreationBean.getProductCode().startsWith("7001")){%>
                        <td><input type="button" value="View Collateral" onclick="javascript:SearchNsc(350,250)" />
                       </td>
                       <%} else if(oLoanAccountCreationBean.getProductCode().startsWith("7010")){%>
                        <td><input type="button" value="View Collateral" onclick="javascript:SearchGold(350,250)" />
                       </td>
                       <%}%>
                        </tr>

                        <tr>
                            <td><lable>Description :</lable></td>
                        <td><textarea readonly id="description" name="description" style="width : 150px"><%=blankNull(oLoanAccountCreationBean.getDescription())%></textarea></td>
                        </tr>
                        <tr>
                            <td><lable>Current Valuation (in Rs.):</lable></td>
                        <td><input type="text" id="currentValuation" name="currentValuation" value="<%=blankNull(oLoanAccountCreationBean.getCurrentValuation())%>" readonly/></td>
                        </tr>
                        <tr>
                            <td><lable>Safe Lending Margin :</lable></td>
                        <td><input type="text" id="safeLendingMargin" name="safeLendingMargin" value="<%=blankNull(oLoanAccountCreationBean.getSafeLendingMargin())%>" readonly/></td>
                        <td><lable>%</lable></td>
                        </tr>

                        <%}%>
                        
                        <tr><td><hr></td></tr>
                        <tr><td><h3>Interest Information:</h3></td></tr>
                        <tr>
                        <td><lable>Interest Rate<font color="red" >*</font>:</lable></td>
                        <td><input type="text" id="intRate" name="intRate" value="<%=blankNull(oLoanAccountCreationBean.getIntRate())%>" readonly></td>
                        </tr>
                        <tr>
                        <td><lable>Penal Interest Rate<font color="red" >*</font>:</lable></td>
                        <td><input type="text" id="penIntRate" name="penIntRate" value="<%=blankNull(oLoanAccountCreationBean.getPenIntRate())%>" readonly></td>
                        </tr>
                        
                        <tr><td><hr></td></tr>
                        <tr><td><h3>Additional Information :</h3></td></tr>

                        <tr>
                            <td><lable>Activity Code :</lable></td>
                        <td>
                            <select id="activityCode" name="activityCode" disabled>
                                <option value="" disabled selected style="display:none;">--Select--</option>
                                <option value="1" <%if (oLoanAccountCreationBean.getActivityCode().equals("1")) {%> selected <%}%>>Direct Agriculture</option>
                                <option value="2" <%if (oLoanAccountCreationBean.getActivityCode().equals("2")) {%> selected <%}%>>Indirect Agriculture</option>
                                <option value="3" <%if (oLoanAccountCreationBean.getActivityCode().equals("3")) {%> selected <%}%>>Agricultural Service Units</option>
                                <option value="4" <%if (oLoanAccountCreationBean.getActivityCode().equals("4")) {%> selected <%}%>>Farm Irrigation</option>
                                <option value="5" <%if (oLoanAccountCreationBean.getActivityCode().equals("5")) {%> selected <%}%>>Fruits & Vegetables</option>
                            </select>
                        </td>
                        </tr>
                        <tr>
                            <td><lable>Customer Type :</lable></td>
                        <td><input type="text" readonly id="customerType" name="customerType" readonly value="<%=blankNull(oLoanAccountCreationBean.getCustomerType())%>">

                        </td>
                        </tr>

                        <%if (!blankNull(oLoanAccountCreationBean.getGurantorName()).equalsIgnoreCase("")) {%>

                        <tr><td><hr></td></tr>
                        <tr><td><h3>Guarantor Information :</h3></td></tr>

                        <tr>
                            <td><lable>Guarantor Name :</lable></td>
                        <td><input type="text" name="gurantorName" id="gurantorName" readonly value="<%=blankNull(oLoanAccountCreationBean.getGurantorName())%>"></td>
                        </tr>
                        <tr>
                            <td><lable>Guarantor Address :</lable></td>
                        <td><textarea name="guarantorAddress" id="guarantorAddress" readonly><%=blankNull(oLoanAccountCreationBean.getGuarantorAddress())%></textarea></td>
                        </tr>
                        <tr>
                            <td><lable>Guarantor Date of Birth :</lable></td>
                        <td><input type="text" id="guarantorDOB" name="guarantorDOB" readonly="true" value="<%=blankNull(oLoanAccountCreationBean.getGuarantorDOB())%>"></td>
                        </tr>
                        <tr>
                            <td><lable>Guarantor Job :</lable></td>
                        <td><select name="guarantorJob" id="guarantorJob" disabled>
                                <option value="S"<%if (blankNull(oLoanAccountCreationBean.getGuarantorJob()).equals("S")) {%> selected <%}%>>Service</option>
                                <option value="B"<%if (blankNull(oLoanAccountCreationBean.getGuarantorJob()).equals("B")) {%> selected <%}%>>Business</option>
                                <option value="O"<%if (blankNull(oLoanAccountCreationBean.getGuarantorJob()).equals("O")) {%> selected <%}%>>Others</option>
                            </select>
                        </td>
                        </tr>
                        <tr>
                            <td><lable>Guarantor Annual Income :</lable></td>
                        <td><input type="text" name="gurantorIncome" id="gurantorIncome" readonly value="<%=blankNull(oLoanAccountCreationBean.getGurantorIncome())%>"></td>
                        </tr>

                        <%}%>

                        <tr>
                            <td><lable>Sanctioned Amount :</lable></td>
                        <td><input type="text" name="sancAmt" id="sancAmt" ></td>
                        </tr>


                        <tr>
                            <td><lable>Charges(if required) :</lable></td>
                        <td><input type="text" name="charges" id="charges"></td>
                        </tr>

                       
                        <tr>
                            <td>Relationship with Guarantor :</td>
                            <td>
                                <input type="text" readonly  name="guarRelation" id="guarRelation" value="<%=blankNullable(oLoanAccountCreationBean.getGuarRelation())%>"/>

                            </td>
                        </tr>
                        <tr>
                            <td>Guarantor Id Type :</td>
                            <td>
                                <input type="text"  readonly name="guarIdType" id="guarIdType" value="<%=blankNullable(oLoanAccountCreationBean.getGuarIdType())%>"/>
                            </td>
                        </tr>
                        <tr>
                            <td>Guarantor ID NO :</td>
                            <td>
                                <input type="text" readonly  name="guarIdNo" id="guarIdNo" value="<%=blankNullable(oLoanAccountCreationBean.getGuarIdNo())%>"/>

                            </td>
                        </tr>
                         <tr>
                            <td>Authorizer's Comment:</td>
                            <td>
                                <textarea  name="AuthComment" id="AuthComment"></textarea>
                            </td>
                        </tr>

                    </table>
                    <center>
                        <input type="button" value="Authorize" onclick="javascript:Approveform(LoanaccCreatFormReadOnly)">
                        <input type="button" value="Reject" name="reset" onclick="javascript:Rform(LoanaccCreatFormReadOnly);" />
                    </center>
                    <tr><td><br></td></tr>
                    <tr><td><br></td></tr>
                    <label style=" font-family: Berlin Sans FB; font-weight:normal; ">All fields are mandatory</label>
                </div>
                <%}%>
                <input type="hidden" name="handle_id" id="handle_id" value="" />
                <input type="hidden" name="AuthActivity" value="LOAN_ACCOUNT" />
                <input type="hidden" name="SearchID" id="SearchID" value="<%=blankNull(oLoanAccountCreationBean.getId())%>" />
            </form>
        </fieldset>
    </body>
</html>
