<%--
    Document   : Leave Balance
    Created on : May 24, 2022, 1:00:00 PM
    Author     : 1242938
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="DataEntryBean.PayrollBean"%>
<%@page import="java.util.ArrayList"%>
<%@page import="LoginDb.DbHandler"%>
<% try {
%>

<html>

    <head>
        <title>Payroll BGL 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>

        <script>

            function noBack()
            {
                window.history.forward();                
            }
            function submitform(formPayroll)
            {
                if (checkDiv(formPayroll))
                {
                    document.forms[0].handle_id.value = "Create";
                    document.forms[0].action = '/PacsApplication/PayrollBglMasterServlet';
                    document.forms[0].submit();
                }
            }
            function amendform(formPayroll)
            { 
                if (checkDivAmend(formPayroll))
                {
                document.forms[0].handle_id.value = "Amend";
                document.forms[0].action = '/PacsApplication/PayrollBglMasterServlet';
                document.forms[0].submit();
                }
            }
            function getDetails(formPayroll)
            {
                document.forms[0].handle_id.value = "getDetails";
                document.forms[0].action = '/PacsApplication/PayrollBglMasterServlet';
                document.forms[0].submit();
            }

            function checkDiv(formPayroll)
            {
                var counter = document.forms[0].rowCounter.value; 
                
                for (var i = 1; i <= counter; i++) {
                    try{
                        var salaryGL = document.getElementById("salaryGL" + i).value;
                        var pTax = document.getElementById("pTax" + i).value;
                        var otherDeduct = document.getElementById("otherDeduct" + i).value;
                        var epfStaffCr = document.getElementById("epfStaffCr" + i).value;
                        var epfSocDr = document.getElementById("epfSocDr" + i).value;
                        var epfSocCr = document.getElementById("epfSocCr" + i).value;
                        
                        if (salaryGL == "" || pTax == "" || otherDeduct == "" || epfStaffCr == "" || epfSocDr == "" || epfSocCr == "") 
                        {
                            alert("Please enter all details.");
                            return false;
                        }                                                  
                    }
                    catch(e){}
                }                
                return true;
            } 
            function checkDivAmend(formPayroll)
            {
                var counter2 = document.forms[0].rowCounter2.value; 
                
                for (var i = 2; i < counter2; i++) {
                    try{
                        var salaryGL = document.getElementById("salaryGL" + i).value;
                        var pTax = document.getElementById("pTax" + i).value;
                        var otherDeduct = document.getElementById("otherDeduct" + i).value;
                        var epfStaffCr = document.getElementById("epfStaffCr" + i).value;
                        var epfSocDr = document.getElementById("epfSocDr" + i).value;
                        var epfSocCr = document.getElementById("epfSocCr" + i).value;
                        
                        if (salaryGL == "" || pTax == "" || otherDeduct == "" || epfStaffCr == "" || epfSocDr == "" || epfSocCr == "") 
                        {
                            alert("Please enter all details.");
                            return false;
                        }
                    }
                    catch(e){}
                }                
                return true;
            }
             
            function SearchSal(width, height, textIndex) 
            {
            if (window.innerWidth) {
                LeftPosition = (window.innerWidth - width) / 2;
                TopPosition = ((window.innerHeight - height) / 2) - 20;
            }
            else {
                LeftPosition = (parseInt(window.screen.width) - width) / 2;
                TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
            }
            attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
                height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
                TopPosition + '';
            //var salGL = document.getElementById("salaryGL"+textIndex).value;    
            var screenName = "PayrollBglMaster.jsp";
            var lovKey = "sal"
            popWin = open('${pageContext.request.contextPath}/CommonSearchInformationShgLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&salGL=' + salGL + '&textIndex=' + textIndex, 'sal', attr);
            popWin.focus();
            }
            function SearchTax(width, height, textIndex)
            {
                if (window.innerWidth) {
                    LeftPosition = (window.innerWidth - width) / 2;
                    TopPosition = ((window.innerHeight - height) / 2) - 20;
                }
                else {
                    LeftPosition = (parseInt(window.screen.width) - width) / 2;
                    TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
                }

                attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
                    height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
                    TopPosition + '';
               // var accNo = document.getElementById("pTax"+textIndex).value;
                var screenName = "PayrollBglMaster.jsp";
                var lovKey = "tax";

                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationShgLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo + '&textIndex=' + textIndex, 'AccountSearch', attr);
                popWin.focus();
            }
            function SearchOther(width, height, textIndex)
            {
                if (window.innerWidth) {
                    LeftPosition = (window.innerWidth - width) / 2;
                    TopPosition = ((window.innerHeight - height) / 2) - 20;
                }
                else {
                    LeftPosition = (parseInt(window.screen.width) - width) / 2;
                    TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
                }

                attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
                    height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
                    TopPosition + '';
                //var accNo = document.getElementById("otherDeduct"+textIndex).value;
                var screenName = "PayrollBglMaster.jsp";
                var lovKey = "other";

                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationShgLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo + '&textIndex=' + textIndex, 'AccountSearch', attr);
                popWin.focus();
            }
            function SearchESC(width, height, textIndex)
            {
                if (window.innerWidth) {
                    LeftPosition = (window.innerWidth - width) / 2;
                    TopPosition = ((window.innerHeight - height) / 2) - 20;
                }
                else {
                    LeftPosition = (parseInt(window.screen.width) - width) / 2;
                    TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
                }

                attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
                    height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
                    TopPosition + '';
               // var accNo = document.getElementById("epfStaffCr"+textIndex).value;
                var screenName = "PayrollBglMaster.jsp";
                var lovKey = "StaffCr";

                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationShgLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo + '&textIndex=' + textIndex, 'AccountSearch', attr);
                popWin.focus();
            }
            function SearchESD(width, height, textIndex)
            {
                if (window.innerWidth) {
                    LeftPosition = (window.innerWidth - width) / 2;
                    TopPosition = ((window.innerHeight - height) / 2) - 20;
                }
                else {
                    LeftPosition = (parseInt(window.screen.width) - width) / 2;
                    TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
                }

                attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
                    height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
                    TopPosition + '';
               // var accNo = document.getElementById("epfSocDr"+textIndex).value;
                var screenName = "PayrollBglMaster.jsp";
                var lovKey = "SocDr";

                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationShgLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo + '&textIndex=' + textIndex, 'AccountSearch', attr);
                popWin.focus();
            }
            function SearchESCC(width, height, textIndex)
            {
                if (window.innerWidth) {
                    LeftPosition = (window.innerWidth - width) / 2;
                    TopPosition = ((window.innerHeight - height) / 2) - 20;
                }
                else {
                    LeftPosition = (parseInt(window.screen.width) - width) / 2;
                    TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
                }

                attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
                    height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
                    TopPosition + '';
               // var accNo = document.getElementById("epfSocCr"+textIndex).value;
                var screenName = "PayrollBglMaster.jsp";
                var lovKey = "SocCr";

                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationShgLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo + '&textIndex=' + textIndex, 'AccountSearch', attr);
                popWin.focus();
            }
            
            function checkop()
            {                
                if (document.getElementById("checkOption").value == "create")
                {

                    document.getElementById('create').style.display = 'block';
                    document.getElementById('forAmend').style.display = 'none';
                    document.getElementById('amend').style.display = 'none';
                }
                if (document.getElementById("checkOption").value == "amend")
                {
                    document.getElementById('create').style.display = 'none';
                    document.getElementById('forAmend').style.display = 'block';
                }
            }
            // to restrict back button
            history.pushState(null, null, location.href);
            window.addEventListener('popstate', function(event) {
                history.pushState(null, null, location.href);
            });

        </script>        

    </head>
    <body onload="noBack()">

        <%          int count = 1;
                    String error_msg = "";
                    Object error = request.getAttribute("message");
                    if (error != null) {
                        error_msg = error.toString();
                    }
        %>
        <%!
            String blankNull(String s) {
                return (s == null) ? "" : s;
            }
        %>

        <%
                    Object oPayrollBeanObj = request.getAttribute("oPayrollBean");
                    Object alPayrollBeanObj = request.getAttribute("arrPayrollBean");

                    PayrollBean oPayrollBean = new PayrollBean();
                    if (oPayrollBeanObj != null) {
                        oPayrollBean = (PayrollBean) request.getAttribute("oPayrollBean");
                    }

                    ArrayList<PayrollBean> alPayrollBean = new ArrayList<PayrollBean>();
                    if (alPayrollBeanObj != null) {
                        alPayrollBean = (ArrayList<PayrollBean>) request.getAttribute("arrPayrollBean");
                    }
        %>

        <%
                    String displayFlag = "";
                    Object display = request.getAttribute("displayFlag");
                    if (display != null) {
                        displayFlag = display.toString();
                    }
                    
                    String userRole = (String) session.getAttribute("userRole");
                    
                    String checkOption = "";
                error = request.getAttribute("checkOption");
                if (error != null) {
                 checkOption = error.toString();
                }
        %>

        <jsp:include page="MenuHead_Payroll.jsp" flush="true" />
        <br>                    
        <fieldset style="border-color: black;  background-image: url('/PacsApplication/img/download.jpg'); border-width: 3px">

            <legend style="padding: 8px; border-radius: 20px; background-color: #006600; color: white">Payroll BGL Master</legend>

            <form id="formPayroll" name="formPayroll" method="post" action="PayrollBglMasterServlet">


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

                <center><label style=" font-family: Berlin Sans FB; font-weight:  normal;">Operation Selection:</label>
                    <select id="checkOption" onchange="checkop()" name="checkOption" >
                        <option value="" style="display:none;" >--Select--</option>                            
                            <option value="create" >Create</option>
                            <option value="amend" >Amend</option>
                    </select>                    
                </center>
                <br>
                <center>
                <div id="create" style="display:none;" >
                    <center>
                        <div style="overflow:scroll; width: 1300px">
                        <br><br>
                        <table id="order-list" style="margin-left: 20px;"  border="2" cellspacing="1" cellpadding="1" style="text-align: center ;overflow-y: scroll; font-size: 15px; width: 100%;">
                            <thead  class="CSSTableGenerator" >
                                <tr>
                                    <td></td>
                                    <td colspan="2">Salary GL (Debit)</td>
                                    <td colspan="2">PTax GL (Credit)</td>
                                    <td colspan="2">Other Deduction GL (Credit)</td>
                                    <td colspan="2">EPF Staff GL (Credit)</td>
                                    <td colspan="2">EPF Society GL (Debit)</td>
                                    <td colspan="2">EPF Society GL (Credit)</td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td><input type="checkbox" name="chckbox<%=count%>" id="chckbox<%=count%>" onclick="return checkboxTrue(<%=count%>)"/></td>
                                    <td><input type="text" name="salaryGL<%=count%>" id="salaryGL<%=count%>" ondrop="return false;" onpaste="return false;" /></td>  
                                    <td><input type="button" style="width: 70px" name="SearchSal<%=count%>" id="SearchSal<%=count%>" value="Search" onclick="javascript:SearchSal(550,240,<%=count%>);" /></td>
                                    <td><input size="20" type="text" name="pTax<%=count%>" id="pTax<%=count%>" ondrop="return false;" onpaste="return false;" /></td>  
                                    <td><input type="button" style="width: 70px" name="SearchTax<%=count%>" id="SearchTax<%=count%>" value="Search" onclick="javascript:SearchTax(550,240,<%=count%>);"/></td>
                                    <td><input size="20" type="text" name="otherDeduct<%=count%>" id="otherDeduct<%=count%>" ondrop="return false;" onpaste="return false;" /></td>  
                                    <td><input type="button" style="width: 70px" name="SearchOther<%=count%>" id="SearchOther<%=count%>" value="Search" onclick="javascript:SearchOther(550,240,<%=count%>);" /></td>
                                    <td><input size="20" type="text" name="epfStaffCr<%=count%>" id="epfStaffCr<%=count%>" ondrop="return false;" onpaste="return false;" /></td>  
                                    <td><input type="button" style="width: 70px" name="SearchESC<%=count%>" id="SearchESC<%=count%>" value="Search" onclick="javascript:SearchESC(550,240,<%=count%>);" /></td>
                                    <td><input size="20" type="text" name="epfSocDr<%=count%>" id="epfSocDr<%=count%>" ondrop="return false;" onpaste="return false;" /></td>  
                                    <td><input type="button" style="width: 70px" name="SearchESD<%=count%>" id="SearchESD<%=count%>" value="Search" onclick="javascript:SearchESD(550,240,<%=count%>);" /></td>
                                    <td><input size="20" type="text" name="epfSocCr<%=count%>" id="epfSocCr<%=count%>" ondrop="return false;" onpaste="return false;" /></td>  
                                    <td><input type="button" style="width: 70px" name="SearchESCC<%=count%>" id="SearchESCC<%=count%>" value="Search" onclick="javascript:SearchESCC(550,240,<%=count%>);" /></td>
                                    <td style="display: none"><input type="hidden" name="glid<%=count%>" id="glid<%=count%>" ></td>
                                    <td style="display: none"><input type="hidden" name="taxid<%=count%>" id="taxid<%=count%>" ></td>
                                    <td style="display: none"><input type="hidden" name="otherid<%=count%>" id="otherid<%=count%>" ></td>
                                    <td style="display: none"><input type="hidden" name="staffcrid<%=count%>" id="staffcrid<%=count%>" ></td>
                                    <td style="display: none"><input type="hidden" name="socdrid<%=count%>" id="socdrid<%=count%>" ></td>
                                    <td style="display: none"><input type="hidden" name="soccrid<%=count%>" id="soccrid<%=count%>" ></td>
                                    <td style="display: none"><input type="hidden" name="id<%=count%>" id="id<%=count%>" ></td>
                                </tr>
                            </tbody>
                        </table>  
                        </div>        
                        <br/><br/>
                        <center>
<!--                            <input type="button" id="addRow" value="Add Row"/>
                            <input type="button" id="deleteRow" value="Delete Row"/>-->
                            <input type="button" value="Submit" onmouseover="calDays(formPayroll)" onclick="javascript:submitform(formPayroll)"/>
                            <input type="button" value="Reset" onclick="ShowParent();" />

                        </center>
                        <input type="hidden" name="rowCounter" id="rowCounter" value="<%=count%>">
                        <input type="hidden" name="chkboxCounter" id="chkboxCounter" value="0">
                    </center>
                </div>
               </center> 
                        <br>        
                <center>        
                <div id="forAmend" style="display:none;" >    
                                        
                    <center>    
                    <tr><input type="button" value="Fetch Payroll BGL Master Details" onclick="javascript:getDetails()" /></tr>
                    <input type="button" value="Reset" onclick="ShowParent();" />    
                    </center>                         
                </div>        
                <br>
                </center>
                <%if (displayFlag.equalsIgnoreCase("Y")) {%>
                <div id="amend" >
                    <center>  
                    <div style="overflow:scroll; width: 1300px">    
                    <table id="order-listAmend" style="overflow-y: scroll">
                        <thead  class="CSSTableGenerator" >
                            <tr>
                                <td colspan="2">Salary GL (Debit)</td>
                                <td colspan="2">PTax GL (Credit)</td>
                                <td colspan="2">Other Deduction GL (Credit)</td>
                                <td colspan="2">EPF Staff GL (Credit)</td>
                                <td colspan="2">EPF Society GL (Debit)</td>
                                <td colspan="2">EPF Society GL (Credit)</td>
                            </tr>
                        </thead>
                        <tbody style="background-color: white; font-size: 15px">
                            <%
                                oPayrollBean = null;
                                oPayrollBean = new PayrollBean();
                                int count2= 1;

                                for (int i = 0; i < alPayrollBean.size(); i++) {
                                    oPayrollBean = alPayrollBean.get(i);
                                    count2++;
                            %>
                            <tr>
                                <td><input size="20" type="text" name="salaryGL<%=count2%>" id="salaryGL<%=count2%>" ondrop="return false;" onpaste="return false;" value="<%=blankNull(oPayrollBean.getSalaryGL())%>"/></td>  
                                    <td><input type="button" style="width: 70px" name="SearchSal<%=count2%>" id="SearchSal<%=count2%>" value="Search" onclick="javascript:SearchSal(550,240,<%=count2%>);" /></td>
                                    <td><input size="20" type="text" name="pTax<%=count2%>" id="pTax<%=count2%>" ondrop="return false;" onpaste="return false;" value="<%=blankNull(oPayrollBean.getpTax())%>"/></td>  
                                    <td><input type="button" style="width: 70px" name="SearchTax<%=count2%>" id="SearchTax<%=count2%>" value="Search" onclick="javascript:SearchTax(550,240,<%=count2%>);" /></td>
                                    <td><input size="20" type="text" name="otherDeduct<%=count2%>" id="otherDeduct<%=count2%>" ondrop="return false;" onpaste="return false;" value="<%=blankNull(oPayrollBean.getOtherDeduct())%>" /></td>  
                                    <td><input type="button" style="width: 70px" name="SearchOther<%=count2%>" id="SearchOther<%=count2%>" value="Search" onclick="javascript:SearchOther(550,240,<%=count2%>);" /></td>
                                    <td><input size="20" type="text" name="epfStaffCr<%=count2%>" id="epfStaffCr<%=count2%>" ondrop="return false;" onpaste="return false;" value="<%=blankNull(oPayrollBean.getEpfStaffCr())%>" /></td>  
                                    <td><input type="button" style="width: 70px" name="SearchESC<%=count2%>" id="SearchESC<%=count2%>" value="Search" onclick="javascript:SearchESC(550,240,<%=count2%>);" /></td>
                                    <td><input size="20" type="text" name="epfSocDr<%=count2%>" id="epfSocDr<%=count2%>" ondrop="return false;" onpaste="return false;" value="<%=blankNull(oPayrollBean.getEpfSocDr())%>"/></td>  
                                    <td><input type="button" style="width: 70px" name="SearchESD<%=count2%>" id="SearchESD<%=count2%>" value="Search" onclick="javascript:SearchESD(550,240,<%=count2%>);" /></td>
                                    <td><input size="20" type="text" name="epfSocCr<%=count2%>" id="epfSocCr<%=count2%>" ondrop="return false;" onpaste="return false;" value="<%=blankNull(oPayrollBean.getEpfSocCr())%>"/></td>  
                                    <td><input type="button" style="width: 70px" name="SearchESCC<%=count2%>" id="SearchESCC<%=count2%>" value="Search" onclick="javascript:SearchESCC(550,240,<%=count2%>);" /></td>
                                    <td style="display:none"><input type="hidden" name="glid<%=count2%>" id="glid<%=count2%>" value="<%=blankNull(oPayrollBean.getGlid())%>"></td>
                                    <td style="display:none"><input type="hidden" name="taxid<%=count2%>" id="taxid<%=count2%>" value="<%=blankNull(oPayrollBean.getTaxid())%>"></td>
                                    <td style="display:none"><input type="hidden" name="otherid<%=count2%>" id="otherid<%=count2%>" value="<%=blankNull(oPayrollBean.getOtherid())%>"></td>
                                    <td style="display:none"><input type="hidden" name="staffcrid<%=count2%>" id="staffcrid<%=count2%>" value="<%=blankNull(oPayrollBean.getStaffcrid())%>"></td>
                                    <td style="display:none"><input type="hidden" name="socdrid<%=count2%>" id="socdrid<%=count2%>" value="<%=blankNull(oPayrollBean.getSocdrid())%>"></td>
                                    <td style="display:none"><input type="hidden" name="soccrid<%=count2%>" id="soccrid<%=count2%>" value="<%=blankNull(oPayrollBean.getSoccrid())%>"></td>
                                    <td style="display:none"><input type="hidden" name="id<%=count2%>" id="id<%=count2%>" value="<%=blankNull(oPayrollBean.getId())%>"></td>
                            </tr>

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

                $("#addRow").click(function () {

                   // var counter = $("#rowCounter").val();
                    ++counter;
                    $('#order-list tr:last').after('<tr> <td align="center"><input type="checkbox" name="chckbox' + counter + '" id="chckbox' + counter + '" onclick="return checkboxTrue('+counter+')"/></td>\n\
                                    <td><input type="text" name="salaryGL' + counter + '" id="salaryGL' + counter + '" ondrop="return false;" onpaste="return false;" /></td>\n\
                                    <td><input type="button" style="width: 70px" name="SearchSal' + counter + '" id="SearchSal' + counter + '" value="Search" onclick="javascript:SearchSal(550,240,' + counter + ');" /></td>\n\
                                    <td><input size="20" type="text" name="pTax' + counter + '" id="pTax' + counter + '" ondrop="return false;" onpaste="return false;" /></td>\n\
                                    <td><input type="button" style="width: 70px" name="SearchTax' + counter + '" id="SearchTax' + counter + '" value="Search" onclick="javascript:SearchTax(550,240,' + counter + ');" /></td>\n\
                                    <td><input size="20" type="text" name="otherDeduct' + counter + '" id="otherDeduct' + counter + '" ondrop="return false;" onpaste="return false;" /></td>\n\
                                    <td><input type="button" style="width: 70px" name="SearchOther' + counter + '" id="SearchOther' + counter + '" value="Search" onclick="javascript:SearchOther(550,240,' + counter + ');" /></td>\n\
                                    <td><input size="20" type="text" name="epfStaffCr' + counter + '" id="epfStaffCr' + counter + '" ondrop="return false;" onpaste="return false;" /></td>\n\
                                    <td><input type="button" style="width: 70px" name="SearchESC' + counter + '" id="SearchESC' + counter + '" value="Search" onclick="javascript:SearchESC(550,240,' + counter + ');" /></td>\n\
                                    <td><input size="20" type="text" name="epfSocDr' + counter + '" id="epfSocDr' + counter + '" ondrop="return false;" onpaste="return false;" /></td>\n\
                                    <td><input type="button" style="width: 70px" name="SearchESD' + counter + '" id="SearchESD' + counter + '" value="Search" onclick="javascript:SearchESD(550,240,' + counter + ');" /></td>\n\
                                    <td><input size="20" type="text" name="epfSocCr' + counter + '" id="epfSocCr' + counter + '" ondrop="return false;" onpaste="return false;" /></td>\n\
                                    <td><input type="button" style="width: 70px" name="SearchESCC' + counter + '" id="SearchESCC' + counter + '" value="Search" onclick="javascript:SearchESCC(550,240,' + counter + ');" /></td>\n\
                                    <td style="display: none"><input type="hidden" name="glid' + counter + '" id="glid' + counter + '"/></td>\n\
                                    <td style="display: none"><input type="hidden" name="taxid' + counter + '" id="taxid' + counter + '"/></td>\n\
                                    <td style="display: none"><input type="hidden" name="otherid' + counter + '" id="otherid' + counter + '"/></td>\n\
                                    <td style="display: none"><input type="hidden" name="staffcrid' + counter + '" id="staffcrid' + counter + '"/></td>\n\
                                    <td style="display: none"><input type="hidden" name="socdrid' + counter + '" id="socdrid' + counter + '"/></td>\n\
                                    <td style="display: none"><input type="hidden" name="soccrid' + counter + '" id="soccrid' + counter + '"/></td>\n\
                                    <td style="display: none"><input type="hidden" name="id' + counter + '" id="id' + counter + '"/></td>\n\
                        </tr>');
                    $("#rowCounter").val(counter);
                });
                $( "#deleteRow" ).click(function() {

                    var len = ($("#order-list tr").length)-1;
                    var counter = $("#rowCounter").val();
                    var chkboxCounter=$("#chkboxCounter").val();
                    //alert(chkboxCounter);
                    counter=counter-chkboxCounter;
                    // alert(counter);
                    if (counter==0){

                        alert("All rows cannot be deleted");
                    }
                    else{
                        if (len ==chkboxCounter) {
                            alert("All rows can not be deleted");
                            return false;
                        }

                        $('input:checkbox:checked').closest('tr').remove();
                        chkboxCounter=0;
                        $("#chkboxCounter").val(chkboxCounter);
                    }
                });

                function checkboxTrue(i){

                    if(document.getElementById("chckbox"+i).checked==true)
                    {
                        var counter = $("#chkboxCounter").val();
                        counter++;
                        $("#chkboxCounter").val(counter);
                    }
                    else{
                        var counter = $("#chkboxCounter").val();
                        counter--;
                        $("#chkboxCounter").val(counter);
                    }
                }
                function ShowParent()
                {
                    document.forms[0].action = "${pageContext.request.contextPath}/Payroll/PayrollBglMaster.jsp";
                    document.forms[0].submit();
                }

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