<%--
    Document   : EmployeeMaster
    Created on : March 31, 2022, 6: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>Employee 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(); 
                calDaAmt2(formPayroll);
            }
            
            function submitform(formPayroll)
            {
              if (checkDiv(formPayroll))
                {
                    document.forms[0].handle_id.value = "Create";
                    document.forms[0].action = '/PacsApplication/EmployeeMasterServlet';
                    document.forms[0].submit();
                }
            }
            function amendform(formPayroll)
            { 
                if (checkDivAmend(formPayroll))
                {
                document.forms[0].handle_id.value = "Amend";
                document.forms[0].action = '/PacsApplication/EmployeeMasterServlet';
                document.forms[0].submit();
                }
            }
            function getDetails(formPayroll)
            {
                document.forms[0].handle_id.value = "getDetails";
                document.forms[0].action = '/PacsApplication/EmployeeMasterServlet';
                document.forms[0].submit();
            }

            function checkDiv(formPayroll)
            {
                var counter = document.forms[0].rowCounter.value; 
                
                for (var i = 1; i <= counter; i++) {
                    try{
                        var employee = document.getElementById("employee" + i).value;
                        var JD = document.getElementById("joinDate" + i).value;
                        var CD = document.getElementById("confirmDate" + i).value;
                        var RD = document.getElementById("retireDate" + i).value;
                        var basic = document.getElementById("basicAmt" + i).value;
                        var daRt = document.getElementById("daRate" + i).value;
                        var msaAmt = document.getElementById("msaAmt" + i).value;
                        var epfStaffRate = document.getElementById("epfStaffRate" + i).value;
                        var epfSocRate = document.getElementById("epfSocRate" + i).value;
                        var taxAmt = document.getElementById("taxAmt" + i).value;
                        var otherAmt = document.getElementById("otherAmt" + i).value;
                        var status = document.getElementById("status" + i).value;
                        var netP = document.getElementById("netPay" + i).value;
//                        var arr = JD.split("/");
//                        var arr2 = CD.split("/");
//                        var arr3 = RD.split("/");
//                        var dat1 = (arr[1] + "/" + arr[0] + "/" + arr[2]);
//                        var dat2 = (arr2[1] + "/" + arr2[0] + "/" + arr2[2]);
//                        var dat3 = (arr3[1] + "/" + arr3[0] + "/" + arr3[2]);
//                        var d1 = new Date(dat1);
//                        var d2 = new Date(dat2);
//                        var d3 = new Date(dat3);
                        
                        if (employee == "" || JD == "" || CD == "" || RD == "" || basic == "" || daRt == "" || msaAmt == "" || 
                                epfStaffRate == "" || epfSocRate == "" || taxAmt == "" || otherAmt == "" || status == "" ) 
                        {
                            alert("Please enter all fields.");
                            return false;
                        }
//                        if(d1>=d2) {
//                            alert("Joining Date should be older than Confirm Date");
//                            return false;
//                        }
//                        if(d2>=d3) {
//                            alert("Confirm Date should be older than Retire Date");
//                            return false;
//                        }
                        if(epfStaffRate != epfSocRate) {
                            alert("EPF Staff Rate and EPF Society Rate should be same");
                            return false;
                        }
                        if( netP<=0 ) {
                            alert("Net Pay should be valid");
                            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 employee = document.getElementById("employee" + i).value;
                        var JD = document.getElementById("joinDate" + i).value;
                        var CD = document.getElementById("confirmDate" + i).value;
                        var RD = document.getElementById("retireDate" + i).value;
                        var basic = document.getElementById("basicAmt" + i).value;
                        var daRt = document.getElementById("daRate" + i).value;
                        var msaAmt = document.getElementById("msaAmt" + i).value;
                        var epfStaffRate = document.getElementById("epfStaffRate" + i).value;
                        var epfSocRate = document.getElementById("epfSocRate" + i).value;
                        var taxAmt = document.getElementById("taxAmt" + i).value;
                        var otherAmt = document.getElementById("otherAmt" + i).value;
                        var status = document.getElementById("status" + i).value;
                        var netP = document.getElementById("netPay" + i).value;
//                        var arr = JD.split("/");
//                        var arr2 = CD.split("/");
//                        var arr3 = RD.split("/");
//                        var dat1 = (arr[1] + "/" + arr[0] + "/" + arr[2]);
//                        var dat2 = (arr2[1] + "/" + arr2[0] + "/" + arr2[2]);
//                        var dat3 = (arr3[1] + "/" + arr3[0] + "/" + arr3[2]);
//                        var d1 = new Date(dat1);
//                        var d2 = new Date(dat2);
//                        var d3 = new Date(dat3);
                        
                        if (employee == "" || JD == "" || CD == "" || RD == "" || basic == "" || daRt == "" || msaAmt == "" || 
                                epfStaffRate == "" || epfSocRate == "" || taxAmt == "" || otherAmt == "" || status == "" ) 
                        {
                            alert("Please enter all fields.");
                            return false;
                        }
//                        if(d1>=d2) {
//                            alert("Joining Date should be older than Confirm Date");
//                            return false;
//                        }
//                        if(d2>=d3) {
//                            alert("Confirm Date should be older than Retire Date");
//                            return false;
//                        }
                        if(epfStaffRate != epfSocRate) {
                            alert("EPF Staff Rate and EPF Society Rate should be same");
                            return false;
                        }
                        if( netP<=0 ) {
                            alert("Net Pay should be valid");
                            return false;
                        }
                    }
                    catch(e){}
                }                
                return true;
            }

            function checkop()
            {                
                if (document.getElementById("checkOption").value == "create")
                {

                    document.getElementById('create').style.display = 'block';
                    document.getElementById('forAmend').style.display = 'none';
                    document.getElementById('amend').style.display = 'none';
                }
                if (document.getElementById("checkOption").value == "amend")
                {
                    document.getElementById('create').style.display = 'none';
                    document.getElementById('forAmend').style.display = 'block';
                }
            } 
            function SearchCIF(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("cif"+textIndex).value;
                var screenName = "EmployeeMaster.jsp";
                var lovKey = "PickUPCustomer";

                popWin = open('${pageContext.request.contextPath}/CommonSearchInfoLOVNew.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo + '&textIndex=' + textIndex, 'AccountSearch', attr);
                popWin.focus();
            }
            function SearchSalAcc(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("cif"+textIndex).value;
                var screenName = "EmployeeMaster.jsp";
                var lovKey = "PickUPSalary";

                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationShgLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo + '&textIndex=' + textIndex, 'AccountSearch', attr);
                popWin.focus();
            }
            function SearchDesgCode(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("cif"+textIndex).value;
                var screenName = "EmployeeMaster.jsp";
                var lovKey = "PickUPDesgCode";

                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationShgLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo + '&textIndex=' + textIndex, 'AccountSearch', attr);
                popWin.focus();
            }
            function SearchGradeCode(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("cif"+textIndex).value;
                var screenName = "EmployeeMaster.jsp";
                var lovKey = "PickUPGradeCode";

                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationShgLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo + '&textIndex=' + textIndex, 'AccountSearch', attr);
                popWin.focus();
            }
            function calDaAmt(formPayroll) 
            {
                var counter = document.forms[0].rowCounter.value;
                
                for (var i = 1; i <= counter; i++) {    
                    var basic = document.getElementById("basicAmt" + i).value;
                    var dart = document.getElementById("daRate" + i).value;
                    
                    var numStr = String(dart);
                    if(numStr.includes('.')){
                        var len =  numStr.split('.')[1].length;                                            
                        if (len>2) {
                            alert("DA Rate is allowed upto two decimals.");
                            document.getElementById("daRate" + i).value = (parseFloat(dart)).toFixed(2);
                            return false;
                        }
                    }
                    var basic1 = parseFloat(basic);
                    var dart1 = parseFloat(dart);
                    var daAm = ((basic1*dart1)/100);                    
                    document.getElementById("daAmt" + i).value = (parseFloat(daAm)).toFixed(0);
                }
                calGross();
            }
            function calGross(formPayroll) 
            {
                var counter = document.forms[0].rowCounter.value;
                
                for (var i = 1; i <= counter; i++) {    
                    var basic = document.getElementById("basicAmt" + i).value;
                    var da = document.getElementById("daAmt" + i).value;
                    var msa = document.getElementById("msaAmt" + i).value;
                    
                    var numStr = String(basic);
                    if(numStr.includes('.')){
                        var len =  numStr.split('.')[1].length;                                            
                        if (len>0) {
                            alert("Basic Amt does not allow decimals.");
                            document.getElementById("basicAmt" + i).value = (parseFloat(basic)).toFixed(0);
                            return false;
                        }
                    }
                    var numStr2 = String(msa);
                    if(numStr2.includes('.')){
                        var len2 =  numStr2.split('.')[1].length;                                            
                        if (len2>0) {
                            alert("MSA Amt does not allow decimals.");
                            document.getElementById("msaAmt" + i).value = (parseFloat(msa)).toFixed(0);
                            return false;
                        }
                    }
                    var basic1 = parseFloat(basic);
                    var da1 = parseFloat(da);
                    var msa1 = parseFloat(msa);
                    
                    var gross = (basic1+da1+msa1);

                    document.getElementById("grossAmt" + i).value = (parseFloat(gross)).toFixed(0);
                }
                calStaffAmt();
                calSocAmt();
                calNetPay();
            }
            function calStaffAmt(formPayroll) 
            {
                var counter = document.forms[0].rowCounter.value;
                
                for (var i = 1; i <= counter; i++) {    
                    var basicAmt = document.getElementById("basicAmt" + i).value;
                    var rate = document.getElementById("epfStaffRate" + i).value;
                    
                    var numStr = String(rate);
                    if(numStr.includes('.')){
                        var len =  numStr.split('.')[1].length;                                            
                        if (len>2) {
                            alert("EPF Staff Rate is allowed upto two decimals.");
                            document.getElementById("epfStaffRate" + i).value = (parseFloat(rate)).toFixed(2);
                            return false;
                        }
                    }
                    var amt1 = parseFloat(basicAmt);
                    var rate1 = parseFloat(rate);                    
                    var amt = ((amt1*rate1)/100);

                    document.getElementById("epfStaffAmt" + i).value = (parseFloat(amt)).toFixed(0);
                }
                calTotalEpf();
            }
            function calSocAmt(formPayroll) 
            {
                var counter = document.forms[0].rowCounter.value;
                
                for (var i = 1; i <= counter; i++) {    
                    var basicAmt = document.getElementById("basicAmt" + i).value;
                    var rate = document.getElementById("epfSocRate" + i).value;
                    
                    var numStr = String(rate);
                    if(numStr.includes('.')){
                        var len =  numStr.split('.')[1].length;                                            
                        if (len>2) {
                            alert("EPF SOC Rate is allowed upto two decimals.");
                            document.getElementById("epfSocRate" + i).value = (parseFloat(rate)).toFixed(2);
                            return false;
                        }
                    }
                    var amt1 = parseFloat(basicAmt);
                    var rate1 = parseFloat(rate);                    
                    var amt = ((amt1*rate1)/100);

                    document.getElementById("epfSocAmt" + i).value = (parseFloat(amt)).toFixed(0);
                } 
                calTotalEpf();
            }
            function calTotalEpf(formPayroll) 
            {
                var counter = document.forms[0].rowCounter.value;
                
                for (var i = 1; i <= counter; i++) {    
                    var samt = document.getElementById("epfStaffAmt" + i).value;
                    var camt = document.getElementById("epfSocAmt" + i).value;
                    var samt1 = parseFloat(samt);
                    var camt1 = parseFloat(camt);                    
                    var tot = (samt1+camt1);
                    document.getElementById("totalEPF" + i).value = tot.toFixed(2);
                }
            }
            function calNetPay(formPayroll) 
            {   
                var counter = document.forms[0].rowCounter.value;
                
                for (var i = 1; i <= counter; i++) {    
                    var gamt = document.getElementById("grossAmt" + i).value;
                    var samt = document.getElementById("epfStaffAmt" + i).value;
                    var tax = document.getElementById("taxAmt" + i).value;
                    var other = document.getElementById("otherAmt" + i).value;
                    
                    var numStr = String(tax);
                    if(numStr.includes('.')){
                        var len =  numStr.split('.')[1].length;                                            
                        if (len>0) {
                            alert("P.Tax Amt does not allow decimals.");
                            document.getElementById("taxAmt" + i).value = (parseFloat(tax)).toFixed(0);
                            return false;
                        }
                    }
                    var numStr2 = String(other);
                    if(numStr2.includes('.')){
                        var len2 =  numStr2.split('.')[1].length;                                            
                        if (len2>0) {
                            alert("Other Deduction Amt does not allow decimals.");
                            document.getElementById("otherAmt" + i).value = (parseFloat(other)).toFixed(0);
                            return false;
                        }
                    }
                    var g = parseFloat(gamt);
                    var s = parseFloat(samt);
                    var t = parseFloat(tax);
                    var o = parseFloat(other);
                                        
                    var net = (g-(s+t+o));
                    document.getElementById("netPay" + i).value = net.toFixed(2);
                }    
            }            
            // Calculation for Amend
            
            function calDaAmt2(formPayroll) 
            { 
                var counter2 = document.forms[0].rowCounter2.value;
                
                for (var i = 1; i <= counter2; i++) {    
                    var basic = document.getElementById("basicAmt" + i).value;
                    var dart = document.getElementById("daRate" + i).value;
                    
                    var numStr = String(dart);
                    if(numStr.includes('.')){
                        var len =  numStr.split('.')[1].length;                                            
                        if (len>2) {
                            alert("DA Rate is allowed upto two decimals.");
                            document.getElementById("daRate" + i).value = (parseFloat(dart)).toFixed(2);
                            return false;
                        }
                    }                   
                    var basic1 = parseFloat(basic);
                    var dart1 = parseFloat(dart);
                    var daAm = ((basic1*dart1)/100);                    
                    document.getElementById("daAmt" + i).value = (parseFloat(daAm)).toFixed(0);
                }
                calGross2();
            }
            function calGross2(formPayroll) 
            { 
                var counter2 = document.forms[0].rowCounter2.value;
                
                for (var i = 1; i <= counter2; i++) {    
                    var basic = document.getElementById("basicAmt" + i).value;
                    var da = document.getElementById("daAmt" + i).value;
                    var msa = document.getElementById("msaAmt" + i).value;

                    var numStr = String(basic);
                    if(numStr.includes('.')){
                        var len =  numStr.split('.')[1].length;                                            
                        if (len>0) {
                            alert("Basic Amt does not allow decimals.");
                            document.getElementById("basicAmt" + i).value = (parseFloat(basic)).toFixed(0);
                            return false;
                        }
                    }
                    var numStr2 = String(msa);
                    if(numStr2.includes('.')){
                        var len2 =  numStr2.split('.')[1].length;                                            
                        if (len2>0) {
                            alert("MSA Amt does not allow decimals.");
                            document.getElementById("msaAmt" + i).value = (parseFloat(msa)).toFixed(0);
                            return false;
                        }
                    }
                    var basic1 = parseFloat(basic);
                    var da1 = parseFloat(da);
                    var msa1 = parseFloat(msa);
                    
                    var gross = (basic1+da1+msa1);

                    document.getElementById("grossAmt" + i).value = gross.toFixed(2);
                }
                calStaffAmt2();
                calSocAmt2();
                calNetPay2();
            }
            function calStaffAmt2(formPayroll) 
            { 
                var counter2 = document.forms[0].rowCounter2.value;
                
                for (var i = 1; i <= counter2; i++) {    
                    var basicAmt = document.getElementById("basicAmt" + i).value;
                    var rate = document.getElementById("epfStaffRate" + i).value;
                    
                    var numStr = String(rate);
                    if(numStr.includes('.')){
                        var len =  numStr.split('.')[1].length;                                            
                        if (len>2) {
                            alert("EPF Staff Rate is allowed upto two decimals.");
                            document.getElementById("epfStaffRate" + i).value = (parseFloat(rate)).toFixed(2);
                            return false;
                        }
                    }
                    var amt1 = parseFloat(basicAmt);
                    var rate1 = parseFloat(rate);                    
                    var amt = ((amt1*rate1)/100);

                    document.getElementById("epfStaffAmt" + i).value = (parseFloat(amt)).toFixed(0);
                }
                calTotalEpf2();
            }
            function calSocAmt2(formPayroll) 
            {
                var counter2 = document.forms[0].rowCounter2.value;
                
                for (var i = 1; i <= counter2; i++) {    
                    var basicAmt = document.getElementById("basicAmt" + i).value;
                    var rate = document.getElementById("epfSocRate" + i).value;
                    
                    var numStr = String(rate);
                    if(numStr.includes('.')){
                        var len =  numStr.split('.')[1].length;                                            
                        if (len>2) {
                            alert("EPF SOC Rate is allowed upto two decimals.");
                            document.getElementById("epfSocRate" + i).value = (parseFloat(rate)).toFixed(2);
                            return false;
                        }
                    }
                    var amt1 = parseFloat(basicAmt);
                    var rate1 = parseFloat(rate);                    
                    var amt = ((amt1*rate1)/100);

                    document.getElementById("epfSocAmt" + i).value = (parseFloat(amt)).toFixed(0);
                } 
                calTotalEpf2();
            }
            function calTotalEpf2(formPayroll) 
            {
                var counter2 = document.forms[0].rowCounter2.value;
                
                for (var i = 1; i <= counter2; i++) {    
                    var samt = document.getElementById("epfStaffAmt" + i).value;
                    var camt = document.getElementById("epfSocAmt" + i).value;
                    var samt1 = parseFloat(samt);
                    var camt1 = parseFloat(camt);                    
                    var tot = (samt1+camt1);
                    document.getElementById("totalEPF" + i).value = tot.toFixed(2);
                }
            }
            function calNetPay2(formPayroll) 
            {   
                var counter2 = document.forms[0].rowCounter2.value;
                
                for (var i = 1; i <= counter2; i++) {    
                    var gamt = document.getElementById("grossAmt" + i).value;
                    var samt = document.getElementById("epfStaffAmt" + i).value;
                    var tax = document.getElementById("taxAmt" + i).value;
                    var other = document.getElementById("otherAmt" + i).value;
                    
                    var numStr = String(tax);
                    if(numStr.includes('.')){
                        var len =  numStr.split('.')[1].length;                                            
                        if (len>0) {
                            alert("P.Tax Amt does not allow decimals.");
                            document.getElementById("taxAmt" + i).value = (parseFloat(tax)).toFixed(0);
                            return false;
                        }
                    }
                    var numStr2 = String(other);
                    if(numStr2.includes('.')){
                        var len2 =  numStr2.split('.')[1].length;                                            
                        if (len2>0) {
                            alert("Other Deduction Amt does not allow decimals.");
                            document.getElementById("otherAmt" + i).value = (parseFloat(other)).toFixed(0);
                            return false;
                        }
                    }
                    var g = parseFloat(gamt);
                    var s = parseFloat(samt);
                    var t = parseFloat(tax);
                    var o = parseFloat(other);
                                        
                    var net = (g-(s+t+o));
                    document.getElementById("netPay" + i).value = net.toFixed(2);
                }    
            }
            // 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">Employee Master</legend>

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

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

                <center><label style=" font-family: Berlin Sans FB; font-weight:  normal;">Operation Selection:</label>
                    <select id="checkOption" onchange="checkop()" name="checkOption" >
                        <option value="" style="display:none;" >--Select--</option>                            
                            <option value="create" >Create</option>
                            <option value="amend" >Amend</option>
                    </select>                    
                </center>
                <br>
            <div id ="create" style="display:none;" >
            <center>     
                <div style="overflow:scroll; width: 1300px">
                <center>
                        <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>Employee ID</td>
                                    <td colspan="2">CIF No</td>
                                    <td>Employee Name</td>
                                    <td colspan="2">Joining Date</td>
                                    <td colspan="2">Confirmation Date</td>
                                    <td colspan="2">Retirement Date</td>
                                    <td colspan="2">Designation Code</td>
                                    <td colspan="2">Salary Account</td>
                                    <td colspan="2">Grade Code</td>
                                    <td>Basic Amount</td>
                                    <td>DA Rate</td>
                                    <td>DA Amount</td>
                                    <td>MSA Amount</td>
                                    <td>Gross Amount</td>
                                    <td>EPF Staff Rate</td>
                                    <td>EPF Staff Amount</td>
                                    <td>EPF Society Rate</td>
                                    <td>EPF Society Amount</td>
                                    <td>P.Tax Amount</td>
                                    <td>Other Deduction Amount</td>
                                    <td>Total EPF</td>
                                    <td>Net Pay</td>
                                    <td>Status</td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td><input type="checkbox" name="chckbox<%=count%>" id="chckbox<%=count%>" onclick="return checkboxTrue(<%=count%>)"/></td>
                                    <td><input size="15" type="text" name="employee<%=count%>" id="employee<%=count%>" onkeypress="return event.charCode >= 48 && event.charCode <= 57" ondrop="return false;" onpaste="return false;" /></td>  
                                    <td><input size="18" type="text" name="cif<%=count%>" id="cif<%=count%>" onkeypress="return event.charCode >= 48 && event.charCode <= 57" /></td>
                                    <td><input type="button" style="width: 70px" name="SearchCIF<%=count%>" id="SearchCIF<%=count%>" value="Search"  onclick="javascript:SearchCIF(550,240,<%=count%>);" /></td>
                                    <td><input readonly size="20" type="text" name="ename<%=count%>" id="ename<%=count%>" ondrop="return false;" onpaste="return false;" /></td>
                                    <td><input type="text" size="8" id="joinDate<%=count%>" name="joinDate<%=count%>" readonly="true"></td>
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].joinDate<%=count%>);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>
                                    <td><input type="text" size="8" id="confirmDate<%=count%>" name="confirmDate<%=count%>" readonly="true"></td>
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].confirmDate<%=count%>);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>
                                    <td><input type="text" size="8" id="retireDate<%=count%>" name="retireDate<%=count%>" readonly="true"></td>
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].retireDate<%=count%>);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>
                                    <td><input size="15" type="text" name="designationCode<%=count%>" id="designationCode<%=count%>" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                                    <td><input type="button" style="width: 70px" name="SearchDesgCode<%=count%>" id="SearchDesgCode<%=count%>" value="Search"  onclick="javascript:SearchDesgCode(550,240,<%=count%>);" /></td>
                                    <td><input size="18" type="text" name="salaryAcc<%=count%>" id="salaryAcc<%=count%>" onkeypress="return event.charCode >= 48 && event.charCode <= 57" ondrop="return false;" onpaste="return false;" /></td>
                                    <td><input type="button" style="width: 70px" name="SearchSalAcc<%=count%>" id="SearchSalAcc<%=count%>" value="Search"  onclick="javascript:SearchSalAcc(550,240,<%=count%>);" /></td>
                                    <td><input size="15" type="text" name="gradeCode<%=count%>" id="gradeCode<%=count%>" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                                    <td><input type="button" style="width: 70px" name="SearchGradeCode<%=count%>" id="SearchGradeCode<%=count%>" value="Search"  onclick="javascript:SearchGradeCode(550,240,<%=count%>);" /></td>
                                    <td><input size="15" type="text" name="basicAmt<%=count%>" id="basicAmt<%=count%>" onkeyup="calDaAmt(formPayroll)" onkeyup="calGross(formPayroll)" onkeyup="calTotalEpf(formPayroll)" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" name="daRate<%=count%>" id="daRate<%=count%>" onkeyup="calDaAmt(formPayroll)" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" readonly name="daAmt<%=count%>" id="daAmt<%=count%>" onkeyup="calGross(formPayroll)" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" name="msaAmt<%=count%>" id="msaAmt<%=count%>" onkeyup="calGross(formPayroll)" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" readonly name="grossAmt<%=count%>" id="grossAmt<%=count%>" /></td>
                                    <td><input size="15" type="text" name="epfStaffRate<%=count%>" id="epfStaffRate<%=count%>" onkeyup="calStaffAmt(formPayroll)" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" readonly name="epfStaffAmt<%=count%>" id="epfStaffAmt<%=count%>" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" name="epfSocRate<%=count%>" id="epfSocRate<%=count%>" onkeyup="calSocAmt(formPayroll)" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" readonly name="epfSocAmt<%=count%>" id="epfSocAmt<%=count%>" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" name="taxAmt<%=count%>" id="taxAmt<%=count%>" onkeyup="calNetPay(formPayroll)" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" name="otherAmt<%=count%>" id="otherAmt<%=count%>" onkeyup="calNetPay(formPayroll)" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" readonly name="totalEPF<%=count%>" id="totalEPF<%=count%>" /></td>
                                    <td><input size="15" type="text" readonly name="netPay<%=count%>" id="netPay<%=count%>" /></td>
                                    <td><select style="width:100%"  id="status<%=count%>" name="status<%=count%>" >
                                            <option value="N">No</option><option value="Y">Yes</option></select></td>                                    
                                    <td style="display:none"><input type="hidden" name="employee_id<%=count%>" id="employee_id<%=count%>"></td>

                                </tr>
                            </tbody>
                        </table>
                    <br>            
                </center>
                </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" 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>            
                        <br>        
                <center>        
                <div id="forAmend" style="display:none;" >    
                    
                        <input type="button"  value="Fetch Employee Details" onclick="javascript:getDetails()" />
                                             
                </div>        
                <br>
                </center>
                <%if (displayFlag.equalsIgnoreCase("Y")) {%>
                <div id="amend" >
                <div style="overflow:scroll; width: 1300px">
                    <center>                       
                    <table id="order-listAmend" 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>Employee ID</td>
                                    <td colspan="2">CIF No</td>
                                    <td>Employee Name</td>
                                    <td colspan="2">Joining Date</td>
                                    <td colspan="2">Confirmation Date</td>
                                    <td colspan="2">Retirement Date</td>
                                    <td colspan="2">Designation Code</td>
                                    <td colspan="2">Salary Account</td>
                                    <td colspan="2">Grade Code</td>
                                    <td>Basic Amount</td>
                                    <td>DA Rate</td>
                                    <td>DA Amount</td>
                                    <td>MSA Amount</td>
                                    <td>Gross Amount</td>
                                    <td>EPF Staff Rate</td>
                                    <td>EPF Staff Amount</td>
                                    <td>EPF Society Rate</td>
                                    <td>EPF Society Amount</td>
                                    <td>P.Tax Amount</td>
                                    <td>Other Deduction Amount</td>
                                    <td>Total EPF</td>
                                    <td>Net Pay</td>
                                    <td>Status</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="15" type="text" name="employee<%=count2%>" id="employee<%=count2%>" value="<%=blankNull(oPayrollBean.getEmployee())%>" onkeypress="return event.charCode >= 48 && event.charCode <= 57" ondrop="return false;" onpaste="return false;" /></td>
                                    <td><input size="18" type="text" name="cif<%=count2%>" id="cif<%=count2%>" value="<%=blankNull(oPayrollBean.getCif())%>" onkeypress="return event.charCode >= 48 && event.charCode <= 57" /></td>
                                    <td><input type="button" style="width: 70px" name="SearchCIF<%=count2%>" id="SearchCIF<%=count2%>" value="Search"  onclick="javascript:SearchCIF(550,240,<%=count2%>);" /></td>
                                    <td><input readonly size="20" type="text" name="ename<%=count2%>" id="ename<%=count2%>" value="<%=blankNull(oPayrollBean.getEname())%>" ondrop="return false;" onpaste="return false;" /></td>
                                    <td><input type="text" size="8" id="joinDate<%=count2%>" name="joinDate<%=count2%>" readonly="true" value="<%=blankNull(oPayrollBean.getJoinDate())%>"></td>
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].joinDate<%=count2%>);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>
                                    <td><input type="text" size="8" id="confirmDate<%=count2%>" name="confirmDate<%=count2%>" readonly="true" value="<%=blankNull(oPayrollBean.getConfirmDate())%>"></td>
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].confirmDate<%=count2%>);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>
                                    <td><input type="text" size="8" id="retireDate<%=count2%>" name="retireDate<%=count2%>" readonly="true" value="<%=blankNull(oPayrollBean.getRetireDate())%>"></td>
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].retireDate<%=count2%>);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>
                                    <td><input size="15" type="text" name="designationCode<%=count2%>" id="designationCode<%=count2%>" value="<%=blankNull(oPayrollBean.getDesignationCode())%>" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                                    <td><input type="button" style="width: 70px" name="SearchDesgCode<%=count2%>" id="SearchDesgCode<%=count2%>" value="Search"  onclick="javascript:SearchDesgCode(550,240,<%=count2%>);" /></td>
                                    <td><input size="18" type="text" name="salaryAcc<%=count2%>" id="salaryAcc<%=count2%>" value="<%=blankNull(oPayrollBean.getSalaryAcc())%>" onkeypress="return event.charCode >= 48 && event.charCode <= 57" ondrop="return false;" onpaste="return false;" /></td>
                                    <td><input type="button" style="width: 70px" name="SearchSalAcc<%=count2%>" id="SearchSalAcc<%=count2%>" value="Search"  onclick="javascript:SearchSalAcc(550,240,<%=count2%>);" /></td>
                                    <td><input size="15" type="text" name="gradeCode<%=count2%>" id="gradeCode<%=count2%>" value="<%=blankNull(oPayrollBean.getGradeCode())%>" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                                    <td><input type="button" style="width: 70px" name="SearchGradeCode<%=count2%>" id="SearchGradeCode<%=count2%>" value="Search"  onclick="javascript:SearchGradeCode(550,240,<%=count2%>);" /></td>
                                    <td><input size="15" type="text" name="basicAmt<%=count2%>" id="basicAmt<%=count2%>" value="<%=blankNull(oPayrollBean.getBasicAmt())%>" onkeyup="calTotalEpf2(formPayroll)" onkeyup="calDaAmt2(formPayroll)" onkeyup="calGross2(formPayroll)" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" name="daRate<%=count2%>" id="daRate<%=count2%>" value="<%=blankNull(oPayrollBean.getDaRate())%>" onkeyup="calDaAmt2(formPayroll)" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" readonly name="daAmt<%=count2%>" id="daAmt<%=count2%>" value="<%=blankNull(oPayrollBean.getDaAmt())%>" onkeyup="calGross2(formPayroll)" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" name="msaAmt<%=count2%>" id="msaAmt<%=count2%>" value="<%=blankNull(oPayrollBean.getMsaAmt())%>" onkeyup="calGross2(formPayroll)" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" readonly name="grossAmt<%=count2%>" id="grossAmt<%=count2%>" /></td>
                                    <td><input size="15" type="text" name="epfStaffRate<%=count2%>" id="epfStaffRate<%=count2%>" value="<%=blankNull(oPayrollBean.getEpfStaffRate())%>" onkeyup="calStaffAmt2(formPayroll)" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" readonly name="epfStaffAmt<%=count2%>" id="epfStaffAmt<%=count2%>" value="<%=blankNull(oPayrollBean.getEpfStaffAmt())%>" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" name="epfSocRate<%=count2%>" id="epfSocRate<%=count2%>" onkeyup="calSocAmt2(formPayroll)" value="<%=blankNull(oPayrollBean.getEpfSocRate())%>" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" readonly name="epfSocAmt<%=count2%>" id="epfSocAmt<%=count2%>" value="<%=blankNull(oPayrollBean.getEpfSocAmt())%>" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" name="taxAmt<%=count2%>" id="taxAmt<%=count2%>" value="<%=blankNull(oPayrollBean.getTaxAmt())%>" onkeyup="calNetPay2(formPayroll)" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td>
                                    <td><input size="15" type="text" name="otherAmt<%=count2%>" id="otherAmt<%=count2%>" value="<%=blankNull(oPayrollBean.getOtherAmt())%>" onkeyup="calNetPay2(formPayroll)" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' /></td> 
                                    <td><input size="15" type="text" readonly name="totalEPF<%=count2%>" id="totalEPF<%=count2%>" /></td>
                                    <td><input size="15" type="text" readonly name="netPay<%=count2%>" id="netPay<%=count2%>" /></td>
                                    <td>
                                    <select style="width: 150px"  name="status<%=count2%>" id="status<%=count2%>" >
                                        <option <%if (oPayrollBean.getStatus().equalsIgnoreCase("Y")) {%>selected <%}%> value="Y">Yes</option>
                                        <option <%if (oPayrollBean.getStatus().equalsIgnoreCase("N")) {%>selected <%}%> value="N">No</option>
                                    </select></td>                                
                                    <td display: none><input type="hidden" name="employee_id<%=count2%>" id="employee_id<%=count2%>" value="<%=blankNull(oPayrollBean.getEmployee_id())%>"></td>
                            </tr>

                            <%}%></tbody>
                    </table>                    
                
                    </center>
                </div>    
                    <br><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 size="15" type="text" id="employee' + counter + '" name="employee' + counter + '" onkeypress="return event.charCode >= 48 && event.charCode <= 57" ondrop="return false;" onpaste="return false;" /></td>\n\
                                    <td><input size="18" type="text" name="cif' + counter+ '" id="cif' + counter + '" onkeypress="return event.charCode >= 48 && event.charCode <= 57" /></td>\n\
                                    <td><input type="button" name="SearchCIF' + counter + '" id="SearchCIF' + counter + '" value="Search"  onclick="SearchCIF(280,240,'+counter+')" /></td> \n\
                                    <td><input readonly size="20" type="text" name="ename' + counter + '" id="ename' + counter + '" ondrop="return false;" onpaste="return false;" /></td>\n\
                                    <td><input type="text" size="8" id="joinDate' + counter + '" name="joinDate' + counter + '" readonly="true"></td>\n\
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].joinDate' + counter + ');"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>\n\
                                    <td><input type="text" size="8" id="confirmDate' + counter + '" name="confirmDate' + counter + '" readonly="true"></td>\n\
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].confirmDate' + counter + ');"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>\n\
                                    <td><input type="text" size="8" id="retireDate' + counter + '" name="retireDate' + counter + '" readonly="true"></td>\n\
                                    <td><a href="#" onclick="return getCalendar(document.forms[0].retireDate' + counter + ');"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" style="display:block;"  height="100%" width="20" /></a></td>\n\
                                    <td><input size="15" type="text" name="designationCode' + counter + '" id="designationCode' + counter + '" onkeypress="return event.charCode >= 48 && event.charCode <= 57" /></td>\n\
                                    <td><input type="button" name="SearchDesgCode' + counter + '" id="SearchDesgCode' + counter + '" value="Search"  onclick="SearchDesgCode(280,240,'+counter+')" /></td> \n\
                                    <td><input size="18" type="text" name="salaryAcc' + counter + '" id="salaryAcc' + counter + '" onkeypress="return event.charCode >= 48 && event.charCode <= 57" ondrop="return false;" onpaste="return false;" /></td>\n\
                                    <td><input type="button" name="SearchSalAcc' + counter + '" id="SearchSalAcc' + counter + '" value="Search"  onclick="SearchSalAcc(280,240,'+counter+')" /></td> \n\
                                    <td><input size="15" type="text" name="gradeCode' + counter + '" id="gradeCode' + counter + '" onkeypress="return event.charCode >= 48 && event.charCode <= 57" /></td>\n\
                                    <td><input type="button" name="SearchGradeCode' + counter + '" id="SearchGradeCode' + counter + '" value="Search"  onclick="javascript:SearchGradeCode(550,240,'+counter+');" /></td>\n\
                                    <td><input size="15" type="text" name="basicAmt' + counter + '" id="basicAmt' + counter + '" onkeyup="calDaAmt(formPayroll)" onkeyup="calGross(formPayroll)" onkeyup="calTotalEpf(formPayroll)" onkeypress="return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47" /></td>\n\
                                    <td><input size="15" type="text" name="daRate' + counter + '" id="daRate' + counter + '" onkeyup="calDaAmt(formPayroll)" onkeypress="return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47" /></td>\n\
                                    <td><input size="15" type="text" readonly name="daAmt' + counter + '" id="daAmt' + counter + '" onkeyup="calGross(formPayroll)" onkeypress="return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47" /></td>\n\
                                    <td><input size="15" type="text" name="msaAmt' + counter + '" id="msaAmt' + counter + '" onkeyup="calGross(formPayroll)" onkeypress="return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47" /></td>\n\
                                    <td><input size="15" type="text" readonly name="grossAmt' + counter + '" id="grossAmt' + counter + '" /></td>\n\
                                    <td><input size="15" type="text" name="epfStaffRate' + counter + '" id="epfStaffRate' + counter + '" onkeyup="calStaffAmt(formPayroll)" onkeypress="return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47" /></td>\n\
                                    <td><input size="15" type="text" readonly name="epfStaffAmt' + counter + '" id="epfStaffAmt' + counter + '" onkeypress="return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47" /></td>\n\
                                    <td><input size="15" type="text" name="epfSocRate' + counter + '" id="epfSocRate' + counter + '" onkeyup="calSocAmt(formPayroll)" onkeypress="return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47" /></td>\n\
                                    <td><input size="15" type="text" readonly name="epfSocAmt' + counter + '" id="epfSocAmt' + counter + '" onkeypress="return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47" /></td>\n\
                                    <td><input size="15" type="text" name="taxAmt' + counter + '" id="taxAmt' + counter + '" onkeyup="calNetPay(formPayroll)" onkeypress="return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47" /></td>\n\
                                    <td><input size="15" type="text" name="otherAmt' + counter + '" id="otherAmt' + counter + '" onkeyup="calNetPay(formPayroll)" onkeypress="return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47" /></td>\n\
                                    <td><input size="15" type="text" readonly name="totalEPF' + counter + '" id="totalEPF' + counter + '" /></td>\n\
                                    <td><input size="15" type="text" readonly name="netPay' + counter + '" id="netPay' + counter + '" /></td>\n\
                                    <td><select style="width:100%"  id="status' + counter + '" name="status' + counter + '" ><option value="N">No</option><option value="Y">Yes</option></select></td>\n\
                                    <td style="display: none"><input type="hidden" name="employee_id' + counter + '" id="employee_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/EmployeeMaster.jsp";
                    document.forms[0].submit();
                }

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