<%--
    Document   : Deposit_Report
    Created on : Jul 28, 2016, 9:18:24 PM
    Author     : 986137
--%>

<%@page import="LoginDb.DbHandler"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.util.ArrayList"%>
<%@page import="DataEntryBean.EnquiryBean"%>
<%@page import="java.util.Date"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList" %>
<%@page import="java.lang.String" %>
<% try {
%>
<html>
    <head>
        <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 downloadFiles() {

                var e = document.getElementById("reportSelection");
                //Both From and To date are mandatory
               // var reports = [1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,41,43,44,45,46,47,48,49,50,51,52,53,54,55,56];
                var reports = ["1","2","3","4","5","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","35","36","37","41","43","44","45","46","47","48","49","50","51","52","53","54","55","56","58","59","60","61","62"];
                var fromdate_reports = ["34","38","39","40","57","63"]; //From date not mandatory
                var todate_reports = ["6","34","38","39","40","42","57"];//To Date not mandatory
                var val = e.options[e.selectedIndex].value;                

                if (e.options[e.selectedIndex].value == "")
                {
                    alert("Report Name cannot be empty.");
                    document.forms[0].reportSelection.focus();
                    return false;
                }

                if ((document.forms[0].from_date.value == "" || document.forms[0].to_date.value == "") && reports.includes(val) )
                {
                    alert("From Date or To Date cannot be empty for this report.");
                    document.forms[0].from_date.focus();
                    return false;
                }
                if (document.forms[0].from_date.value == "" && !(fromdate_reports.includes(val)) )
                {
                    alert("From Date cannot be empty for this report.");
                    document.forms[0].from_date.focus();
                    return false;
                }
                if (document.forms[0].to_date.value == "" && !(todate_reports.includes(val)) )
                {
                    alert("To Date cannot be empty for this report.");
                    document.forms[0].to_date.focus();
                    return false;
                }
                <%--if (document.forms[0].from_date.value == "" &&  (e.options[e.selectedIndex].value == "1" || e.options[e.selectedIndex].value == "2" || e.options[e.selectedIndex].value == "7" || e.options[e.selectedIndex].value == "12" || e.options[e.selectedIndex].value == "15" || e.options[e.selectedIndex].value == "16" || e.options[e.selectedIndex].value == "5" || e.options[e.selectedIndex].value == "8" || e.options[e.selectedIndex].value == "9" ))
                {
                    alert("From Date cannot be empty.");
                    document.forms[0].txn_date.focus();
                    return false;
                } if (document.forms[0].to_date.value == "" && (e.options[e.selectedIndex].value == "1" || e.options[e.selectedIndex].value == "2" || e.options[e.selectedIndex].value == "7" || e.options[e.selectedIndex].value == "12" || e.options[e.selectedIndex].value == "15" || e.options[e.selectedIndex].value == "16" || e.options[e.selectedIndex].value == "5" || e.options[e.selectedIndex].value == "8" || e.options[e.selectedIndex].value == "9" ))
                {
                    alert("To Date cannot be empty.");
                    document.forms[0].txn_date.focus();
                    return false;
                }--%>
                
                
                var startDate = $('#from_date').val();
                var endDate = $('#to_date').val();
                var adata = startDate.split('/');
                var dd = parseInt(adata[0],10);
                var mm = parseInt(adata[1],10);
                var yyyy = parseInt(adata[2],10);
                var from_date = new Date(yyyy,mm-1,dd);
                
                adata = endDate.split('/');
                var dd = parseInt(adata[0],10);
                var mm = parseInt(adata[1],10);
                var yyyy = parseInt(adata[2],10);
                var to_date = new Date(yyyy,mm-1,dd);

                if(Date.parse(from_date) > Date.parse(to_date) &&  reports.includes(val)){
                    alert("From Date cannot be greater than To Date.");
                    return false;
                }

                switch (e.options[e.selectedIndex].value) {

                    case "1" :

                        document.forms[0].reportPath.value = "/Reports/CashTxnReportDenoWise";
                        document.forms[0].reportName.value = "CASH TRANSACTION REPORT - DenoWise";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "2" :

                        document.forms[0].reportPath.value = "/Reports/System Gen Txn";
                        document.forms[0].reportName.value = "SYSTEM GENERATED TRANSACTION REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "3" :

                        document.forms[0].reportPath.value = "/Reports/transferTxnReport";
                        document.forms[0].reportName.value = "TRANSFER TRANSACTION REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "4" :

                        document.forms[0].reportPath.value = "/Reports/Transfer Txn Report_gl";
                        document.forms[0].reportName.value = "GL TRANSACTION REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

		    case "5" :

                        document.forms[0].reportPath.value = "/Reports/DayBook";
                        document.forms[0].reportName.value = "Day Book";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "6" :

                        document.forms[0].reportPath.value = "/Reports/Dep_Detail_list";
                        document.forms[0].reportName.value = "Deposit Detail List";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "7" :

                        document.forms[0].reportPath.value = "/Reports/consolidated_daybook";
                        document.forms[0].reportName.value = "Consolidated Day Book Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "8" :

                        document.forms[0].reportPath.value = "/Reports/Cash txn Report1";
                        document.forms[0].reportName.value = "Cash Transaction Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "9" :

                        document.forms[0].reportPath.value = "/Reports/DailyCashScroll";
                        document.forms[0].reportName.value = "Daily Cash Scroll Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case "10" :

                        if((document.getElementById("userRole").value=="201603000005020")||(document.getElementById("userRole").value=="201603000007020")){
                        document.forms[0].DOWNLOAD.value = "C";
                        document.forms[0].reportPath.value = "/Reports/Inward_csv";
                        document.forms[0].reportName.value = "Inward Report";
                        }
                        else{
                        document.forms[0].DOWNLOAD.value = "P";
                        document.forms[0].reportPath.value = "/Reports/Inward_Neft_report";
                        document.forms[0].reportName.value = "Inward Report";
                        }
                        break;

                    case "11" :

                        document.forms[0].reportPath.value = "/Reports/Outward_Neft_report";
                        document.forms[0].reportName.value = "Outward Report";
                        
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case "12" :

                        document.forms[0].reportPath.value = "/Reports/ACCT_OPEN_REGISTER";
                        document.forms[0].reportName.value = "Account Open Register";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case "13" :

                        document.forms[0].reportPath.value = "/Reports/cash_deno_report_daily";
                        document.forms[0].reportName.value = "Cash Denomination Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case "14" :

                        document.forms[0].reportPath.value = "/Reports/MIS_TRANSFER_TXN";
                        document.forms[0].reportName.value = "MIS transfer Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case "15" :

                        document.forms[0].reportPath.value = "/Reports/dds_report_agent_wise";
                        document.forms[0].reportName.value = "Agent wise DDS Transaction report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case "16" :

                        document.forms[0].reportPath.value = "/Reports/total_dds_transaction";
                        document.forms[0].reportName.value = "Total DDS Transaction Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case "17" :

                        document.forms[0].reportPath.value = "/Reports/cash_account";
                        document.forms[0].reportName.value = "Cash Account Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                     case "18" :

                        document.forms[0].reportPath.value = "/Reports/charges_report";
                        document.forms[0].reportName.value = "Charges Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                     case "19" :

                        document.forms[0].reportPath.value = "/Reports/direct_benefit_transfer";
                        document.forms[0].reportName.value = "Direct Benefit Transfer Report";
                        if((document.getElementById("userRole").value=="201603000005020")||(document.getElementById("userRole").value=="201603000007020"))
                        document.forms[0].DOWNLOAD.value = "C";
                        else
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                     case "20" :

                        document.forms[0].reportPath.value = "/Reports/Inward_cheque_clearance";
                        document.forms[0].reportName.value = "Inward Cheque Status Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case "21" :

                        document.forms[0].reportPath.value = "/Reports/Si_report";
                        document.forms[0].reportName.value = "SI Transaction Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case "22" :

                        document.forms[0].reportPath.value = "/Reports/Sweep_report";
                        document.forms[0].reportName.value = "Sweep Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case "23" :

                        document.forms[0].reportPath.value = "/Reports/INT_COLLECTION_REPORT";
                        document.forms[0].reportName.value = "DDS Interest Collection Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "24" :

                        document.forms[0].reportPath.value = "/Reports/NEFT_RETURN_report";
                        document.forms[0].reportName.value = "NEFT Return Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "25" :

                        document.forms[0].reportPath.value = "/Reports/ACCT_SERVICES_report";
                        document.forms[0].reportName.value = "Account Services Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "26" :

                        document.forms[0].reportPath.value = "/Reports/dds_report_agent_wise_total";
                        document.forms[0].reportName.value = "DDS teller wise Total Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "27" :

                        document.forms[0].reportPath.value = "/Reports/AGENT_TOTAL_CASH";
                        document.forms[0].reportName.value = "Agent Total Cash Deposit Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "28" :

                        document.forms[0].reportPath.value = "/Reports/dds_acct_txn_tot";
                        document.forms[0].reportName.value = "DDS ACCT WISE TOTAL COLLECTION";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "29" :

                        document.forms[0].reportPath.value = "/Reports/MIS_MATURITY_REPORT";
                        document.forms[0].reportName.value = "MIS MATURITY REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "30" :

                        document.forms[0].reportPath.value = "/Reports/DDS_Agent_Mapping";
                        document.forms[0].reportName.value = "DDS Agent Mapping";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "31" :

                        document.forms[0].reportPath.value = "/Reports/SMS_CHARGES_LIST";
                        document.forms[0].reportName.value = "SMS CHARGES LIST";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "32" :

                        document.forms[0].reportPath.value = "/Reports/MISDCL_CHARGES_LIST";
                        document.forms[0].reportName.value = "MISSED CALL CHARGES LIST";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "33" :

                        document.forms[0].reportPath.value = "/Reports/SB_INT_POSTING";
                        document.forms[0].reportName.value = "SB INT POSTING REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                   case "34" :

                        document.forms[0].reportPath.value = "/Reports/SI_DETAILS";
                        document.forms[0].reportName.value = "ALL SI DETAIL REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                   case "35" :

                        document.forms[0].reportPath.value = "/Reports/BGL_REPORT_PL_WISE";
                        document.forms[0].reportName.value = "BGL REPORT PL WISE";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                   case "36" :

                        document.forms[0].reportPath.value = "/Reports/Inward_RTGS_report";
                        document.forms[0].reportName.value = "Inward RTGS REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                   case "37" :

                        document.forms[0].reportPath.value = "/Reports/ACCT_CLOSE_REGISTER";
                        document.forms[0].reportName.value = "ACCT CLOSE REGISTER REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                   case "38" :

                        document.forms[0].reportPath.value = "/Reports/ACCOUNT_HOLD_REPORT";
                        document.forms[0].reportName.value = "ACCT HOLD REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                   case "39" :

                        document.forms[0].reportPath.value = "/Reports/ACCOUNT_STOP_REPORT";
                        document.forms[0].reportName.value = "ACCT STOP REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                   case "40" :

                        document.forms[0].reportPath.value = "/Reports/kyc_report_list";
                        document.forms[0].reportName.value = "ALL KYC DETAIL REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                   case "41" :

                        document.forms[0].reportPath.value = "/Reports/moc_dtl_report";
                        document.forms[0].reportName.value = "MOC DETAIL REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                   case "42" :

                        document.forms[0].reportPath.value = "/Reports/SUB_GL_REPORT";
                        document.forms[0].reportName.value = "SUB GL REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                   case "43" :

                        document.forms[0].reportPath.value = "/Reports/LEDGER_STATEMENT_REPORT";
                        document.forms[0].reportName.value = "LEDGER STATEMENT REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                   case "44" :

                        document.forms[0].reportPath.value = "/Reports/BULK_MARK_MAP_REPORT";
                        document.forms[0].reportName.value = "BULK MARK MAP REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                   case "45" :

                        document.forms[0].reportPath.value = "/Reports/batch_dtl_report";
                        document.forms[0].reportName.value = "Batch Transaction Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                   case "46" :

                        document.forms[0].reportPath.value = "/Reports/MISSED_CALL_CHARGE_DEDUCTION_REPORT";
                        document.forms[0].reportName.value = "MISSED CALL CHARGE DEDUCTION REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                   case "47" :

                        document.forms[0].reportPath.value = "/Reports/SMS_CHARGE_DEDUCTION_REPORT";
                        document.forms[0].reportName.value = "SMS CHARGE DEDUCTION REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                   case "48" :

                        document.forms[0].reportPath.value = "/Reports/EMAIL_CHARGE_DEDUCTION_REPORT";
                        document.forms[0].reportName.value = "EMAIL CHARGE DEDUCTION REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "49" :

                        document.forms[0].reportPath.value = "/Reports/NON_TRANSACTION_CHARGE_DEDUCTION_REPORT";
                        document.forms[0].reportName.value = "NON TRANSACTION CHARGE DEDUCTION REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "50" :

                        document.forms[0].reportPath.value = "/Reports/MINBALANCE_CHARGE_DEDUCTION_REPORT";
                        document.forms[0].reportName.value = "MINIMUM BALANCE CHARGE DEDUCTION REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "51" :

                        document.forms[0].reportPath.value = "/Reports/Mat_Dep_Detail_list";
                        document.forms[0].reportName.value = "MATURED ACCOUNT DETAIL LIST REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "52" :

                        document.forms[0].reportPath.value = "/Reports/Bank_Sweep_report";
                        document.forms[0].reportName.value = "BANK SWEEP REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "53" :

                        document.forms[0].reportPath.value = "/Reports/SAMABAY_SUBIDHA_ACCT_CLOSE_REGISTER";
                        document.forms[0].reportName.value = "SAMABAY SUBIDHA ACCT CLOSE REGISTER REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "54" :

                        document.forms[0].reportPath.value = "/Reports/Inward_cheque_Final_clearance";
                        document.forms[0].reportName.value = "INWARD CHEQUE CLEARANCE REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "55" :

                        document.forms[0].reportPath.value = "/Reports/all_account_kyc_report";
                        document.forms[0].reportName.value = "ALL ACCOUNT KYC REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "56" :

                        document.forms[0].reportPath.value = "/Reports/int_prov_report";
                        document.forms[0].reportName.value = "MONTH-END INTEREST PROVISION REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                        
                    case "57" :

                        document.forms[0].reportPath.value = "/Reports/Bank_Account_mapping_report";
                        document.forms[0].reportName.value = "Bulk Account Mapping Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    
                    case "58" :

                        document.forms[0].reportPath.value = "/Reports/Bank_Inward_Neft_report";
                        document.forms[0].reportName.value = "Inward NEFT Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "59" :

                        document.forms[0].reportPath.value = "/Reports/Bank_Inward_RTGS_report";
                        document.forms[0].reportName.value = "Inward RTGS Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "60" :

                        document.forms[0].reportPath.value = "/Reports/bank_direct_benefit_transfer";
                        document.forms[0].reportName.value = "Direct Benefit Transfer Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;

                    case "61" :

                        document.forms[0].reportPath.value = "/Reports/Bank_Outward_Neft_report";
                        document.forms[0].reportName.value = "Outward NEFT Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                        
                    case "62" :

                        document.forms[0].reportPath.value = "/Reports/Bank_NEFT_RETURN_report";
                        document.forms[0].reportName.value = "Outward NEFT Return Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                        
                    case "63" :

                        document.forms[0].reportPath.value = "/Reports/cash_drawer_status_report";
                        document.forms[0].reportName.value = "Cash Drawer Status Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;    

                    default :

                        null;
                }

                if(e.options[e.selectedIndex].value == "10" && ((document.getElementById("userRole").value=="201603000005020")||(document.getElementById("userRole").value=="201603000007020")))
                    {
                        document.forms[0].action = '/PacsApplication/InwardCsvServlet';
                        document.forms[0].submit();
                    }
                else if(e.options[e.selectedIndex].value == "19" && ((document.getElementById("userRole").value=="201603000005020")||(document.getElementById("userRole").value=="201603000007020")))
                    {
                        document.forms[0].action = '/PacsApplication/DirectBenifitTransferServlet';
                        document.forms[0].submit();
                    }
                else if(e.options[e.selectedIndex].value == "7" || e.options[e.selectedIndex].value == "1" ||  e.options[e.selectedIndex].value == "5" || e.options[e.selectedIndex].value == "8" || e.options[e.selectedIndex].value == "9" )
                    {
                        if ( document.forms[0].from_date.value != document.forms[0].to_date.value )
                            {
                                alert("From Date and To Date must be same for this type of reports !");
                                return false;
                            }
                            else {
                                document.forms[0].action = '/PacsApplication/ExcelReportServlet';
                                document.forms[0].submit();
                            }
                    }
                else{
                    document.forms[0].action = '/PacsApplication/ExcelReportServlet';
                    document.forms[0].submit();
                }                                
            }

            $(document).ready(function () {
                $('select#reportSelection').change(function () {
                            $('#dep_prod').hide();
                            $('#fromDate').show();
                            $('#toDate').show();
                            $('#subGLReport').hide();
                    var shouldEnable = $(this).val();
                    switch(shouldEnable)
                    {
                        case '6':
                            $('#dep_prod').show(500);
                            $('#toDate').hide();
                            break;
                       case '34':
                           $('#fromDate').hide();
                            $('#toDate').hide();
                            break;
                       case '38':
                           $('#fromDate').hide();
                            $('#toDate').hide();
                            break;
                       case '39':
                           $('#fromDate').hide();
                            $('#toDate').hide();
                            break;
                       case '40':
                           $('#fromDate').hide();
                            $('#toDate').hide();
                            break;
                       case '42':
                           $('#fromDate').show();
                            $('#toDate').hide();
                            $('#subGLReport').show(500);
                            break;
                       case '43':
                            $('#subGLReport').show(500);
                            break;
                       case '52':
                            $('#pacs_list').show(500);
                            $('#subPacsName').hide();
                            break;
                       case '53':
                            $('#pacs_list').show(500);
                            $('#subPacsName').hide();
                            break;
                       case '57':
                            $('#pacs_list').show(500);
                            $('#subPacsName').hide();
                            $('#fromDate').hide();
                            $('#toDate').hide();
                            break; 
                        case '58':
                            $('#pacs_list').show(500);
                            $('#subPacsName').hide();
                            break;
                       case '59':
                            $('#pacs_list').show(500);
                            $('#subPacsName').hide();
                            break;
                       case '60':
                            $('#pacs_list').show(500);
                            $('#subPacsName').hide();
                            break;
                        case '61':
                            $('#pacs_list').show(500);
                            $('#subPacsName').hide();
                            break;
                       case '62':
                            $('#pacs_list').show(500);
                            $('#subPacsName').hide();
                            break;
                        case '63':
                            $('#pacs_list').hide();                           
                            $('#fromDate').hide();
                            break;    
                       
                       default:
                            $('#dep_prod').hide();
                            $('#fromDate').show();
                            $('#toDate').show();
                            $('#subPacsName').show();
                            $('#pacs_list').hide();
                            break;
                    }
                })
            });
            function ShowParent()
            {
                document.forms[0].action = "${pageContext.request.contextPath}/Deposit/Deposit_Report.jsp";
                document.forms[0].submit();
            }
            
            // to restrict back button
            history.pushState(null, null, location.href);
            window.addEventListener('popstate', function(event) {
                history.pushState(null, null, location.href);
            });
            
        </script>

        <title>Deposit Report</title>

    </head>
    <body  onload="noBack();">
        <script type="text/javascript">
            function noBack()
            {
                window.history.forward();
            }
        </script>
        <jsp:include page="MenuHead_Deposit.jsp" flush="true" />
        <br>
        <%!
            String blankNull(String s) {
                return (s == null) ? "" : s;
            }

            String blankNA(String s) {
                return (s == null) ? "NA" : s;
            }
        %>
        <%
             String pacsId = (String) session.getAttribute("pacsId");
             String userRole = (String) session.getAttribute("userRole");
             String moduleName = new String();
                moduleName = (String) session.getAttribute("moduleName");
             Object oEnquiryBeanSearchObj = request.getAttribute("oEnquiryBeanSearchObj");
             EnquiryBean oEnquiryBean = new EnquiryBean();
             EnquiryBean oEnquiryBeanSearch = new EnquiryBean();
             if (oEnquiryBeanSearchObj != null) {
                 oEnquiryBean = (EnquiryBean) request.getAttribute("oEnquiryBeanSearchObj");
                 session.setAttribute("oEnquiryBeanSearchObj", oEnquiryBeanSearchObj);
             }
        %>
        <%String subPacsFlag = (String) session.getAttribute("subPacsFlag");
        %>

        <div style="top:500px">
            <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">Deposit Report</legend>

                <form name="pacsreport" method="post" action="/PacsApplication/ExcelReportServlet">
                    <br>
                     <input type="hidden" name="userRole" id ="userRole" value="<%=userRole%>">
                    <table>
                        <%if (request.getAttribute("error") != null) {%>
                        <tr><td colspan="2" align="center"><%=request.getAttribute("error").toString()%></td></tr>
                        <%}%>

                        <tr id="fromDate">
                            <td style=" font-family: Berlin Sans FB; font-weight:  normal;">From Date: </td><td><input type="text" style="text-align:center;" id="from_date" name="from_date" maxlength="11" resize="yes" readonly="true">&nbsp;<a href="#" onclick="return getCalendar(document.forms[0].from_date);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" border="0" width="25" height="20" /></a></td>
                        </tr>
                        <tr id="toDate">
                            <td style=" font-family: Berlin Sans FB; font-weight:  normal;">To Date: </td><td><input type="text" style="text-align:center;" id="to_date" name="to_date" maxlength="11" resize="yes" readonly="true">&nbsp;<a href="#" onclick="return getCalendar(document.forms[0].to_date);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" border="0" width="25" height="20" /></a></td>
                        </tr>
                        <tr>
                            <td style=" font-family: Berlin Sans FB; font-weight:normal; ">Report Name <font color="red" >*</font>: </td>
                            <td> <select id="reportSelection" name="reportSelection" >
                                      <%if ((userRole.equalsIgnoreCase(
                     "201603000005020")) ||(userRole.equalsIgnoreCase("201603000007020")) ) {%>
                                    <option value="" disabled selected style="display:none;" >--Select--</option>
                                    <option value="10">Inward Report</option>
                                    <option value="11">Outward Report</option>
                                    <option value="18">Charges Report</option>
                                    <option value="19">Direct Benefit Transfer Report</option>
                                    <option value="22">Sweep Report</option>
                                    <option value="36">Inward RTGS REPORT</option>
                                    <option value="44">BULK MARK MAP REPORT</option>
                                    <option value="40">ALL KYC DETAIL REPORT</option>
                                    <%} else if (userRole.equalsIgnoreCase("201606000004041") && moduleName.equalsIgnoreCase("Special") || moduleName.equalsIgnoreCase("SpecialBothDep")) {%>
                                    <option value="" disabled selected style="display:none;" >--Select--</option>
                                    <option value="10">Inward Report</option>
                                    <option value="11">Outward Report</option>
                                    <option value="18">Charges Report</option>
                                    <option value="19">Direct Benefit Transfer Report</option>
                                    <option value="22">Sweep Report</option>
                                    <option value="36">Inward RTGS REPORT</option>
                                    <option value="44">BULK MARK MAP REPORT</option>
                                    <option value="40">ALL KYC DETAIL REPORT</option>
                                    <%} else if ((userRole.equalsIgnoreCase("201603000004024"))) {%>
                                    <option value="" disabled selected style="display:none;" >--Select--</option>
                                    <option value="1">Cash Transaction Report - Deno Wise</option>
                                    <option value="8">Cash Transaction Report</option>
                                    <option value="5">Day Book</option>
                                    <option value="7">Consolidated Day Book Report</option>
                                    <option value="9">Daily Cash scroll Report</option>
                                    <option value="13">Cash Denomination Report</option>
                                    <option value="17">Cash Account Report</option>
                                    <option value="27">Agent Total Cash Deposit Report</option>
                                    <option value="63">Cash Drawer Status Report</option>
                                    <%} else if ((userRole.equalsIgnoreCase("201603000008020"))) {%>
                                    <option value="" disabled selected style="display:none;" >--Select--</option>
                                    <option value="52">SWEEP REPORT</option>
                                    <option value="53">SAMABAY SUBIDHA ACCT CLOSE REGISTER REPORT</option>
                                    <option value="57">Bulk Account Mapping Report</option>
                                    <option value="58">Inward NEFT Report</option>
                                    <option value="59">Inward RTGS Report</option>
                                    <option value="60">Direct Benefit Transfer Report</option>
                                    <option value="61">Outward NEFT Report</option>
                                    <option value="62">Outward NEFT Return Report</option>
                            <!--    <option value="55">ALL ACCOUNT KYC REPORT</option>
                                    <option value="6">Deposit Detail List</option>-->
                                    <%}else{%>
                                    <option value="" disabled selected style="display:none;" >--Select--</option>
                                    <option value="1">Cash Transaction Report - Deno Wise</option>
                                    <option value="8">Cash Transaction Report</option>
                                    <option value="2">System Generated Transaction Report</option>
                                    <option value="3">Transfer Transaction Report</option>
				    <option value="5">Day Book</option>
                                    <option value="6">Deposit Detail List</option>
                                    <option value="7">Consolidated Day Book Report</option>
                                    <option value="9">Daily Cash scroll Report</option>
                                    <option value="10">Inward Report</option>
                                    <option value="11">Outward Report</option>
                                    <option value="12">Account Open Register</option>
                                    <option value="13">Cash Denomination Report</option>
                                    <option value="14">MIS transfer Report</option>
                                    <option value="15">Agent Wise DDS Transaction Report</option>
                                    <option value="16">Total DDS Transaction Report</option>
                                    <option value="17">Cash Account Report</option>
                                    <option value="18">Charges Report</option>
                                    <option value="19">Direct Benefit Transfer Report</option>
                                    <option value="20">Inward Cheque Status Report</option>
                                    <option value="21">SI Transaction Report</option>
                                    <option value="22">Sweep Report</option>
                                    <option value="23">DDS Interest Collection Report</option>
                                    <option value="24">NEFT Return Report</option>
                                    <option value="25">Account Services Report</option>
                                    <option value="26">DDS Teller wise total Report</option>
                                    <option value="27">Agent Total Cash Deposit Report</option>
                                    <option value="28">DDS ACCT WISE TOTAL COLLECTION</option>
                                    <option value="29">MIS MATURITY REPORT</option>
                                    <option value="30">DDS Agent Mapping</option>
                                    <option value="31">SMS CHARGES LIST</option>
                                    <option value="32">MISSED CALL CHARGES LIST</option>
                                    <option value="33">SB INT POSTING REPORT</option>
                                    <option value="34">ALL SI DETAIL REPORT</option>
                                    <option value="35">BGL REPORT PL WISE</option>
                                    <option value="36">Inward RTGS REPORT</option>
                                    <option value="37">ACCT CLOSE REGISTER REPORT</option>
                                    <option value="38">ACCT HOLD REPORT</option>
                                    <option value="39">ACCT STOP REPORT</option>
                                    <option value="40">ALL KYC DETAIL REPORT</option>
                                    <option value="41">MOC DETAIL REPORT</option>
                                    <option value="42">SUB GL REPORT</option>
                                    <option value="43">LEDGER STATEMENT REPORT</option>
                                    <option value="44">BULK MARK MAP REPORT</option>
                                    <option value="45">BATCH TRANSACTION REPORT</option>
                                    <option value="46">MISSED CALL CHARGE DEDUCTION REPORT</option>
                                    <option value="47">SMS CHARGE DEDUCTION REPORT</option>
                                    <option value="48">EMAIL CHARGE DEDUCTION REPORT</option>
                                    <option value="49">NON TRANSACTION CHARGE DEDUCTION REPORT</option>
                                    <option value="50">MINIMUM BALANCE CHARGE DEDUCTION REPORT</option>
                                    <option value="51">MATURED ACCOUNT DETAIL LIST REPORT</option>
                                    <option value="54">INWARD CHEQUE CLEARANCE REPORT</option>
                                    <option value="55">ALL ACCOUNT KYC REPORT</option>
                                    <option value="56">MONTH-END INTEREST PROVISION REPORT</option>
                                    <option value="63">Cash Drawer Status Report</option>
                                    
                                    <%}%>
                                </select></td>
                        </tr>
                        <tr></tr>

                        <tr id="pacs_list" style="display: none;">                           
                            <td>Select Pacs Name:</td><td>
                            <select id="pacs_code" name="pacs_code">
                               
                                <%
                                        Connection connection1 = null;
                                        ResultSet rs1 = null;
                                        Statement statement1 = null;
                                        connection1 = DbHandler.getDBConnection();
                                        try {
                                            statement1 = connection1.createStatement();
                                            rs1 = statement1.executeQuery("select dp.pacs_id,dp.pacs_id||':'||upper(dp.pacs_name) from pacs_master dp where dp.pacs_id <> '" + pacsId + "' and dp.pacs_id in (select pacs_id from pacs_master pma where lpad(to_number(pma.dccb_code), 2, '0') = (select lpad(to_number(tba.dccb_code), 2, '0') from pacs_master tba where tba.pacs_id = '" + pacsId + "') and lpad(to_number(pma.cbs_br_code), 5, '0') =(select lpad(to_number(tba.cbs_br_code), 5, '0') from pacs_master tba where tba.pacs_id = '" + pacsId + "')) and dp.pacs_id not in (select pacs_id from pacs_neft_interface) order by upper(dp.pacs_name) ");
                                            while (rs1.next()) {%>
                                            <option value="<%=rs1.getString(1)%>"><%=rs1.getString(2)%></option>
                              <%
                                                 }
                                                // statement1.close();
                                                // connection1.close();
                                             } catch (Exception e) {
                                                System.out.println("Error occurred during processing.");
                                             } finally {
                try {
                    if(statement1 !=null)
                        statement1.close();
                    if (connection1 != null)
                    connection1.close();

            } catch (Exception e) {               
               System.out.println("Error Occurred during connection close.");
            }
            }
                                         %>
                            </select>
                        </td>
                        </tr>
                        
                        <tr id="subPacsName">
                            <td style=" font-family: Berlin Sans FB; font-weight:normal; ">Sub-PACS Name: </td>
                            <td><select id="subpacs_id" name="subpacs_id" >
                                    <%if (oEnquiryBean.getSubpacs_id() == null) {%>
                                    <option value="" disabled selected style="display:none;">--Select--</option>
                                    <%if (subPacsFlag.equalsIgnoreCase("N")) {%>
                                    <option value="ALL" >ALL Pacs</option>
                                    <option value="<%=pacsId%>">Own Pacs</option>
                                    <% }%>
                                    <%
                                        Connection connection = null;
                                        ResultSet rs = null;
                                        Statement statement = null;
                                        connection = DbHandler.getDBConnection();
                                        try {
                                            statement = connection.createStatement();
                                            rs = statement.executeQuery("select m.pacs_id,m.pacs_name from pacs_master m where m.head_pacs_id = '" + pacsId + "' and m.pacs_id <> '" + pacsId + "'");
                                            if (!rs.isBeforeFirst()) {%>
                                    <option value="<%=pacsId%>" selected>No Item to Select</option>
                                    <%} else {
                                                                                    while (rs.next()) {%>
                                    <option value="<%=rs.getString(1)%>"><%=rs.getString(2)%></option>
                                    <%}
                                            }
                                           // statement.close();
                                           // connection.close();
                                        } catch (Exception e) {
                                            System.out.println("Error occurred during processing.");
                                        } finally {
                try {
                    if(statement !=null)
                        statement.close();
                    if (connection != null)
                    connection.close();

            } catch (Exception e) {               
               System.out.println("Error Occurred during connection close.");
            }

            }
                                    } else {%>
                                    <option value="<%=blankNull(oEnquiryBean.getSubpacs_id())%>" selected style="display:none;"><%=blankNull(oEnquiryBean.getSubpacs_name())%></option>
                                    <%
                                        Connection connection = null;
                                        ResultSet rs = null;
                                        Statement statement = null;
                                        connection = DbHandler.getDBConnection();
                                        try {
                                            statement = connection.createStatement();
                                            rs = statement.executeQuery("select m.pacs_id,m.pacs_name from pacs_master m where m.head_pacs_id = '" + pacsId + "' and m.pacs_id <> m.head_pacs_id ");
                                            if (!rs.isBeforeFirst()) {%>
                                    <option value="" selected>No Item to Select</option>
                                    <%} else {
                                                                                    while (rs.next()) {%>
                                    <option value="<%=rs.getString(1)%>"><%=rs.getString(2)%></option>
                                    <%}
                                                 }
                                                // statement.close();
                                                //connection.close();
                                             } catch (Exception e) {
                                                System.out.println("Error occurred during processing.");
                                             } finally {
                try {
                    if(statement !=null)
                        statement.close();
                    if (connection != null)
                    connection.close();

            } catch (Exception e) {               
               System.out.println("Error Occurred during connection close.");
            }

            }
                                         }%>
                                </select></td>
                        </tr>
                        <tr></tr>
                        <tr id="dep_prod" style="display: none;">
                            <td>Select Product:</td><td>
                            <select id="prod_id" name="prod_id">
<!--                            <option value="ALL" >ALL Deposit Products</option>-->
                                <%
                                        Connection connection = null;
                                        ResultSet rs = null;
                                        Statement statement = null;
                                        connection = DbHandler.getDBConnection();
                                        try {
                                            statement = connection.createStatement();
                                            rs = statement.executeQuery("select dp.id,dp.prod_code||':'||dp.int_cat||' '||dp.prod_name from dep_product dp where to_number(substr(dp.prod_code,1,1))<5 and dp.pacs_id like '%" + pacsId + "#%'");
                                            while (rs.next()) {%>
                                            <option value="<%=rs.getString(1)%>" ><%=rs.getString(2)%></option>
                              <%
                                                 }
                                                // statement.close();
                                                // connection.close();
                                             } catch (Exception e) {
                                                System.out.println("Error occurred during processing.");
                                             } finally {
                try {
                    if(statement !=null)
                        statement.close();
                    if (connection != null)
                    connection.close();

            } catch (Exception e) {               
               System.out.println("Error Occurred during connection close.");
            }

            }
                                         %>
                            </select>
                        </td>
                        </tr>
                        <tr id="subGLReport"  style="display: none">
                                <td>GL Code:</td>
                                <td><input type="text" maxlength="5" name="code" id="code" /></td>
                        </tr>
                    </table><br><br><br><br>
                    <tr><td><br></td></tr>
                    <tr><td><br></td></tr>
                    <tr><td><label><font color="red" >*</font> marked fields are mandatory.</label></td></tr>
                    <center>

                        <input type="button" value="Fetch Report" onclick="javascript:downloadFiles();">
                        <input type="button" value="Reset" id="Reset" onclick="ShowParent();" />
                    </center>

                    <input type="hidden" name="reportPath" value=""/>
                    <input type="hidden" name="reportName" value=""/>
                    <input type="hidden" name="DOWNLOAD" value=""/>
                   
                </form>
            </fieldset>
        </div>
    </body>
</html>
<% 	} catch (Exception e) {
               
            }
%>
