<%--
    Document   : moc
    Created on : Mar 19, 2018, 5:52:10 PM
    Author     : 981898
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.sql.SQLException"%>
<%@page import="LoginDb.DbHandler"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.util.Date"%>
<%@page import="DataEntryBean.mocProcessingBean"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.UUID" %>
<%String uuid = UUID.randomUUID().toString();%>
<% try {
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <title>MOC Operations</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>
        <%
             String handle_idVal = "";
             Object handle_id = request.getAttribute("handle_id");
             if (handle_id != null) {
                 handle_idVal = handle_id.toString();
             }
             String userRole = (String) session.getAttribute("userRole");
        %>

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

            function ShowParent()
            {
                document.forms[0].action="${pageContext.request.contextPath}/Deposit/mocOperations.jsp";
                document.forms[0].submit();
            }

            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 sendFileToServer()
            {
                var formDownloadNormal = document.getElementById("MOCManual");
                formDownloadNormal.action = '/PacsApplication/BulkFileUploadServlet';
                formDownloadNormal.submit();
            }

            function executeform(mocForm){
                if(document.getElementById("batchID").value == "") {
                        alert("Please enter the MOC ID to search");
                        return false;
                    }
                document.getElementById("handle_id").value = 'execute';
                document.mocForm.action = '/PacsApplication/mocOperationsServlet';
                document.mocForm.submit();
            }

            function submitform(mocForm){
               
               /*roundOff();
                //alert(document.getElementById("handle_id").value);
                if(document.getElementById("handle_id").value == "search"){
                    if(document.getElementById("batchID").value == "") {
                        alert("Please enter the MOC Batch ID to search");
                        return false;
                    }
                    document.mocForm.action = '/PacsApplication/mocOperationsServlet';
                    document.mocForm.submit();
                    return true;
                }
                if(validate()){

                        document.mocForm.action = '/PacsApplication/mocOperationsServlet';
                        document.mocForm.submit();
                    }*/
                    //alert(document.getElementById("handle_id").value);
                if(document.getElementById("handle_id").value == "search"){
                    if(document.getElementById("batchID").value == "") {
                        alert("Please enter the MOC Batch ID to proceed");
                        return false;
                    }
                    document.mocForm.action = '/PacsApplication/mocOperationsServlet';
                    document.mocForm.submit();
                    return true;
                } else if(validate()){
                        roundOff();
                        document.mocForm.action = '/PacsApplication/mocOperationsServlet';
                        document.mocForm.submit();
                }
             }

            function validate(){
                var counter = $("#rowCounter").val();
                //var i = 1;
                for(i=1;i<=counter;i++){
                    re = /^(?=.*\d)\d*(?:\.\d*)?$/;

                    try {
                        if (document.getElementById("accNo"+i).value == "")
                        {
                            alert("Account Number cannot be empty");
                            document.getElementById("accNo"+i).value="";
                            document.getElementById("accNo"+i).focus();
                            //resetRow(i);
                            return false;
                        }

                        if (document.getElementById("secAccNo"+i).value == "")
                        {
                            alert("Second Account Number cannot be empty");
                            document.getElementById("secAccNo"+i).value="";
                            document.getElementById("secAccNo"+i).focus();
                            //resetRow(i);
                            return false;
                        }

                        if (document.getElementById("txnAmt"+i).value == "")
                        {
                            alert("Transaction Amount cannot be empty");
                            document.getElementById("txnAmt"+i).value="";
                            document.getElementById("txnAmt"+i).focus();
                            //resetRow(i);
                            return false;
                        }


                        if (!re.test(document.getElementById("accNo"+i).value))
                        {
                            alert("Account Number could only contain numbers");
                            document.getElementById("accNo"+i).value="";
                            document.getElementById("accNo"+i).focus();
                            //resetRow(i);
                            return false;
                        }

                        if (!re.test(document.getElementById("secAccNo"+i).value))
                        {
                            alert("Account Number could only contain numbers");
                            document.getElementById("secAccNo"+i).value="";
                            document.getElementById("secAccNo"+i).focus();
                            //resetRow(i);
                            return false;
                        }

                        if (!re.test(document.getElementById("txnAmt"+i).value))
                        {
                            alert("Transaction amount could only contain numbers");
                            document.getElementById("txnAmt"+i).value="";
                            document.getElementById("txnAmt"+i).focus();
                            //resetRow(i);
                            return false;
                        }
                        if (document.getElementById("txnInd"+i).value == "")
                        {
                            alert("Transaction indicator should be selected");
                            document.getElementById("txnInd"+i).value="CR";
                            document.getElementById("txnInd"+i).focus();
                            //resetRow(i);
                            return false;
                        }

                        if ((document.getElementById("txnNarration"+i).value.trim()) == "")
                        {
                            alert("Transaction Narration should be filled.");
                            document.getElementById("txnNarration"+i).focus();
                            //resetRow(i);
                            return false;
                        }
                        if(document.getElementById("searched").value!="1")
                            {
                                alert("Kindly Search and select the first A/c Number.")
                                document.getElementById("accNo"+i).focus;
                                return false;
                            }
                        if(document.getElementById("searchedTwo").value!="1")
                            {
                                alert("Kindly Search and select the second A/c Number.")
                                document.getElementById("secAccNo"+i).focus;
                                return false;
                            }
                       if (document.getElementById("txnInd"+i).value == "DR" && document.getElementById("accType"+i).value == "L")
                        {
                            alert("Loan cannot be debited from batch transaction");
                            document.getElementById("txnInd"+i).focus();
                            //resetRow(i);
                            return false;
                        }
                    }
                    catch(err){

                    }
                }
                return true;
            }

            function SearchAccount(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("accNo"+textIndex).value;
                var screenName = "mocOperations.jsp";
                var lovKey = "AccountSearch";

                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationDepositLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo + '&textIndex=' + textIndex, 'AccountSearch', attr);
                popWin.focus();

            }

            function SearchSecondAccount(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("secAccNo"+textIndex).value;
                var screenName = "mocOperations.jsp";
                var lovKey = "SecondAccountSearch";

                popWin = open('${pageContext.request.contextPath}/CommonSearchInformationDepositLOV.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo + '&textIndex=' + textIndex, 'AccountSearch', attr);
                popWin.focus();

            }

            function setVisibility(){
                //document.getElementById("searchBatch").style.visibility='visible';
                $('select#mocOption').change();
            }

            function textChanged(){
                document.getElementById("searched").value="0";
                //alert("IN");
            }

            function textChangedTwo(){
                document.getElementById("searchedTwo").value="0";
                //alert("IN");
            }

            $(document).ready(function () {
                $('#create').hide();
                $('#handle_id').val();
                $('select#mocOption').change(function () {
                    var shouldEnable = $(this).val();
                    switch(shouldEnable)
                    {
                        case 'C':
                            $('#create').show();
                            $('#searchBatch').hide();
                            $('#handle_id').val('create');
                            break;

                        case 'S':
                            $('#searchBatch').show();
                            $('#create').hide();
                            $('#handle_id').val('search');
                            break;

                        default:
                            $('#create').hide();
                            $('#searchBatch').hide();
                            $('#handle_id').val();

                            break;
                    }
                });
            });

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

        <%
             int count = 1;
             String error_msg = "";

             Object error = request.getAttribute("message");
             if (error != null) {
                 error_msg = error.toString();
             }

             Object alMocProcessingBeanObj = request.getAttribute("alMocProcessingBean");
             ArrayList<mocProcessingBean> alMocProcessingBean = new ArrayList<mocProcessingBean>();
             mocProcessingBean oMocProcessingBean = new mocProcessingBean();
             if (alMocProcessingBeanObj != null) {
                 alMocProcessingBean = (ArrayList<mocProcessingBean>) request.getAttribute("alMocProcessingBean");


             }
             error = request.getAttribute("batchID");
             String batchID = "";
             if (request.getAttribute("batchID") != null) {
                 batchID = error.toString();
             }
        %>


        <%!
            String blankNull(String s) {
                return (s == null) ? "" : s;
            }

        %>
    </head>
    <%--<body  onload="javascript:<%if (alMocProcessingBeanObj != null) {%>setVisibility();<%}%>noBack();"> --%>
    <body  onload="javascript:setVisibility();noBack();">

        <jsp:include page="MenuHead_Deposit.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">MOC Operations</legend>

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

            <center  style="display:none">
                <label>Select Operation: </label>
                <select id="mocOption" name="mocOption">
                     <%--<option value="" selected >--Select--</option>--%>
                    <%if ((userRole.equalsIgnoreCase(
                     "201606000004041")) ) {%>
                    <option <%if (blankNull(handle_idVal).equalsIgnoreCase("S")) {%> selected <%}%> value="S">Search</option>
                     <%}else{%>
                     <option <%if (blankNull(handle_idVal).equalsIgnoreCase("C")) {%> selected <%}%> value="C">Create</option>
                     <%}%>
                </select>
            </center>


            <form action="" method="post" name="mocForm" id="mocForm">

                <div id="create" name="create">
                    <br>


                    <div align="center">
                        <table id="mocData" name="mocData" border="2" width="auto" cellspacing="1" cellpadding="1" style="text-align: center ;overflow-y: scroll; font-size: 15px">
                            <thead class="CSSTableGenerator">
                                <tr>
                                    <td></td>
                                    <td>First Account Number</td>
                                    <td>Transaction Amount</td>
                                    <td>Transaction Indicator</td>
                                    <td>Second Account Number</td>
                                    <td>Narration</td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr class="tRow">
                                    <td><input type="checkbox" name="chckbox<%=count%>" id="chckbox<%=count%>" onclick="checkboxTrue(<%=count%>);" /></td>
                                    <td>
                                        <input type="text" onkeypress='return event.charCode >= 48 && event.charCode <= 57'  style="width: 130px" name="accNo<%=count%>" id="accNo<%=count%>" onkeyup="textChanged()" />
                                        <input type="button" style="width: 70px" name="search<%=count%>" id="search<%=count%>" value="Search"  onclick="javascript:SearchAccount(550,240,<%=count%>);" /></td>
                                    <td>
                                        <input type="text" onkeypress='return event.charCode >= 46 && event.charCode <= 57' name="txnAmt<%=count%>" id="txnAmt<%=count%>"  />
                                    </td>
                                    <td>
                                        <select style="width: 150px" name="txnInd<%=count%>" id="txnInd<%=count%>" >
                                            <option value="CR" selected>Credit</option>
                                            <option value="DR">Debit</option>
                                        </select>
                                    </td>
                                    <td>
                                        <input type="text" onkeypress='return event.charCode >= 48 && event.charCode <= 57' style="width: 130px" name="secAccNo<%=count%>" id="secAccNo<%=count%>" onkeyup="textChangedTwo()" />
                                        <input type="button" style="width: 70px" name="searchsecAccNo<%=count%>" id="searchsecAccNo<%=count%>" value="Search"  onclick="javascript:SearchSecondAccount(550,240,<%=count%>);" /></td>
                                    <td>
                                       <input type="text" name="txnNarration<%=count%>" id="txnNarration<%=count%>" />
                                    </td>
                                </tr>
                            </tbody>
                        </table>

                        <br><br><br>
                        <center>
                            <table>
                                <tr>
                                    <td ><input type="button" id="addRow" value="Add Row"/></td>
                                    <td><input type="button" id="deleteRow" value="Delete Row"/></td>
                                    <td><input type="button" value="Submit" onclick="javascript:submitform(mocForm)"></td>
                                    <td><input type="button" value="Reset" onclick="ShowParent();" /></td>
                                </tr>
                            </table>
                        </center>
                    </div>

                    <input type="hidden" name="rowCounterDeleteCreate" id="rowCounterDeleteCreate" value="<%=count%>">
                    <input type="hidden" name="rowCounter" id="rowCounter" value="<%=count%>">
                    <input type="hidden" name="chkboxCounter" id="chkboxCounter" value="0"/>
                    <input type="hidden" name="all_rowsAdded" id="all_rowsAdded" value="1">
                </div>

                <br>
                <center>
                    <div id="searchBatch" style="display:none">
                        <label>MOC ID: </label>
                        <input type="text" name="batchID" id="batchID" value="<%=blankNull(batchID)%>" onkeypress='return event.charCode >= 48 && event.charCode <= 57'/>
                        <input type="button" name="searchBatch" id="searchBatch" value="Submit" onclick="javascript:submitform(mocForm)"/>
                        <br><br>

                        <%if (handle_idVal.equalsIgnoreCase("S")) {%>
                        <div align="center">
                            <table border="2" width="auto" cellspacing="1" cellpadding="1" style="text-align: center ;overflow-y: scroll; font-size: 15px">
                                <thead class="CSSTableGenerator">
                                    <tr>
                                        <td>First Account Number</td>
                                        <td>Transaction Amount</td>
                                        <td>Transaction Indicator</td>
                                        <td>Second Account Number</td>
                                        <td>Narration</td>
                                        <td>Transaction Status</td>
                                        <td>Transaction Ref No</td>
                                    </tr>
                                </thead>
                                <tbody>
                                    <%
                                        for (int k = 0; k < alMocProcessingBean.size(); k++) {
                                            oMocProcessingBean = alMocProcessingBean.get(k);
                                    %>
                                    <tr class="tRow">

                                        <td>
                                            <input type="text"  readonly onkeypress='return event.charCode >= 48 && event.charCode <= 57' style="width: 130px" name="accNo<%=k%>" id="accNo<%=k%>" value="<%=oMocProcessingBean.getAccNo()%>" /> </td>

                                        <td>
                                            <input type="text" readonly name="txnAmt<%=k%>" id="txnAmt<%=k%>" value="<%=oMocProcessingBean.getTxnAmt()%>"  onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.keyCode == 46' />
                                        </td>
                                        <td>
                                            <select disabled style="width: 150px" name="txnInd<%=k%>" id="txnInd<%=k%>" >
                                                <option <%if (oMocProcessingBean.getTxnInd().equalsIgnoreCase("CR")) {%>selected <%}%> value="CR">Credit</option>
                                                <option <%if (oMocProcessingBean.getTxnInd().equalsIgnoreCase("DR")) {%>selected <%}%> value="DR">Debit</option>
                                            </select>
                                        </td>
                                        <td>
                                            <input type="text"  readonly onkeypress='return event.charCode >= 48 && event.charCode <= 57' style="width: 130px" name="accNo<%=k%>" id="accNo<%=k%>" value="<%=oMocProcessingBean.getSec_acc_no()%>" />
                                        </td>

                                        <td>
                                            <input type="text" readonly name="txnNarrationTwo<%=k%>" id="txnNarrationTwo<%=k%>" value="<%=oMocProcessingBean.getNarration()%>" />
                                        </td>
                                        <td>
                                            <input type="text"  readonly name="txnStatus<%=k%>" id="txnStatus<%=k%>" value="<%=oMocProcessingBean.getTxnStatus()%>" /> </td>
                                        <td>
                                            <input type="text"  readonly name="txnRefNo<%=k%>" id="txnRefNo<%=k%>" value="<%=oMocProcessingBean.getTxnRefNo()%>" /> </td>
                                    </tr>
                                    <%}%>
                                </tbody>
                            </table>
                            <br><br><br>
                            <center>
                                <table>
                                    <tr>

                                        <td><input type="button" value="Execute" onclick="javascript:executeform(mocForm)"></td>
                                        <td><input type="button" value="Reset" onclick="ShowParent();" /></td>
                                    </tr>
                                </table>
                            </center>
                        </div>

                        <%}%>
                    </div>
                </center>

                <input type="hidden" name="handle_id" id="handle_id" value="" />
                <input type="hidden" name="searched" id="searched" />
                <input type="hidden" name="searchedTwo" id="searchedTwo" />
            </form>

           <form name="MOCManual" id="MOCManual" action="" method="post" >
                <input type="hidden" id="actionId" value="MOC" name="actionTag">
                <input type="button" value="Download IPKS MOC Document" id ="MOCManual" name="FileType" onclick="sendFileToServer()" style="float: right"/>
           </form>

            <br><br>

            <script  type="text/javascript">
                var x=1;
                $("#addRow").click(function () {
                    if(!validate()){
                        alert('Please fillup one row at a time');
                    } else {
                        document.getElementById("searched").value="0";
                        document.getElementById("searchedTwo").value="0";
                        x=x+1;
                        $("#all_rowsAdded").val(x);
                        var counter = $("#rowCounter").val();
                        counter++;
                        $('#mocData tr:last').after('<tr class="tRow">    <td><input type="checkbox" name="chckbox' + x + '" id="chckbox' + x + '" onclick="checkboxTrue(' + x + ');" /></td>    <td>        <input type="text"  style="width: 130px;text-align:left;" name="accNo' + x + '" id="accNo' + x + '"/>        <input type="button" style="width: 70px" name="search' + x + '" id="search' + x + '" value="Search"  onclick="javascript:SearchAccount(550,240,' + x + ');" /></td>    <td>        <input type="text" name="txnAmt' + x + '" id="txnAmt' + x + '" style="text-align:left;" onkeypress="return event.charCode >= 48 && event.charCode <= 57  && event.keyCode = 46"  />    </td>    <td>        <select style="width: 150px" name="txnInd' + x + '" id="txnInd' + x + '"  >            <option value="CR" selected>Credit</option>            <option value="DR">Debit</option>        </select>    </td> <td><input type="text"  style="width: 130px;text-align:left;" name="secAccNo' + x + '" id="secAccNo' + x + '" onkeyup="textChangedTwo()"/><input type="button" style="width: 70px" name="searchsecAccNo' + x + '" id="searchsecAccNo' + x + '" value="Search"  onclick="javascript:SearchSecondAccount(550,240,' + x + ');" /></td> <td>        <input type="text" name="txnNarration' + x + '" id="txnNarration' + x + '"/>    </td></tr>');

                        $("#rowCounter").val(counter);
                        counter = $("#rowCounterDeleteCreate").val();
                        counter++;
                        $("#rowCounterDeleteCreate").val(counter);
                    }
                });


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

                    var len = ($("#mocData tr").length)-1;
                    var counter = $("#rowCounterDeleteCreate").val();
                    var chkboxCounter=$("#chkboxCounter").val();
                    var counterDelete=counter-chkboxCounter;
                    if (counterDelete==0){
                        alert("All rows cannot be deleted.");
                    }
                    else{
                        if (len == 0) {
                            alert("All rows can not be deleted.");
                            return false;
                        }
                        var rowCounter = $("#rowCounter").val();
                        $('input:checkbox:checked').closest('tr').remove();
                        rowCounter--;
                        $("#rowCounter").val(rowCounter);
                        $("#rowCounterDeleteCreate").val(counterDelete);

                        chkboxCounter=0;
                        $("#chkboxCounter").val(chkboxCounter);
                        //calcAmt();
                        //if(isNaN(document.getElementById("grandTotal").value)){
                        //    document.getElementById("grandTotal").value = 0;
                        //}
                            document.getElementById("searched").value="1";
                            document.getElementById("searchedTwo").value="1";

                    }

                });

                function resetRow(i) {
                    document.getElementById("accNo"+i).value = "";
                    document.getElementById("txnAmt"+i).value = "";
                    document.getElementById("txnInd"+i).value = "CR";
                }
                
                function calcAmt() {                   

                    var counter = $("#rowCounter").val();
                    var crTotal = parseFloat(0);
                    var drTotal = parseFloat(0);
                    var total = parseFloat(0);
                    //var i = 1;
                    for(i=1;i<=counter;i++) {
                        try {
                            if(document.getElementById("txnInd"+i).value == "CR")
                                crTotal = crTotal + parseFloat(document.getElementById("txnAmt"+i).value);
                            else if(document.getElementById("txnInd"+i).value == "DR")
                                drTotal = drTotal + parseFloat(document.getElementById("txnAmt"+i).value);

                        }
                        catch(err){
                            total=0;
                        }
                    }
                    if(isNaN(crTotal)){
                        crTotal = parseFloat(0);
                    }
                    if(isNaN(drTotal)){
                        drTotal = parseFloat(0);
                    }
                    total = crTotal - drTotal;
                    document.getElementById("crTotal").value = crTotal;
                    document.getElementById("drTotal").value = drTotal;
                    document.getElementById("total").value = total;
                }

                function roundOff() {
                    var counter = $("#rowCounter").val();
                    for(i=1;i<=counter;i++) {
                        try {
                          var amt = document.getElementById("txnAmt"+i).value;
                          var num1 = parseFloat(amt);
                            var cleanNum1 = num1.toFixed(2);

                            document.getElementById("txnAmt"+i).value=cleanNum1;
                        }
                        catch(err){
                            amt=0;
                            document.getElementById("txnAmt"+i).value=amt;
                        }
                    }
                }

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