<%--
    Document   : SellPurchaseAdjustment
    Created on : March 7, 2022, 3:16:34 PM
    Author     : 1242938
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="DataEntryBean.PaymentAcknowledgementBean"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="LoginDb.DbHandler"%>
<% try {
%>
<html>
    <head>
        <title>Sell Purchase Adjustment</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>

        <style>

            .dialog{
                border:5px solid #666;
                padding:10px;
                background:#FFFFFF;
                position:absolute;
                left: 300px;
                z-index:1;
                display:none;
            }
            .dialog label{
                display:inline-block;
                color:#151414;
            }
            div .dialog input[type=text]{
                border:1px solid #333;
                display:inline-block;
                margin:5px;
                width: 180px;

            }


        </style>

    </head>
    <script>        
        function ShowParent()
            {
                document.forms[0].action="${pageContext.request.contextPath}/Trading_JSP/SellPurchaseAdjustment.jsp";
                document.forms[0].submit();
            }

    </script>
    <body onload="noBack()">
        <script type="text/javascript">
            function noBack()
            {
                window.history.forward();
            }                        

            function submitform(PaymentAcknowledgementForm)
            {
                if (PaymentAcknowledgementForm.orderno.value == "")
                {
                    alert("Please search Purchase Order Number.");
                    PaymentAcknowledgementForm.orderno.focus();
                    return false;
                }
                
                    document.forms[0].handle_id.value = "purchase";
                    document.forms[0].action='/PacsApplication/SellPurchaseAdjustmentServlet';
                    PaymentAcknowledgementForm.submit();                
            }            

            function updateform(PaymentAcknowledgementForm)
            {
                if (PaymentAcknowledgementForm.salesrefno.value == "")
                {
                    alert("Please search Sales Reference Number.");
                    PaymentAcknowledgementForm.salesrefno.focus();
                    return false;
                }
                
                    document.forms[0].handle_id.value = "stock";
                    document.forms[0].action='/PacsApplication/SellPurchaseAdjustmentServlet';
                    PaymentAcknowledgementForm.submit();                
            }            
            
            function checkop()
            {
                if (document.getElementById("checkOption").value == "stock")
                {
                    document.getElementById('divstock').style.display = 'block';
                    document.getElementById('divpurchase').style.display = 'none';

                }
                if (document.getElementById("checkOption").value == "purchase")
                {
                    document.getElementById('divstock').style.display = 'none';
                    document.getElementById('divpurchase').style.display = 'block';

                }
            }
            
            function search1(width, height,purchaseNo) {

                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 = "SellPurchaseAdjustment.jsp";
                var lovKey = "searchPurchase"
                popWin = open('/PacsApplication/CommonSearchInformationTradingLOV.jsp?screenName=' + screenName + '&purchaseNo='+purchaseNo+ '&lovKey=' + lovKey, 'searchPurchase', attr);
                popWin.focus();

            }
            
            function search2(width, height,salesNo) {

                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 = "SellPurchaseAdjustment.jsp";
                var lovKey = "searchStock"
                popWin = open('/PacsApplication/CommonSearchInformationTradingLOV.jsp?screenName=' + screenName + '&salesNo='+salesNo+ '&lovKey=' + lovKey, 'searchStock', attr);
                popWin.focus();

            }

            $('body').on('keydown',':input.numeric[type="text"]', function() {
                if (event.shiftKey == true) {
                    event.preventDefault();
                }

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

                } else {
                    event.preventDefault();
                }

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

            });
            
            // to restrict back button
            history.pushState(null, null, location.href);
            window.addEventListener('popstate', function(event) {
                history.pushState(null, null, location.href);
            });
            
        </script>


        <%
             String displayFlag = "";
             Object display = request.getAttribute("displayFlag");
             if (display != null) {
                 displayFlag = display.toString();
             }
        %>
        <jsp:include page="MenuHead_TRADING.jsp" flush="true" />
        <br>
        <%!
            String blankNull(String s) {
                return (s == null) ? "" : s;
            }
        %>
        <%          int count = 1;
             String error_msg = "";
             Object error = request.getAttribute("message");
             if (error != null) {
                 error_msg = error.toString();
             }
        %>


        <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">Sell Purchase Adjustment</legend>
            <form name="PaymentAcknowledgementForm" method="post" action="">

                <%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="purchase" >Credit Purchase Item Rejection</option>
                        <option value="stock" >Credit Sell Item Back To Stock</option>
                    </select>
                    <br>
                    <br>
                    <div id="divpurchase" style="display:none;">

                        <table>
                            <tr>
                                <td></td>
                                <td>Enter Purchase Reference Number<font color="red" >*</font>:</td>
                                <td><input type="text" name="orderno" id="orderno" value="" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57'/></td>
                                <td><input type="button" value="Search"  onclick="javascript:search1(520,280,document.PaymentAcknowledgementForm.orderno.value)"></td>                                
                            </tr>
                            <tr><td colspan="5"><hr></td></tr>
                            <tr>
                                <td></td>
                                <td style="text-align:center ">Vendor Name: </td>
                                <td><input type="text" maxlength="30" name="vendorName" readonly id="vendorName"  /></td>
                            </tr>
                            <tr></tr><tr></tr>
                            <tr>
                                <td>Due Date:</td>
                                <td><input type="text" name="vduedate" readonly id="vduedate" style="text-align:center;" /></td>
                                <td style="text-align:center">Total Amount:</td>
                                <td><input type="text" name="vtotal" readonly id="vtotal" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57'/></td>
                            </tr>
                            <tr>
                                <td>Amount Paid:</td>
                                <td><input type="text" name="amountpaid" readonly id="amountpaid" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                                <td style="text-align:center">Due Amount:</td>
                                <td><input type="text" name="amountdue" readonly id="amountdue" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                            </tr>
                            <tr>
                                <td>CGST Rate:</td>
                                <td><input type="text" name="cgstv" readonly id="cgstv" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                                <td style="text-align:center">SGST Rate:</td>
                                <td><input type="text" name="sgstv" readonly id="sgstv" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                            </tr> 
                            
                            <tr><br></tr>
                            <tr>
                                <td></td>
                                <td></td>
                                <td><br><input type="button" name="makepayment" id="makepayment" value="Submit" onclick="submitform(PaymentAcknowledgementForm)"/>
                                <input type="reset" value="Reset" name="reset" onclick="ShowParent();"/></td>
                            </tr>
                        </table>
                    </div>

                    <div id="divstock" style="display:none;">

                        <table>
                            <br>
                            <tr>
                                <td></td>
                                <td>Enter Sell Reference Number<font color="red" >*</font>: </td>
                                <td> <input type="text" name="salesrefno" id="salesrefno" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57'/></td>
                                <td><input type="button"  value="Search" onclick="javascript:search2(620, 280, document.PaymentAcknowledgementForm.salesrefno.value)" /></td>
                            </tr>
                            <tr><td colspan="5"><hr></td></tr>
                            <tr>  
                                <td></td>                              
                                <td style="text-align:center">Customer Name: </td>
                                <td><input type="text" maxlength="30" name="customerName" readonly id="customerName"  /></td>
                                <td><input type="hidden" readonly id="prod" name="prod" /></td>
                            </tr>
                            <tr></tr><tr></tr>
                            <tr>
                                <td>Total Due Amount: </td>
                                <td><input type="text" name="totalDue" readonly id="totalDue" style="text-align:right;" /></td>
                                <td style="text-align:left">Due Date: </td>
                                <td><input type="text" name="dueDt" readonly id="dueDt" style="text-align:center" /></td>
                            </tr>
                            <tr>
                                <td>Product Total Amount: </td>
                                <td><input type="text" name="prodTotalAmt" readonly id="prodTotalAmt" style="text-align:right;" /></td>
                                <td style="text-align:left">Product Total Due: </td>
                                <td><input type="text" name="prodTotalDue" readonly id="prodTotalDue" style="text-align:right;" /></td>
                            </tr>
                            <tr>
                                <td>CGST Rate: </td>
                                <td><input type="text" name="cgstc" readonly id="cgstc" style="text-align:right;" /></td>
                                <td style="text-align:left">SGST Rate: </td>
                                <td><input type="text" name="sgstc" readonly id="sgstc" style="text-align:right;" /></td>
                            </tr>
                            
                            <tr>
                                <td></td>
                                <td></td>
                                <td><br><input type="button" name="receivepayment" id="receivepayment" value="Submit" onclick="updateform(PaymentAcknowledgementForm)"/>
                                <input type="reset" value="Reset" name="reset" onclick="ShowParent();"/></td>
                            </tr>
                        </table><br><br>

                    </div>
                    <input type="hidden" name="handle_id" id="handle_id" value="" />
                    <input type="hidden" name="prod_id" id="prod_id" value="" />
                    <input type="hidden" name="cust_id" id="cust_id" value="" />

                </center>
            </form>
        </fieldset>
    </body>
    <script>
        function check(v){
            if(isNaN(v) || v == '' || v.trim().length == 0){ return parseInt(0);}
            else { return v;}
        }

        //make all inputs whole numbers only
        $('.dialog').on('keydown',':input[type="text"]', 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 == 9 || event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 46) {

            } else {
                event.preventDefault();
            }
        });

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