<%--
    Document   :AddressDetails
    Created on : Apr 20, 2016, 3:16:34 PM
    Author     :
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="DataEntryBean.AddressDetailsBean"%>
<% try {
%>

<html>
    <head>
        
        <title>Address Details</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="${pageContext.request.contextPath}/js/Calendar.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/TableCSSCode.css?pacs=<%=((new java.util.Date()).getTime())%>" />
        <link rel="shortcut icon" href="${pageContext.request.contextPath}/img/favicon.ico?pacs=<%=((new java.util.Date()).getTime())%>" type="image/x-icon" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/styles.css?pacs=<%=((new java.util.Date()).getTime())%>"/>
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/ButtonAndText.css?pacs=<%=((new java.util.Date()).getTime())%>" />
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/info.css?pacs=<%=((new java.util.Date()).getTime())%>" />
        <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-ui-1.10.4.custom/development-bundle/jquery-1.10.2.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <script type="text/javascript" src="/PacsApplication/chromejs/chrome.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <script type="text/javascript" src="/PacsApplication/js/iFrame_killer.js"></script>
    </head>
    <body onload="noBack()">
        <script type="text/javascript">
            function noBack()
            {
                window.history.forward();
            }
            function numbersonly(e){
                    var unicode=e.charCode? e.charCode : e.keyCode
                    if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
                            if (unicode<48||unicode>57) //if not a number
                                    return false ;//disable key press
                    }
            }
            function submitform(addressdetailsform)
            {
                if (checkCreateDiv(addressdetailsform))
                {
                    document.forms[0].handle_id.value = "Create";
                    document.forms[0].action='/PacsApplication/AddressDetailsServlet';

                    addressdetailsform.submit();
                }

            }
            function checkCreateDiv(addressdetailsform)
            {
                if (addressdetailsform.shgcode.value == "")
                {
                    alert("SHG Code should be filled.");
                    addressdetailsform.shgcode.focus();
                    return false;
                }
                if (addressdetailsform.district.value == "")
                {
                    alert("District should be filled.");
                    addressdetailsform.district.focus();
                    return false;
                }
                if (addressdetailsform.subdivisions.value == "")
                {
                    alert("Subdivisions should be filled.");
                    addressdetailsform.subdivisions.focus();
                    return false;
                }
                if (addressdetailsform.municipality.value == "")
                {
                    alert("Municipality should be filled.");
                    addressdetailsform.municipality.focus();
                    return false;
                }
                if (addressdetailsform.panchayat.value == "")
                {
                    alert("Panchayat should be filled.");
                    addressdetailsform.panchayat.focus();
                    return false;
                }
                if (addressdetailsform.village.value == "")
                {
                    alert("Village should be filled.");
                    addressdetailsform.village.focus();
                    return false;
                }
                if (addressdetailsform.policestation.value == "")
                {
                    alert("Police Station should be filled.");
                    addressdetailsform.policestation.focus();
                    return false;
                }
                if (addressdetailsform.postoffice.value == "")
                {
                    alert("Post Office should be filled.");
                    addressdetailsform.postoffice.focus();
                    return false;
                }                
                if (addressdetailsform.pincode.value == "")
                {
                    alert("Pincode should be filled.");
                    addressdetailsform.pincode.focus();
                    return false;
                }

                document.forms[0].submit();
                return true;
            }

            function updateform(addressdetailsform)
            {
                if (checkUpdateDiv(addressdetailsform))
                {
                    document.forms[0].handle_id.value = "Update";
                    document.forms[0].action='/PacsApplication/AddressDetailsServlet';
                    addressdetailsform.submit();

                }
            }
            function checkUpdateDiv(addressdetailsform)
            {
                if (addressdetailsform.districtAmend.value == "")
                {
                    alert("District should be filled.");
                    addressdetailsform.districtAmend.focus();
                    return false;
                }
                if (addressdetailsform.subdivisionsAmend.value == "")
                {
                    alert("Subdivisions should be filled.");
                    addressdetailsform.subdivisionsAmend.focus();
                    return false;
                }
                if (addressdetailsform.municipalityAmend.value == "")
                {
                    alert("Municipality should be filled.");
                    addressdetailsform.municipalityAmend.focus();
                    return false;
                }
                if (addressdetailsform.panchayatAmend.value == "")
                {
                    alert("Panchayat should be filled.");
                    addressdetailsform.panchayatAmend.focus();
                    return false;
                }
                if (addressdetailsform.villageAmend.value == "")
                {
                    alert("Village should be filled.");
                    addressdetailsform.villageAmend.focus();
                    return false;
                }
                if (addressdetailsform.postofficeAmend.value == "")
                {
                    alert("Post Office should be filled.");
                    addressdetailsform.postofficeAmend.focus();
                    return false;
                }
                if (addressdetailsform.policestationAmend.value == "")
                {
                    alert("!! Police Station should be filled.");
                    addressdetailsform.policestationAmend.focus();
                    return false;
                }
                if (addressdetailsform.pincodeAmend.value == "")
                {
                    alert("Pincode should be filled.");
                    addressdetailsform.pincodeAmend.focus();
                    return false;
                }

                document.forms[0].submit();
                return true;
            }

            function checkop()
            {
                if (document.getElementById("checkOption").value == "create")
                {
                    document.getElementById('create').style.display = 'block';
                    document.getElementById('amend').style.display = 'none';
                    document.getElementById('amend2').style.display = 'none';
                }
                if (document.getElementById("checkOption").value == "amend")
                {
                    document.getElementById('create').style.display = 'none';
                    document.getElementById('amend').style.display = 'block';
                    document.getElementById('amend2').style.display = 'none';
                }
            }

            function searchShg(width, height, shgSearch) {

                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 = "AddressDetails.jsp";
                var lovKey = "addressDetails"
                popWin = open('/PacsApplication/CommonSearchInformationShgLOV.jsp?shgSearch=' + shgSearch + '&screenName=' + screenName + '&lovKey=' + lovKey, 'addressDetails', attr);
                popWin.focus();

            }
            function searchShgcode(width, height, shgcodeSearch) {

                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 = "AddressDetails.jsp";
                var lovKey = "addressDetailscode"
                popWin = open('/PacsApplication/CommonSearchInformationShgLOV.jsp?shgcodeSearch=' + shgcodeSearch + '&screenName=' + screenName + '&lovKey=' + lovKey, 'addressDetailscode', attr);
                popWin.focus();

            }
            function getDetails()
            {
                if (document.getElementById("shgSearch").value == "")
                {
                    alert("Shg Code field should be filled.");
                    return false;
                }
                document.forms[0].handle_id.value = "Search";
                document.forms[0].action = '/PacsApplication/AddressDetailsServlet';
                document.forms[0].submit();

            }
            function ShowParent()
            {
                document.forms[0].action = "${pageContext.request.contextPath}/Shg_JSP/AddressDetails.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>
        <%
                    String error_msg = "";
                    Object error = request.getAttribute("message");
                    if (error != null) {
                        error_msg = error.toString();
                    }
        %>

        <%
                    String displayFlag = "";
                    Object display = request.getAttribute("displayFlag");
                    if (display != null) {
                        displayFlag = display.toString();
                    }
        %>
        <%
                    Object oAddressDetailsBeanObj = request.getAttribute("AddressDetailsBeanObj");
                    AddressDetailsBean oAddressDetailsBean = new AddressDetailsBean();
                    if (oAddressDetailsBeanObj != null) {
                        oAddressDetailsBean = (AddressDetailsBean) request.getAttribute("AddressDetailsBeanObj");

                    }
        %>
        <jsp:include page="MenuHead_SHG.jsp" flush="true" />
        <br>
        <%!
            String blankNull(String s) {
                return (s == null) ? "" : s;
            }
        %>

        <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">Address Details</legend>
            <form name="addressdetailsform" method="post" action="">

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

                <br>
                <br>
                <center><lable style=" font-family: Berlin Sans FB; font-weight:  normal;">Operation Selection:</lable>
                    <select id="checkOption" onchange="checkop()" name="checkOption" >
                        <option value="" disabled selected style="display:none;" > --Select-- </option>
                        <option value="create" >Create</option>
                        <option value="amend" >Amend</option>
                    </select>
                </center>
                <div id="create" style="display:none;">
                    <table>
                        <tr></tr>
                        <tr></tr>
                        <tr></tr>
                        <tr></tr> <tr></tr>
                        <tr></tr><br><br>
                        <tr>
                            <td>SHG Code<font color="red" >*</font>: </td><td><input type="text" id="shgcode" name="shgcode" readonly style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' ></td>
                            <td> <input type="button" name="Search Code" value="Search" onclick="javascript:searchShgcode(500, 220, document.addressdetailsform.shgcode.value)" > </td></tr>
                        <tr></tr>
                        <tr></tr><tr>
                            <td>District<font color="red" >*</font>: </td><td> <input type="text" name="district" id="district" class="textColor">

                            </td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Subdivisions<font color="red" >*</font>: </td><td> <input type="text" name="subdivisions" id="subdivisions" class="textColor">

                            </td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Block/Municipality<font color="red" >*</font>: </td><td> <input type="text" name="municipality" id="municipality" class="textColor">

                            </td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Panchayat/Ward Number<font color="red" >*</font>: </td><td><input type="text" id="panchayat" name="panchayat"></td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Village<font color="red" >*</font>: </td><td><input type="text" id="village" name="village"></td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Police Station<font color="red" >*</font>: </td><td><input type="text" id="policestation" name="policestation"></td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Post Office<font color="red" >*</font>: </td><td><input type="text" id="postoffice" name="postoffice"></td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Pin Code<font color="red" >*</font>: </td><td><input maxlength="6" type="text" id="pincode" name="pincode" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' ></td>
                        </tr>

                        <tr><td><br></td></tr>
                        <tr><td><br></td></tr>
                        <tr><td><font color="red" >*</font>All fields are mandatory.</td></tr>
                        </tbody>
                    </table><br><br>

                    <center>
                        <input type="button" value="Submit" onclick="javascript:submitform(addressdetailsform)">
                        <input type="button" value="Reset" name="reset" onclick="ShowParent();" />
                    </center>
                </div>
                <br><br>

                <div id="amend" style="display: none;">
                    <center>
                        <lable style=" font-family: Berlin Sans FB; font-weight:  normal;" >Enter SHG Code: </lable>
                        <input type="text" readonly name="shgSearch" id="shgSearch" style="text-align:right;" />
                        <input type="button"  value="Search" onclick="javascript:searchShg(220, 180, document.addressdetailsform.shgSearch.value)" />
                        <input type="button"  value="Submit" onclick="javascript:getDetails()" />
                    </center>
                    <br><br>
                </div>

                <%if (displayFlag.equalsIgnoreCase("Y")) {%>
                <div id="amend2" >

                    <table>
                        <tr></tr>
                        <tr></tr>
                        <tr></tr>
                        <tr></tr> <tr></tr>
                        <tr></tr><br><br>
                        <tr>
                            <td>SHG Code<font color="red" >*</font>: </td><td><input type="text" readonly id="shgcodeAmend" name="shgcodeAmend"  value="<%=blankNull(oAddressDetailsBean.getShgcode())%>" style="text-align:right;" ></td>
                        </tr> <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>District<font color="red" >*</font>:</td>
                            <td>
                                <input type="text" name="districtAmend" id="districtAmend"  value="<%=blankNull(oAddressDetailsBean.getDistrict())%>">

                            </td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Subdivisions<font color="red" >*</font>:</td>
                            <td>
                                <input type="text" name="subdivisionsAmend" id="subdivisionsAmend"  value="<%=blankNull(oAddressDetailsBean.getSubdivisions())%>">

                            </td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Block/Municipality<font color="red" >*</font>:</td>
                            <td>
                                <input type="text" name="municipalityAmend" id="municipalityAmend"  value="<%=blankNull(oAddressDetailsBean.getMunicipality())%>">

                            </td>
                        </tr>
                        <tr>
                            <td>Panchayat/Ward Number<font color="red" >*</font>:</td>
                            <td> <input type="text" id="panchayatAmend" name="panchayatAmend"  value="<%=blankNull(oAddressDetailsBean.getPanchayat())%>"></td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Village<font color="red" >*</font>:</td>
                            <td> <input type="text" id="villageAmend" name="villageAmend" value="<%=blankNull(oAddressDetailsBean.getVillage())%>"></td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Police Station<font color="red" >*</font>:</td>
                            <td> <input type="text" id="policestationAmend" name="policestationAmend" value="<%=blankNull(oAddressDetailsBean.getPolicestation())%>"></td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Post Office<font color="red" >*</font>:</td>
                            <td> <input type="text" id="postofficeAmend" name="postofficeAmend" value="<%=blankNull(oAddressDetailsBean.getPostoffice())%>"></td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Pin Code<font color="red" >*</font>:</td>
                            <td> <input type="text" id="pincodeAmend" maxlength="6" name="pincodeAmend" style="text-align:right;"  onKeyPress="return numbersonly( event)"  value="<%=blankNull(oAddressDetailsBean.getPincode())%>"></td>
                        </tr>

                        <tr><td><br></td></tr>
                        <tr><td><br></td></tr>
                        <tr><td><font color="red" >*</font>All fields are mandatory.</td></tr>

                    </table><br><br>

                    <br><br>
                    <input type="hidden" name="shg_id" value="<%=blankNull(oAddressDetailsBean.getShg_id())%>"/>
                    <center>
                        <input type="button" value="Update" onclick="javascript:updateform(addressdetailsform)">
                        <input type="button" value="Reset" name="reset" onclick="ShowParent();" />
                    </center>

                </div>
                <% }%>
                <input name="handle_id" id="handle_id" type="hidden" value="" />



            </form>

        </fieldset>

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