<%--
    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.AssetRegisterBean"%>
<%@page import="java.util.ArrayList"%>
<%@page import="LoginDb.DbHandler"%>
<% try {
%>

<html>

    <head>
        <title>Asset Register</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_type, asset_subtype) {
                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 = "assetRegister.jsp";
                var lovKey = "assetDetails"
                popWin = open('${pageContext.request.contextPath}/CommonSearchInformation_ASSET_LOV.jsp?asset_type=' + asset_type + '&asset_subtype=' + asset_subtype + '&screenName=' + screenName + '&lovKey=' + lovKey, 'assetDetails', attr);
                popWin.focus();

            }
            function submitform(assetregister)
            {

                if (assetregister.asset_type.value == "" )
                {
                    alert("Enter Asset Type details.");
                    assetregister.asset_type.focus();
                    return false;
                }
                if (assetregister.asset_subtype.value == "")
                {
                    alert("Enter Asset Sub-Type details.");
                    assetregister.asset_subtype.focus();
                    return false;
                }

                document.forms[0].action = '/PacsApplication/AssetRegisterServlet';
                document.assetregister.submit();
            }

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

            // to restrict going back 
            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 alpdsStockRegisterBeanApendObj = request.getAttribute("alAssetRegisterBean");
                    Object oAssetRegisterBeanObj = request.getAttribute("oAssetRegisterBean");

                    AssetRegisterBean oAssetRegisterBeanApend = new AssetRegisterBean();
                    if (oAssetRegisterBeanObj != null) {
                        oAssetRegisterBeanApend = (AssetRegisterBean) request.getAttribute("oAssetRegisterBean");
                    }

                    ArrayList<AssetRegisterBean> alAssetRegisterBeanApend = new ArrayList<AssetRegisterBean>();
                    if (alpdsStockRegisterBeanApendObj != null) {
                        alAssetRegisterBeanApend = (ArrayList<AssetRegisterBean>) request.getAttribute("alAssetRegisterBean");
                    }
        %>

        <%
                    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 Register</legend>

            <form id="assetregister" name="assetregister" method="post" action="">

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

                <center>
                    <table>
                        <tbody>
                            <tr>
                                <td>Asset Type<font color="red" >*</font>: </td>
                                <td><input type="text" name="asset_type" id="asset_type" readonly="true" style="text-align:right;" value="<%=blankNull(oAssetRegisterBeanApend.getAsset_type())%>"/><input type="button"  value="Search" onclick="javascript:popup_asset(220, 180, document.assetregister.asset_type.value, document.assetregister.asset_subtype.value);" /></td>
                            </tr>
                            <tr>
                                <td>Asset Sub-Type<font color="red" >*</font>: </td>
                                <td> <input type="text" name="asset_subtype" id="asset_subtype" readonly="true" style="text-align:right;" value="<%=blankNull(oAssetRegisterBeanApend.getAsset_subtypoe())%>"/><input type="button"  value="Search" onclick="javascript:popup_asset(220, 180, document.assetregister.asset_type.value, document.assetregister.asset_subtype.value)" /></td>
                            </tr>

                        </tbody>
                    </table>
                    <br><br>
                    <input type="hidden" name="asset_mst_id" id="asset_mst_id" value="<%=blankNull(oAssetRegisterBeanApend.getAsset_mst_id())%>"/>
                    <input type="button" value="Submit" id="Submit" onclick="javascript:submitform(assetregister)"/>
                    <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">
                                <%
                                    oAssetRegisterBeanApend = null;

                                    int i;
                                    for (i = 0; i < alAssetRegisterBeanApend.size(); i++) {
                                        oAssetRegisterBeanApend = alAssetRegisterBeanApend.get(i);
                                %>
                                <tr>
                                    <td><input readonly="true" type="text" name="asset_id<%=i%>" id="asset_id<%=i%>" value="<%=blankNull(oAssetRegisterBeanApend.getAsset_id())%>" /></td>
                                    <td><input readonly="true" type="text" name="description<%=i%>" id="description<%=i%>" value="<%=blankNull(oAssetRegisterBeanApend.getDescription())%>" /></td>
                                    <td><input readonly="true"  type="text" name="int_value<%=i%>" id="int_value<%=i%>" value="<%=blankNull(oAssetRegisterBeanApend.getInt_value())%>" /></td>
                                    <td><input readonly="true"  type="text" name="mode_of_aqr<%=i%>" id="mode_of_aqr<%=i%>" value="<%=blankNull(oAssetRegisterBeanApend.getMode_of_aqr())%>" /></td>
                                    <td><input readonly="true" style="text-align:center;" type="text" name="purchase_date<%=i%>" id="purchase_date<%=i%>" value="<%=blankNull(oAssetRegisterBeanApend.getPurchase_date())%>" /></td>
                                    <td><input readonly="true" style="text-align:center;" type="text" name="entry_date<%=i%>" id="entry_date<%=i%>" value="<%=blankNull(oAssetRegisterBeanApend.getEntry_date())%>" /></td>
                                    <td><input readonly="true" type="text" name="glcode<%=i%>" id="glcode<%=i%>" value="<%=blankNull(oAssetRegisterBeanApend.getGlcode())%>" /></td>
                                    <td><input readonly="true"  type="text" name="depRate<%=i%>" id="depRate<%=i%>" value="<%=blankNull(oAssetRegisterBeanApend.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 (oAssetRegisterBeanApend.getStatus().equals("A")) {%> selected <%}%>>Active</option>
                                            <option value="I" <%if (oAssetRegisterBeanApend.getStatus().equals("I")) {%> selected <%}%>>Inactive</option>
                                        </select>
                                    </td>

                                    <td style="display: none;"><input type="hidden" name="detail_id<%=i%>" id="detail_id<%=i%>" value="<%=blankNull(oAssetRegisterBeanApend.getAsset_id())%>"/></td>
                                </tr>
                                <%}%>
                            </tbody>
                        </table>

                    </div>
                </center>
                <%}%>


            </form>

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