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

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="DataEntryBean.pdsProductCreationBean"%>
<% try {
%>
<html>
    <head>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="${pageContext.request.contextPath}/js/Calendar.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/TableCSSCode.css?pacs=<%=((new java.util.Date()).getTime())%>" />
        <link rel="shortcut icon" href="${pageContext.request.contextPath}/img/favicon.ico?pacs=<%=((new java.util.Date()).getTime())%>" type="image/x-icon" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/styles.css?pacs=<%=((new java.util.Date()).getTime())%>"/>
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/ButtonAndText.css?pacs=<%=((new java.util.Date()).getTime())%>" />
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/info.css?pacs=<%=((new java.util.Date()).getTime())%>" />
        <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-ui-1.10.4.custom/development-bundle/jquery-1.10.2.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <script type="text/javascript" src="/PacsApplication/chromejs/chrome.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <script type="text/javascript" src="/PacsApplication/js/iFrame_killer.js"></script>
        <title>PDS Product</title>
    </head>
    <body onload="noBack()">
        <script type="text/javascript">
            function noBack()
            {
                window.history.forward();
            }
function numbersonly(e){
                    var unicode=e.charCode? e.charCode : e.keyCode
                    if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
                            if (unicode<48||unicode>57) //if not a number
                                    return false ;//disable key press
                    }
            }

            function submitform(pdsProductForm)
            {
                if (checkCreateDiv(pdsProductForm))
                {
                    document.forms[0].handle_id.value = "Create";
                    document.forms[0].action = '/PacsApplication/PdsProductOperationServlet';
                    pdsProductForm.submit();
                }

            }
            function checkCreateDiv(pdsProductForm)
            {
                if (pdsProductForm.status.value == ""||pdsProductForm.productType.value == ""||pdsProductForm.productDescription.value == ""||pdsProductForm.productSubType.value == ""||pdsProductForm.productSubTypeDescription.value == ""||pdsProductForm.unit.value == "")
                {
                    alert("!! All fields must be filled !!");
                   // pdsProductForm.status.focus();
                    return false;
                }


                return true;
            }

            function updateform(pdsProductForm)
            {
                if (checkUpdateDiv(pdsProductForm))
                {
                    document.forms[0].handle_id.value = "Update";
                    document.forms[0].action = '/PacsApplication/PdsProductOperationServlet';
                    pdsProductForm.submit();

                }
            }
            function checkUpdateDiv(pdsProductForm)
            {

                if (pdsProductForm.statusAmend.value == ""||pdsProductForm.productTypeAmend.value == ""||pdsProductForm.productDescriptionAmend.value == ""||pdsProductForm.productSubTypeAmend.value == ""||pdsProductForm.productSubTypeDescriptionAmend.value == ""||pdsProductForm.unitAmend.value == "")
                {
                    alert("!! All fields must be filled !!");

                    return false;
                }

                return true;
            }
function SearchProductSubType(width, height,productTypeSearch,productSubTypeSearch)
                {

                    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=500,screenY=300,left=' + LeftPosition + ',top=' +
                        TopPosition + '';
                    var screenName = "pdsProductCreation.jsp";
                    var  lovKey="PdsProductSearch1"
                    popWin = open('/PacsApplication/CommonSearchInformationPdsLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey+'&productTypeSearch='+productTypeSearch+'&productSubTypeSearch='+productSubTypeSearch, 'PdsProductSearch1', attr);
                    popWin.focus();

                }
            function checkop()
            {
                if (document.getElementById("checkOption").value == "create")
                {
                    document.getElementById('create').style.display = 'block';
                    document.getElementById('amend').style.display = 'none';
                   // document.getElementById('active').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('active').style.display = 'none';
                    document.getElementById('amend2').style.display = 'none';


                }



            }

            function searchProduct() {

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

            }



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

        <%
            Object pdsProductCreationBeanObj = request.getAttribute("pdsProductCreationBeanObj");
            pdsProductCreationBean opdsProductCreationBean = new pdsProductCreationBean();
            if (pdsProductCreationBeanObj != null) {
                opdsProductCreationBean = (pdsProductCreationBean) request.getAttribute("pdsProductCreationBeanObj");

            }
        %>

        <form name="pdsProductForm" method="post" action="">
            <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">Product Management</legend>
                <%if (!error_msg.equalsIgnoreCase("")) {%>
                <center><div class="info" id="errorMessage"><center><%= error_msg%></center></div></center>
                <% }%>

                <br>
                <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" >Create</option>
                        <option value="amend" >Amend</option>

                    </select>
                </center>
                <div id="create" style="display:none;">
                    <table>
                        <tbody>
                            <tr>
                                <td>Status:</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>Product Type:</td>
                                <td><input type="text" name="productType" id="productType" value="" onkeypress="return numbersonly(event)"/></td>
                            </tr>
                            <tr>
                                <td>Product Description:</td>
                                <td><input type="text" name="productDescription"  id="productDescription" value="" /></td>
                            </tr>
                            <tr>
                                <td>Product Sub Type:</td>
                                <td><input type="text" name="productSubType" id="productSubType" value="" onkeypress="return numbersonly(event)"/></td>
                            </tr>
                            <tr>
                                <td>Product Sub Type Description:</td>
                                <td><input type="text" name="productSubTypeDescription"  id="productSubTypeDescription" value="" /></td>
                            </tr>
                            <tr>
                                <td>Quantity Unit:</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>
                                    </select>
                                </td>
                            </tr>
                            <!--<tr>
                                <td>Profit Factor (%):</td>
                                <td><input type="text" name="profitFactor"  id="profitFactor" value="" /></td>
                            </tr>-->

                            <tr><td><br></td></tr>
                            <tr><td><br></td></tr>

                        </tbody>
                    </table><br><br>

                    <center>
                        <input type="button" value="Submit" onclick="javascript:submitform(pdsProductForm)">
                        <input type="reset" value="Reset" name="reset" />
                    </center>
                    <table>
                            <tr><td><br></td></tr>
                            <tr><td><br></td></tr>

                            <tr><td><label style=" font-family: Berlin Sans FB; font-weight:normal; ">All fields are mandatory</label></td></tr>
                            </tbody>
                        </table>
                </div>
                <br><br>

                <div id="amend" style="display: none;">
                    <center>
                       <!-- <label style=" font-family: Berlin Sans FB; font-weight:  normal;" >Enter Product Code: </label>-->
                       <table>

                           <tr><td><label style=" font-family: Berlin Sans FB; font-weight:  normal;" >Enter Product Description: </label></td>
                        <td><input type="text" readonly="true" id="inventorySearchByDescription" name="inventorySearchByDescription"/></td>
                        <td></td><td></td><td></td><td></td></tr>
                           <tr> <td><label style=" font-family: Berlin Sans FB; font-weight:  normal;" >Enter Product Sub Type Description: </label></td>
                        <td><input type="text" readonly="true"  id="inventorySearchBySubTypeDescription" name="inventorySearchBySubTypeDescription"/></td><td><input type="button" value="Search" id="search" name="search" onclick="SearchProductSubType(350,180,document.getElementById('inventorySearchByDescription').value,document.getElementById('inventorySearchBySubTypeDescription').value)" /></td></tr>
                       </table>
                       <!--<label style=" font-family: Berlin Sans FB; font-weight:  normal;" >Enter Product Type: </label>
                        <input type="text" name="inventorySearchByType"/>
                        <tr><td><label style=" font-family: Berlin Sans FB; font-weight:  normal;" >Enter Product Description: </label></td>
                        <td><input type="text" name="inventorySearchByDescription"/></td></tr>
                        <tr><td><label style=" font-family: Berlin Sans FB; font-weight:  normal;" >Enter Product Sub Type: </label></td>
                        <td><input type="text" name="inventorySearchBySubType"/></td></tr>
                        <tr><td><label style=" font-family: Berlin Sans FB; font-weight:  normal;" >Enter Product Sub Type Description: </label></td>
                        <td><input type="text" name="inventorySearchBySubTypeDescription"/></td></tr>-->
                       <br/>
                        <input type="button"  value="Submit" onclick="javascript:searchProduct()" />
                        <input type="reset"  value="Clear" />
                    </center>
                    <br><br>
                </div>

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

                    <table>
                        <tbody>
                            <tr>
                                <td>Status:</td>
                                <td><select id="statusAmend" name="statusAmend">
                                        <option value="" disabled selected style="display:none;">--Select--</option>
                                        <option value="A" <%if (opdsProductCreationBean.getStatus().equals("A")) {%> selected <%}%>>Active</option>
                                        <option value="I" <%if (opdsProductCreationBean.getStatus().equals("I")) {%> selected <%}%>>Inactive</option>
                                    </select>
                                </td>
                            </tr>
                            <!--<tr>
                                <td>Product Name:</td>
                                <td><input type="text" name="productNameAmend" id="productNameAmend" value="<%=blankNull(opdsProductCreationBean.getProductName())%>" /></td>
                            </tr>
                            <tr>
                                <td>Product Code:</td>
                                <td><input type="text" name="productCodeAmend"  id="productCodeAmend" value="<%=blankNull(opdsProductCreationBean.getProductCode())%>" /></td>
                            </tr>
                            <tr>
                                <td>Quantity Unit:</td>
                                <td><select id="unitAmend" name="unitAmend">
                                        <option value="" disabled selected style="display:none;">--Select--</option>
                                        <option value="kg" <%if (opdsProductCreationBean.getUnit().equals("kg")) {%> selected <%}%>>K.g.</option>
                                        <option value="ltr" <%if (opdsProductCreationBean.getUnit().equals("ltr")) {%> selected <%}%>>Lt.</option>
                                        <option value="packet" <%if (opdsProductCreationBean.getUnit().equals("packet")) {%> selected <%}%>>Packets</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>Profit Factor (%):</td>
                                <td><input type="text" name="profitFactorAmend"  id="profitFactor" value="<%=blankNull(opdsProductCreationBean.getProfitFactor())%>" /></td>
                            </tr>-->
                            <tr>
                                <td>Product Type:</td>
                                <td><input type="text" readonly name="productTypeAmend" id="productTypeAmend" value="<%=blankNull(opdsProductCreationBean.getProductType())%>" onkeypress="return numbersonly(event)"/></td>
                            </tr>
                            <tr>
                                <td>Product Description:</td>
                                <td><input type="text" name="productDescriptionAmend"  id="productDescriptionAmend" value="<%=blankNull(opdsProductCreationBean.getProductDescription())%>" /></td>
                            </tr>
                            <tr>
                                <td>Product Sub Type:</td>
                                <td><input type="text" readonly name="productSubTypeAmend" id="productSubTypeAmend" value="<%=blankNull(opdsProductCreationBean.getProductSubType())%>" onkeypress="return numbersonly(event)"/></td>
                            </tr>
                            <tr>
                                <td>Product Sub Type Description:</td>
                                <td><input type="text" name="productSubTypeDescriptionAmend"  id="productSubTypeDescriptionAmend" value="<%=blankNull(opdsProductCreationBean.getProductSubTypeDescription())%>" /></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 (opdsProductCreationBean.getUnit().equals("1")) {%> selected <%}%>>K.g.</option>
                                        <option value="2" <%if (opdsProductCreationBean.getUnit().equals("2")) {%> selected <%}%>>Lt.</option>
                                        <option value="3" <%if (opdsProductCreationBean.getUnit().equals("3")) {%> selected <%}%>>Packets</option>
                                    </select>
                                </td>
                            </tr>

                            <tr><td><br></td></tr>
                            <tr><td><br></td></tr>

                        </tbody>
                    </table><br><br>

                    <br><br>
                    <input type="hidden" id="product_id" name="product_id" value="<%=blankNull(opdsProductCreationBean.getProduct_id())%>"/>
                    <center>
                        <input type="button" value="Update" onclick="javascript:updateform(pdsProductForm)">
                    </center>
                    <table>
                            <tr><td><br></td></tr>
                            <tr><td><br></td></tr>

                            <tr><td><label style=" font-family: Berlin Sans FB; font-weight:normal; ">All fields are mandatory</label></td></tr>
                            </tbody>
                        </table>

                </div>
                <% }%>


<input type="hidden" id="product_id_search" name="product_id_search" value=""/>
                <input type="hidden" name="handle_id" value="" />

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