<%--
    Document   : PACS_REPORT
    Created on : Sep 17, 2015, 12:59:59 PM
    Author     : 454222
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList" %>
<%@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 import="java.util.ArrayList" %>
<%@page import="java.lang.String" %>
<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 type="text/javascript">
            function downloadFiles()
            {
//                if (document.forms[0].reportSelection.value != "" && document.forms[0].txn_date.value == "")
//                {
//                    var a = document.getElementById("reportSelection").value;
//                    if (a == "1"||a=="3"||a=="4"||a=="5") {
//                        alert("Transaction Date cannot be empty.");
//                        document.forms[0].txn_date.focus();
//                        return false;
//                    }
//                }

                var e = document.getElementById("reportSelection");
                if (e.options[e.selectedIndex].value == "") {
                    alert("Report Name cannot be empty.");
                    document.forms[0].reportSelection.focus();
                    return false;
                }
                var reports = ["7", "8", "9", "10", "11", "12", "13", "16", "20", "21", "22", "23", "25", "26", "28", "29", "30", "31"];
                var fromdate_reports = ["1", "2", "3", "4", "5", "17", "27"];
                var todate_reports = ["1", "2", "3", "4", "5", "6", "14", "15", "17", "18", "19", "24", "27"];
                var val = e.options[e.selectedIndex].value;
                
                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;
                }
                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/BGL_DAY_BOOK";
                        document.forms[0].reportName.value = "BGL TRANSACTION REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"2":
                        document.forms[0].reportPath.value = "/Reports/BAL_IN_GL_ACC_GLCC_WISE_DET_";
                        document.forms[0].reportName.value = "BGL BALANCE REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"3":
                        document.forms[0].reportPath.value = "/Reports/CC_TXN_REPORT";
                        document.forms[0].reportName.value = "CC ACCOUNT TRANSACTION REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"4":
                        document.forms[0].reportPath.value = "/Reports/CC_BALANCE_FILE";
                        document.forms[0].reportName.value = "CC ACCOUNT BALANCE REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"5":
                        document.forms[0].reportPath.value = "/Reports/NODC REPORT";
                        document.forms[0].reportName.value = "NODC REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"6":
                        document.forms[0].reportPath.value = "/Reports/kcc_dtl_list";
                        document.forms[0].reportName.value = "KCC DETAIL LIST REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"7":
                        document.forms[0].reportPath.value = "/Reports/kcc_subvension";
                        document.forms[0].reportName.value = "KCC SUBVENTION REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"8":
                        document.forms[0].reportPath.value = "/Reports/kcc_disb_reg";
                        document.forms[0].reportName.value = "KCC DISBURSEMENT REGISTER";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"9":
                        document.forms[0].reportPath.value = "/Reports/kcc_repay_reg";
                        document.forms[0].reportName.value = "KCC REPAYMENT REGISTER";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"10":
                        document.forms[0].reportPath.value = "/Reports/crop_insurance_claim_report";
                        document.forms[0].reportName.value = "CROP INSURANCE CLAIM REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"11":
                        document.forms[0].reportPath.value = "/Reports/NPA_DUE_LIST";
                        document.forms[0].reportName.value = "NPA DUE LIST REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"12":
                        document.forms[0].reportPath.value = "/Reports/consolidated_npa_report";
                        document.forms[0].reportName.value = "Consolidated NPA Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"13":
                        document.forms[0].reportPath.value = "/Reports/kcc_subvension_total";
                        document.forms[0].reportName.value = "KCC Total Subvention Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"14":
                        document.forms[0].reportPath.value = "/Reports/village_wise_kcc_dtl_list";
                        document.forms[0].reportName.value = "Village Wise KCC Detail List Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"15":
                        document.forms[0].reportPath.value = "/Reports/kcc_overdue_dtl_list";
                        document.forms[0].reportName.value = "KCC Overdue Detail List Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"16":
                        document.forms[0].reportPath.value = "/Reports/kcc_disb_repay_list";
                        document.forms[0].reportName.value = "KCC DISBURSEMENT LIST REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"17":
                        document.forms[0].reportPath.value = "/Reports/FARMER_DETAIL_REPORT";
                        document.forms[0].reportName.value = "FARMER LAND DETAIL REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"18":
                        document.forms[0].reportPath.value = "/Reports/kcc_npa_dtl_list";
                        document.forms[0].reportName.value = "NPA DETAIL LIST REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"19":
                        document.forms[0].reportPath.value = "/Reports/kcc_dtl_report";
                        document.forms[0].reportName.value = "KCC DETAIL REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"20":
                        document.forms[0].reportPath.value = "/Reports/Rupay_unreconciled_cbs";
                        document.forms[0].reportName.value = "RUPAY KCC MICRO-ATM/ATM TRANSACTIONS NOT RECONCILED IN BANK REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"21":
                        document.forms[0].reportPath.value = "/Reports/Rupay_Recon_Map";
                        document.forms[0].reportName.value = "RUPAY KCC MICRO-ATM/ATM TRANSACTIONS NOT RECONCILED IN PACS FOR MAPPED ACCOUNTS REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"22":
                        document.forms[0].reportPath.value = "/Reports/Rupay_kcc_unreconciled_unmapped";
                        document.forms[0].reportName.value = "RUPAY KCC MICRO-ATM/ATM TRANSACTIONS NOT RECONCILED IN PACS FOR NON-MAPPED ACCOUNTS REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"23":
                        document.forms[0].reportPath.value = "/Reports/Rupay_kcc_Transaction_List";
                        document.forms[0].reportName.value = "RUPAY KCC MICRO-ATM/ATM TRANSACTION PACS LIST FOR MAPPED ACCOUNTS REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"24":
                        document.forms[0].reportPath.value = "/Reports/bank_Rupay_kcc_dtl_list";
                        document.forms[0].reportName.value = "RUPAY KCC DETAIL LIST REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"25":
                        document.forms[0].reportPath.value = "/Reports/rupay_kcc_disb_reg";
                        document.forms[0].reportName.value = "RUPAY KCC DISBURSEMENT REGISTER REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"26":
                        document.forms[0].reportPath.value = "/Reports/rupay_kcc_repay_reg";
                        document.forms[0].reportName.value = "RUPAY KCC REPAYMENT REGISTER REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"27":
                        document.forms[0].reportPath.value = "/Reports/Rupay_kcc_reconciliation_acct_details";
                        document.forms[0].reportName.value = "RUPAY KCC MICRO-ATM/ATM RECONCILIATION ACCOUNT DETAILS REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"28":
                        document.forms[0].reportPath.value = "/Reports/Rupay_kcc_sanction_update";
                        document.forms[0].reportName.value = "RUPAY KCC SANCTION UPDATE REPORT";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"29":
                        document.forms[0].reportPath.value = "/Reports/Rupay_KCC_PACS_recon";
                        document.forms[0].reportName.value = "RuPay KCC Auto Reconciliation Report";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"30":
                        document.forms[0].reportPath.value = "/Reports/vccb_kcc_disb_reg";
                        document.forms[0].reportName.value = "KCC Disbursement Register Vidyasagar";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    case"31":
                        document.forms[0].reportPath.value = "/Reports/vccb_kcc_disb_reg_banklevel";
                        document.forms[0].reportName.value = "KCC DISBURSEMENT REGISTER VIDYASAGAR";
                        document.forms[0].DOWNLOAD.value = "P";
                        break;
                    default:
                        null;
                }
                document.forms[0].action = '/PacsApplication/ExcelReportServlet';
                document.forms[0].submit();
            }
            $(document).ready(function ()
            {
                $('select#reportSelection').change(function () {
                    var val = $(this).val();
                    switch (val)
                    {
                        case'1':
                            $('#dep_prod').hide();
                            $('#DateTD').show();
                            $('#fromDt').hide();
                            $('#toDt').hide();
                            break;
                        case'2':
                            $('#dep_prod').hide();
                            $('#DateTD').hide();
                            $('#fromDt').hide();
                            $('#toDt').hide();
                            break;
                        case'3':
                            $('#dep_prod').hide();
                            $('#DateTD').show();
                            $('#fromDt').hide();
                            $('#toDt').hide();
                            break;
                        case'4':
                            $('#dep_prod').hide();
                            $('#DateTD').show();
                            $('#fromDt').hide();
                            $('#toDt').hide();
                            break;
                        case'5':
                            $('#dep_prod').hide();
                            $('#DateTD').show();
                            $('#fromDt').hide();
                            $('#toDt').hide();
                            break;
                        case'6':
                            $('#DateTD').hide();
                            $('#dep_prod').show();
                            $('#fromDt').show();
                            $('#toDt').hide();
                            break;
                        case'7':
                            $('#DateTD').hide();
                            $('#dep_prod').show();
                            $('#fromDt').show();
                            $('#toDt').show();
                            break;
                        case'8':
                            $('#DateTD').hide();
                            $('#dep_prod').hide();
                            $('#fromDt').show();
                            $('#toDt').show();
                            break;
                        case'9':
                            $('#DateTD').hide();
                            $('#dep_prod').hide();
                            $('#fromDt').show();
                            $('#toDt').show();
                            break;
                        case'10':
                            $('#DateTD').hide();
                            $('#dep_prod').hide();
                            $('#fromDt').show();
                            $('#toDt').show();
                            break;
                        case'11':
                            $('#fromDt').show();
                            $('#toDt').show();
                            break;
                        case'12':
                            $('#fromDt').show();
                            $('#toDt').show();
                            break;
                        case'13':
                            $('#DateTD').hide();
                            $('#dep_prod').show();
                            $('#fromDt').show();
                            $('#toDt').show();
                            break;
                        case'14':
                            $('#DateTD').hide();
                            $('#dep_prod').show();
                            $('#fromDt').show();
                            $('#toDt').hide();
                            break;
                        case'15':
                            $('#DateTD').hide();
                            $('#dep_prod').show();
                            $('#fromDt').show();
                            $('#toDt').hide();
                            break;
                        case'16':
                            $('#DateTD').hide();
                            $('#dep_prod').hide();
                            $('#fromDt').show();
                            $('#toDt').show();
                            break;
                        case'18':
                            $('#DateTD').hide();
                            $('#dep_prod').show();
                            $('#fromDt').show();
                            $('#toDt').hide();
                            break;
                        case'19':
                            $('#DateTD').hide();
                            $('#dep_prod').show();
                            $('#fromDt').show();
                            $('#toDt').hide();
                            break;
                        case'20':
                            $('#DateTD').hide();
                            $('#dep_prod').hide();
                            $('#fromDt').show();
                            $('#toDt').show();
                            $('#subPacsID').hide();
                            $('#pacs_list').hide();
                            break;
                        case'21':
                            $('#DateTD').hide();
                            $('#dep_prod').hide();
                            $('#fromDt').show();
                            $('#toDt').show();
                            $('#subPacsID').hide();
                            $('#pacs_list').hide();
                            break;
                        case'22':
                            $('#DateTD').hide();
                            $('#dep_prod').hide();
                            $('#fromDt').show();
                            $('#toDt').show();
                            $('#subPacsID').hide();
                            $('#pacs_list').hide();
                            break;
                        case'23':
                            $('#DateTD').hide();
                            $('#dep_prod').hide();
                            $('#fromDt').show();
                            $('#toDt').show();
                            $('#subPacsID').hide();
                            $('#pacs_list').hide();
                            break;
                        case'24':
                            $('#DateTD').hide();
                            $('#dep_prod').hide();
                            $('#fromDt').show();
                            $('#toDt').hide();
                            $('#subPacsID').hide();
                            $('#pacs_list').show();
                            break;
                        case'25':
                            $('#DateTD').hide();
                            $('#dep_prod').hide();
                            $('#fromDt').show();
                            $('#toDt').show();
                            $('#subPacsID').hide();
                            $('#pacs_list').show();
                            break;
                        case'26':
                            $('#DateTD').hide();
                            $('#dep_prod').hide();
                            $('#fromDt').show();
                            $('#toDt').show();
                            $('#subPacsID').hide();
                            $('#pacs_list').show();
                            break;
                        case'27':
                            $('#DateTD').hide();
                            $('#dep_prod').hide();
                            $('#fromDt').hide();
                            $('#toDt').hide();
                            $('#subPacsID').hide();
                            $('#pacs_list').hide();
                            break;
                        case'28':
                            $('#DateTD').hide();
                            $('#dep_prod').hide();
                            $('#fromDt').show();
                            $('#toDt').show();
                            $('#subPacsID').hide();
                            $('#pacs_list').show();
                            break;
                        case'29':
                            $('#DateTD').hide();
                            $('#dep_prod').hide();
                            $('#fromDt').show();
                            $('#toDt').show();
                            break;
                        case'30':
                            $('#DateTD').hide();
                            $('#dep_prod').hide();
                            $('#fromDt').show();
                            $('#toDt').show();
                            $('#subPacsID').show();
                            //$('#pacs_list').show();
                            break;
                        case'31':
                            $('#DateTD').hide();
                            $('#dep_prod').hide();
                            $('#fromDt').show();
                            $('#toDt').show();
                            $('#subPacsID').hide();
                            $('#pacs_list').show();
                            break;
                        default:
                            $('#dep_prod').hide();
                            $('#DateTD').hide();
                            $('#fromDt').hide();
                            $('#toDt').hide();
                            $('#subPacsID').show();
                            $('#pacs_list').hide();
                            break;
                    }
                });
            });

            function ShowParent() {
                document.forms[0].action = "${pageContext.request.contextPath}/PACS_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>KCC Report</title>
        <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon"/>
    </head>

    <body onload="noBack();">
        <script type="text/javascript">function noBack() {
                window.history.forward();
                alert("pacs" + pacsId);
            }</script>
            <jsp:include page="MenuHead.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">KCC Report</legend>

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



                        <tr>

                            <td>Report Name <font color="red">*</font>: </td>
                            <td> <select id="reportSelection" name="reportSelection">
                                    <% if (userRole.equalsIgnoreCase("201603000008020")) {%>
                                    <option value="" disabled selected style="display:none;">--Select--</option>
                                    <option value="20">RUPAY KCC MICRO-ATM/ATM TRANSACTIONS NOT RECONCILED IN BANK REPORT</option>
                                    <option value="21">RUPAY KCC MICRO-ATM/ATM TRANSACTIONS NOT RECONCILED IN PACS FOR MAPPED ACCOUNTS REPORT</option>
                                    <option value="22">RUPAY KCC MICRO-ATM/ATM TRANSACTIONS NOT RECONCILED IN PACS FOR NON-MAPPED ACCOUNTS REPORT</option>
                                    <option value="23">RUPAY KCC MICRO-ATM/ATM TRANSACTION PACS LIST FOR MAPPED ACCOUNTS REPORT</option>
                                    <option value="24">RUPAY KCC DETAIL LIST REPORT</option>
                                    <option value="25">RUPAY KCC DISBURSEMENT REGISTER REPORT</option>
                                    <option value="26">RUPAY KCC REPAYMENT REGISTER REPORT</option>
                                    <option value="27">RUPAY KCC MICRO-ATM/ATM RECONCILIATION ACCOUNT DETAILS REPORT</option>
                                    <option value="28">RUPAY KCC SANCTION UPDATE REPORT</option>
                                    <option value="31">KCC DISBURSEMENT REGISTER VIDYASAGAR</option>


                                    <%} else if ((userRole.equalsIgnoreCase("201603000006020")) || (userRole.equalsIgnoreCase("201603000007020"))) {%>
                                    <option value="" disabled selected style="display:none;">--Select--</option>
                                    <option value="6">KCC Detail List</option>
                                    <option value="8">KCC Disbursement Register</option>
                                    <option value="9">KCC Repayment Register</option>
                                    <%} else if (userRole.equalsIgnoreCase("201606000004041") && moduleName.equalsIgnoreCase("SpecialKcc") || moduleName.equalsIgnoreCase("SpecialBothKcc")) {%>
                                    <option value="" disabled selected style="display:none;">--Select--</option>
                                    <option value="6">KCC Detail List</option>
                                    <option value="8">KCC Disbursement Register</option>
                                    <option value="9">KCC Repayment Register</option>
                                    <%} else {%>
                                    <option value="" disabled selected style="display:none;">--Select--</option>
                                    <%--<option value="1">BGL Transaction Report</option>
                                    <option value="2">BGL Wise Balance Report</option>
                                    <option value="3">CC Transaction Report</option>
                                    <option value="4">CC Balance Report</option>--%>
                                    <option value="5">NODC Report</option>
                                    <option value="6">KCC Detail List</option>
                                    <option value="7">KCC AGRIL Subvention Report</option>
                                    <option value="8">KCC Disbursement Register</option>
                                    <option value="30">KCC Disbursement Register Vidyasagar</option>
                                    <option value="9">KCC Repayment Register</option>
                                    <option value="10">Crop Insurance Claim Report</option>
                                    <option value="11">NPA Due List Report</option>
                                    <option value="12">Consolidated NPA Report</option>
                                    <option value="13">KCC Total Subvention Report</option>
                                    <option value="14">Village Wise KCC Detail List Report</option>
                                    <option value="15">KCC Overdue Detail List Report</option>
                                    <option value="16">KCC DISBURSEMENT LIST REPORT</option>
                                    <option value="17">FARMER LAND DETAIL REPORT</option>
                                    <option value="18">NPA DETAIL LIST REPORT</option>
                                    <option value="19">KCC DETAIL REPORT</option>
                                    <option value="29">RuPay KCC Auto Reconciliation Report</option>
                                    <%}%>
                                </select></td>
                        </tr>
                        <tr id="subPacsID">
                            <td>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: <%out.println(pacsId);%></option>
                                    <% }%>
                                    <%//pacsId="12343"; ignore this%>
                                    <%
                                        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>
                                    <%}
                                            }
                                        } 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 id="fromDt"><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" data-pagespeed-url-hash="1494549184" onload="pagespeed.CriticalImages.checkImageForCriticality(this);"/></a></td>
                        </tr>
                        <tr id="toDt"><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" data-pagespeed-url-hash="1494549184" onload="pagespeed.CriticalImages.checkImageForCriticality(this);"/></a></td>
                        </tr>

                        <tr id="dep_prod" style="display: none;">
                            <td>Select Product:</td><td>
                                <select id="productId" name="productId">
                                    <!--<option value="ALL">ALL KCC 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="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 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 in (select pacs_id from pacs_kcc_param) 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>

                    </table>                            
                    <br><br><br><br>
                    <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>
