<%--
    Document   : tradingProductCreation
    Created on : Apr 20, 2016, 3:16:34 PM
    Author     : 590685
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="DataEntryBean.tradingProductCreationBean"%>
<% try {
%>

<html>
    <head>
        <title>Trading Product Master</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> <link rel="shortcut icon" href="${pageContext.request.contextPath}/img/favicon.ico" type="image/x-icon" />
    </head>
    <body onload="noBack();checkLease()">
        <script type="text/javascript">
            function noBack()
            {
                window.history.forward();
            }
            function ShowParent()
            {
                document.forms[0].action = "${pageContext.request.contextPath}/Trading_JSP/tradingProductCreation.jsp";
                document.forms[0].submit();
            }

            function onChange(){
                if (tradingProductForm.cgst.value != "")
                {
                    var cg = document.getElementById("cgst").value;
                     var num1 = parseFloat(cg);
                    var cleanNum1 = num1.toFixed(2);
                    document.getElementById('cgst').value=cleanNum1;
                }    
                if (tradingProductForm.sgst.value != "")
                {
                    var sg = document.getElementById("sgst").value;             
                    var num2 = parseFloat(sg);
                    var cleanNum2 = num2.toFixed(2);                
                    document.getElementById('sgst').value=cleanNum2;
                }                  
             }
             function onChangeAmend(){
              var cg = document.getElementById("cgstAmend").value;
              var sg = document.getElementById("sgstAmend").value;

              var num1 = parseFloat(cg);
                var cleanNum1 = num1.toFixed(2);

                var num2 = parseFloat(sg);
                var cleanNum2 = num2.toFixed(2);

                document.getElementById('cgstAmend').value=cleanNum1;
                document.getElementById('sgstAmend').value=cleanNum2;
             }
            function checkLease(){
                var a;
                a=$('#leaseFlag').val();
                $('#priceFreqAmend').change();
                if(a=='Y'){
                    $('#leaseTableAmend').show();
                } else
                    $('#leaseTableAmend').hide();

            }
            $(document).ready(function(){

                $('#lease').change(function(){
                    $('#pricePerUnit').val('');
                    $('#priceFreq').val('');
                    $('#minDays').val('');
                    $('#maxDays').val('');
                    var w = $(this).val();
                    switch (w)
                    {
                        case 'Y':
                            $('#leaseTable').show();
                            break;
                        case 'N':
                            $('#leaseTable').hide();
                            break;
                        default:
                            $('#leaseTable').hide();
                            break;
                    }
                })

                $('#leaseAmend').change(function(){
                    var w = $(this).val();
                    switch (w)
                    {
                        case 'Y':
                            $('#leaseTableAmend').show();
                            break;
                        case 'N':
                            $('#leaseTableAmend').hide();
                            break;
                        default:
                            $('#leaseTableAmend').hide();
                            break;
                    }
                })

                $('#priceFreq').change(function(){
                    trmLength("priceFreq");
                })

                $('#priceFreqAmend').change(function(){
                    trmLength("priceFreqAmend");
                })
            });

            function submitform(tradingProductForm)
            {
                if (checkCreateDiv(tradingProductForm))
                {
                    document.forms[0].handle_id.value = "Create";
                    document.forms[0].action = '/PacsApplication/TradingProductOperationServlet';
                    tradingProductForm.submit();
                }
            }
            function checkCreateDiv(tradingProductForm)
            {
                if (tradingProductForm.commoditytype.value == "")
                {
                    alert("Commodity type must be filled.");
                    tradingProductForm.commoditytype.focus();
                    return false;
                }
                if (tradingProductForm.typeDesc.value == "")
                {
                    alert("Commodity type description must be filled.");
                    tradingProductForm.typeDesc.focus();
                    return false;
                }
                if (tradingProductForm.commoditysubtype.value == "")
                {
                    alert("Commodity subtype must be filled.");
                    tradingProductForm.commoditysubtype.focus();
                    return false;
                }
                if (tradingProductForm.subtypeDesc.value == "")
                {
                    alert("Commodity subtype description must be filled.");
                    tradingProductForm.subtypeDesc.focus();
                    return false;
                }
                if (tradingProductForm.unit.value == "")
                {
                    alert("Quantity Unit must be filled.");
                    tradingProductForm.unit.focus();
                    return false;
                }

                if (tradingProductForm.status.value == "")
                {
                    alert("Status must be filled.");
                    tradingProductForm.status.focus();
                    return false;
                }
                if (tradingProductForm.lease.value == "Y")
                {
                    if (tradingProductForm.pricePerUnit.value == "" || tradingProductForm.priceFreq.value == "" || tradingProductForm.minDays.value == "" || tradingProductForm.maxDays.value == "") {
                        alert("All Lease details must be filled.");
                        return false;
                    }
                }
                if (tradingProductForm.cgst.value == "")
                {
                    alert("CGST rate must be filled.");
                    tradingProductForm.cgst.focus();
                    return false;
                }
                if (tradingProductForm.sgst.value == "")
                {
                    alert("SGST rate must be filled.");
                    tradingProductForm.sgst.focus();
                    return false;
                }
                if (tradingProductForm.lease.value == "")
                {
                    alert("Selct Available for Lease.");
                    tradingProductForm.lease.focus();
                    return false;
                }
                if (tradingProductForm.purchaseGL.value == "")
                {
                    alert("Purchase GL must be filled.");
                    tradingProductForm.purchaseGL.focus();
                    return false;
                }
                if (tradingProductForm.saleGL.value == "")
                {
                    alert("Sale GL must be filled.");
                    tradingProductForm.saleGL.focus();
                    return false;
                }
                if (tradingProductForm.closeGL.value == "")
                {
                    alert("Close GL must be filled.");
                    tradingProductForm.closeGL.focus();
                    return false;
                }
                if (tradingProductForm.tradeGL.value == "")
                {
                    alert("Trade GL must be filled.");
                    tradingProductForm.tradeGL.focus();
                    return false;
                }
                return true;
            }

            function updateform(tradingProductForm)
            {
                if (checkUpdateDiv(tradingProductForm))
                {
                    document.forms[0].handle_id.value = "Update";
                    document.forms[0].action = '/PacsApplication/TradingProductOperationServlet';
                    tradingProductForm.submit();
                }
            }
            function checkUpdateDiv(tradingProductForm)
            {
                if (tradingProductForm.commoditytypeAmend.value == "")
                {
                    alert("Commodity type must be filled..");
                    tradingProductForm.commoditytypeAmend.focus();
                    return false;
                }
                if (tradingProductForm.typeDescAmend.value == "")
                {
                    alert("Commodity type description must be filled.");
                    tradingProductForm.typeDescAmend.focus();
                    return false;
                }
                if (tradingProductForm.commoditysubtypeAmend.value == "")
                {
                    alert("Commodity subtype must be filled.");
                    tradingProductForm.commoditysubtypeAmend.focus();
                    return false;
                }
                if (tradingProductForm.subtypeDescAmend.value == "")
                {
                    alert("Commodity subtype description must be filled.");
                    tradingProductForm.subtypeDescAmend.focus();
                    return false;
                }
                if (tradingProductForm.unitAmend.value == "")
                {
                    alert("Quantity Unit must be filled.");
                    tradingProductForm.unitAmend.focus();
                    return false;
                }
                if (tradingProductForm.statusAmend.value == "")
                {
                    alert("Status must be filled.");
                    tradingProductForm.statusAmend.focus();
                    return false;
                }
                if (tradingProductForm.leaseAmend.value == "Y")
                {
                    if (tradingProductForm.pricePerUnitAmend.value == "" || tradingProductForm.priceFreqAmend.value == "" || tradingProductForm.minDaysAmend.value == "" || tradingProductForm.maxDaysAmend.value == "") {
                        alert("All Lease details must be filled.");
                        return false;
                    }
                }
                if (tradingProductForm.purchaseGLAmend.value == "")
                {
                    alert("Purchase GL must be filled.");
                    tradingProductForm.purchaseGLAmend.focus();
                    return false;
                }
                if (tradingProductForm.saleGLAmend.value == "")
                {
                    alert("Sale GL must be filled.");
                    tradingProductForm.saleGLAmend.focus();
                    return false;
                }
                if (tradingProductForm.closeGLAmend.value == "")
                {
                    alert("Close GL must be filled.");
                    tradingProductForm.closeGLAmend.focus();
                    return false;
                }
                if (tradingProductForm.tradeGLAmend.value == "")
                {
                    alert("Trade GL must be filled.");
                    tradingProductForm.tradeGLAmend.focus();
                    return false;
                }
                return true;
            }

            function checkop()
            {
                if (document.getElementById("checkOption").value == "create")
                {
                    document.getElementById('create').style.display = 'block';
                    document.getElementById('amend').style.display = 'none';

                    document.getElementById('amend2').style.display = 'none';

                }
                if (document.getElementById("checkOption").value == "amend")
                {
                    document.getElementById('create').style.display = 'none';
                    document.getElementById('amend').style.display = 'block';

                    document.getElementById('amend2').style.display = 'none';

                }
                if (document.getElementById("checkOption").value == "active")
                {
                    document.getElementById('create').style.display = 'none';
                    document.getElementById('amend').style.display = 'none';
                    document.getElementById('amend2').style.display = 'none';

                }
                if (document.getElementById("checkOption").value == "deactive")
                {
                    document.getElementById('create').style.display = 'none';
                    document.getElementById('amend').style.display = 'none';
                    document.getElementById('amend2').style.display = 'none';
                }
            }

            function searchProduct(width, height, commoditytype,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 = "tradingProductCreation.jsp";
                var lovKey = "prodDetails"
                popWin = open('/PacsApplication/CommonSearchInformationTradingLOV.jsp?commoditytype=' + commoditytype + '&Subtype='+Subtype+ '&screenName=' + screenName + '&lovKey=' + lovKey, 'prodDetails', attr);
                popWin.focus();

            }
            function searchCommType(width, height, commoditytype) 
            {
                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 = "tradingProductCreation.jsp";
                var lovKey = "commoditytype"
                popWin = open('/PacsApplication/CommonSearchInformationTradingLOV.jsp?commoditytype=' + commoditytype + '&screenName=' + screenName + '&lovKey=' + lovKey, 'commoditytype', attr);
                popWin.focus();

            }
            function SearchPurchase(width, height)
            {
                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 accNo = document.getElementById("purchaseGL").value;
                var screenName = "tradingProductCreation.jsp";
                var lovKey = "purchaseGL";

                popWin = open('/PacsApplication/CommonSearchInformationTradingLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo, 'AccountSearch', attr);
                popWin.focus();
            }
            function SearchSale(width, height)
            {
                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 accNo = document.getElementById("saleGL").value;
                var screenName = "tradingProductCreation.jsp";
                var lovKey = "saleGL";

                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationTradingLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo, 'AccountSearch', attr);
                popWin.focus();
            }
            function SearchClose(width, height)
            {
                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 accNo = document.getElementById("closeGL").value;
                var screenName = "tradingProductCreation.jsp";
                var lovKey = "closeGL";

                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationTradingLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo, 'AccountSearch', attr);
                popWin.focus();
            }
            function SearchTrade(width, height)
            {
                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 accNo = document.getElementById("tradeGL").value;
                var screenName = "tradingProductCreation.jsp";
                var lovKey = "tradeGL";

                popWin = open('/PacsApplication/CommonSearchInformationTradingLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo, 'AccountSearch', attr);
                popWin.focus();
            }
            
            // For Amend
            function SearchPurchaseAmend(width, height)
            {
                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 accNo = document.getElementById("purchaseGLAmend").value;
                var screenName = "tradingProductCreation.jsp";
                var lovKey = "purchaseGLAmend";

                popWin = open('/PacsApplication/CommonSearchInformationTradingLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo, 'AccountSearch', attr);
                popWin.focus();
            }
            function SearchSaleAmend(width, height)
            {
                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 accNo = document.getElementById("saleGLAmend").value;
                var screenName = "tradingProductCreation.jsp";
                var lovKey = "saleGLAmend";

                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationTradingLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo, 'AccountSearch', attr);
                popWin.focus();
            }
            function SearchCloseAmend(width, height)
            {
                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 accNo = document.getElementById("closeGLAmend").value;
                var screenName = "tradingProductCreation.jsp";
                var lovKey = "closeGLAmend";

                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationTradingLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo, 'AccountSearch', attr);
                popWin.focus();
            }
            function SearchTradeAmend(width, height)
            {
                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 accNo = document.getElementById("tradeGLAmend").value;
                var screenName = "tradingProductCreation.jsp";
                var lovKey = "tradeGLAmend";

                popWin = open('/PacsApplication/CommonSearchInformationTradingLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo, 'AccountSearch', attr);
                popWin.focus();
            }
            
            function getDetails() 
            {
                if (tradingProductForm.commoditytypeSearch.value == "")
                {
                    alert("Commodity type must be filled..");
                    tradingProductForm.commoditytypeSearch.focus();
                    return false;
                }
                if (tradingProductForm.commoditySubtypeSearch.value == "")
                {
                    alert("Commodity Sub type must be filled..");
                    tradingProductForm.commoditySubtypeSearch.focus();
                    return false;
                }
                document.forms[0].handle_id.value = "Search";
                document.forms[0].action = '/PacsApplication/TradingProductOperationServlet';
                document.forms[0].submit();
            }

            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
                    }
            }
            function trmLength(a){
                var v=document.getElementById(a).value;
                if(v=="HR")
                    v="(In Hours)";
                else if(v=="D")
                    v="(In Days)";
                else if(v=="W")
                    v="(In Weeks)";
                else if(v=="M")
                    v="(In Months)";
                else if(v=="Q")
                    v="(In Quaters)";
                else if(v=="H")
                    v="(In Half Years)";
                else if(v=="Y")
                    v="(In Years)";
                if($('#trm1').length && $('#trm2').length){
                    document.getElementById('trm1').innerHTML = v;
                    document.getElementById('trm2').innerHTML = v;
                }
                if($('#trm3').length && $('#trm4').length){
                    document.getElementById('trm3').innerHTML = v;
                    document.getElementById('trm4').innerHTML = v;
                }
            }
            
            // to restrict back button
            history.pushState(null, null, location.href);
            window.addEventListener('popstate', function(event) {
                history.pushState(null, null, location.href);
            });

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


             String ServletName = "";
             display = request.getAttribute("ServletName");
             if (display != null) {
                 ServletName = display.toString();
             }
        %>
        <jsp:include page="MenuHead_TRADING.jsp" flush="true" />
        <br>
        <%!
            String blankNull(String s) {
                return (s == null) ? "" : s;
            }
        %>

        <%
             String pacsId = (String) session.getAttribute("pacsId");
             String userRole = (String) session.getAttribute("userRole");
             Object tradingProductCreationBeanObj = request.getAttribute("tradingProductCreationBeanObj");
             tradingProductCreationBean otradingProductCreationBean = new tradingProductCreationBean();
             if (tradingProductCreationBeanObj != null) {
                 otradingProductCreationBean = (tradingProductCreationBean) request.getAttribute("tradingProductCreationBeanObj");

             }
        %>
        <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">Trading Product Master</legend>
            <form name="tradingProductForm" method="post" action="TradingProductOperationServlet">

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

                <br>
                <center><lable style=" font-family: Berlin Sans FB; font-weight:  normal;">Operation Selection: </lable>
                    <select id="checkOption" onchange="checkop()" name="checkOption" >
                        <option value="" disabled selected style="display:none;" >--select--</option>
                        <option value="create" <%if (ServletName.equalsIgnoreCase("Create")) {%>selected<%}%>>Create</option>
                        <option value="amend" <%if (ServletName.equalsIgnoreCase("Amend")) {%>selected<%}%>>Amend</option>

                    </select>
                    <br><br>
                    <div id="create" style="display:none;">
                        <table>
                            <tbody>
                                <tr>
                                    <td>Commodity Type<font color="red" >*</font>:</td>
                                    <td><input type="text" size="18" id="commoditytype" name="commoditytype" onkeypress="return numbersonly(event)" readonly style="text-align:right;"/></td>
                                    <td><input type="button" value="Search"  onclick="javascript:searchCommType(450,180,document.getElementById('commoditytype').value)"></td>
                                    
                                    <td>Type Description<font color="red" >*</font>:</td>
                                    <td><input type="text" name="typeDesc" id="typeDesc" value="" readonly /></td>
                                </tr>
                                <tr>
                                    <td>Commodity Sub Type<font color="red" >*</font>:</td>
                                    <td><input type="text" name="commoditysubtype"  id="commoditysubtype" onkeypress="return numbersonly(event)" value="" readonly style="text-align:right;" /></td>
                                    <td></td>
                                    <td>Sub Type Description<font color="red" >*</font>:</td>
                                    <td><input type="text" name="subtypeDesc" id="subtypeDesc" value="" /></td>
                                </tr>
                                <tr>
                                    <td>Quantity Unit<font color="red" >*</font>:</td>
                                    <td>
                                        <select id="unit" name="unit">
                                            <option value="" disabled selected style="display:none;">--Select--</option>
                                            <option value="1">K.g.</option>
                                            <option value="2">Lt.</option>
                                            <option value="3">Packets</option>
                                            <option value="4">Quintal</option>
                                            <option value="5">Others</option>
                                        </select>
                                    </td>
                                    <td></td>
                                    <td>Status<font color="red" >*</font>:</td>
                                    <td><select id="status" name="status">
                                            <option value="" disabled selected style="display:none;">--Select--</option>
                                            <option value="A">Active</option>
                                            <option value="I">Inactive</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>CGST Rate<font color="red" >*</font>:</td>
                                    <td><input type="text" onpaste="return false" ondrop="return false;" name="cgst" id="cgst" value="" onclick="javascript:onChange();" style="text-align:right;" onkeypress='return event.charCode >= 46 && event.charCode <= 57' /></td>
                                    <td></td>
                                    <td>SGST Rate<font color="red" >*</font>:</td> 
                                    <td><input type="text" onpaste="return false" ondrop="return false;" name="sgst" id="sgst" value="" onclick="javascript:onChange();" style="text-align:right;" onkeypress='return event.charCode >= 46 && event.charCode <= 57' /></td>
                                </tr>
                                <tr>
                                    <td>Purchase GL<font color="red" >*</font>:</td>
                                    <td><input type="text" size="18" id="purchaseGL" name="purchaseGL" /></td>
                                    <td><input type="button" value="Search" onclick="javascript:SearchPurchase(550,240);"></td>
                                    
                                    <td>Sale GL<font color="red" >*</font>:</td>
                                    <td><input type="text" size="18" id="saleGL" name="saleGL" /></td>
                                    <td><input type="button" value="Search" onclick="javascript:SearchSale(550,240);"></td>
                                </tr>
                                <tr>
                                    <td>Closing Stock GL<font color="red" >*</font>:</td>
                                    <td><input type="text" size="18" id="closeGL" name="closeGL" /></td>
                                    <td><input type="button" value="Search" onclick="javascript:SearchClose(550,240);"></td>
                                    
                                    <td>Stock-In Trade GL<font color="red" >*</font>:</td>
                                    <td><input type="text" size="18" id="tradeGL" name="tradeGL" /></td>
                                    <td><input type="button" value="Search" onclick="javascript:SearchTrade(550,240);"></td>
                                </tr>
                                <tr><td></td><td></td></tr>
                                <tr><td></td><td></td></tr>
                                <tr>
                                    <td></td>
                                    <td>Available for Lease<font color="red" >*</font>:</td>
                                    <td><select id="lease" name="lease" onclick="javascript:onChange();" >
                                            <option value="" disabled selected style="display:none;">--Select--</option>
                                            <option value="Y">Yes</option>
                                            <option value="N">No</option>
                                        </select>
                                    </td>
                                    <td></td>
                                </tr>
                                <%if (userRole.equalsIgnoreCase("201603000004021") ){%>
                                <tr>
                                    <td></td>
                                    <td>Pacs Id</td>
                                    <td><input type="text" name="pacsId"  id="pacsId" value="" onclick="javascript:onChange();" style="text-align:right;" /></td>
                                    <td></td>
                                </tr>
                                <%}else if(userRole.equalsIgnoreCase("201606000004041") ) {%>
                                <tr>
                                    <td></td>
                                    <td>Pacs Id</td>
                                    <td><input type="text"  readonly name="pacsId"  id="pacsId" value="<%=pacsId%>" onclick="javascript:onChange();" style="text-align:right;" /></td>
                                    <td></td>
                                </tr>
                                <%}%>
                            </tbody>
                        </table><br>

                        <table border="2" cellpadding="1" cellspacing="1" style="text-align: center; display: none;" id="leaseTable" name="leaseTable">
                            <thead class="CSSTableGenerator">
                                <tr>
                                    <td>Price per Unit</td>
                                    <td>Price Frequency</td>
                                    <td>Minimum Term <label id="trm1"></label></td>
                                    <td>Maximum Term <label id="trm2"></label></td>
                                    <td>Land Area</td>
                                </tr>
                            </thead>
                            <tbody style="background-color:white;">
                                <tr>
                                    <td><input type="text" id="pricePerUnit" name="pricePerUnit" onkeypress="return numbersonly(event)"/></td>
                                    <td>
                                        <select id="priceFreq" name="priceFreq">
                                            <option style="display:none;" selected value="">--select--</option>
                                            <option value="HR">Hourly</option>
                                            <option value="D">Daily</option>
                                            <option value="W">Weekly</option>
                                            <option value="M">Monthly</option>
                                            <option value="Q">Quarterly</option>
                                            <option value="H">Half Yearly</option>
                                            <option value="Y">Yearly</option>
                                        </select>
                                    </td>
                                    <td><input type="text" id="minDays" name="minDays" onkeypress="return numbersonly(event)"/></td>
                                    <td><input type="text" id="maxDays" name="maxDays" onkeypress="return numbersonly(event)"/></td>
                                    <td>
                                        <select id="landArea" name="landArea">
                                            <option style="display:none;" selected value="">--select--</option>
                                            <option value="A">Per Acre</option>
                                            <option value="S">Per Satak</option>
                                        </select>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <br><br>
                        <center>
                            <input type="button" value="Submit" onclick="javascript:submitform(tradingProductForm)">
                            <input type="button" value="Reset" name="reset" onclick="ShowParent()"/>
                        </center>
                        <input type="hidden" name="purchaseID" id="purchaseID" />
                        <input type="hidden" name="saleID" id="saleID" />
                        <input type="hidden" name="closeID" id="closeID" />
                        <input type="hidden" name="tradeID" id="tradeID" />
                    </div>
                    <br><br>

                    <div id="amend" style="display: none;">
                        <center>
                            <lable style=" font-family: Berlin Sans FB; font-weight:  normal;" >Enter Commodity Type<font color="red" >*</font>: </lable>
                            <input type="text" name="commoditytypeSearch" id="commoditytypeSearch" onkeypress="return numbersonly(event)" style="text-align:right;"/>
                            <lable style=" font-family: Berlin Sans FB; font-weight:  normal;" >Enter Commodity Sub Type<font color="red" >*</font>: </lable>
                            <input type="text" name="commoditySubtypeSearch" id="commoditySubtypeSearch" onkeypress="return numbersonly(event)" style="text-align:right;" /> 
                            <input type="button"  value="Search" onclick="javascript:searchProduct(220, 180, document.tradingProductForm.commoditytypeSearch.value, document.tradingProductForm.commoditySubtypeSearch.value)" />
                            <center>
                                <br>
                                <input type="button"  value="Submit" onclick="javascript:getDetails()" />
                                <input type="button" value="Reset" name="reset" onclick="ShowParent()"/>
                            </center>
                        </center>
                        <br>
                    </div>

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

                        <table>
                            <tbody>
                                <tr>
                                    <td>Commodity type:</td>
                                    <td><input type="text" name="commoditytypeAmend" readonly id="commoditytypeAmend" value="<%=blankNull(otradingProductCreationBean.getCommoditytype())%>" style="text-align:right;" /></td>
                                
                                    <td>Type Description:</td>
                                    <td><input type="text" readonly name="typeDescAmend" id="typeDescAmend" value="<%=blankNull(otradingProductCreationBean.getTypeDesc())%>" /></td>
                                </tr>
                                <tr>
                                    <td>Commodity Sub Type:</td>
                                    <td><input type="text" readonly name="commoditysubtypeAmend"  id="commoditysubtypeAmend" value="<%=blankNull(otradingProductCreationBean.getCommoditysubtype())%>" onkeypress="return numbersonly(event)" style="text-align:right;" /></td>
                                
                                    <td>Sub Type Description:</td>
                                    <td><input type="text" name="subtypeDescAmend" id="subtypeDescAmend" value="<%=blankNull(otradingProductCreationBean.getSubtypeDesc())%>" /></td>
                                </tr>

                                <tr>
                                    <td>Quantity Unit:</td>
                                    <td><select id="unitAmend" name="unitAmend">
                                            <option value="" disabled selected style="display:none;">--Select--</option>
                                            <option value="1" <%if (blankNull(otradingProductCreationBean.getUnit()).equals("1")) {%> selected <%}%>>K.g.</option>
                                            <option value="2" <%if (blankNull(otradingProductCreationBean.getUnit()).equals("2")) {%> selected <%}%>>Lt.</option>
                                            <option value="3" <%if (blankNull(otradingProductCreationBean.getUnit()).equals("3")) {%> selected <%}%>>Packets</option>
                                            <option value="4" <%if (blankNull(otradingProductCreationBean.getUnit()).equals("4")) {%> selected <%}%>>Quintal</option>
                                            <option value="5" <%if (blankNull(otradingProductCreationBean.getUnit()).equals("5")) {%> selected <%}%>>Others</option>
                                        </select>
                                    </td>
                                
                                    <td>Status:</td>
                                    <td><select id="statusAmend" name="statusAmend">
                                            <option value="" disabled selected style="display:none;">--Select--</option>
                                            <option value="A" <%if (blankNull(otradingProductCreationBean.getStatus()).equals("A")) {%> selected <%}%>>Active</option>
                                            <option value="I" <%if (blankNull(otradingProductCreationBean.getStatus()).equals("I")) {%> selected <%}%>>Inactive</option>
                                        </select>
                                    </td></tr>
                                <tr>
                                    <td>CGST Rate</td>
                                    <td><input type="text" name="cgstAmend"  id="cgstAmend" value="<%=blankNull(otradingProductCreationBean.getCgst())%>" onclick="javascript:onChangeAmend();" style="text-align:right;" onkeypress='return event.charCode >= 46 && event.charCode <= 57'/></td>
                                
                                    <td>SGST Rate</td>
                                    <td><input type="text" name="sgstAmend" id="sgstAmend" value="<%=blankNull(otradingProductCreationBean.getSgst())%>" onclick="javascript:onChangeAmend();" style="text-align:right;" onkeypress='return event.charCode >= 46 && event.charCode <= 57'/></td>
                                </tr>
                                <tr>
                                    <td>Purchase GL<font color="red" >*</font>:</td>
                                    <td><input type="text" size="18" id="purchaseGLAmend" name="purchaseGLAmend" value="<%=blankNull(otradingProductCreationBean.getPurchaseGL())%>"/></td>
                                    <td><input type="button" value="Search" onclick="javascript:SearchPurchaseAmend(550,240);"></td>
                                    
                                    <td>Sale GL<font color="red" >*</font>:</td>
                                    <td><input type="text" size="18" id="saleGLAmend" name="saleGLAmend" value="<%=blankNull(otradingProductCreationBean.getSaleGL())%>"/></td>
                                    <td><input type="button" value="Search" onclick="javascript:SearchSaleAmend(550,240);"></td>
                                </tr>
                                <tr>
                                    <td>Closing Stock GL<font color="red" >*</font>:</td>
                                    <td><input type="text" size="18" id="closeGLAmend" name="closeGLAmend" value="<%=blankNull(otradingProductCreationBean.getCloseGL())%>"/></td>
                                    <td><input type="button" value="Search" onclick="javascript:SearchCloseAmend(550,240);"></td>
                                    
                                    <td>Stock-In Trade GL<font color="red" >*</font>:</td>
                                    <td><input type="text" size="18" id="tradeGLAmend" name="tradeGLAmend" value="<%=blankNull(otradingProductCreationBean.getTradeGL())%>"/></td>
                                    <td><input type="button" value="Search" onclick="javascript:SearchTradeAmend(550,240);"></td>
                                </tr>
                                <tr><td></td><td></td></tr>
                                <tr><td></td><td></td></tr>
                                <tr>
                                    <td></td>
                                    <td>Available for Lease</td>
                                    <td><select id="leaseAmend" name="leaseAmend" onclick="javascript:onChangeAmend();" >
                                            <option value="" disabled selected style="display:none;">--Select--</option>
                                            <option value="Y" <%if (blankNull(otradingProductCreationBean.getLease()).equals("Y")) {%> selected <%}%>>Yes</option>
                                            <option value="N" <%if (blankNull(otradingProductCreationBean.getLease()).equals("N")) {%> selected <%}%>>No</option>
                                        </select>
                                    </td>
                                    <td></td>
                                </tr>
                                <%if (userRole.equalsIgnoreCase("201603000004021") ){%>
                                <tr> 
                                    <td></td>
                                    <td>Pacs Id</td>
                                    <td><input type="text" name="pacsId"  id="pacsId" value="<%=blankNull(otradingProductCreationBean.getPacsId())%>" onclick="javascript:onChangeAmend();" style="text-align:right;" /></td>
                                    <td></td>
                                </tr>
                                <%}else if(userRole.equalsIgnoreCase("201606000004041") ) {%>
                                <tr> 
                                    <td></td>
                                    <td>Pacs Id</td>
                                    <td><input type="text"  readonly name="pacsId"  id="pacsId" value="<%=pacsId%>" onclick="javascript:onChangeAmend();" style="text-align:right;"/></td>
                                    <td></td>
                                </tr>
                                <%}%>

                                <tr><td><br></td></tr>
                            </tbody>
                        </table><br>

                        <table border="2" cellpadding="1" cellspacing="1" style="text-align: center;display: none;" id="leaseTableAmend" name="leaseTableAmend">
                            <thead class="CSSTableGenerator">
                                <tr>
                                    <td>Price per Unit</td>
                                    <td>Price Frequency</td>
                                    <td>Minimum Term <label id="trm3"></label></td>
                                    <td>Maximum Term <label id="trm4"></label></td>
                                    <td>Land Area</td>
                                </tr>
                            </thead>
                            <tbody style="background-color:white;">
                                <tr>
                                    <td><input type="text" id="pricePerUnitAmend" name="pricePerUnitAmend" value="<%=blankNull(otradingProductCreationBean.getPricePerUnit())%>" onkeypress="return numbersonly(event)"/></td>
                                    <td>
                                        <select id="priceFreqAmend" name="priceFreqAmend">
                                            <option style="display:none;" selected value="">--select--</option>
                                            <option value="D" <%if (blankNull(otradingProductCreationBean.getPriceFreq()).equals("D")) {%> selected <%}%>>Daily</option>
                                            <option value="W" <%if (blankNull(otradingProductCreationBean.getPriceFreq()).equals("W")) {%> selected <%}%>>Weekly</option>
                                            <option value="M" <%if (blankNull(otradingProductCreationBean.getPriceFreq()).equals("M")) {%> selected <%}%>>Monthly</option>
                                            <option value="Q" <%if (blankNull(otradingProductCreationBean.getPriceFreq()).equals("Q")) {%> selected <%}%>>Quarterly</option>
                                            <option value="H" <%if (blankNull(otradingProductCreationBean.getPriceFreq()).equals("H")) {%> selected <%}%>>Half Yearly</option>
                                            <option value="Y" <%if (blankNull(otradingProductCreationBean.getPriceFreq()).equals("Y")) {%> selected <%}%>>Yearly</option>
                                        </select>
                                    </td>
                                    <td><input type="text" id="minDaysAmend" name="minDaysAmend" value="<%=blankNull(otradingProductCreationBean.getMinDays())%>" onkeypress="return numbersonly(event)"/></td>
                                    <td><input type="text" id="maxDaysAmend" name="maxDaysAmend" value="<%=blankNull(otradingProductCreationBean.getMaxDays())%>" onkeypress="return numbersonly(event)"/></td>
                                    <td>
                                        <select id="landAreaAmend" name="landAreaAmend">
                                            <option style="display:none;" selected value="">--select--</option>
                                            <option value="A" <%if (blankNull(otradingProductCreationBean.getLandArea()).equals("A")) {%> selected <%}%>>Per Acre</option>
                                            <option value="S" <%if (blankNull(otradingProductCreationBean.getLandArea()).equals("S")) {%> selected <%}%>>Per Satak</option>
                                        </select>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <br>
                        <center>
                            <input type="button" value="Update" onclick="javascript:updateform(tradingProductForm)">
                            <input type="button" value="Reset" name="reset" onclick="ShowParent()"/>
                        </center>
                        <input type="hidden" name="purchaseIDAmend" id="purchaseIDAmend" value="<%=blankNull(otradingProductCreationBean.getPurchaseID())%>"/>
                        <input type="hidden" name="saleIDAmend" id="saleIDAmend" value="<%=blankNull(otradingProductCreationBean.getSaleID())%>"/>
                        <input type="hidden" name="closeIDAmend" id="closeIDAmend" value="<%=blankNull(otradingProductCreationBean.getCloseID())%>"/>
                        <input type="hidden" name="tradeIDAmend" id="tradeIDAmend" value="<%=blankNull(otradingProductCreationBean.getTradeID())%>"/>
                    </div>
                    <% }%>

                </center>
                <input type="hidden" name="handle_id" value="" />
                <input type="hidden" name="leaseFlag" id="leaseFlag" value="<%=blankNull(otradingProductCreationBean.getLease())%>"/>
                <input type="hidden" name="product_id" id="product_id" value="<%=blankNull(otradingProductCreationBean.getProduct_id())%>"/>                
            </form>
        </fieldset>
    </body>
</html>
<% 	} catch (Exception e) {
                
            }
%>
