<%-- 
    Document   : AssignToCashDrawer
    Created on : Nov 9, 2016, 1:32:46 PM
    Author     : 986137
--%>

<%@page import="DataEntryBean.transactionOperationBean"%>
<%@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" %>
<%String uuid = UUID.randomUUID().toString();%>
<% try {
%>
<html>
    <head>
        <title>Assign Cash To Cash-Drawer</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>
        <script type="text/javascript" src="/PacsApplication/js/angular.min.js"></script>
    </head>
    <style>
        table tbody.NoBorder tr td input[type=text]{
            border:none;
        }
    </style>
    <body  onload="noBack()">
        <script type="text/javascript">
            function noBack()
            {
                window.history.forward();
            }

            function popup_pacstellers(width, height, teller_id) {
                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 = "AssignToCashDrawer.jsp";
                var lovKey = "PopupTellers"
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationDepositLOV.jsp?teller_id=' + teller_id + '&screenName=' + screenName + '&lovKey=' + lovKey, 'PopupTellers', attr);
                popWin.focus();
            }
            // to restrict going back 
            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();
             }
        %>
        <%   String odeno2000 = "";
             String odeno500 = "";
             String odeno200 = "";
             String odeno100 = "";
             String odeno50 = "";
             String odeno20 = "";
             String odeno10 = "";
             String odeno5 = "";
             String odeno2 = "";
             String odeno1 = "";
             String odeno50P = "";
             String odeno1P = "";
             String pacsid = (String) session.getAttribute("pacsId");
             Connection connection = null;
             ResultSet rs = null;
             Statement statement = null;
             connection = DbHandler.getDBConnection();
             try {
                 statement = connection.createStatement();
                 rs = statement.executeQuery("select nvl(r.deno_2000,0),nvl(r.deno_500,0),nvl(r.deno_100,0),nvl(r.deno_50,0),nvl(r.deno_20,0),nvl(r.deno_10,0),nvl(r.deno_5,0),nvl(r.deno_2,0),nvl(r.deno_1,0),nvl(r.DENO_50P,0),nvl(r.DENO_1P,0),nvl(r.deno_200,0) from cash_reserve r where r.pacs_id = '" + pacsid + "' ");

                 while (rs.next()) {
                     odeno2000 = rs.getString(1);
                     odeno500 = rs.getString(2);
                     odeno100 = rs.getString(3);
                     odeno50 = rs.getString(4);
                     odeno20 = rs.getString(5);
                     odeno10 = rs.getString(6);
                     odeno5 = rs.getString(7);
                     odeno2 = rs.getString(8);
                     odeno1 = rs.getString(9);
                     odeno50P = rs.getString(10);
                     odeno1P = rs.getString(11);
                     odeno200 = rs.getString(12);

                 }
                // 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.");
            }

            }
        %>


         <%
             String ModuleName = new String();

             ModuleName = (String) session.getAttribute("moduleName");
        %>
        <% if (ModuleName.equalsIgnoreCase("KCC")) {%>
        <jsp:include page="/MenuHead.jsp" flush="true" />
        <%} else if (ModuleName.equalsIgnoreCase("Deposit")) {%>
        <jsp:include page="/Deposit/MenuHead_Deposit.jsp" flush="true" />
        <%} else if (ModuleName.equalsIgnoreCase("Loan")) {%>
        <jsp:include page="/Loan/MenuHead_Loan.jsp" flush="true" />
        <%}%>
        <br>
        <%!
            String blankNull(String s) {
                return (s == null) ? "" : s;
            }
        %>

        <%
             Object otransactionOperationBeanObj = request.getAttribute("otransactionOperationBeanObj");
             transactionOperationBean otransactionOperationBean = new transactionOperationBean();
             if (otransactionOperationBeanObj != null) {
                 otransactionOperationBean = (transactionOperationBean) request.getAttribute("otransactionOperationBeanObj");
                 session.setAttribute("otransactionOperationBeanObj", otransactionOperationBeanObj);
             }
        %>

        <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">Assign Cash To Cash-Drawer</legend>
            <form name="transactionForm" id="transactionForm" method="post" action="">


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

                    <div id="transaction" style="display:block;">

                        <label>Enter Teller ID: </label><input type="text" maxlength="6" name="teller_id" id="teller_id" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' />
                        <input type="button" name="" id="" value="Search" onclick="javascript:popup_pacstellers(220, 180, document.transactionForm.teller_id.value);"/>
                        <br><br>
                        <table border="2" width="auto" cellspacing="1" cellpadding="1" style="text-align: center ;overflow-y: scroll; font-size: 15px">

                            <thead class="CSSTableGenerator">
                                <tr>
                                    <td>Denominations</td>
                                    <td>Available</td>
                                    <td>To Be Transfered</td>
                                </tr>
                            </thead>
                            <tbody class="NoBorder">

                                <tr>
                                    <td style="background:white;padding-left: 5px;" align="left">Rs.2000 Note</td>
                                    <td><input type="text" readonly name="twothouAvail" id="twothouAvail" value="<%=odeno2000%>" class="avail" style="text-align:right;" /></td>
                                    <td><input type="text" name="twothouIN" id="twothouIN" class="tobTransfer" value="0" style="text-align:right;" /></td>
                                </tr>
                                <tr>
                                    <td style="background:white;padding-left: 5px;" align="left">Rs.500 Note</td>
                                    <td><input type="text" readonly name="fivehundredAvail" id="fivehundredAvail" value="<%=odeno500%>" class="avail" style="text-align:right;"/></td>
                                    <td><input type="text" name="fivehundredIN" id="fivehundredIN"  class="tobTransfer" value="0" style="text-align:right;"/></td>
                                </tr>
                                <tr>
                                    <td style="background:white;padding-left: 5px;" align="left">Rs.200 Note</td>
                                    <td><input type="text" readonly name="twohundredAvail" id="twohundredAvail" value="<%=odeno200%>" class="avail" style="text-align:right;"/></td>
                                    <td><input type="text" name="twohundredIN" id="twohundredIN"  class="tobTransfer" value="0" style="text-align:right;"/></td>
                                </tr>
                                <tr>
                                    <td style="background:white;padding-left: 5px;" align="left">Rs.100 Note</td>
                                    <td><input type="text" readonly name="hundredAvail" id="hundredAvail" value="<%=odeno100%>" class="avail" style="text-align:right;"/></td>
                                    <td><input type="text" name="hundredIN" id="hundredIN"  class="tobTransfer" value="0" style="text-align:right;"/></td>
                                </tr>
                                <tr>
                                    <td style="background:white;padding-left: 5px;" align="left">Rs.50 Note</td>
                                    <td><input type="text" readonly name="ponchasAvail" id="ponchasAvail" value="<%=odeno50%>" class="avail" style="text-align:right;"/></td>
                                    <td><input type="text" name="ponchasIN" id="ponchasIN"  class="tobTransfer" value="0" style="text-align:right;" /></td>
                                </tr>
                                <tr>
                                    <td style="background:white;padding-left: 5px;" align="left">Rs.20 Note</td>
                                    <td><input type="text" readonly name="twentyAvail" id="twentyAvail" value="<%=odeno20%>" class="avail" style="text-align:right;"/></td>
                                    <td><input type="text" name="twentyIN" id="twentyIN"  class="tobTransfer" value="0" style="text-align:right;"/></td>
                                </tr>
                                <tr>
                                    <td style="background:white;padding-left: 5px;" align="left">Rs.10 Note/Coin</td>
                                    <td><input type="text" readonly name="tenAvail" id="tenAvail" value="<%=odeno10%>" class="avail" style="text-align:right;"/></td>
                                    <td><input type="text" name="tenIN" id="tenIN"  class="tobTransfer" value="0" style="text-align:right;"/></td>
                                </tr>
                                <tr>
                                    <td style="background:white;padding-left: 5px;" align="left">Rs.5 Note/Coin</td>
                                    <td><input type="text" readonly name="fiveAvail" id="fiveAvail" value="<%=odeno5%>" class="avail" style="text-align:right;"/></td>
                                    <td><input type="text" name="fiveIN" id="fiveIN"  class="tobTransfer" value="0" style="text-align:right;"/></td>
                                </tr>
                                <tr>
                                    <td style="background:white;padding-left: 5px;" align="left">Rs.2 Note/Coin</td>
                                    <td><input type="text" readonly name="twoAvail" id="twoAvail" value="<%=odeno2%>" class="avail" style="text-align:right;"/></td>
                                    <td><input type="text" name="twoIN" id="twoIN" class="tobTransfer" value="0" style="text-align:right;"/></td>
                                </tr>
                                <tr>
                                    <td style="background:white;padding-left: 5px;" align="left">Rs.1 Coin</td>
                                    <td><input type="text" readonly name="oneAvail" id="oneAvail" value="<%=odeno1%>" class="avail" style="text-align:right;"/></td>
                                    <td><input type="text" name="oneIN" id="oneIN"  class="tobTransfer" value="0" style="text-align:right;"/></td>
                                </tr>
                                <tr>
                                    <td style="background:white;padding-left: 5px;" align="left"><label>50 Paisa</label></td>
                                    <td><input type="text" readonly name="fiftyPaisaAvail" id="fiftyPaisaAvail" class="avail" value="<%=odeno50P%>" style="text-align:right;" ></td>
                                    <td><input type="text" name="fiftyPaisaIN" id="fiftyPaisaIN" class="tobTransfer" value="0" style="text-align:right;"></td>

                                </tr>
                                <tr>
                                    <td style="background:white;padding-left: 5px;" align="left"><label>1 Paisa</label></td>
                                    <td><input type="text" readonly name="onePaisaAvail" id="onePaisaAvail" class="avail" value="<%=odeno1P%>" style="text-align:right;" ></td>
                                    <td><input type="text" name="onePaisaIN" id="onePaisaIN" class="tobTransfer" value="0" style="text-align:right;"></td>

                                </tr>
                                <tr>
                                    <td style="background:white;padding-left: 5px;font-weight: bold;" align="left" >Total Amount(INR)</td>
                                    <td><input type="text" readonly name="totalAvail" id="totalAvail" style="text-align:right;" /></td>
                                    <td><input type="text" readonly name="totalIN" id="totalIN"  value="0" style="text-align:right;" /></td>
                                </tr>


                            </tbody>
                        </table><br><br>

                        <center>
                            <input type="submit" value="Submit" name="submit" id="submit">
                            <input type="button" value="Reset" name="reset" id="reset" />
                        </center>
                    </div>
                </center>
            </form>
        </fieldset>
        <script>
            var first = $('#twothouAvail').val();
            var second = $('#fivehundredAvail').val();
            var third = $('#hundredAvail').val();
            var fourth = $('#ponchasAvail').val();
            var fifth = $('#twentyAvail').val();
            var sixth = $('#tenAvail').val();
            var seventh = $('#fiveAvail').val();
            var eighth = $('#twoAvail').val();
            var ninth = $('#oneAvail').val();
            var eleventh = $('#fiftyPaisaAvail').val();
            var twelveth = $('#onePaisaAvail').val();
            var thirtinth = $('#twohundredAvail').val();

            var AvailsumOnLoad = 0;
            var DenoINsumOnLoad = 0;
           
            AvailsumOnLoad = parseInt($('#twothouAvail').val() * 2000) + parseInt($('#fivehundredAvail').val() * 500) + parseInt($('#twohundredAvail').val() * 200) + parseInt($('#hundredAvail').val() * 100)+ parseInt($('#ponchasAvail').val() * 50)+ parseInt($('#twentyAvail').val() * 20)+ parseInt($('#tenAvail').val() * 10)+ parseInt($('#fiveAvail').val() * 5)+ parseInt($('#twoAvail').val() * 2)+ parseInt($('#oneAvail').val() * 1 )+ parseFloat(parseInt($('#fiftyPaisaAvail').val()) * 0.50)+ parseFloat(parseInt($('#onePaisaAvail').val()) * 0.01);
            $("#totalAvail").val(AvailsumOnLoad);

            var totalDenoAvailable = $("#totalAvail").val();
            
            $(document).ready(function() {
                $('#transaction').find(':input.tobTransfer[type="text"]').val('0');
            });

            $('#transaction').on('keydown',':input.tobTransfer[type="text"]', function(event) {
                if (event.shiftKey == true) {
                    event.preventDefault();
                }
                if ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105)) {
                } else {
                    event.preventDefault();
                }
            });

            $('#transaction').on("keyup", ".tobTransfer", function() {
                var DenoINsumOnChange = 0;
                DenoINsumOnChange = parseInt($('#twothouIN').val()) * 2000 + parseInt($('#fivehundredIN').val()) * 500 + parseInt($('#twohundredIN').val()) * 200 + parseInt($('#hundredIN').val()) * 100 + parseInt($('#ponchasIN').val()) * 50 + parseInt($('#twentyIN').val()) * 20 + parseInt($('#tenIN').val()) * 10 + parseInt($('#fiveIN').val()) * 5 + parseInt($('#twoIN').val()) * 2 + parseInt($('#oneIN').val())+ parseFloat(parseInt($('#fiftyPaisaIN').val()) * 0.50)+ parseFloat(parseInt($('#onePaisaIN').val()) * 0.01);
                $("#totalIN").val(DenoINsumOnChange);
            });

            //for 1  paisa starts
            $('#transaction').on("keyup", "#onePaisaIN", function() {
                if(parseInt($("#onePaisaAvail").val())<= 0)
                {
                    alert("Insufficiernt 1 Paisa");
                    $( "#reset" ).click();
                }
                else{
                    $('#onePaisaAvail').val(parseInt(twelveth) - parseInt($('#onePaisaIN').val()));
                    $("#totalAvail").val(parseInt($('#twothouAvail').val()) * 2000 + parseInt($('#fivehundredAvail').val()) * 500 + parseInt($('#twohundredAvail').val()) * 200 + parseInt($('#hundredAvail').val()) * 100 + parseInt($('#ponchasAvail').val()) * 50 + parseInt($('#twentyAvail').val()) * 20 + parseInt($('#tenAvail').val()) * 10 + parseInt($('#fiveAvail').val()) * 5 + parseInt($('#twoAvail').val()) * 2 + parseInt($('#oneAvail').val()) * 1 + parseFloat(parseInt($('#fiftyPaisaAvail').val()) * 0.50)+ parseFloat(parseInt($('#onePaisaAvail').val()) * 0.01));
                }
            });
            $('#transaction').on("change", "#onePaisaIN", function() {
                if(parseInt(twelveth)< parseInt($('#onePaisaIN').val())){
                    alert("Insufficient Denomination !!!");
                    $('#reset').click();
                }
            });
            //for 50 Paisa starts
            $('#transaction').on("keyup", "#fiftyPaisaIN", function() {
                if(parseInt($("#fiftyPaisaAvail").val())<= 0)
                {
                    alert("Insufficiernt 50 Paisa");
                    $( "#reset" ).click();
                }
                else{
                    $('#fiftyPaisaAvail').val(parseInt(eleventh) - parseInt($('#fiftyPaisaIN').val()));
                    $("#totalAvail").val(parseInt($('#twothouAvail').val()) * 2000 + parseInt($('#fivehundredAvail').val()) * 500 + parseInt($('#twohundredAvail').val()) * 200 + parseInt($('#hundredAvail').val()) * 100 + parseInt($('#ponchasAvail').val()) * 50 + parseInt($('#twentyAvail').val()) * 20 + parseInt($('#tenAvail').val()) * 10 + parseInt($('#fiveAvail').val()) * 5 + parseInt($('#twoAvail').val()) * 2 + parseInt($('#oneAvail').val()) * 1 + parseFloat(parseInt($('#fiftyPaisaAvail').val()) * 0.50)+ parseFloat(parseInt($('#onePaisaAvail').val()) * 0.01));
                }
            });
            $('#transaction').on("change", "#fiftyPaisaIN", function() {
                if(parseInt(eleventh)< parseInt($('#fiftyPaisaIN').val())){
                    alert("Insufficient Denomination !!!");
                    $('#reset').click();
                }
            });
            //for Rs 1 starts
            $('#transaction').on("keyup", "#oneIN", function() {
                if(parseInt($("#oneAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.1 Notes");
                    $( "#reset" ).click();
                }
                else{
                    $('#oneAvail').val(parseInt(ninth) - parseInt($('#oneIN').val()));
                    $("#totalAvail").val(parseInt($('#twothouAvail').val()) * 2000 + parseInt($('#fivehundredAvail').val()) * 500 + parseInt($('#twohundredAvail').val()) * 200 + parseInt($('#hundredAvail').val()) * 100 + parseInt($('#ponchasAvail').val()) * 50 + parseInt($('#twentyAvail').val()) * 20 + parseInt($('#tenAvail').val()) * 10 + parseInt($('#fiveAvail').val()) * 5 + parseInt($('#twoAvail').val()) * 2 + parseInt($('#oneAvail').val()) * 1 + parseFloat(parseInt($('#fiftyPaisaAvail').val()) * 0.50)+ parseFloat(parseInt($('#onePaisaAvail').val()) * 0.01));
                }
            });
            $('#transaction').on("change", "#oneIN", function() {
                if(parseInt(ninth)< parseInt($('#oneIN').val())){
                    alert("Insufficient Denomination !!!");
                    $('#reset').click();
                }
            });

            //for Rs 2 starts
            $('#transaction').on("keyup", "#twoIN", function() {
                if(parseInt($("#twoAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.2 Notes");
                    $( "#reset" ).click();
                }
                else{
                    $('#twoAvail').val(parseInt(eighth) - parseInt($('#twoIN').val()));
                    $("#totalAvail").val(parseInt($('#twothouAvail').val()) * 2000 + parseInt($('#fivehundredAvail').val()) * 500 + parseInt($('#twohundredAvail').val()) * 200 + parseInt($('#hundredAvail').val()) * 100 + parseInt($('#ponchasAvail').val()) * 50 + parseInt($('#twentyAvail').val()) * 20 + parseInt($('#tenAvail').val()) * 10 + parseInt($('#fiveAvail').val()) * 5 + parseInt($('#twoAvail').val()) * 2 + parseInt($('#oneAvail').val()) * 1 + parseFloat(parseInt($('#fiftyPaisaAvail').val()) * 0.50)+ parseFloat(parseInt($('#onePaisaAvail').val()) * 0.01));
                }
            });
            $('#transaction').on("change", "#twoIN", function() {
                if(parseInt(eighth)< parseInt($('#twoIN').val())){
                    alert("Insufficient Denomination !!!");
                    $('#reset').click();
                }
            });

            //for Rs 5 starts
            $('#transaction').on("keyup", "#fiveIN", function() {
                if(parseInt($("#fiveAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.5 Notes");
                    $( "#reset" ).click();
                }
                else{
                    $('#fiveAvail').val(parseInt(seventh) - parseInt($('#fiveIN').val()));
                    $("#totalAvail").val(parseInt($('#twothouAvail').val()) * 2000 + parseInt($('#fivehundredAvail').val()) * 500 + parseInt($('#twohundredAvail').val()) * 200 + parseInt($('#hundredAvail').val()) * 100 + parseInt($('#ponchasAvail').val()) * 50 + parseInt($('#twentyAvail').val()) * 20 + parseInt($('#tenAvail').val()) * 10 + parseInt($('#fiveAvail').val()) * 5 + parseInt($('#twoAvail').val()) * 2 + parseInt($('#oneAvail').val()) * 1 + parseFloat(parseInt($('#fiftyPaisaAvail').val()) * 0.50)+ parseFloat(parseInt($('#onePaisaAvail').val()) * 0.01));
                }
            });
            $('#transaction').on("change", "#fiveIN", function() {
                if(parseInt(seventh)< parseInt($('#fiveIN').val())){
                    alert("Insufficient Denomination !!!");
                    $('#reset').click();
                }
            });

            //for Rs 10 starts
            $('#transaction').on("keyup", "#tenIN", function() {
                if(parseInt($("#tenAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.10 Notes");
                    $( "#reset" ).click();
                }
                else{
                    $('#tenAvail').val(parseInt(sixth) - parseInt($('#tenIN').val()));
                    $("#totalAvail").val(parseInt($('#twothouAvail').val()) * 2000 + parseInt($('#fivehundredAvail').val()) * 500 + parseInt($('#twohundredAvail').val()) * 200 + parseInt($('#hundredAvail').val()) * 100 + parseInt($('#ponchasAvail').val()) * 50 + parseInt($('#twentyAvail').val()) * 20 + parseInt($('#tenAvail').val()) * 10 + parseInt($('#fiveAvail').val()) * 5 + parseInt($('#twoAvail').val()) * 2 + parseInt($('#oneAvail').val()) * 1 + parseFloat(parseInt($('#fiftyPaisaAvail').val()) * 0.50)+ parseFloat(parseInt($('#onePaisaAvail').val()) * 0.01));
                }
            });
            $('#transaction').on("change", "#tenIN", function() {
                if(parseInt(sixth)< parseInt($('#tenIN').val())){
                    alert("Insufficient Denomination !!!");
                    $('#reset').click();
                }
            });

            //for Rs 20 starts
            $('#transaction').on("keyup", "#twentyIN", function() {
                if(parseInt($("#twentyAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.20 Notes");
                    $( "#reset" ).click();
                }
                else{
                    $('#twentyAvail').val(parseInt(fifth) - parseInt($('#twentyIN').val()));
                    $("#totalAvail").val(parseInt($('#twothouAvail').val()) * 2000 + parseInt($('#fivehundredAvail').val()) * 500 + parseInt($('#twohundredAvail').val()) * 200 + parseInt($('#hundredAvail').val()) * 100 + parseInt($('#ponchasAvail').val()) * 50 + parseInt($('#twentyAvail').val()) * 20 + parseInt($('#tenAvail').val()) * 10 + parseInt($('#fiveAvail').val()) * 5 + parseInt($('#twoAvail').val()) * 2 + parseInt($('#oneAvail').val()) * 1 + parseFloat(parseInt($('#fiftyPaisaAvail').val()) * 0.50)+ parseFloat(parseInt($('#onePaisaAvail').val()) * 0.01));
                }
            });
            $('#transaction').on("change", "#twentyIN", function() {
                if(parseInt(fifth)< parseInt($('#twentyIN').val())){
                    alert("Insufficient Denomination !!!");
                    $('#reset').click();
                }
            });

            //for Rs 50 starts
            $('#transaction').on("keyup", "#ponchasIN", function() {
                if(parseInt($("#ponchasAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.50 Notes");
                    $( "#reset" ).click();
                }
                else{
                    $('#ponchasAvail').val(parseInt(fourth) - parseInt($('#ponchasIN').val()));
                    $("#totalAvail").val(parseInt($('#twothouAvail').val()) * 2000 + parseInt($('#fivehundredAvail').val()) * 500 + parseInt($('#twohundredAvail').val()) * 200 + parseInt($('#hundredAvail').val()) * 100 + parseInt($('#ponchasAvail').val()) * 50 + parseInt($('#twentyAvail').val()) * 20 + parseInt($('#tenAvail').val()) * 10 + parseInt($('#fiveAvail').val()) * 5 + parseInt($('#twoAvail').val()) * 2 + parseInt($('#oneAvail').val()) * 1 + parseFloat(parseInt($('#fiftyPaisaAvail').val()) * 0.50)+ parseFloat(parseInt($('#onePaisaAvail').val()) * 0.01));
                }
            });
            $('#transaction').on("change", "#ponchasIN", function() {
                if(parseInt(fourth)< parseInt($('#ponchasIN').val())){
                    alert("Insufficient Denomination !!!");
                    $('#reset').click();
                }
            });

            //for Rs 100 starts
            $('#transaction').on("keyup", "#hundredIN", function() {
                if(parseInt($("#hundredAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.100 Notes");
                    $( "#reset" ).click();
                }
                else{
                    $('#hundredAvail').val(parseInt(third) - parseInt($('#hundredIN').val()));
                    $("#totalAvail").val(parseInt($('#twothouAvail').val()) * 2000 + parseInt($('#fivehundredAvail').val()) * 500 + parseInt($('#twohundredAvail').val()) * 200 + parseInt($('#hundredAvail').val()) * 100 + parseInt($('#ponchasAvail').val()) * 50 + parseInt($('#twentyAvail').val()) * 20 + parseInt($('#tenAvail').val()) * 10 + parseInt($('#fiveAvail').val()) * 5 + parseInt($('#twoAvail').val()) * 2 + parseInt($('#oneAvail').val()) * 1 + parseFloat(parseInt($('#fiftyPaisaAvail').val()) * 0.50)+ parseFloat(parseInt($('#onePaisaAvail').val()) * 0.01));
                }
            });
            $('#transaction').on("change", "#hundredIN", function() {
                if(parseInt(third)< parseInt($('#hundredIN').val())){
                    alert("Insufficient Denomination !!!");
                    $('#reset').click();
                }
            });

           //for Rs 200 starts
            $('#transaction').on("keyup", "#twohundredIN", function() {
                if(parseInt($("#twohundredAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.200 Notes");
                    $( "#reset" ).click();
                }
                else{
                    $('#twohundredAvail').val(parseInt(thirtinth) - parseInt($('#twohundredIN').val()));
                    $("#totalAvail").val(parseInt($('#twothouAvail').val()) * 2000 + parseInt($('#fivehundredAvail').val()) * 500 + parseInt($('#twohundredAvail').val()) * 200 + parseInt($('#hundredAvail').val()) * 100 + parseInt($('#ponchasAvail').val()) * 50 + parseInt($('#twentyAvail').val()) * 20 + parseInt($('#tenAvail').val()) * 10 + parseInt($('#fiveAvail').val()) * 5 + parseInt($('#twoAvail').val()) * 2 + parseInt($('#oneAvail').val()) * 1 + parseFloat(parseInt($('#fiftyPaisaAvail').val()) * 0.50)+ parseFloat(parseInt($('#onePaisaAvail').val()) * 0.01));
                }
            });
            $('#transaction').on("change", "#twohundredIN", function() {
                if(parseInt(thirtinth)< parseInt($('#twohundredIN').val())){
                    alert("Insufficient Denomination !!!");
                    $('#reset').click();
                }
            });

            //for Rs 500 starts
            $('#transaction').on("keyup", "#fivehundredIN", function() {
                if(parseInt($("#fivehundredAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.500 Notes");
                    $( "#reset" ).click();
                }
                else{
                    $('#fivehundredAvail').val(parseInt(second) - parseInt($('#fivehundredIN').val()));
                    $("#totalAvail").val(parseInt($('#twothouAvail').val()) * 2000 + parseInt($('#fivehundredAvail').val()) * 500 + parseInt($('#twohundredAvail').val()) * 200 + parseInt($('#hundredAvail').val()) * 100 + parseInt($('#ponchasAvail').val()) * 50 + parseInt($('#twentyAvail').val()) * 20 + parseInt($('#tenAvail').val()) * 10 + parseInt($('#fiveAvail').val()) * 5 + parseInt($('#twoAvail').val()) * 2 + parseInt($('#oneAvail').val()) * 1 + parseFloat(parseInt($('#fiftyPaisaAvail').val()) * 0.50)+ parseFloat(parseInt($('#onePaisaAvail').val()) * 0.01));
                }
            });
            $('#transaction').on("change", "#fivehundredIN", function() {
                if(parseInt(second)< parseInt($('#fivehundredIN').val())){
                    alert("Insufficient Denomination !!!");
                    $('#reset').click();
                }
            });

            //for Rs 2000 starts
            $('#transaction').on("keyup", "#twothouIN", function() {
                if(parseInt($("#twothouAvail").val())<= 0)
                {
                    alert("Insufficiernt Rs.2000 Notes");
                    $( "#reset" ).click();
                }
                else{
                    $('#twothouAvail').val(parseInt(first) - parseInt($('#twothouIN').val()));
                    $("#totalAvail").val(parseInt($('#twothouAvail').val()) * 2000 + parseInt($('#fivehundredAvail').val()) * 500 + parseInt($('#twohundredAvail').val()) * 200 + parseInt($('#hundredAvail').val()) * 100 + parseInt($('#ponchasAvail').val()) * 50 + parseInt($('#twentyAvail').val()) * 20 + parseInt($('#tenAvail').val()) * 10 + parseInt($('#fiveAvail').val()) * 5 + parseInt($('#twoAvail').val()) * 2 + parseInt($('#oneAvail').val()) * 1 + parseFloat(parseInt($('#fiftyPaisaAvail').val()) * 0.50)+ parseFloat(parseInt($('#onePaisaAvail').val()) * 0.01));
                }
            });
            $('#transaction').on("change", "#twothouIN", function() {
                if(parseInt(first)< parseInt($('#twothouIN').val())){
                    alert("Insufficient Denomination !!!");
                    $('#reset').click();
                }
            });


            $( "#reset" ).click(function() {
                $('#teller_id').val('');
                $('#transaction').find(':input.tobTransfer[type="text"]').val('0');
                $("#totalIN").val('0');
                $('#twothouAvail').val(first);
                $('#fivehundredAvail').val(second);
                $('#hundredAvail').val(third);
                $('#ponchasAvail').val(fourth);
                $('#twentyAvail').val(fifth);
                $('#tenAvail').val(sixth);
                $('#fiveAvail').val(seventh);
                $('#twoAvail').val(eighth);
                $('#oneAvail').val(ninth);
                $('#fiftyPaisaAvail').val(eleventh);
                $('#onePaisaAvail').val(twelveth);
                $('#twohundredAvail').val(thirtinth);

                $("#totalAvail").val(totalDenoAvailable);
            });

            $( "#transactionForm" ).submit(function( event ) {
                var bad=0;
                $(':input.tobTransfer[type="text"]').each(function(){
                    if( $.trim($(this).val()) == "0" ) bad++;
                });
                
                if ($.trim($('#teller_id').val()) == "" || bad>11 )
                {
                    alert("!! Please enter Teller ID & Denominations to proceed further !!");
                    event.preventDefault();
                }else{                    
                    document.transactionForm.action = '/PacsApplication/AssignToCashDrawerServlet';
                }
                
            });

            

        </script>
    </body>
</html>
<% 	} catch (Exception e) {
               
            }
%>

