<%--
    Document   : CashWithdrawlDeposit
    Created on : Jul 16, 2018, 5:40:14 PM
    Author     : 1004242
--%>

<%@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"%>




<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/TableCSSCode.css?pacs=<%=((new java.util.Date()).getTime())%>" />
        <title>Agent Mapping</title>
        <%-- <link rel="shortcut icon" href="img/favicon.ico?pacs=<%=((new java.util.Date()).getTime())%>" type="image/x-icon" />--%>
        <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="/PacsApplication/chromejs/chrome.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <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/js/iFrame_killer.js"></script>
        <script type="text/javascript" src="/PacsApplication/bootstrap/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="/PacsApplication/bootstrap/js/bootstrap.js"></script>
        <link rel="stylesheet" type="text/css" href="/PacsApplication/bootstrap/css/bootstrap.min.css" />
        <link rel="stylesheet" type="text/css" href="/PacsApplication/bootstrap/css/bootstrap.css" />
    </head>
    <script>

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

        function popup_depAccountAgnt(width, height, custName) {
            if (window.innerWidth) {
                LeftPosition = (window.innerWidth - width) / 2;
                TopPosition = ((window.innerHeight - height) / 2) - 20;
            }
            else {
                LeftPosition = (parseInt(window.screen.width) - width) / 2;
                TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
            }
            attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
                height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
                TopPosition + '';
            var screenName = "AgentMapping.jsp";
        var lovKey = "agntAccount";
            popWin = open('${pageContext.request.contextPath}/CommonSearchInfoLOVNew.jsp?customerName=' + custName + '&screenName=' + screenName + '&lovKey=' + lovKey, 'agntAccount', attr);
            popWin.focus();

        }

    function popup_AgentList(width, height, agentName) {
        if (window.innerWidth) {
            LeftPosition = (window.innerWidth - width) / 2;
            TopPosition = ((window.innerHeight - height) / 2) - 20;
        }
        else {
            LeftPosition = (parseInt(window.screen.width) - width) / 2;
            TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
        }
        attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
            height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
            TopPosition + '';
        var screenName = "AgentMapping.jsp";
    var lovKey =     "agntMap";
        popWin = open('${pageContext.request.contextPath}/CommonSearchInfoLOVNew.jsp?agentName=' + agentName + '&screenName=' + screenName + '&lovKey=' + lovKey, 'agntMap', attr);
        popWin.focus();

    }

    function popup_AgentList1(width, height, agentName) {
        if (window.innerWidth) {
            LeftPosition = (window.innerWidth - width) / 2;
            TopPosition = ((window.innerHeight - height) / 2) - 20;
        }
        else {
            LeftPosition = (parseInt(window.screen.width) - width) / 2;
            TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
        }
        attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
            height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
            TopPosition + '';
        var screenName = "AgentMapping.jsp";
    var lovKey = "limitSetting";
        popWin = open('${pageContext.request.contextPath}/CommonSearchInfoLOVNew.jsp?agentName=' + agentName + '&screenName=' + screenName + '&lovKey=' + lovKey, 'agntMap', attr);
        popWin.focus();

    }

        <%-- function checkDiv(cashForm)
         {
                if (cashForm.amnt.value == "" || cashForm.amnt.value == 0 )
                {
                    alert("Amount must be greater than zero!!");
                    cashForm.amnt.focus();
                    return false;
                }
                else if (cashForm.accNo.value == "" )
                {
                    alert("Account must be selected!!");
                    cashForm.accNo.focus();
                    return false;
                }

                return true;
            }--%>
                function submitform(cashForm)
                {
        <%--if(checkDiv(cashForm)){--%>
                        $('#tranType').val($('#tranTypeOrg').val());
                        $('#accNoServer').val($('#accNo').val());
                        $('#agntIdServer').val($('#agntIdId').val());
                        document.cashForm.action = '/PacsApplication/AgentMappingServlet';
                        document.cashForm.submit();                
                    }

                    function submitform2(limitSettingForm)
                {
                        $('#agntIdServer2').val($('#agentId').val());
                        document.limitSettingForm.action = '/PacsApplication/AgentMappingServlet';
                        document.limitSettingForm.submit();
                }

                    function openPage(){
                       // var pageType=document.querySelector('input[name="pageType"]:checked').value;
                        //alert(pageType);
                        $('#'+pageType).show();
                        if(pageType=="agentMapping")
                            $('#pageName').html('Agent Mapping');
                        if(pageType=="limitSetting")
                            $('#pageName').html('Limit Setting');
                        //alert();
                       // pageType=document.querySelector('input[name="pageType"]:not(:checked)').value;
                        $('#'+pageType).hide();
                        $('#selOptn').hide();
                        //document.getElementsByName('pageName').innerHTML='';
                    }

                    function pageLoad(){
                        if($('#errorMessage').length > 0 ){
                            $('#agentMapping').show();
                            $('#limitSetting').hide();
                            $('#pageName').html('Agent Mapping');
                            $('#selOptn').hide();
                        } else if($('#errorMessage2').length > 0 ){
                            $('#agentMapping').hide();
                            $('#limitSetting').show();
                            $('#pageName').html('Limit Setting');
                            $('#selOptn').hide();
                        } else {
                            $('#agentMapping').hide();
                            $('#limitSetting').hide();
                            $('#pageName').html('Agent Mapping/Limit Setting');
                            $("input[name='pageType']").attr('checked', false);
                            $('#selOptn').show();
                        }
                    }
        // to restrict going back 
            history.pushState(null, null, location.href);
            window.addEventListener('popstate', function(event) {
                history.pushState(null, null, location.href);
            });

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

                String error_msg2 = "";
                Object error2 = request.getAttribute("message2");
                if (error2 != null) {
                    error_msg2 = error2.toString();
                }
    %>
    <style>

        legend.scheduler-border {

            text-align: left !important;
            width:inherit; /* Or auto */

            border-bottom:none;
            padding: 8px;
            border-radius: 20px;
            background-color: #006600;
            color: white
        }
        fieldset.scheduler-border {
            border: 5px groove #ddd !important;
            padding: 0 1.4em 1.4em 1.4em !important;
            margin: 0 0 1.5em 0 !important;
            -webkit-box-shadow:  0px 0px 0px 0px #000;
            box-shadow:  0px 0px 0px 0px #000;
            border-color: black;
            background-image: url('/PacsApplication/img/download.jpg');
            border-width: 3px
        }

    </style>

    <body onload="noBack();pageLoad();">
        <jsp:include page="MenuHead_Deposit.jsp" flush="true" />
        <fieldset class="scheduler-border">
            <legend class="scheduler-border" id="pageName" name="pageName">Agent Mapping/Limit Setting</legend>
            <div id="selOptn">
                <input type="radio" name="pageType" value="agentMapping" onclick="javascript:openPage()"> <b>Agent Mapping</b> &nbsp;&nbsp;
                <input type="radio" name="pageType" value="limitSetting" onclick="javascript:openPage()"> <b>Limit Setting</b><br><br>
            </div>
            <div class="container-fluid" id="agentMapping">
                <form name="cashForm" method="post" action="">

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

                    <div class="row">
                        <div class="col-xs-4 col-md-4"></div>
                        <div class="col-xs-4 col-md-4">
                            <div class="form-group">
                                <label>Select type of Operation:</label>
                                <select class="selectpicker" id="tranTypeOrg">
                                    <option value="CREATE" >Create new agent mapping to account</option>
                                    <option value="UPDATE" >Update agent mapping </option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="accName">Customer Name: </label>
                                <input type="text" class="form-control" id="accName" name="accntName" placeholder="Customer Name">
                                <input type="button"  value="Search" onclick="javascript:popup_depAccountAgnt(750, 250,document.cashForm.accntName.value)"/>

                            </div>                            
                            <div class="form-group">
                                <label for="accName">Account Number: </label>
                                <input type="text" class="form-control" id="accNo" name="accntNo" placeholder="account No." disabled style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' >

                            </div>
                            <div class="form-group">
                                <label for="accName">Agent ID: </label>
                                <input type="text" class="form-control" id="agntIdId" name="agntIdname" placeholder="Agent Id" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' >
                                <input type="button"  value="Search" onclick="javascript:popup_AgentList(750, 250,document.cashForm.agntIdname.value)" />

                            </div>
                            <div class="form-group">
                                <%--<label for="accName">Avail Bal.</label>--%>
                                <input type="hidden" class="form-control" id="avlBal" name="avlBal" placeholder="Avail Balance" disabled>

                            </div>
                            <div class="form-group">
                                <%-- <label for="amntName">Amount:</label>--%>
                                <input type="hidden" class="form-control" id="amntName" name="amnt" placeholder="enter amount">
                            </div>

                            <%--   <div class="form-group">
                                   <label for="narration">Narration:</label>
                                   <textarea class="form-control" id="narration" name="narration" rows="3"></textarea>
                               </div>--%>
                            <input class="btn btn-primary" type="submit" value="Submit" onclick="javascript:submitform(cashForm)">
                            <input class="btn btn-primary" type="reset" value="Reset" onclick="javascript:pageLoad()">
                            <input type="hidden" name="tranType" id="tranType" value=""/>
                            <input type="hidden" name="accNoServer" id="accNoServer" value=""/>
                            <input type="hidden" name="agntIdServer" id="agntIdServer" value=""/>
                        </div>
                        <div class="col-xs-4 col-md-4"></div>
                    </div>
                </form>
            </div>

            <div class="container-fluid" id="limitSetting">
                <form name="limitSettingForm" method="post" action="">

                    <%if (!error_msg2.equalsIgnoreCase("")) {%>
                    <center><div class="info" id="errorMessage2"><center><%= error_msg2%></center></div></center>
                    <% }%>

                    <div class="row">
                        <div class="col-xs-4 col-md-4"></div>
                        <div class="col-xs-4 col-md-4">


                            <div class="form-group">
                                <label for="agentId">Agent ID: </label>
                                <input type="text" class="form-control" id="agentId" name="agentId" placeholder="Agent ID" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' >
                                <input type="button"  value="Search" onclick="javascript:popup_AgentList1(750, 250,document.limitSettingForm.agentId.value)"/>                            
                            </div>

                            <div class="form-group">
                                <label>Limit: </label>
                                <input type="text" id="limit" name="limit" placeholder="Limit" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' >
                            </div>

                            <input class="btn btn-primary" type="submit" value="Submit" onclick="javascript:submitform2(limitSettingForm)">
                            <input class="btn btn-primary" type="reset" value="Reset" onclick="javascript:pageLoad()">
                            <input type="hidden" name="agntIdServer2" id="agntIdServer2" value=""/>


                        </div>
                        <div class="col-xs-4 col-md-4"></div>
                    </div>
                </form>
            </div>
        </fieldset>
    </body>
    <html>







