<%--
    Document   : pds_stock_register
    Created on : May 5, 2016, 12:31:09 PM
    Author     : 590685
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="DataEntryBean.Asset_EnquiryBean"%>
<%@page import="java.util.ArrayList"%>
<%@page import="LoginDb.DbHandler"%>

<% try {
%>
<html>

    <head>
        <title>Asset 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>
        <script type="text/javascript">

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

            function popup_asset(width, height, asset_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 = "Asset_Enquiry.jsp";
                var lovKey = "Asset_EnquiryDetails"
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformation_ASSET_LOV.jsp?asset_id=' + asset_id + '&screenName=' + screenName + '&lovKey=' + lovKey, 'Asset_EnquiryDetails', attr);

                popWin.focus();

            }
            function submitform(asset_enquiry)
            {

                if (asset_enquiry.asset_id.value == "" )
                {
                    alert("Asset ID must be filled.");
                    asset_enquiry.asset_id.focus();
                    return false;
                }

                document.forms[0].action = '/PacsApplication/Asset_EnquiryServlet';
                document.asset_enquiry.submit();
            }
            // to restrict back button
            history.pushState(null, null, location.href);
            window.addEventListener('popstate', function(event) {
                history.pushState(null, null, location.href);
            });

        </script>
    </head>
    <body onload="noBack()">

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

        <%
                    Object alpdsStockAsset_EnquiryBeanApendObj = request.getAttribute("alAsset_EnquiryBean");
                    Object oAsset_EnquiryBeanObj = request.getAttribute("oAsset_EnquiryBean");

                    Asset_EnquiryBean oAsset_EnquiryBeanApend = new Asset_EnquiryBean();
                    if (oAsset_EnquiryBeanObj != null) {
                        oAsset_EnquiryBeanApend = (Asset_EnquiryBean) request.getAttribute("oAsset_EnquiryBean");
                    }

                    ArrayList<Asset_EnquiryBean> alAsset_EnquiryApend = new ArrayList<Asset_EnquiryBean>();
                    if (alpdsStockAsset_EnquiryBeanApendObj != null) {
                        alAsset_EnquiryApend = (ArrayList<Asset_EnquiryBean>) request.getAttribute("alAsset_EnquiryBean");
                    }
        %>

        <%
                    String displayFlag = "";
                    Object display = request.getAttribute("displayFlag");
                    if (display != null) {
                        displayFlag = display.toString();
                    }
        %>

        <jsp:include page="MenuHead_ASSET.jsp" flush="true" />
        <br>
        <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">Asset Enquiry</legend>

            <form id="asset_enquiry" name="asset_enquiry" method="post" action="Asset_EnquiryServlet">

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

                <center>
                    <table>
                        <tbody>
                            <tr>
                                <td>Asset ID<font color="red" >*</font>: </td>
                                <td> <input type="text" id="asset_id" name="asset_id" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' >&nbsp;&nbsp;&nbsp;
                                    <input type="button" name="assetidSearch" id="assetidSearch" value="Search" onclick="javascript:popup_asset(220, 180, document.asset_enquiry.asset_id.value);" /></td>
                            </tr>
                        </tbody>
                    </table>
                    <br><br>
                    <input type="hidden" name="asset_mst_id" id="asset_mst_id" value="<%=blankNull(oAsset_EnquiryBeanApend.getAsset_mst_id())%>"/>
                    <input type="button" value="Submit" id="Submit" onclick="javascript:submitform(asset_enquiry)"/>
                    <input type="button" value="Reset" id="Reset" onclick="ShowParent();" />
                </center>
                <br><br>

                <%if (displayFlag.equalsIgnoreCase("Y")) {%>
                <center>
                    <div id="displayDiv">

                        <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>Asset ID</b>  </td>
                                    <td ><b>Description</b></td>
                                    <td ><b>Purchase Value</b></td>
                                    <td ><b>Mode of Acquirement</b></td>
                                    <td ><b>Purchase Date</b></td>
                                    <td ><b>Entry Date</b></td>
                                    <td ><b>GL Code</b></td>
                                    <td ><b>Depreciation Rate</b></td>
                                    <td><b>Asset Status</b></td>
                                </tr>
                            </thead>
                            <tbody style="background-color: white; font-size: 15px">
                                <%
                                    oAsset_EnquiryBeanApend = null;

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

                                    <td ><input readonly="true" type="text" name="asset_id<%=i%>" id="asset_id<%=i%>" value="<%=blankNull(oAsset_EnquiryBeanApend.getAsset_id())%>" /></td>
                                    <td ><input readonly="true" type="text" name="description<%=i%>" id="description<%=i%>" value="<%=blankNull(oAsset_EnquiryBeanApend.getDescription())%>" /></td>
                                    <td><input readonly="true"  type="text" name="int_value<%=i%>" id="int_value<%=i%>" value="<%=blankNull(oAsset_EnquiryBeanApend.getInt_value())%>" /></td>
                                    <td><input readonly="true"  type="text" name="mode_of_aqr<%=i%>" id="mode_of_aqr<%=i%>" value="<%=blankNull(oAsset_EnquiryBeanApend.getMode_of_aqr())%>" /></td>
                                    <td><input readonly="true" style="text-align:center;" type="text" name="purchase_date<%=i%>" id="purchase_date<%=i%>" value="<%=blankNull(oAsset_EnquiryBeanApend.getPurchase_date())%>" /></td>
                                    <td><input readonly="true" style="text-align:center;" type="text" name="entry_date<%=i%>" id="entry_date<%=i%>" value="<%=blankNull(oAsset_EnquiryBeanApend.getEntry_date())%>" /></td>
                                    <td><input readonly="true" type="text" name="glcode<%=i%>" id="glcode<%=i%>" value="<%=blankNull(oAsset_EnquiryBeanApend.getGlcode())%>" /></td>
                                    <td><input readonly="true"  type="text" name="depRate<%=i%>" id="depRate<%=i%>" value="<%=blankNull(oAsset_EnquiryBeanApend.getDepRate())%>" /></td>
                                    <td><select disabled="true" name="status<%=i%>" id="status<%=i%>" >
                                            <option value="" disabled selected style="display:none;">--Select--</option>
                                            <option value="A" <%if (oAsset_EnquiryBeanApend.getStatus().equals("A")) {%> selected <%}%>>Active</option>
                                            <option value="I" <%if (oAsset_EnquiryBeanApend.getStatus().equals("I")) {%> selected <%}%>>Inactive</option>
                                        </select>
                                    </td>
                                </tr>
                            <input type="hidden" name="detail_id<%=i%>" id="detail_id<%=i%>" value="<%=blankNull(oAsset_EnquiryBeanApend.getAsset_id())%>" />

                            <%}%>
                            </tbody>
                        </table>
                    </div>
                </center>
                <%}%>

            </form>
            <script>
                function ShowParent()
                {
                    document.forms[0].action = "${pageContext.request.contextPath}/Asset_JSP/Asset_Enquiry.jsp";
                    document.forms[0].submit();
                }
            </script>
        </fieldset>
    </body>
</html>
<% 	} catch (Exception e) {
              
            }
%>

