<%-- 
    Document   : bulkIncrDetails
    Created on : Oct 26, 2018, 1:20:17 PM
    Author     : 1004242
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@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.ChequeDetailsBean"%>
<%@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>Bulk Mark</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>

    </head>
<style>



#recordsTable {
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    border-collapse: collapse;
    width: 100%;
}

#recordsTable td, #recordsTable th {
    border: 2px solid #000000;
    padding: 8px;
}

#recordsTable tr:<%--nth-child(even)--%>{background-color: #f2f2f2;}

#recordsTable tr:hover {background-color: #a8ecab;}

#recordsTable th {
    padding-top: 12px;
    padding-bottom: 12px;
    text-align: left;
    background-color: #4CAF50;
    color: white;
}

#recordsTable2 {
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    border-collapse: collapse;
    width: 100%;
}

#recordsTable2 td, #recordsTable2 th {
    border: 2px solid #000000;
    padding: 8px;
}

#recordsTable2 tr:<%--nth-child(even)--%>{background-color: #f2f2f2;}

#recordsTable2 tr:hover {background-color: #a8ecab;}

#recordsTable2 th {
    padding-top: 12px;
    padding-bottom: 12px;
    text-align: left;
    background-color: #4CAF50;
    color: white;
}

</style>


    <script>
        
        function getAccountList() 
        {
            var accN =document.getElementById("accNo").value;
            if( accN == "" )
                {
                    alert("Enter Account Number.");
                    document.getElementById("accNo").focus();
                }
            else    {
                    $.ajax({
                url:'../BulkMarkServlet',
                data:{"temp":"allAcc" ,"accNo":document.getElementById("accNo").value},
                type:'post',
                cache:false,
                //success:function(data){
                    if(data!=null){
                    //response = $.parseJSON(data);
                    $("#recordsTable tbody tr").remove();
                $(function() {
                    $.each(data, function(i, item) {
                    var $tr = $('<tr>').append(
                    $('<td id="accNo'+i+'">').text(item.rejectedQ),
                    $('<td>').text(item.authorisedQ),
                    $('<td>').text(item.pendingQ),
                    $('<td>').text(item.cashIn),
                    $('<td>').html('<input type="button" id="'+i+'" value="Mark" onclick="submitform('+i+')"/>')
                    //$('<td>').html('<input type="radio"/>')
                    //$('<td>').html('<input type="checkbox" id="chk'+i+'"/>')
                    ).appendTo('#recordsTable');
                //console.log($tr.wrap('<p>').html());
            });
        });
                }
                else
                {
                    alert("No records");
                }},
                error:function(){

                }
            }
             );
             document.getElementById("accNo").readOnly = true;
             document.getElementById("srchbttn").disabled = true;
        }                
        };
        function getExsAccountList()
        {
            var accN =document.getElementById("exAccNo").value;
            if( accN == "" )
                {
                    alert("Enter Account Number");
                    document.getElementById("exAccNo").focus();
                }
            else    {
                    $.ajax({
                url:'../BulkMarkServlet',
                data:{"temp":"allAcc_Exs" ,"exAccNo":document.getElementById("exAccNo").value},
                type:'post',
                cache:false,
               // success:function(data){
                    if(data!=null){
                    //response = $.parseJSON(data);
                    $("#recordsTable2 tbody tr").remove();
                $(function() {
                    $.each(data, function(i, item) {
                    var $tr = $('<tr>').append(
                    $('<td id="exAccNo'+i+'">').text(item.rejectedQ),
                    $('<td>').text(item.authorisedQ),
                    $('<td>').text(item.pendingQ),
                    $('<td>').text(item.cashIn),
                    $('<td>').text(item.bankCif),
                    $('<td>').html('<input type="button" id="'+i+'" value="Mark" onclick="submitform2('+i+')"/>')
                    //$('<td>').html('<input type="radio"/>')
                    //$('<td>').html('<input type="checkbox" id="chk'+i+'"/>')
                    ).appendTo('#recordsTable2');
                //console.log($tr.wrap('<p>').html());
            });
        });
                }
                else
                {
                    alert("No records");
                }},
                error:function(){

                }
            }
             );
             document.getElementById("exAccNo").readOnly = true;
             document.getElementById("srchbttn2").disabled = true;
        }
        };
        $(document).ready(function () {
               $('select#searchCust').change(function () {
                    var shouldEnable = $(this).val();
                    switch(shouldEnable)
                    {
                        case 'N':
                            $('#nonExAcc').show();
                            $('#chequDetTab').show();
                            $('#exAcc').hide();
                            $('#exsTab').hide();
                            break;
                        case 'E':
                            $('#nonExAcc').hide();
                            $('#chequDetTab').hide();
                            $('#exAcc').show();
                            $('#exsTab').show();
                            break;
                        default:
                            $('#nonExAcc').hide();
                            $('#chequDetTab').hide();
                            $('#exAcc').hide();
                            $('#exsTab').hide();
                            break;
                    }
                });
            });

        function submitform(i)
        {
            var table =document.getElementById("recordsTable");
             var accno = $('#accNo'+i).text();
            <%--for (var i = 0; i < table.rows.length; i++) {
                if ($('#chk'+i).is(':checked')) {
                    value_check += $('#accNo'+i).text()+":";
        }
        }--%>
            $.ajax({
                url:'../BulkMarkServlet',
                data:{"temp":"markBulk" ,"accNo":accno},
                type:'post',
                cache:false,
                success:function(data){
                    if(data!=null){
                    alert(data.result);
                    $("#recordsTable tbody tr").remove();
                    getAccountList();
                }
                else
                {
                    alert("Operation Unsuccessfull");
                }},
                error:function(){
                }                
            }
             );
            alert(value_check);
        }
        function submitform2(i)
        {
            var accno = $('#exAccNo'+i).text();

            $.ajax({
                url:'../BulkMarkServlet',
                data:{"temp":"markBulk_Exs" ,"exAccNo":accno},
                type:'post',
                cache:false,
                success:function(data){
                    if(data!=null){
                    alert(data.result);
                    $("#recordsTable tbody tr").remove();
                    getExsAccountList();
                }
                else
                {
                    alert("Operation Unsuccessfull");
                }},
                error:function(){

                }
            }
             );
            alert(value_check);
        }

            function noBack()
            {
                window.history.forward();
                            $('#nonExAcc').hide();
                            $('#chequDetTab').hide();
                            $('#exAcc').hide();
                            $('#exsTab').hide();
            }
            function ShowParent(    )
            {
                document.forms[0].action="${pageContext.request.contextPath}/Deposit/bulkIncrDetails.jsp";
                document.forms[0].submit();
            }
                      var repeater;

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

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

    <body onload="noBack();">
        <jsp:include page="MenuHead_Deposit.jsp" flush="true" />

        <div id="ChequeEnquiry">
            <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"></legend>--%>
                <legend style="padding: 8px; border-radius: 20px; background-color: #006600; color: white">Bulk Mark</legend>
                <form name="bulkDetForm" method="post" action="" id="bulkDetForm">
                  <%--  <%if (!error_msg1.equalsIgnoreCase("")) {%>
                    <center><div class="info" id="errorMessage"><center><%= error_msg1%></center></div></center>
                    <% }%>
                    <br>--%>
                  <br><br>
                     <center>
                         <tr><td>Bulk Mark for: </td><td><select id="searchCust" name="searchCust"><option value=""> --select-- </option><option value="N">Non-Existing Bank CIF</option><option value="E">Existing Bank CIF</option></select></td></tr>
                         <tr><td> <br></td></tr>
                         <br><br>
                         <div id="nonExAcc" >
                         <td>Non-Existing Account Number<font color="red" >*</font>:</td>
                        <td><input type="text" name="accNo" id="accNo" placeholder="Enter account number" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                        <td><input type="button"  value="Get Details" id="srchbttn" onclick="javascript:getAccountList();"/></td>
                         <td><input type="button" value="Reset" onclick="ShowParent();" /></td></div>
                         <div id="exAcc" >
                         <td>Existing Account Number<font color="red" >*</font>:</td>
                        <td><input type="text" name="exAccNo" id="exAccNo" placeholder="Enter account number" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                        <td><input type="button"  value="Get Details" id="srchbttn2" onclick="javascript:getExsAccountList();"/></td>
                         <td><input type="button" value="Reset" onclick="ShowParent();" /></td></div>
                        <br><br>
                        <%-- <td style="text-align: right">Customer Name.: </td>
                         <td><input type="text " name="custNm" id="custNm" value="" readonly/></td>--%>
                    </center>
                    
                    <div align="center" style="display:block" id="chequDetTab">
                        <%--<p>Tellerwise Transaction details</p>--%>
                        <div><p><font face="Trebuchet MS" color="#000000" size="4"><u>Non-Existing Bank CIF Bulk Account Details</u></font></p></div>
                        <table border="2" width="auto" cellspacing="1" cellpadding="1" id ="recordsTable" style="text-align: center ;overflow-y: scroll; font-size: 15px">
                            <thead class="CSSTableGenerator">

                                <tr>
                                   
                                    <td>Account Number</td>
                                    <td>Product</td>
                                    <td>Customer Name</td>
                                    <td>Guardian Name</td>
                                    <td>Select</td>
                                    
                                </tr>
                            </thead>
                        </table>
                        <center>
                        <br><br>
                        <%--<input type="button" id="submitButton"  value="Submit" onclick="javascript:submitform(bulkDetForm)">--%>
                    </center>
                    </div>
                    <div align="center" style="display:block" id="exsTab">
                        <div><p><font face="Trebuchet MS" color="#000000" size="4"><u>Existing Bank CIF Bulk Account Details</u></font></p></div>
                        <table border="2" width="auto" cellspacing="1" cellpadding="1" id ="recordsTable2" style="text-align: center ;overflow-y: scroll; font-size: 15px">
                            <thead class="CSSTableGenerator">

                                <tr>

                                    <td>Account Number</td>
                                    <td>Product</td>
                                    <td>Customer Name</td>
                                    <td>Guardian Name</td>
                                    <td>Bank CIF</td>
                                    <td>Select</td>

                                </tr>
                            </thead>
                        </table>
                    </div>
                </form>
            </fieldset>
        </div>
    </body>

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