<%--
    Document   : pdsRationingLedger
    Created on : Jul 15, 2016, 10:05:16 AM
    Author     : 1320035
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="DataEntryBean.RationingLedgerHeaderBean"%>
<%@page import="DataEntryBean.RationingLedgerDetailsBean"%>
<%@page import="java.lang.String"%>
<%@page import="LoginDb.DbHandler"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.util.ArrayList"%>
<% try {
%>
<html>
    <head>
        <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>
        <title>Ration Card Type Enrollment</title>

    </head>
    <body  onload="noBack()">
        <script src="${pageContext.request.contextPath}/jquery-ui-1.10.4.custom/development-bundle/jquery-1.10.2.js"></script>
        <script type="text/javascript">

            function ShowParent()
            {
                document.forms[0].action = "${pageContext.request.contextPath}/Pds_JSP/pdsRationingLedger.jsp";
                document.forms[0].submit();
            }

            function noBack()
            {
                window.history.forward();
            }


            function numbersonly(e){
                    var unicode=e.charCode? e.charCode : e.keyCode
                    if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
                            if (unicode<48||unicode>57) //if not a number
                                    return false ;//disable key press
                    }
            }





            //LOV
            function popup_CIF(width, height, cardNo,CustomerName) {
                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 = "pdsRationingLedger.jsp";
                var  lovKey="memberDetails"
                popWin = open('/PacsApplication/CommonSearchInformationPdsLOV.jsp?cardNo=' + cardNo + '&CustomerName=' + CustomerName +'&screenName=' + screenName+'&lovKey='+lovKey, 'memberDetails', attr);
                popWin.focus();

            }












        </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();
             }
        %>

        <%
             Object RationingLedgerHeaderBeanObj = request.getAttribute("oRationingLedgerHeaderBean");
             RationingLedgerHeaderBean ORationingLedgerHeaderBean = new RationingLedgerHeaderBean();
             if (RationingLedgerHeaderBeanObj != null) {
                 ORationingLedgerHeaderBean = (RationingLedgerHeaderBean) request.getAttribute("oRationingLedgerHeaderBean");

             }

        %>
        <%
             Object alRationingLedgerDetailsBeanApendObj = request.getAttribute("alRationingLedgerDetailsBeanApend");
             RationingLedgerDetailsBean rationingLedgerDetailsBeanObj = new RationingLedgerDetailsBean();
             ArrayList<RationingLedgerDetailsBean> alRationingLedgerDetailsBeanApend = new ArrayList<RationingLedgerDetailsBean>();
             if (alRationingLedgerDetailsBeanApendObj != null) {
                 alRationingLedgerDetailsBeanApend = (ArrayList<RationingLedgerDetailsBean>) request.getAttribute("alRationingLedgerDetailsBeanApend");
             }

        %>


        <jsp:include page="MenuHead_PDS.jsp" flush="true" />
        <br>
        <%!
            String blankNull(String s) {
                return (s == null) ? "" : s;
            }
        %>



        <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">RATIONING LEDGER</legend>
            <form name="rationingLedgerForm" method="post" action="RationingLedgerServlet" >

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


                <br>
                <br>

                <div id="displayDiv" >


                    <div align="center" id="header">
                        <table>

                            <tr>
                                <td>Card Holder Name: </td>
                                <td><input type="text" name="cardHolderName" size="30" id="cardHolderName" value="<%=blankNull(ORationingLedgerHeaderBean.getCardHolderName())%>"/><input type="button"  value="Search" onclick="javascript:popup_CIF(220, 180, document.rationingLedgerForm.cardNo.value,document.rationingLedgerForm.cardHolderName.value);" /></td>
                            </tr>
                            <tr>
                                <td>Card No: </td>
                                <td> <input type="text" size="30" name="cardNo" id="cardNo" value="<%=blankNull(ORationingLedgerHeaderBean.getCardNo())%>"/><input type="button"  value="Search" onclick="javascript:popup_CIF(220, 180, document.rationingLedgerForm.cardNo.value,document.rationingLedgerForm.cardHolderName.value);" /></td>
                            </tr>

                            <tr>
                                <td>Card Type:</td>
                                <td><input type="text" readonly name="cardType" id="cardType" value="<%=blankNull(ORationingLedgerHeaderBean.getCardType())%>"/></td>
                            </tr>
                            <tr>

                            <input type="hidden" name="customerId" id="customerId" value=""  />
                        </table>
                        <br>

                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="button"  value="Submit" onclick="javascript:rationing_ledger(rationingLedgerForm);" />
                        <input type="button" value="Reset" name="reset" onclick="ShowParent();" />

                        <br>
                    </div>
                    <br>
                    <br>
                    <%if (displayFlag.equalsIgnoreCase("Y")) {%>
                    <center>
                        <div id="details"   style="overflow:scroll; width: 900px;">

                            <table id="order-list" border="2" cellspacing="1" cellpadding="1" style="text-align: center ;overflow-y: scroll; font-size: 15px; width: 100%;">
                                <thead class="CSSTableGenerator">
                                    <tr>
                                        <td>
                                            Product Type Details

                                        </td>
                                        <td>
                                            Product Sub Type Details

                                        </td>

                                        <td>
                                            Eligibility Begin Date

                                        </td>
                                        <td>
                                            Eligibility End Date

                                        </td>
                                        <td>
                                            Expiry Date

                                        </td>
                                        <td>
                                            Base Quantity

                                        </td>

                                        <td>
                                            Availed Quantity

                                        </td>
                                        <td>
                                            Quantity Available

                                        </td>

                                    </tr>
                                </thead>

                                <tbody >


                                    <% for (int i = 0; i < alRationingLedgerDetailsBeanApend.size(); i++) {
                                            rationingLedgerDetailsBeanObj = alRationingLedgerDetailsBeanApend.get(i);
                                    %>
                                    <tr>


                                        <td style="text-align:center;"><input type="text" size="25" value="<%=blankNull(rationingLedgerDetailsBeanObj.getProductTypeDetails())%>" readonly="true"></td>
                                        <td style="text-align:center;"><input type="text" size="25" value="<%=blankNull(rationingLedgerDetailsBeanObj.getProductSubTypeDetails())%>" readonly="true"></td>
                                        <td style="text-align:center;"><input type="text" size="18" value="<%=blankNull(rationingLedgerDetailsBeanObj.getEligibilityBeginDate())%>" readonly="true"></td>
                                        <td style="text-align:center;"><input type="text" size="18" value="<%=blankNull(rationingLedgerDetailsBeanObj.getEligibilityEndDate())%>" readonly="true"></td>
                                        <td style="text-align:center;"><input type="text" size="15" value="<%=blankNull(rationingLedgerDetailsBeanObj.getExpiryDate())%>" readonly="true"></td>
                                        <td style="text-align:center;"><input type="text" size="15" value="<%=blankNull(rationingLedgerDetailsBeanObj.getBaseQuantity())%>" readonly="true"></td>

                                        <td style="text-align:center;"><input type="text" size="15" value="<%=blankNull(rationingLedgerDetailsBeanObj.getAvailedQuantity())%>" readonly="true"></td>
                                        <td style="text-align:center;"><input type="text" size="15" value="<%=blankNull(rationingLedgerDetailsBeanObj.getQuantityAvailable())%>" readonly="true"></td>


                                    </tr>
                                    <%}%>
                                </tbody>
                            </table>

                        </div>
                    </center>
                    <%}%>
                    <input type="hidden" name="handle_id" value="" />
                </div>



            </form>
        </fieldset>
        <script>
            function rationing_ledger(rationingLedgerForm)
            {

                if (checkDisplayDiv(rationingLedgerForm))
                {

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


                }

            }
            function checkDisplayDiv(rationingLedgerForm)
            {

                if (rationingLedgerForm.cardHolderName.value == ""||rationingLedgerForm.cardNo.value == "")
                {
                    alert("!! All fields must be filled !!");

                    return false;
                }

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