<%--
    Document   : BasicInformation
    Created on : Jul 14, 2016, 10:59:29 AM
    Author     : 1320029
--%>



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

<html>
    <head>

        <title>Basic Information</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 numbersonly(e){

                var unicode=e.charCode? e.charCode : e.keyCode
                if(unicode==46)
                {document.forms[0].decimalcounter.value ++;}

                if((document.forms[0].decimalcounter.value>1)&&(unicode==46))
                    return false;
                if ((unicode!=8)&&(unicode!=46)){ //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 ShowCalender(){

                getCalendar(document.getElementById("dateOfFormation"));
            }
            function noBack()
            {
                window.history.forward();
            }

            function submitform(BasicInformationform)
            {
                if (checkCreateDiv(BasicInformationform))
                {
                    document.forms[0].handle_id.value = "Create";
                    document.forms[0].action='/PacsApplication/BasicInformationServlet';
                    document.forms[0].submit();
                }
            }
            function checkCreateDiv(BasicInformationform)
            {
                if (BasicInformationform.shgcode.value == "")
                {
                    alert("SHG Code should be filled.");
                    BasicInformationform.shgcode.focus();
                    return false;
                }
                if (BasicInformationform.cif.value == "")
                {
                    alert("CIF Number should be filled.");
                    BasicInformationform.cif.focus();
                    return false;
                }
                if (BasicInformationform.nameOfShg.value == "")
                {
                    alert("Name Of SHG should be filled.");
                    BasicInformationform.nameOfShg.focus();
                    return false;
                }
                if (BasicInformationform.groupCategory.value == "")
                {
                    alert("Group Category should be filled.");
                    BasicInformationform.groupCategory.focus();
                    return false;
                }
                if (BasicInformationform.dateOfFormation.value == "")
                {
                    alert("Date Of Formation should be filled.");
                    BasicInformationform.dateOfFormation.focus();
                    return false;
                }
                if (BasicInformationform.duration.value == "")
                {
                    alert("Duration should be filled.");
                    BasicInformationform.duration.focus();
                    return false;
                }


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

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

                }
            }
            function checkUpdateDiv(BasicInformationform)
            {
                if (BasicInformationform.shgcodeAmend.value == "")
                {
                    alert("SHG Code field should be filled.");
                    BasicInformationform.shgcodeAmend.focus();
                    return false;
                }
                if (BasicInformationform.nameOfShgAmend.value == "")
                {
                    alert("Name Of SHG field should be filled.");
                    BasicInformationform.nameOfShgAmend.focus();
                    return false;
                }
                if (BasicInformationform.groupCategoryAmend.value == "")
                {
                    alert("Group Category field should be filled.");
                    BasicInformationform.groupCategoryAmend.focus();
                    return false;
                }
                if (BasicInformationform.dateOfFormationAmend.value == "")
                {
                    alert("Date Of Formation field should be filled.");
                    BasicInformationform.dateOfFormationAmend.focus();
                    return false;
                }
                if (BasicInformationform.durationAmend.value == "")
                {
                    alert("Duration field should be filled.");
                    BasicInformationform.durationAmend.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 = "BasicInformation.jsp";
                var lovKey = "BasicInformation"
                popWin = open('/PacsApplication/CommonSearchInformationShgLOV.jsp?shgSearch=' + shgSearch + '&screenName=' + screenName + '&lovKey=' + lovKey, 'BasicInformation', attr);
                popWin.focus();

            }
            function popup_cif(width, height, cif) {
            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 = "BasicInformation.jsp";
            var lovKey = "cif"
            popWin = open('${pageContext.request.contextPath}/CommonSearchInformationShgLOV.jsp?cif=' + cif + '&screenName=' + screenName + '&lovKey=' + lovKey, 'cif', attr);
            popWin.focus();

        }
         function popup_cifamend(width, height, cif) {
            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 = "BasicInformation.jsp";
            var lovKey = "cifamend"
            popWin = open('${pageContext.request.contextPath}/CommonSearchInformationShgLOV.jsp?cifamend=' + cif + '&screenName=' + screenName + '&lovKey=' + lovKey, 'cif', 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/BasicInformationServlet';
                document.forms[0].submit();

            }
            function ShowParent()
            {
                document.forms[0].action = "${pageContext.request.contextPath}/Shg_JSP/BasicInformation.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 oBasicInformationBeanObj = request.getAttribute("BasicInformationBeanObj");
                    BasicInformationBean oBasicInformationBean = new BasicInformationBean();
                    if (oBasicInformationBeanObj != null) {
                        oBasicInformationBean = (BasicInformationBean) request.getAttribute("BasicInformationBeanObj");

                    }
        %>
        <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">Basic Information</legend>
            <form name="BasicInformationform" method="post" action="BasicInformationServlet">

                <%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" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' ></td>
                        </tr> <tr></tr>
                        <tr>
                            <td>CIF Number<font color="red" >*</font>: </td><td><input type="text" id="cif" name="cif"></td>
                             <td><input type="button"  value="Search" onclick="javascript:popup_cif(220, 180, document.BasicInformationform.cif.value);"/></td>
                        </tr>
                        <tr></tr>
                        <tr>
                            <td>Name of SHG<font color="red" >*</font>: </td><td><input type="text" readonly id="nameOfShg" name="nameOfShg"></td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Group Category<font color="red" >*</font>: </td><td><select name="groupCategory" id="groupCategory" class="textColor">
                                    <option value="" selected="selected"> --Select-- </option>
                                    <option value="1" >SGSY</option>
                                    <option value="2">NABARD</option>
                                    <option value="3" >CO-Operative</option>
                                    <option value="4" >Others</option>
                                </select>
                            </td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Date of Formation<font color="red" >*</font>: </td>
                            <td>
                                <input type="text" name="dateOfFormation" id="dateOfFormation" readOnly style="text-align:center;" />&nbsp;<a href="#" onclick="return getCalendar(document.forms[0].dateOfFormation);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" border="0" width="25" height="20" /></a>
                            </td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Duration<font color="red" >*</font>: </td><td><input type="text" id="duration" name="duration" onKeyPress="return numbersonly( event)" style="text-align:right;" ></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>
                    
                    <center>
                        <input type="button" value="Submit" onclick="javascript:submitform(BasicInformationform)">
                        <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" name="shgSearch" readonly id="shgSearch" style="text-align:right;" />
                        <input type="button"  value="Search" onclick="javascript:searchShg(220, 180, document.BasicInformationform.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: </td><td><input type="text" id="shgcodeAmend" name="shgcodeAmend" readonly value="<%=blankNull(oBasicInformationBean.getShgcode())%>" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                        </tr> <tr></tr>

                         <tr>
                            <td>CIF Number: </td>
                            <td> <input type="text" id="cifamend" name="cifamend" readonly value="<%=blankNull(oBasicInformationBean.getCif())%>" style="text-align:right;" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                             <td><input type="button"  value="Search" onclick="javascript:popup_cifamend(220, 180, document.BasicInformationform.cifamend.value);"/></td>
                        </tr>
                        <tr></tr>
                        <tr>
                            <td>Name of SHG: </td>
                            <td> <input type="text" id="nameOfShgAmend" name="nameOfShgAmend"  value="<%=blankNull(oBasicInformationBean.getNameOfShg())%>"/></td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Group Category: </td>
                            <td>
                                <select name="groupCategoryAmend" id="groupCategoryAmend" class="textColor">
                                    <option value="" selected="selected"> --Select-- </option>

                                    <option value="1"<%if (oBasicInformationBean.getGroupCategory().equalsIgnoreCase("1")) {%> selected <%}%>>SGSY</option>
                                    <option value="2"<%if (oBasicInformationBean.getGroupCategory().equalsIgnoreCase("2")) {%> selected <%}%>>NABARD</option>
                                    <option value="3"<%if (oBasicInformationBean.getGroupCategory().equalsIgnoreCase("3")) {%> selected <%}%>>Co-Operative</option>
                                    <option value="4"<%if (oBasicInformationBean.getGroupCategory().equalsIgnoreCase("4")) {%> selected <%}%>>Others</option>
                                </select>
                            </td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Date Of Formation: </td>
                            <td><input type="text" name="dateOfFormationAmend" id="dateOfFormationAmend" style="text-align:center;" value="<%=blankNull(oBasicInformationBean.getDateOfFormation())%>" readOnly />&nbsp;<a href="#" onclick="return getCalendar(document.forms[0].dateOfFormationAmend);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" border="0" width="25" height="20" /></a>
                            </td>
                        </tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td>Duration: </td>
                            <td> <input type="text" id="durationAmend" name="durationAmend" value="<%=blankNull(oBasicInformationBean.getDuration())%>"  onKeyPress="return numbersonly( event)" style="text-align:right;" /></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(oBasicInformationBean.getShg_id())%>"/>
                    <center>
                        <input type="button" value="Update" onclick="javascript:updateform(BasicInformationform)">
                        <input type="button" value="Reset" name="reset" onclick="ShowParent();" />
                    </center>

                </div>
                <% }%>

                <input name="handle_id" id="handle_id" type="hidden" value="" />
                <input name="decimalcounter" id="decimalcounter" type="hidden" value="" />
            </form>

        </fieldset>

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