<%--
    Document   : UserAmendment
    Created on : Sep 13, 2019, 6:00:55 PM
    Author     : 1242938
--%>

<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.util.Date"%>
<%@page import="LoginDb.DbHandler"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.UUID" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%String uuid = UUID.randomUUID().toString();%>
<% try {
%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>User Amendment</title>
        <link rel="shortcut icon" href="${pageContext.request.contextPath}/img/favicon.ico" type="image/x-icon" />
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/TableCSSCode.css" />
        <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 src="${pageContext.request.contextPath}/js/Calendar.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/chromejs/chrome.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <script type="text/javascript" src="/PacsApplication/js/iFrame_killer.js"></script>

        <style>
            .beforeAccSrch {
                display: none;
            }
        </style>
    </head>
    <body  onload="noBack()">
        <script type="text/javascript">
            function noBack()
            {
                window.history.forward();
                document.getElementById("block1").style.display = "none";
                document.getElementById("block2").style.display = "none";
                document.getElementById("block3").style.display = "none";
                document.getElementById("block4").style.display = "none";
                document.getElementById("flag").style.display = "none";
            }

            function ShowParent()
            {

                document.forms[0].action = "${pageContext.request.contextPath}/Deposit/UserAmendment.jsp";
                document.forms[0].submit();
            }
            function popup_user(width, height, userId) {

                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 = "UserAmendment.jsp";
                var  lovKey="UserSrch"
                popWin = open('${pageContext.request.contextPath}/CommonSearchInfoLOVNew.jsp?screenName=' + screenName+ '&userId='+userId +'&lovKey='+lovKey, 'UserSrch', attr);
                popWin.focus();

            }
            function submitform(){
                
                if(validateForm()){
                    document.UserAmendment.action = '/PacsApplication/UserAmendmentServlet';
                    document.UserAmendment.submit();
                }
            }
            function validateForm()
            {
               if($('#opType').val() == "")
                {
                    alert("Select any Operation first.");
                    UserAmendment.opType.focus();
                    return false;
                }
               if($('#userName').val() == "")
                {
                    alert("User Name cannot be blank.");
                    UserAmendment.userName.focus();
                    return false;
                }
                if($('#ipFlag').val() == "")
                {
                    alert("Please select IP Flag.");
                    UserAmendment.ipFlag.focus(); 
                    return false;
                }
                if($('#ipFlag').val() == "Y")
                {
                    if( ($('#staticIP').val() == "") || ($('#staticIP').val() == "NA") )
                    {    
                        alert("Please enter valid Static IP.");
                        UserAmendment.staticIP.focus(); 
                        return false;
                    }    
                }
                return true;
            }            
            function checkop() {
                var opt = document.getElementById("opType").value;
                document.getElementById("userName").value = "";
                document.getElementById("userId").value = "";
                document.getElementById("ipFlag").value = "";
                document.getElementById("staticIP").value = "";

                if( opt == "" ){
                    document.getElementById("block1").style.display = "none";
                    document.getElementById("block2").style.display = "none";
                    document.getElementById("block3").style.display = "none";
                    document.getElementById("block4").style.display = "none";
                    document.getElementById("flag").style.display = "none";
                }
                else if( opt == "DELETE" || opt == "DETAG" ){
                    document.getElementById("userName").readOnly = true;
                    document.getElementById("block1").style.display = "block";
                    document.getElementById("block2").style.display = "block";
                    document.getElementById("block3").style.display = "block";
                    document.getElementById("block4").style.display = "none";
                    document.getElementById("flag").style.display = "none";
                }
                else{
                    document.getElementById("userName").readOnly = false;
                    document.getElementById("block1").style.display = "block";
                    document.getElementById("block2").style.display = "block";
                    document.getElementById("block3").style.display = "block";
                    document.getElementById("block4").style.display = "block";
                    document.getElementById("flag").style.display = "block";
                }                
            }
            function checkopFlag() {
                var opt = document.getElementById("ipFlag").value;
               
                if( opt == "" || opt == "N"){
                    document.getElementById("flag").style.visibility = "hidden";
                    document.getElementById("block2").style.visibility = "visible";
                    document.getElementById("block3").style.visibility = "visible";
                    document.getElementById("block4").style.visibility = "visible";
                }
                else if( opt == "Y" ){
                    document.getElementById("flag").style.visibility = "visible";
                    document.getElementById("block2").style.visibility = "visible";
                    document.getElementById("block3").style.visibility = "visible";
                    document.getElementById("block4").style.visibility = "visible";
                }                                
            }
            
            // to restrict back button
            history.pushState(null, null, location.href);
            window.addEventListener('popstate', function(event) {
                history.pushState(null, null, location.href);
            });
            
        </script>

        <jsp:include page="MenuHead_Deposit.jsp" flush="true" />
        <br>

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

                 String error_msg = "";
                 Object error = request.getAttribute("message1");
                  if (error != null) {
                     error_msg = error.toString();

                 }
         %>

        <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">User Amendment</legend>
            <%if (!error_msg.equalsIgnoreCase("")) {%>
                    <center><div class="info" id="errorMessage"><center><%= error_msg%></center></div></center>
                    <% }%>
            <form name="UserAmendment" id="UserAmendment" action="" method="post">

                    <tr></tr><tr></tr><tr></tr>
                    <tr></tr><tr></tr><tr></tr>
                    <table>
                        <tbody>
                            <tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>
                            <center><lable>Operation Selection<font color="red" >*</font>: </lable>
                            <select id="opType" onchange="checkop()" name="opType" >
                                <option value="" > --Select-- </option>
                                <option value="AMEND" >User Amendment</option>
                                <option value="DELETE" >User Deactivation</option>
                                <option value="DETAG" >Detag DDS Device</option>
                            </select>

                            <div id="div1" >
                            <table>
                            <tr id="block1">
                                <%--<td><input type="button" value="Search User" onclick="javascript:popup_user(500,300,UserAmendment.userId.value);"  /></td>--%>
                            </tr>
                            <tr></tr><tr></tr><tr></tr>
                            <tr></tr><tr></tr><tr></tr>
                            <tr id="block2">
                                <td>User Name<font color="red" >*</font>:</td>
                                <td><input type="text" size="30" name="userName" id="userName" Value="" /></td>
                                <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>  
                                <td><input type="button" value="Search User" onclick="javascript:popup_user(500,300,UserAmendment.userId.value);"  /></td>
                            </tr>
                            <tr></tr><tr></tr><tr></tr>
                            <tr id="block3">
                                <td>User Id:</td>
                                <td><input type="text" readonly size="20" name="userId" id="userId" Value="" style="text-align:right;" /></td>
                            </tr>
                            <tr></tr><tr></tr><tr></tr>
                            <tr id="block4"><td><lable>Select IP Flag<font color="red" >*</font>: </lable></td>
                            <td><select id="ipFlag" onchange="checkopFlag()" name="ipFlag" >
                                <option value="" > --Select-- </option>
                                <option value="Y" >Yes</option>
                                <option value="N" >No</option>
                            </select>
                            </td></tr><tr></tr><tr></tr>
                            <tr id="flag">
                                <td>Static IP:</td>
                                <td><input type="text" size="30" name="staticIP" id="staticIP" value="" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' onclick="onChange()"/></td>
                                </tr><tr></tr>                            
                            <tr>
                                <td><input type="text" hidden size="20" name="roleId" id="roleId" Value="" /></td>
                            </tr>

                            </table>
                            </div>
                        </center>
                        </tbody>

                    </table>
                    <br>
                    <center>  
                    <input type="button" value="Submit" id="Submit" onclick="submitform();" />
                    <input type="button" value="Reset" id="Reset" onclick="ShowParent();" />

                </center>
            </form>
        </fieldset>
    </body>
</html>
<% 	} catch (Exception e) {
              
            }
%>