<%-- 
    Document   : authBulkIncr_STB
    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>

     $(window).load(function(){ 
        // getAccountList();
        //getExsAccountList();
     });

    function getExsAccountList() {

        var pacsId = $('#pacsId_STB').val();
            $.ajax({
                url:'/PacsApplication/BulkMarkServletSTB',
                data:{"temp":"allAccAuth_Exs","pacsId_STB":pacsId},
                type:'post',
                cache:false,
                //success:function(data){
                    if(data!=null){
                    //response = $.parseJSON(data);
                $(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>').text(item.bankCif),
                    $('<td>').html('<input type="button" id="'+i+'" value="Unmark" onclick="unmarkRecord('+i+')"/>')
                    ).appendTo('#recordsTable2');
            });
        });
                }
                else
                {
                    alert("no records");
                }},
                error:function(){
                }
            }
             );
    };
        function getAccountList() {

            var pacsId = $('#pacsId_STB').val();
            $.ajax({
                url:'/PacsApplication/BulkMarkServletSTB',
                data:{"temp":"allAccAuth","pacsId_STB":pacsId},
                type:'post',
                cache:false,
               // success:function(data){
                    if(data!=null){
                    //response = $.parseJSON(data);
                $(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>').text(item.cashOut),
                    $('<td>').text(item.guardianName),
                    $('<td>').text(item.idTypeTwo),
                    $('<td>').text(item.idNumberTwo),
                    $('<td>').html('<input type="button" id="'+i+'" value="Unmark" onclick="unmarkRecord('+i+')"/>')
                    ).appendTo('#recordsTable');
                //console.log($tr.wrap('<p>').html());
            });
        });
                }
                else
                {
                    alert("no records");
                }},
                error:function(){
                }
            }
        
             );
        };

        function submitform(bulkDetForm)
        {
                $("#recordsTable tbody tr").remove();
                $("#recordsTable2 tbody tr").remove();
                bulkDetForm.action = '/PacsApplication/BulkMarkServletSTB';
                bulkDetForm.submit();                
        }

        function unmarkRecord(i)
        {
            var table =document.getElementById("recordsTable");
            var accno = $('#accNo'+i).text();
            var pacsId = $('#pacsId_STB').val();
            $.ajax({
                url:'/PacsApplication/BulkMarkServletSTB',
                data:{"temp":"unmark" ,"accNo":accno,"pacsId_STB":pacsId },
                type:'post',
                cache:false,
                success:function(data){
                    if(data!=null){
                    alert(data.result);
                    $("#recordsTable tbody tr").remove();
                    $("#recordsTable2 tbody tr").remove();
                    getAccountList();
                    getExsAccountList();
                }
                else
                {
                    alert("Operation Unsuccessfull");
                }},
                error:function(){
                }
            }
             );            
        }

            function noBack()
            {
                window.history.forward();
            }

                      var repeater;

            $(document).ready(function () {
                    var shouldEnable = $(mark_Type).val();
                    switch(shouldEnable)
                    {
                        case 'N':
                            $('#chequDetTab').show();
                            $('#exsDetTab').hide();
                            getAccountList();
                            break;
                        case 'E':
                            $('#chequDetTab').hide();
                            $('#exsDetTab').show();
                            getExsAccountList();
                            break;
                        default:
                            $('#chequDetTab').hide();
                            $('#exsDetTab').hide();
                            break;
                    }
            });
            
        // 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;
            }            
        %>--%>

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



    <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_msg.equalsIgnoreCase("")) {%>
                    <center><div class="info" id="errorMessage"><center><%= error_msg%></center></div></center>
                    <% }%>
                                        
                    <br>
                  <br><br>                    
                    
                    <div align="center" style="display:block" id="chequDetTab">
                        <%--<p>Tellerwise Transaction details</p>--%>
                        <div><p><font face="Trebuchet MS" color="#000000" size="4"><u>Marked 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 No</td>
                                    <td>Product</td>
                                    <td>Customer Name</td>
                                    <td>Guardian Name</td>
                                    <td>First ID Type</td>
                                    <td>First ID Number</td>
                                    <td>Second ID Type</td>
                                    <td>Second ID Number</td>
                                    <td>Select</td>                                    
                                </tr>
                            </thead>
                        </table>
                        <center>
                        <br><br>
                         
                         <input type="button" id="submitButton"  value="Send for Bulk" onclick="javascript:submitform(bulkDetForm)">
                         <input type="hidden" id="tempId" value="authBulk" name="temp">
                         <input type="hidden" id="pacsId_STB" name="pacsId_STB" value='<%=request.getAttribute("messageSTB")%>'>
                         <input type="hidden" id="mark_Type" name="mark_Type" value='<%=request.getAttribute("markType")%>'>
                    </center>
                    </div>

                    <div align="center" style="display:block" id="exsDetTab">
                        <%--<p>Tellerwise Transaction details</p>--%>
                        <div><p><font face="Trebuchet MS" color="#000000" size="4"><u>Marked 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 No</td>
                                    <td>Product</td>
                                    <td>Customer Name</td>
                                    <td>Guardian Name</td>
                                    <td>Bank CIF Number</td>
                                    <td>Select</td>
                                </tr>
                            </thead>
                        </table>
                        <center>
                        <br><br>

                         <input type="button" id="submitButton"  value="Send for Bulk" onclick="javascript:submitform(bulkDetForm)">
                         <input type="hidden" id="tempId" value="authBulk" name="temp">
                         <input type="hidden" id="pacsId_STB" name="pacsId_STB" value='<%=request.getAttribute("messageSTB")%>'>
                         <input type="hidden" id="mark_Type" name="mark_Type" value='<%=request.getAttribute("markType")%>'>
                    </center>
                    </div>
                </form>
            </fieldset>
        </div>
    </body>

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