<%--
    Document   : assetentry
    Created on : Jun 24, 2016, 2:34:00 PM
    Author     : Tcs Helpdesk10
--%>

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

<html>

    <head>
        <title>Asset Entry</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 submitform(assetentry)
            {
                if (checkDiv(assetentry))
                {
                    document.forms[0].handle_id.value = "Create";
                    document.forms[0].action='/PacsApplication/AssetEntryServlet';
                    document.forms[0].submit();
                }
            }
            function amendform(assetentry)
            { 
                if (checkDivAmend(assetentry))
                {
                document.forms[0].handle_id.value = "Amend";
                document.forms[0].action = '/PacsApplication/AssetEntryServlet';
                document.forms[0].submit();
                }
            }
            function getDetails(assetentry)
            {
                document.forms[0].handle_id.value = "getDetails";
                document.forms[0].action = '/PacsApplication/AssetEntryServlet';
                document.forms[0].submit();
            }
            function checkDiv(assetentry)
            {
                var counter = document.forms[0].rowCounter.value; 
                
                for (var i = 1; i <= counter; i++) {
                    try{
                        var asset_type = document.getElementById("asset_type" + i).value;
                        var asset_subtype = document.getElementById("asset_subtype" + i).value;
                        var asset_mst_id = document.getElementById("asset_mst_id" + i).value;
                        var asset_id = document.getElementById("asset_id" + i).value;
                        var description = document.getElementById("description" + i).value;
                        var curr_val = document.getElementById("curr_val" + i).value;
                        var purchaseDate = document.getElementById("purchaseDate" + i).value;
                        var glcode = document.getElementById("glcode" + i).value;
                        var depRate = document.getElementById("depRate" + i).value;
                        
                        if (asset_type == "" || asset_subtype == "" || asset_mst_id == "" || asset_id == "" || description == "" 
                                || curr_val == "" || purchaseDate == "" || glcode == "" || depRate == "") 
                        {
                            alert("Please enter all details.");
                            return false;
                        }                                                  
                    }
                    catch(e){}
                }                
                return true;
            } 
            function checkDivAmend(assetentry)
            {
                var counter2 = document.forms[0].rowCounter2.value; 
                
                for (var i = 2; i < counter2; i++) {
                    try{
                        var asset_type = document.getElementById("asset_type" + i).value;
                        var asset_subtype = document.getElementById("asset_subtype" + i).value;
                        var asset_mst_id = document.getElementById("asset_mst_id" + i).value;
                        var asset_id = document.getElementById("asset_id" + i).value;
                        var description = document.getElementById("description" + i).value;
                        var curr_val = document.getElementById("curr_val" + i).value;
                        var purchaseDate = document.getElementById("purchaseDate" + i).value;
                        var glcode = document.getElementById("glcode" + i).value;
                        var depRate = document.getElementById("depRate" + i).value;
                        
                        if (asset_type == "" || asset_subtype == "" || asset_mst_id == "" || asset_id == "" || description == "" 
                                || curr_val == "" || purchaseDate == "" || glcode == "" || depRate == "") 
                        {
                            alert("Please enter all details.");
                            return false;
                        }
                    }
                    catch(e){}
                }                
                return true;
            }
            function SearchGL(width, height, textIndex) 
            {
            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 glcode = document.getElementById("glcode"+textIndex).value;    
            var screenName = "assetEntry.jsp";
            var lovKey = "gl"
            popWin = open('${pageContext.request.contextPath}/CommonSearchInformation_ASSET_LOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&glcode=' + glcode + '&textIndex=' + textIndex, 'gl', attr);
            popWin.focus();
            }
            function checkop()
            {                
                if (document.getElementById("checkOption").value == "create")
                {
                    document.getElementById('create').style.display = 'block';
                    document.getElementById('forAmend').style.display = 'none';
                    document.getElementById('amend').style.display = 'none';
                }
                if (document.getElementById("checkOption").value == "amend")
                {
                    document.getElementById('create').style.display = 'none';
                    document.getElementById('forAmend').style.display = 'block';
                }
            }
            function calDepAmt(assetentry) 
            {
                var counter = document.forms[0].rowCounter.value;                
                for (var i = 1; i <= counter; i++) {    
                    var dart = document.getElementById("depRate" + i).value;
                    
                    var numStr = String(dart);
                    if(numStr.includes('.')){
                        var len =  numStr.split('.')[1].length;                                            
                        if (len>2) {
                            alert("Dep Rate is allowed upto two decimals.");
                            document.getElementById("depRate" + i).value = (parseFloat(dart)).toFixed(2);
                            return false;
                        }
                    }                    
                }
            }
            function calDepAmt2(assetentry) 
            {
                var counter2 = document.forms[0].rowCounter2.value;                
                for (var i = 2; i <= counter2; i++) {    
                    var dart = document.getElementById("depRate" + i).value;
                    
                    var numStr = String(dart);
                    if(numStr.includes('.')){
                        var len =  numStr.split('.')[1].length;                                            
                        if (len>2) {
                            alert("Dep Rate is allowed upto two decimals.");
                            document.getElementById("depRate" + i).value = (parseFloat(dart)).toFixed(2);
                            return false;
                        }
                    }                    
                }
            }
            
            // 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()">

        <%          int count = 1;
             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("alpdsStockRegisterBeanApend");
             ArrayList<pdsStockRegisterBean> alpdsStockRegisterBeanApend = new ArrayList<pdsStockRegisterBean>();
             if (alpdsStockRegisterBeanApendObj != null) {
                 alpdsStockRegisterBeanApend = (ArrayList<pdsStockRegisterBean>) request.getAttribute("alpdsStockRegisterBeanApend");
             }
        %>

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

                    AssetEntryBean oAssetEntryBean = new AssetEntryBean();
                    if (oAssetEntryBeanObj != null) {
                        oAssetEntryBean = (AssetEntryBean) request.getAttribute("oAssetEntryBean");
                    }

                    ArrayList<AssetEntryBean> alAssetEntryBean = new ArrayList<AssetEntryBean>();
                    if (alAssetEntryBeanObj != null) {
                        alAssetEntryBean = (ArrayList<AssetEntryBean>) request.getAttribute("arrAssetEntryBean");
                    }
        %>

        <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 Entry</legend>

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

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

                <center><label style=" font-family: Berlin Sans FB; font-weight:  normal;">Operation Selection:</label>
                    <select id="checkOption" onchange="checkop()" name="checkOption" >
                        <option value="" style="display:none;" >--Select--</option>                            
                            <option value="create" >Create</option>
                            <option value="amend" >Amend</option>
                    </select>                    
                </center>
                <br>
                <div id="create" style="display:none;">
                    <center>
                        <div style="overflow:scroll; width: 1300px">
                        <br><br>    
                        <table id="order-list" style="margin-left: 20px;" class="NumbersOnly"  border="2" cellspacing="1" cellpadding="1" style="text-align: center ;overflow-y: scroll; font-size: 15px; width: 100%;">
                            <thead  class="CSSTableGenerator" >
                                <tr border="2">
                                    <td></td>
                                    <td colspan="2">Asset Type</td>
                                    <td>Asset SubType</td>
                                    <td>Asset ID</td>
                                    <td>Description</td>
                                    <td>Current Valuation</td>
                                    <td>Mode of Acquirement</td>
                                    <td colspan="2">Purchase Date</td>
                                    <td colspan="2">GL Code</td>
                                    <td>Depreciation Rate</td>
                                    <td>Status</td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td><input type="checkbox" name="chckbox<%=count%>" id="chckbox<%=count%>" onclick="checkboxTrue(<%=count%>);" /></td>
                                    <td><input type="text" readonly name="asset_type<%=count%>" id="asset_type<%=count%>"/></td>
                                    <td><input type="button" name="SearchAsset<%=count%>" id="SearchAsset<%=count%>" value="Search"  onclick="SearchAsset(220,180,<%=count%>)" /></td>
                                    <td><input type="text" readonly name="asset_subtype<%=count%>" id="asset_subtype<%=count%>"/></td>
                                    <td><input type="text" name="asset_id<%=count%>" id="asset_id<%=count%>" /></td>
                                    <td><input type="text" name="description<%=count%>" id="description<%=count%>"/></td>
                                    <td><input type="text" name="curr_val<%=count%>" id="curr_val<%=count%>" class="numbersOn"onchange="Total(<%=count%>);" onkeypress='return event.charCode >= 48 && event.charCode <= 57'/></td>
                                    <td><select style="width: 153px;" name="mode_of_aqr<%=count%>" id="mode_of_aqr<%=count%>"><option disabled selected value="not"> --Select-- </option>
                                            <option value="p">Purchase</option>
                                            <option value="d">Donation</option>
                                            <option value="o">Others</option>
                                        </select></td>
                                    <td><input type="text" size="8" id="purchaseDate<%=count%>" name="purchaseDate<%=count%>" readonly="true"></td>
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].purchaseDate<%=count%>);" ><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>    
                                    <td><input type="text" name="glcode<%=count%>" id="glcode<%=count%>" ondrop="return false;" onpaste="return false;" /></td>  
                                    <td><input type="button" style="width: 70px" name="SearchGL<%=count%>" id="SearchGL<%=count%>" value="Search" onclick="javascript:SearchGL(550,240,<%=count%>);" /></td>
                                    <td><input size="15" type="text" name="depRate<%=count%>" id="depRate<%=count%>" onkeyup="calDepAmt(assetentry)" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><select style="width:100%" id="status<%=count%>" name="status<%=count%>" >
                                    <option value="A">Active</option><option value="I">Inactive</option></select></td>                                    
                                    <td style="display: none;"><input type="hidden" name="asset_mst_id<%=count%>" id="asset_mst_id<%=count%>"/></td>
                                    <td style="display: none;"><input type="hidden" readonly="textIndex" name="textIndex" value="<%=count%>"/></td>
                                    <td style="display: none;"><input type="hidden" name="id<%=count%>" id="id<%=count%>"/></td>
                                    <td style="display: none;"><input type="hidden" name="glid<%=count%>" id="glid<%=count%>"/></td>
                                </tr>
                            </tbody>
                        </table>
                        <br/><br/>
                        <center>
                            <input type="button" id="addRow" value="Add Row"/>
                            <input type="button" id="deleteRow" value="Delete Row"/>
                            <input type="button" value="Submit" onclick="javascript:submitform(assetentry)"/>
                            <input type="button" value="Reset" onclick="ShowParent();" />

                        </center>
                        <input type="hidden" name="rowCounter" id="rowCounter" value="<%=count%>">
                        <input type="hidden" name="rowCounterDelete" id="rowCounterDelete" value="<%=count%>">
                        <input type="hidden" name="chkboxCounter" id="chkboxCounter" value="0"/>
                    </div>
                    </center>
                </div>
                <br>
                <center>        
                <div id="forAmend" style="display:none;" >    
                                        
                    <center>    
                    <tr><input type="button" value="Fetch Asset Entry Details" onclick="javascript:getDetails()" /></tr>
                    <input type="button" value="Reset" onclick="ShowParent();" />    
                    </center>                         
                </div>        
                <br>
                </center>
                <%if (displayFlag.equalsIgnoreCase("Y")) {%>
                <div id="amend" >
                    <center>  
                    <div style="overflow:scroll; width: 1300px">    
                    <table id="order-listAmend" style="overflow-y: scroll">
                        <thead  class="CSSTableGenerator" >
                            <tr>
                                <td colspan="2">Asset Type</td>
                                <td>Asset SubType</td>
                                    <td>Asset ID</td>
                                    <td>Description</td>
                                    <td>Current Valuation</td>
                                    <td>Mode of Acquirement</td>
                                    <td colspan="2">Purchase Date</td>
                                    <td colspan="2">GL Code</td>
                                    <td>Depreciation Rate</td>
                                    <td>Status</td>
                            </tr>
                        </thead>
                        <tbody style="background-color: white; font-size: 15px">
                            <%
                                oAssetEntryBean = null;
                                oAssetEntryBean = new AssetEntryBean();
                                int count2= 1;

                                for (int i = 0; i < alAssetEntryBean.size(); i++) {
                                    oAssetEntryBean = alAssetEntryBean.get(i);
                                    count2++;
                            %>
                            <tr>
                                    <td><input type="text" readonly name="asset_type<%=count2%>" id="asset_type<%=count2%>" value="<%=blankNull(oAssetEntryBean.getAsset_type())%>"/></td>
                                    <td><input type="button" name="SearchAsset<%=count2%>" id="SearchAsset<%=count2%>" value="Search"  onclick="SearchAsset(220,180,<%=count2%>)" /></td>
                                    <td><input type="text" readonly name="asset_subtype<%=count2%>" id="asset_subtype<%=count2%>" value="<%=blankNull(oAssetEntryBean.getAsset_subtype())%>" /></td>
                                    <td><input type="text" name="asset_id<%=count2%>" id="asset_id<%=count2%>" value="<%=blankNull(oAssetEntryBean.getAsset_id())%>" /></td>
                                    <td><input type="text" name="description<%=count2%>" id="description<%=count2%>" value="<%=blankNull(oAssetEntryBean.getDescription())%>" /></td>
                                    <td><input type="text" name="curr_val<%=count2%>" id="curr_val<%=count2%>" class="numbersOn"onchange="Total(<%=count2%>);" onkeypress='return event.charCode >= 48 && event.charCode <= 57' value="<%=blankNull(oAssetEntryBean.getCurr_val())%>" /></td>
                                    <td><select style="width: 153px;" name="mode_of_aqr<%=count2%>" id="mode_of_aqr<%=count2%>">                                            
                                            <option <%if (oAssetEntryBean.getMode_of_aqr().equalsIgnoreCase("p")) {%>selected <%}%> value="p">Purchase</option>
                                            <option <%if (oAssetEntryBean.getMode_of_aqr().equalsIgnoreCase("d")) {%>selected <%}%> value="d">Donation</option>
                                            <option <%if (oAssetEntryBean.getMode_of_aqr().equalsIgnoreCase("o")) {%>selected <%}%> value="o">Others</option>
                                        </select></td>
                                    <td><input type="text" size="8" id="purchaseDate<%=count2%>" name="purchaseDate<%=count2%>" readonly="true" value="<%=blankNull(oAssetEntryBean.getPurchaseDate())%>"></td>
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].purchaseDate<%=count2%>);" ><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>    
                                    <td><input type="text" name="glcode<%=count2%>" id="glcode<%=count2%>" ondrop="return false;" onpaste="return false;" value="<%=blankNull(oAssetEntryBean.getGlcode())%>" /></td>  
                                    <td><input type="button" style="width: 70px" name="SearchGL<%=count2%>" id="SearchGL<%=count2%>" value="Search" onclick="javascript:SearchGL(550,240,<%=count2%>);" /></td>
                                    <td><input size="15" type="text" name="depRate<%=count2%>" id="depRate<%=count2%>" onkeyup="calDepAmt2(assetentry)" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' value="<%=blankNull(oAssetEntryBean.getDepRate())%>" /></td>
                                    <td><select style="width: 150px"  name="status<%=count2%>" id="status<%=count2%>" >
                                        <option <%if (oAssetEntryBean.getStatus().equalsIgnoreCase("A")) {%>selected <%}%> value="A">Active</option>
                                        <option <%if (oAssetEntryBean.getStatus().equalsIgnoreCase("I")) {%>selected <%}%> value="I">Inactive</option>
                                    </select></td>
                                    <td style="display:none"><input type="hidden" name="id<%=count2%>" id="id<%=count2%>" value="<%=blankNull(oAssetEntryBean.getId())%>"></td>
                                    <td style="display:none"><input type="hidden" name="glid<%=count2%>" id="glid<%=count2%>" value="<%=blankNull(oAssetEntryBean.getGlid())%>"></td>
                            </tr>

                            <%}%></tbody>
                    </table>                                        
                    </center>    
                    <br>
                        <center>
                            <input type="button" value="Submit" onclick="javascript:amendform(assetentry)"/>
                            <input type="button" value="Reset" onclick="ShowParent();" />
                        </center>    
                            <input type="hidden" name="indicator" id="indicator" value="">
                            <input type="hidden" name="rowCounter2" id="rowCounter2" value="<%=count2%>">
                            <input type="hidden" name="chkboxCounter" id="chkboxCounter" value="0">
                </div> 
            <%}%>                
                <input type="hidden" name="handle_id" value="" />
                <input type="hidden" name="actionApl" value="" />
                <input type="hidden" name="vendor_id" id="vendor_id"/>
                <input type="hidden" id="displayFlag" name="displayFlag" value="<%=displayFlag%>"/>
            </form>
            <script>
                               
                $("#addRow").click(function(){

                  //  var counter = $("#rowCounter").val();
                    counter++;
                    $('#order-list tr:last').after('<tr> <td align="center"><input type="checkbox" name="chckbox'+counter+'" id="chckbox'+counter+'" onclick="checkboxTrue('+counter+');"/></td>\n\
                                            <td><input type="text" id="asset_type'+counter+'" name="asset_type'+counter+'"/></td>\n\
                                            <td><input type="button" name="SearchAsset'+counter+'" id="SearchAsset'+counter+'" value="Search"  onclick="SearchAsset(220,180,'+counter+');" /></td>\n\
                                            <td><input type="text" name="asset_subtype'+counter+'" id="asset_subtype'+counter+'"/></td><td><input type="text" name="asset_id'+counter+'" id="asset_id'+counter+'" /></td>\n\
                                            <td><input type="text" id="description'+counter+'" name="description'+counter+'"/></td><td><input type="text" class="numbersOn" id="curr_val'+counter+'" name="curr_val'+counter+'" onkeypress="return event.charCode >= 48 && event.charCode <= 57"/></td>\n\
                                            <td><select style="width: 153px;" name="mode_of_aqr'+counter+'" id="mode_of_aqr'+counter+'"><option disabled selected> --Select-- </option><option value="p">Purchase</option><option value="d">Donation</option><option value="o">Others</option></select></td>\n\
                                            <td><input type="text" size="8" id="purchaseDate'+counter+'" name="purchaseDate'+counter+'" readonly="true"></td>\n\
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].purchaseDate'+counter+');" ><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>\n\
                                    <td><input type="text" name="glcode'+counter+'" id="glcode'+counter+'" ondrop="return false;" onpaste="return false;" /></td>\n\
                                    <td><input type="button" style="width: 70px" name="SearchGL'+counter+'" id="SearchGL'+counter+'" value="Search" onclick="javascript:SearchGL(550,240,'+counter+');" /></td>\n\
                                    <td><input size="15" type="text" name="depRatev" id="depRate'+counter+'" onkeyup="calDepAmt(assetentry)" onkeypress="return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47" /></td>\n\
                                    <td><select style="width:100%" id="status'+counter+'" name="status'+counter+'" ><option value="A">Active</option><option value="I">Inactive</option></select></td>\n\
                                    <td style="display: none;"><input type="hidden" name="asset_mst_id'+counter+'" id="asset_mst_id'+counter+'"/></td>\n\
                                    <td style="display: none;"><input type="hidden" readonly="textIndex" name="textIndex" value="'+counter+'"/></td>\n\
                                    <td style="display: none;"><input type="hidden" name="id'+counter+'" id="id'+counter+'"/></td>\n\
                                    <td style="display: none;"><input type="hidden" name="glid'+counter+'" id="glid'+counter+'"/></td>\n\
                                    </tr>');
                    $("#rowCounter").val(counter);
                    $("#rowCounterDelete").val(counter);
                });
                $( "#deleteRow" ).click(function() 
                {
                    var len = ($("#order-list tr").length)-1;
                    var rowcount = $("#rowCounterDelete").val();
                    var chkboxCounter=$("#chkboxCounter").val();
                    var counterDelete = rowcount-chkboxCounter;
                    
                    if (counterDelete == 0) {
                        alert("All rows can not be deleted");
                        return false;
                    }
                    else{
                        if (len ==chkboxCounter) {
                            alert("All rows can not be deleted");
                            return false;
                        }                        
                        $('input:checkbox:checked').closest('tr').remove();

                        $("#rowCounterDelete").val( $("#rowCounter").val());
                        chkboxCounter=0;
                        $("#chkboxCounter").val(chkboxCounter);
                    }
                       
                });
                function checkboxTrue(i){
                    if(document.getElementById("chckbox"+i).checked==true)
                    {
                        var counter = $("#chkboxCounter").val();
                        counter++;
                        $("#chkboxCounter").val(counter);
                    }
                    else{
                        var counter = $("#chkboxCounter").val();
                        counter--;
                        $("#chkboxCounter").val(counter);
                    }
                }
                function ShowCalender(i){

                    getCalendar(document.getElementById("purchaseDate"+i));
                }
                function SearchAsset(width, height,i)
                {
                    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 = "assetEntry.jsp";
                    var  lovKey="AssetCodeSearch"
                    popWin = open('${pageContext.request.contextPath}/CommonSearchInformation_ASSET_LOV.jsp?screenName=' + screenName+'&lovKey='+lovKey+'&textIndex='+i , 'ProductSearch', attr);
                    popWin.focus();

                }
                function ShowParent()
                {
                    document.forms[0].action="${pageContext.request.contextPath}/Asset_JSP/assetEntry.jsp";
                    document.forms[0].submit();
                }
            </script>
        </fieldset>
    </body>

    <script>
        $('table.NumbersOnly').on('keydown','.numbersOn', function(event) {
            if (event.shiftKey == true) {
                event.preventDefault();
            }

            if ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) || event.keyCode == 8  || event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 46 || event.keyCode == 190 || event.keyCode == 110) {

            } else {
                event.preventDefault();
            }
            if($(this).val().indexOf('.') !== -1 && (event.keyCode == 190 || event.keyCode == 110))
            { event.preventDefault();}
        });

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