<%--
    Document   : CashDrawerEnquiry
    Created on : Nov 9, 2016, 1:33:18 PM
    Author     : 986137
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@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 import="java.util.ArrayList"%>
<%@page import="java.util.UUID" %>
<%String uuid = UUID.randomUUID().toString();%>
<% try {
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head> 
        <title>Cash Drawer Enquiry</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>
    <style>
        table#denotable tbody tr td input{
            border: none;
        }
    </style>
    <body onload="noback()">
        <script type="text/javascript">
            function noBack()
            {
                window.history.forward();
            }

            function submitform()
            {
                document.teller.action = '/PacsApplication/CashDrawerEnquiryServlet';
                document.teller.submit();

            }

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

            }
            function ShowParent()
            {
                document.forms[0].action = "${pageContext.request.contextPath}/Deposit/CashDrawerEnquiry.jsp";
                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 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>

        <form name="teller" id="teller" method="post" action="">
            <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">Cash Drawer Enquiry</legend>
                <%
                     String pacsid = (String) session.getAttribute("pacsId");
                     String userRole = (String) session.getAttribute("userRole");

                     Connection connection = null;
                     ResultSet rs = null;
                     Statement statement = null;

                %>

                <%
                     String error_msg = "";
                     Object error = request.getAttribute("message");
                     if (error != null) {
                         error_msg = error.toString();
                     }
                %>
                <center>
                    <%if (!error_msg.equalsIgnoreCase("")) {%>
                    <center><div class="info" id="errorMessage"><center><%= error_msg%></center></div></center>
                    <% }%>

                    <br>
                    <b>Teller ID:</b>
                    <input type="text" readonly id="tellerid" name="tellerid" value="" style="text-align: right" />
                    <input type="button" value="Search" onclick="javascript:popup_pacstellers(220, 180, document.teller.tellerid.value);"/>
                    <br><br>
                    <input type="button" id="getdetails" name="getdetails" value="Get Details" onclick="javascript:submitform()"/>
                    <input type="button" value="Reset" id="Reset" onclick="ShowParent();" />
                </center>



                <%
                     String status = "Closed";
                     error = request.getAttribute("status");
                     if (error != null) {
                         status = error.toString();
                     }

                     int deno2000 = 0;
                     error = request.getAttribute("deno2000");
                     if (error != null) {
                         deno2000 = Integer.parseInt(error.toString());
                     }

                     int deno500 = 0;
                     error = request.getAttribute("deno500");
                     if (error != null) {
                         deno500 = Integer.parseInt(error.toString());
                     }

                     int deno200 = 0;
                     error = request.getAttribute("deno200");
                     if (error != null) {
                         deno200 = Integer.parseInt(error.toString());
                     }

                     int deno100 = 0;
                     error = request.getAttribute("deno100");
                     if (error != null) {
                         deno100 = Integer.parseInt(error.toString());
                     }

                     int deno50 = 0;
                     error = request.getAttribute("deno50");
                     if (error != null) {
                         deno50 = Integer.parseInt(error.toString());
                     }

                     int deno20 = 0;
                     error = request.getAttribute("deno20");
                     if (error != null) {
                         deno20 = Integer.parseInt(error.toString());
                     }

                     int deno10 = 0;
                     error = request.getAttribute("deno10");
                     if (error != null) {
                         deno10 = Integer.parseInt(error.toString());
                     }

                     int deno5 = 0;
                     error = request.getAttribute("deno5");
                     if (error != null) {
                         deno5 = Integer.parseInt(error.toString());
                     }

                     int deno2 = 0;
                     error = request.getAttribute("deno2");
                     if (error != null) {
                         deno2 = Integer.parseInt(error.toString());
                     }

                     int deno1 = 0;
                     error = request.getAttribute("deno1");
                     if (error != null) {
                         deno1 = Integer.parseInt(error.toString());
                     }

                     int deno50p = 0;
                     error = request.getAttribute("deno50p");
                     if (error != null) {
                         deno50p = Integer.parseInt(error.toString());
                     }
                     int deno1p = 0;
                     error = request.getAttribute("deno1p");
                     if (error != null) {
                         deno1p = Integer.parseInt(error.toString());
                     }


                     double totalAmt = 0;
                     totalAmt = (2000 * deno2000) + (500 * deno500) + (200 * deno200) + (100 * deno100) + (50 * deno50) + (20 * deno20) + (10 * deno10) + (5 * deno5) + (2 * deno2) + (deno1) + (0.50 * deno50p) + (deno1p * 0.01);

                     int odeno2000 = 0;
                     error = request.getAttribute("odeno2000");
                     if (error != null) {
                         odeno2000 = Integer.parseInt(error.toString());
                     }

                     int odeno500 = 0;
                     error = request.getAttribute("odeno500");
                     if (error != null) {
                         odeno500 = Integer.parseInt(error.toString());
                     }

                     int odeno200 = 0;
                     error = request.getAttribute("odeno200");
                     if (error != null) {
                         odeno200 = Integer.parseInt(error.toString());
                     }

                     int odeno100 = 0;
                     error = request.getAttribute("odeno100");
                     if (error != null) {
                         odeno100 = Integer.parseInt(error.toString());
                     }

                     int odeno50 = 0;
                     error = request.getAttribute("odeno50");
                     if (error != null) {
                         odeno50 = Integer.parseInt(error.toString());
                     }

                     int odeno20 = 0;
                     error = request.getAttribute("odeno20");
                     if (error != null) {
                         odeno20 = Integer.parseInt(error.toString());
                     }

                     int odeno10 = 0;
                     error = request.getAttribute("odeno10");
                     if (error != null) {
                         odeno10 = Integer.parseInt(error.toString());
                     }

                     int odeno5 = 0;
                     error = request.getAttribute("odeno5");
                     if (error != null) {
                         odeno5 = Integer.parseInt(error.toString());
                     }

                     int odeno2 = 0;
                     error = request.getAttribute("odeno2");
                     if (error != null) {
                         odeno2 = Integer.parseInt(error.toString());
                     }

                     int odeno1 = 0;
                     error = request.getAttribute("odeno1");
                     if (error != null) {
                         odeno1 = Integer.parseInt(error.toString());
                     }

                     int odeno50p = 0;
                     error = request.getAttribute("odeno50p");
                     if (error != null) {
                         odeno50p = Integer.parseInt(error.toString());
                     }

                     int odeno1p = 0;
                     error = request.getAttribute("odeno1p");
                     if (error != null) {
                         odeno1p = Integer.parseInt(error.toString());
                     }

                     int Hdeno2000 = 0;
                     int Hdeno500 = 0;
                     int Hdeno200 = 0;
                     int Hdeno100 = 0;
                     int Hdeno50 = 0;
                     int Hdeno20 = 0;
                     int Hdeno10 = 0;
                     int Hdeno5 = 0;
                     int Hdeno2 = 0;
                     int Hdeno1 = 0;
                     int Hdeno50p = 0;
                     int Hdeno1p = 0;


                     error = request.getAttribute("Hdeno2000");
                     if (error != null) {
                         Hdeno2000 = Integer.parseInt(error.toString());
                     }
                     error = request.getAttribute("Hdeno500");
                     if (error != null) {
                         Hdeno500 = Integer.parseInt(error.toString());
                     }
                     error = request.getAttribute("Hdeno200");
                     if (error != null) {
                         Hdeno200 = Integer.parseInt(error.toString());
                     }
                     error = request.getAttribute("Hdeno100");
                     if (error != null) {
                         Hdeno100 = Integer.parseInt(error.toString());
                     }
                     error = request.getAttribute("Hdeno50");
                     if (error != null) {
                         Hdeno50 = Integer.parseInt(error.toString());
                     }
                     error = request.getAttribute("Hdeno20");
                     if (error != null) {
                         Hdeno20 = Integer.parseInt(error.toString());
                     }
                     error = request.getAttribute("Hdeno10");
                     if (error != null) {
                         Hdeno10 = Integer.parseInt(error.toString());
                     }
                     error = request.getAttribute("Hdeno5");
                     if (error != null) {
                         Hdeno5 = Integer.parseInt(error.toString());
                     }
                     error = request.getAttribute("Hdeno2");
                     if (error != null) {
                         Hdeno2 = Integer.parseInt(error.toString());
                     }
                     error = request.getAttribute("Hdeno1");
                     if (error != null) {
                         Hdeno1 = Integer.parseInt(error.toString());
                     }
                     error = request.getAttribute("Hdeno50p");
                     if (error != null) {
                         Hdeno50p = Integer.parseInt(error.toString());
                     }
                     error = request.getAttribute("Hdeno1p");
                     if (error != null) {
                         Hdeno1p = Integer.parseInt(error.toString());
                     }

                %>



                <%
                     String tellerName = "";
                     error = request.getAttribute("tellerName");
                     if (error != null) {
                         tellerName = error.toString();
                     }

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

                <br>


                <%if (!tellerName.equalsIgnoreCase("")) {%>
                <center>
                    <table>
                        <thead>
                            <tr>
                                <td style="text-align: center">Teller Name</td>
                                <td style="text-align: center">Opening Balance</td>
                                <td style="text-align: center">Status</td>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td><input type="text" style="text-align: left" readonly value="<%= tellerName%>" /></td>
                                <td><input type="text" style="text-align: right" readonly value="<%=open_bal%>"/></td>
                                <td><input type="text" style="text-align: left" readonly value="<%=status%>"/></td>
                            </tr>
                        </tbody>
                    </table>
                </center>


                <br>
                <center>
                    <table id="denotable" name="denotable" border="2" width="auto" cellspacing="1" cellpadding="1" style="text-align: center ;overflow-y: scroll; font-size: 15px;">
                        <thead class="CSSTableGenerator">
                            <tr><td><b>Denomination</b></td>

                                <td><b>Available</b></td>
                                <td><b>Drawer Opening value</b></td>
                                <td><b>Cash on hold</b></td>

                            </tr>

                        </thead>

                        <tbody style="background-color: white; font-size: 15px">
                            <tr>
                                <td style="text-align: left" >Rs 2000</td>
                                <td><input type="text" style="text-align: right; border: none;" id="" name="" value="<%=deno2000%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=odeno2000%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=Hdeno2000%>" readonly /> </td>

                            </tr>
                            <tr>
                                <td style="text-align: left" >Rs 500</td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=deno500%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=odeno500%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=Hdeno500%>" readonly /> </td>
                            </tr>
                            <tr>
                                <td style="text-align: left" >Rs 200</td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=deno200%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=odeno200%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=Hdeno200%>" readonly /> </td>
                            </tr>
                            <tr>
                                <td style="text-align: left" >Rs 100</td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=deno100%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=odeno100%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=Hdeno100%>" readonly /> </td>
                            </tr>
                            <tr>
                                <td style="text-align: left" >Rs 50</td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=deno50%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=odeno50%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=Hdeno50%>" readonly /> </td>
                            </tr>
                            <tr>
                                <td style="text-align: left" >Rs 20</td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=deno20%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=odeno20%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=Hdeno20%>" readonly /> </td>
                            </tr>
                            <tr>
                                <td style="text-align: left" >Rs 10</td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=deno10%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=odeno10%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=Hdeno10%>" readonly /> </td>
                            </tr>
                            <tr>
                                <td style="text-align: left" >Rs 5</td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=deno5%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=odeno5%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=Hdeno5%>" readonly /> </td>
                            </tr>
                            <tr>
                                <td style="text-align: left" >Rs 2</td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=deno2%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=odeno2%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=Hdeno2%>" readonly /> </td>
                            </tr>
                            <tr>
                                <td style="text-align: left" >Rs 1</td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=deno1%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=odeno1%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=Hdeno1%>" readonly /> </td>
                            </tr>
                            <tr>
                                <td style="text-align: left" >50 Paisa</td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=deno50p%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=odeno50p%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=Hdeno50p%>" readonly /> </td>
                            </tr>
                            <tr>
                                <td style="text-align: left" >1 Paisa</td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=deno1p%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=odeno1p%>" readonly /> </td>
                                <td><input type="text" style="text-align: right" id="" name="" value="<%=Hdeno1p%>" readonly /> </td>
                            </tr>
                        </tbody>

                    </table>
                    <p style="font-size:medium; font-weight: bold">
                        Total Cash Available: <input type="text" style="text-align: right; font-weight: bold" readonly id="totalcash" name="totalcash" value="<%=totalAmt%>"/>
                    </p>




                </center>
                <% }%>





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