<%--
    Document   : CashReserveEnquiry
    Created on : Nov 9, 2016, 1:33:08 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="javax.servlet.http.HttpSession"%>
<%@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 Reserve 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>
    <body onload="noback()">
        <script type="text/javascript">
            function noBack()
            {
                window.history.forward();
            }
            
            // 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>
            <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 Reserve</legend>
                <%
                     int d2000, d500, d200, d100, d50, d20, d10, d5, d2, d1, d50p, d1p, totalAmt;
                     double d ;
                     d2000 = 0;
                     d500 = 0;
                     d200 = 0;
                     d100 = 0;
                     d50 = 0;
                     d20 = 0;
                     d10 = 0;
                     d5 = 0;
                     d2 = 0;
                     d1 = 0;
                     d50p = 0;
                     d1p = 0;
                     totalAmt = 0;
                     String pacsid = (String) session.getAttribute("pacsId");
                     String open_bal, close_bal, last_upd_dt;
                     open_bal = "";
                     close_bal = "";
                     last_upd_dt = "";
                     Connection connection = null;
                     ResultSet rs = null;
                     Statement statement = null;
                     connection = DbHandler.getDBConnection();
                     try {
                         statement = connection.createStatement();
                         rs = statement.executeQuery("select pacs_id,deno_2000,deno_500,deno_100,deno_50,deno_20,deno_10,deno_5,deno_2,deno_1,last_update_date,opening_bal,nvl(closing_bal,'Not Yet Closed'),DENO_50P,DENO_1P,deno_200 "
                                 + "from cash_reserve where pacs_id='" + pacsid + "'");
                         while (rs.next()) {
                             d2000 = Integer.parseInt(rs.getString(2));
                             d500 = Integer.parseInt(rs.getString(3));
                             d100 = Integer.parseInt(rs.getString(4));
                             d50 = Integer.parseInt(rs.getString(5));
                             d20 = Integer.parseInt(rs.getString(6));
                             d10 = Integer.parseInt(rs.getString(7));
                             d5 = Integer.parseInt(rs.getString(8));
                             d2 = Integer.parseInt(rs.getString(9));
                             d1 = Integer.parseInt(rs.getString(10));
                             last_upd_dt = rs.getString(11);
                             open_bal = rs.getString(12);
                             close_bal = rs.getString(13);
                             d50p = Integer.parseInt(rs.getString(14));
                             d1p = Integer.parseInt(rs.getString(15));
                             d200 = Integer.parseInt(rs.getString(16));
                         }
                        // 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.");
            }

            }
                     d = (2000 * d2000) + (500 * d500) + (200 * d200) + (100 * d100) + (50 * d50) + (20 * d20) + (10 * d10) + (5 * d5) + (2 * d2) + d1 + (0.50 * d50p)+ (0.01 * d1p);
                %>

                <center>
                <div> 
                  <label>Opening Balance: </label><input type="text" style="text-align: right" readonly id="openBal" name="openBal" value="<%=open_bal%>"/>
                   
                    <label style="margin-left:400px;">Closing Balance: </label><input type="text" style="text-align: right" readonly id="closeBal" name="closeBal" value="<%=close_bal%>"/>
                </div>
                </center>
                <center>
                    <table 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>
                            </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"style="text-align: center" readonly id="2000rs" name="2000rs" value="<%=d2000%>"/></td>
                            </tr>
                            <tr>
                                <td style="text-align: left">Rs 500</td>
                                <td><input type="text" style="text-align: right" readonly id="500rs" name="500rs" value="<%=d500%>"/></td>
                            </tr>
                            <tr>
                                <td style="text-align: left">Rs 200</td>
                                <td><input type="text" style="text-align: right" readonly id="200rs" name="200rs" value="<%=d200%>"/></td>
                            </tr>
                            <tr>
                                <td style="text-align: left">Rs 100</td>
                                <td><input type="text" style="text-align: right" readonly id="100rs" name="100rs" value="<%=d100%>"/></td>
                            </tr>
                            <tr>
                                <td style="text-align: left">Rs 50</td>
                                <td><input type="text" style="text-align: right" readonly id="50rs" name="50rs" value="<%=d50%>"/></td>
                            </tr>
                            <tr>
                                <td style="text-align: left">Rs 20</td>
                                <td><input type="text" style="text-align: right" readonly id="20rs" name="20rs" value="<%=d20%>"/></td>
                            </tr>
                            <tr>
                                <td style="text-align: left">Rs 10</td>
                                <td><input type="text" style="text-align: right" readonly id="10rs" name="10rs" value="<%=d10%>"/></td>
                            </tr>
                            <tr>
                                <td style="text-align: left">Rs 5</td>
                                <td><input type="text" style="text-align: right" readonly id="5rs" name="5rs" value="<%=d5%>"/></td>
                            </tr>
                            <tr>
                                <td style="text-align: left">Rs 2</td>
                                <td><input type="text" style="text-align: right" readonly id="2rs" name="2rs" value="<%=d2%>"/></td>
                            </tr>
                            <tr>
                                <td style="text-align: left">Rs 1</td>
                                <td><input type="text" style="text-align: right" readonly id="1rs" name="1rs" value="<%=d1%>"/></td>
                            </tr>
                            <tr>
                                <td style="text-align: left">50 Paisa</td>
                                <td><input type="text" style="text-align: right" readonly id="" name="" value="<%=d50p%>"/></td>
                            </tr>
                            <tr>
                                <td style="text-align: left">1 Paisa</td>
                                <td><input type="text" style="text-align: right" readonly id="" name="" value="<%=d1p%>"/></td>
                            </tr>
                        </tbody>
                    </table>
                    <p style="font-size:medium; font-weight: bold">
                        Reserve Cash Available: <input type="text" style="text-align: right; font-weight: bold" readonly id="totalcash" name="totalcash" value="<%=d%>"/>
                    </p>
                </center>
            </fieldset>

        </form>

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