<%--
    Document   : AccountModeOfOperation
    Created on : june 19, 2019, 8:18:55 PM
    Author     : 1242938
--%>

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

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

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

        <script type="text/javascript">
            function noBack()
            {
                window.history.forward();
            }

            function popup_DepositAccLOV(width, height, depositAccSearch) {
                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 = "AccountModeOfOperation.jsp";
                var  lovKey="DepositAccLOV"
                popWin = open('${pageContext.request.contextPath}/CommonSearchInfoLOVNew.jsp?depositAccSearch=' + depositAccSearch + '&screenName=' + screenName+'&lovKey='+lovKey, 'DepositAccLOB', attr);
                popWin.focus();

            }

            function popup_TransactionNo(width,height,txn_no,acc_no){
                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 = "DepositMiscellaneousOperation.jsp";
                var  lovKey="TransactionNoSearch";
                popWin = open('${pageContext.request.contextPath}/CommonSearchInfoLOVNew.jsp?depositAccNo=' + acc_no + '&TxnNo=' + txn_no + '&screenName=' + screenName+'&lovKey='+lovKey, 'DepositAccLOB', attr);
                popWin.focus();
            }


            function popup_SecondCifLOB(width, height, secondCifSearch ,lovkey) {
                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 = "AccountModeOfOperation.jsp";
                var  lovKey=lovkey;
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationDepositLOV.jsp?depositAccSearch=' + secondCifSearch + '&screenName=' + screenName+'&lovKey='+lovKey, 'DepositAccLOB', attr);
                popWin.focus();

            }


            function submitform(AccountModeOfOperationForm)
            {
                if (AccountModeOfOperationForm.depositAccSearch.value == "")
                {
                    alert("Please enter Deposit Account Number.");
                    AccountModeOfOperationForm.depositAccSearch.focus();
                    return false;
                }                
                re = /^\d+$/; //this checks whether field contains digits
                if (!re.test(document.getElementById("depositAccSearch").value))
                {
                    alert("Deposit Account could only contain numbers.");
                    AccountModeOfOperationForm.depositAccSearch.focus();
                    return false;
                }
                
                document.forms[0].handle_id.value = "Search";
                document.forms[0].action = '/PacsApplication/AccountModeOfOperationServlet';
                document.forms[0].submit();

            }
            function submitOperation()
            {                
                re = /^\d+$/;
                if (AccountModeOfOperationForm.operation_type.value == "")
                {
                    alert("Please select Account Mode of Operation.");
                    AccountModeOfOperationForm.operation_type.focus();
                    return false;
                }
                if(document.getElementById("displayFlag").value == "Y" && document.getElementById("operation_type").value == "NOM") {
                    if (!re.test(document.getElementById("nomId").value))
                    {
                        alert("Please enter nominee CIF correctly.");
                        document.getElementById("nomId").focus();
                        return false;
                    }
                    if(document.getElementById("secondCifSearchFlag").value == "") {
                        alert("Please search the nominee CIF to proceed.");
                        document.getElementById("nomId").focus();
                        return false;
                    }
                }

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

            }

            function ShowParent()
            {
                document.forms[0].action="${pageContext.request.contextPath}/Deposit/AccountModeOfOperation.jsp";
                document.forms[0].submit();
            }
            
            function onRadioClick(temp)
            {
                if (temp == 1){
                    document.getElementById("transactionInputBox").style.display='block';
                    document.getElementById("accountInputBox").style.display='none';
                    document.getElementById("radio1").value='txn';
                }
                else if(temp == 2){
                    document.getElementById("accountInputBox").style.display='block';
                    document.getElementById("transactionInputBox").style.display='none';
                    document.getElementById("radio2").value='accnt';
                }
            }
            // to restrict going back 
            history.pushState(null, null, location.href);
            window.addEventListener('popstate', function(event) {
                history.pushState(null, null, location.href);
            });

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

        <%

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

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

        <%
            String pacsId = (String) session.getAttribute("pacsId");
             Object oDepositMiscellaneousBeanObj = request.getAttribute("oDepositMiscellaneousBeanObj");
             DepositMiscellaneousBean oDepositMiscellaneousBean = new DepositMiscellaneousBean();
             if (oDepositMiscellaneousBeanObj != null) {
                 oDepositMiscellaneousBean = (DepositMiscellaneousBean) request.getAttribute("oDepositMiscellaneousBeanObj");
             }
        %>

        <fieldset style="border-color: black; background-image: url('/PacsApplication/img/download.jpg'); border-width: 3px">
            <legend style="padding: 8px; border-radius: 20px; background-color: #006600; color: white">Account Mode Of Operation</legend>
            <form name="AccountModeOfOperationForm" id="AccountModeOfOperationForm" action="" method="post">


                <%if (!error_msg.equalsIgnoreCase("")) {%>
                <center><div class="info" id="errorMessage"><center><%= error_msg%></center></div></center>
                <% }%>
                <br>
                <br>
                <center>
                    <table class="numbersOnly">
                        <tr><td>Enter Deposit Account<font color="red" >*</font>:</td><td></td><td><input type="text"  maxlength="25" name="depositAccSearch" id="depositAccSearch" value="<%=blankNull(oDepositMiscellaneousBean.getDepositAccountNumber())%>" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /><input type="button" value="Search" onclick="javascript:popup_DepositAccLOV(900, 350, document.AccountModeOfOperationForm.depositAccSearch.value);"/></td></tr>
                        <tr></tr>
                        <tr></tr>
                        <tr></tr>
                        <tr></tr>
                        <tr></tr>
                        <tr></tr>

                    </table>
                    <br>
                    <input type="button" value="Get Details" id="Submit" onclick="javascript:submitform(AccountModeOfOperationForm)"/>
                    <input type="button" value="Reset" id="Reset" onclick="ShowParent();" />
                    </center>
                    <br>

                <%!
                    String blankNull(String s) {
                        return (s == null) ? "" : s;
                    }
                %>
                <%
                     if (displayFlag.equalsIgnoreCase("Y")) {

                %>
                <div id="show" align="left" >

                    <br>
                    <center>
                        <table>
                            <thead>
                            </thead>
                            <tbody>
                                <tr>
                                    <td style="font:large;">Deposit Account Number: </td>
                                    <td><input type="text" readonly="true" name="depositAccountNumber"  id="depositAccountNumber" style="text-align:right;" style="width: 260px" value="<%=blankNull(oDepositMiscellaneousBean.getDepositAccountNumber())%>" /></td>
                                    <td></td><td></td><td></td>
                                    <td>Account Balance: </td>
                                    <td><input type="text" readonly name="accBalance"  id="accBalance" style="text-align:right;" style="width: 260px" value="<%=blankNull(oDepositMiscellaneousBean.getAccBalance())%>" /></td>
                                </tr>
                                <tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>
                                <tr>
                                    <td style="text-align:right;"> 1st CIF Number: </td>
                                    <td><input type="text" readonly="true" name="cifNo"  id="cifNo" style="text-align:right;" style="width: 260px" value="<%=blankNull(oDepositMiscellaneousBean.getCifNo())%>" /></td>
                                    <td></td><td></td><td></td>
                                    <td style="text-align:right;"> 1st A/C Holder: </td>
                                    <td><input type="text" readonly="true" name="cifName"  id="cifName" style="width: 260px" value="<%=blankNull(oDepositMiscellaneousBean.getCustomer1Name())%>" /></td>
                                </tr>
                                <tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>
                                <tr>
                                    <td style="text-align:right;"> 2nd CIF Number: </td>
                                    <td><input type="text" readonly="true" name="cif2No"  id="cif2No" style="text-align:right;" style="width: 260px" value="<%=blankNull(oDepositMiscellaneousBean.getCif2No())%>" /></td>
                                    <td></td><td></td><td></td>
                                    <td style="text-align:right;"> 2nd A/C Holder: </td>
                                    <td><input type="text" readonly="true" name="cif2Name"  id="cif2Name" style="width: 260px" value="<%=blankNull(oDepositMiscellaneousBean.getCustomer2Name())%>" /></td>
                                </tr>
                                <tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>
                                <tr>
                                    <td style="text-align:right;">Account Status: </td>
                                    <td><input type="text" readonly name="accStat" style="width: 260px" id="accStat" value="<%=blankNull(oDepositMiscellaneousBean.getAccStat())%>"/></td>
                                    <td></td><td></td><td></td>
                                    <td style="text-align:right;">Nominee CIF: </td>
                                    <td><input type="text" readonly name="nomCif" style="text-align:right;" style="width: 260px" id="nomCif" value="<%=blankNull(oDepositMiscellaneousBean.getNomCif())%>"/></td>
                                </tr>
                                <tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>
                                <tr>
                                    <td>Account Mode Operation: </td>
                                    <td><input type="text" readonly name="mode" style="width: 260px" id="mode" value="<%=blankNull(oDepositMiscellaneousBean.getMode())%>" /></td>
                                </tr>
                                <tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>
                     </table>
                    <tr><td colspan="10"><hr></td></tr>
                        <tr>
                            <td>Select Account Mode of Operation<font color="red" >*</font>:</td><td>
                            <select id="operation_type" name="operation_type">
                                <option value="" > --Select-- </option>
                                <%
                                        Connection connection = null;
                                        ResultSet rs = null;
                                        Statement statement = null;
                                        connection = DbHandler.getDBConnection();
                                        try {
                                            statement = connection.createStatement();
                                            rs = statement.executeQuery("select dp.mop_code, dp.mop_name from acc_mop_map dp order by to_number(dp.mop_code)");
                                            while (rs.next()) {%>
                                            <option value="<%=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>
                </center>
                    <br>
                    <center>
                        <input type="button" value="Submit" id="Submit" onclick="javascript:submitOperation()"/></center>
                </div>
                <%}%>
                <input type="hidden" name="handle_id" value="" >
                <input type="hidden" name="secondCifSearchFlag" id="secondCifSearchFlag" value="">
                <input type="hidden" name="displayFlag" id="displayFlag" value="<%=displayFlag%>" >                
            </form>
        </fieldset>
    </body>
    <script>
        //make all inputs whole numbers only
        /*$('table.numbersOnly').on('keydown','#depositAccSearch', function(event) {
            if (event.shiftKey == true) {
                event.preventDefault();
            }

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

            } else {
                event.preventDefault();
            }
        });*/
    </script>
</html>
<% 	} catch (Exception e) {
               
            }
%>

