<%--
    Document   : CBSAccountMapping
    Created on : March 8, 2019, 6:00:55 PM
    Author     : 1242938
--%>

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

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

        <style>
            .beforeAccSrch {
                display: none;
            }
        </style>
    </head>
    <body  onload="noBack()">
        <script type="text/javascript">
            function noBack()
            {
                window.history.forward();
               // document.getElementById("Submit").disabled = true;
               // document.getElementById("Submit").style.backgroundColor ='grey';
                document.getElementById("head").style.visibility = 'hidden';
                document.getElementById("cbs").style.visibility = 'hidden';
                document.getElementById("Submit").style.visibility = 'hidden';
                document.getElementById("uppin").style.visibility = 'hidden';
                document.getElementById("curr").style.visibility = 'hidden';
            }

            function ShowParent()
            {

                document.forms[0].action = "${pageContext.request.contextPath}/Deposit/CBSAccountMapping.jsp";
                document.forms[0].submit();
            }
            function popup_Acc(width, height, Acc, Option) {

                document.getElementById("Submit").disabled = false;
                document.getElementById("Submit").style.backgroundColor ='#006600';

                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 = "CBSAccountMapping.jsp";
                var  lovKey="AccSrch"
                popWin = open('${pageContext.request.contextPath}/CommonSearchInfoLOVNew.jsp?Acc=' + Acc + '&Option=' + Option + '&screenName=' + screenName+'&lovKey='+lovKey, 'AccSrch', attr);
                popWin.focus();
                
            }
            function submitform(){

                if(validateForm()){
                    document.CBSAccountMapping.action = '/PacsApplication/CBSAccountMappingServlet';
                    document.CBSAccountMapping.submit();
                }
            }
            function validateForm(){
                if ($('#checkOption').val() == "camap")
                {
                    if ($('#currAccount').val() == "") {
                        alert("Current Account cannot be blank.");
                        CBSAccountMapping.currAccount.focus();
                        return false;
                    }
                }
                else if ( $('#checkOption').val() != "mappin" && $('#checkOption').val() != "camap")
                {
                    if($('#accNo').val() == ""){
                    alert("Account Number cannot be blank.");
                    CBSAccountMapping.accNo.focus();
                    return false;
                    }
                    if($('#cbsAccount').val() == ""){
                    alert("CBS Account cannot be blank.");
                    CBSAccountMapping.cbsAccount.focus();
                    return false;
                    }
                }
                else if ($('#checkOption').val() != "camap")
                {
                    if ($('#PIN').val() == "") {
                        alert("PIN Code cannot be blank.");
                        CBSAccountMapping.PIN.focus();
                        return false;
                    }
                }
                document.getElementById("checkOption").disabled= false;
                return true;
            }
            
            function number(){$("#cbsAccount").keypress(function(e){if(e.which!=8&&e.which!=0&&(e.which<48||e.which>57)){alert("Enter numbers only");
                        return false;}});
                $("#PIN").keypress(function(e){if(e.which!=8&&e.which!=0&&(e.which<48||e.which>57)){alert("Enter numbers only");
                        return false;}});}
            function curAcc(){alert("Kindly Note: Current Account can not be mapped more than once. Click OK.");
                $("#currAccount").keypress(function(e){if(e.which!=8&&e.which!=0&&(e.which<48||e.which>57)){alert("Enter numbers only");
                        return false;}});}
            
            $(document).ready(function () {
                $('select#checkOption').change(function () {
                    document.getElementById("checkOption").disabled= true;
                    document.getElementById("Submit").style.visibility = 'visible';
                    document.getElementById("head").style.visibility = 'visible';
                    document.getElementById("cbs").style.visibility = 'visible';
                    document.getElementById("uppin").style.visibility = 'hidden';
                    document.getElementById("curr").style.visibility = 'hidden';
                    var shouldEnable = $(this).val();
                    switch(shouldEnable)
                    {
                        case 'remove':
                            document.getElementById("cbsAccount").readOnly = true;
                            break;

                        case 'nremark':
                            document.getElementById("cbs").style.visibility = 'hidden';
                            break;

                        case 'eremark':
                            document.getElementById("cbs").style.visibility = 'hidden';
                            break;

                        case 'mappin':
                            document.getElementById("uppin").style.visibility = 'visible';
                            document.getElementById("cbs").style.visibility = 'hidden';
                            document.getElementById("head").style.visibility = 'hidden';
                            break;

                        case 'camap':
                            document.getElementById("curr").style.visibility = 'visible';
                            document.getElementById("uppin").style.visibility = 'hidden';
                            document.getElementById("cbs").style.visibility = 'hidden';
                            document.getElementById("head").style.visibility = 'hidden';
                            break;

                        default:
                            document.getElementById("cbsAccount").readOnly = false;
                            break;
                    }
                })
            });
            
            // 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_Deposit.jsp" flush="true" />
        <br>

        <%!
            String blankNull(String s) {
                return (s == null) ? "" : s;
            }
        %>
          <%
                 String error_msg = "";
                 Object error = request.getAttribute("message1");
                  if (error != null) {
                     error_msg = error.toString();
                 }
         %>

        <fieldset style="border-color: black; background-image: url('/PacsApplication/img/download.jpg'); border-width: 3px">
            <legend style="padding: 8px; border-radius: 20px; background-color: #006600; color: white">CBS Account Mapping</legend>
            <%if (!error_msg.equalsIgnoreCase("")) {%>
                    <center><div class="info" id="errorMessage"><center><%= error_msg%></center></div></center>
                    <% }%>
            <form name="CBSAccountMapping" id="CBSAccountMapping" action="" method="post">

                <br><br>
                <center>
                    <tr><td><label style=" font-family: Berlin Sans FB; font-weight:  normal;">Operation Selection :</label></td>
                    <td><select id="checkOption" name="checkOption" >
                            <option value="" disabled selected style="display:none;" > --Select-- </option>
                            <%--<option value="update" >Add/Update CBS Account</option>
                            <option value="remove" >Remove CBS Account</option> --%>
                            <option value="mappin" >PIN Code Mapping</option>
                            <option value="camap" >Current Account Mapping</option>
                            <option value="nremark" >Remark for Non-Existing Bank CIF</option>
                            <option value="eremark" >Remark for Existing Bank CIF</option>

                        </select></td></tr>
                    <br>
                    <br>
                    <br>
                    <table>
                        <tbody>
                            <tr id="head">
                                <td>Account Number<font color="red" >*</font>: </td>
                                <td><input type="text" name="accNo" id="accNo" value="" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                                <td><input type="button" value="Search" onclick="javascript:popup_Acc(500,300,$('#accNo').val(),$('#checkOption').val());"/></td>
                            </tr>
                            <tr></tr>
                            <tr id="cbs" >
                              <td style="text-align: right">CBS Account: </td>
                              <td><input type="text"  maxlength="13" name="cbsAccount" id="cbsAccount" placeholder="Enter number only" onclick="number();" /></td>
                           </tr>
                           <tr></tr>
                            <tr id="curr" >                                
                              <td style="text-align: right">Current Account<font color="red" >*</font>: </td>
                              <td><input type="text"  maxlength="13" name="currAccount" id="currAccount" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57'onclick="curAcc();" /></td>
                           </tr>
                            <tr id="uppin" >                                
                              <td style="text-align: right">Enter PIN Code<font color="red" >*</font>: </td>
                              <td><input type="text"  maxlength="6" name="PIN" id="PIN" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                           </tr>
                           <tr><tr><tr>
                        </tbody>

                    </table>
                    <br>
                    <input type="button" value="Submit" id="Submit" onclick="submitform();" />
                    <input type="button" value="Reset" id="Reset" onclick="ShowParent();" />

                    <%--<input type="hidden" value="" id="intCat" name="intCat" />--%>
                </center>
            </form>
        </fieldset>
    </body>
</html>
<% 	} catch (Exception e) {
                
            }
%>