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

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="DataEntryBean.MemberDetailsBean"%>
<%@page import="java.util.ArrayList"%>
<%@page import="LoginDb.DbHandler"%>
<% try {
%>

<html>
    <head>

        <title>Member 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>

        <script src="${pageContext.request.contextPath}/js/Calendar.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(MemberDetailsform)
            {
                if (MemberDetailsform.shgcode.value == "")
                {
                    alert("SHG code should be filled.");
                    MemberDetailsform.shgcode.focus();
                    return false;
                }
                if (checkCreateDiv(MemberDetailsform))
                {
                    document.forms[0].handle_id.value = "Create";
                    document.forms[0].action = '/PacsApplication/MemberDetailsServlet';

                    MemberDetailsform.submit();
                }
            }
            function checkCreateDiv(memberdetailsform)
            {
                var counter = document.forms[0].rowCounter.value;

                for (var i = 1; i <= counter; i++)
                {
                    try{
                        if (document.getElementById("membername"+i)!=null)
                        {
                            if(document.getElementById("membername"+i).value == "")
                            { alert("Member Name should be filled.");
                                return false;
                            }
                        }
                        if (document.getElementById("gender"+i).value == "")
                        {
                            alert("Gender should be filled.");
                            return false;
                        }
                        if (document.getElementById("dob"+i).value == "")
                        {
                            alert("Date Of Birth should be filled.");
                            return false;
                        }
                        if (document.getElementById("guardianname"+i).value == "")
                        {
                            alert("Guardian Name should be filled.");
                            return false;
                        }
                        if (document.getElementById("address"+i).value == "")
                        {
                            alert("Address should be filled.");
                            return false;
                        }
                        if (document.getElementById("religion"+i).value == "")
                        {
                            alert("Religion should be filled.");
                            return false;

                        }
                        if(document.getElementById("caste"+i).value=="")
                            {
                                alert("Caste should be filled.");
                                return false;
                            }
                        if(document.getElementById("qualification"+i).value=="")
                            {
                                alert("Qualification should be filled.");
                                return false;
                            }
                    }
                    catch(e)
                    {

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

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

                }
            }
            function checkUpdateDiv(memberdetailsform)
            {
                var counter = document.forms[0].rowCounter.value;

                for (var i = 1; i <= counter; i++) {
                    try{
                        if (document.getElementById("membernameAmend"+i).value == "")
                        {
                            alert("Member Name should be filled.");
                            return false;
                        }
                        if (document.getElementById("genderAmend"+i).value == "")
                        {
                            alert("Gender should be filled.");
                            return false;
                        }
                        if (document.getElementById("dobAmend"+i).value == "")
                        {
                            alert("Date Of Birth should be filled.");
                            return false;
                        }
                        if (document.getElementById("guardiannameAmend"+i).value == "")
                        {
                            alert("Guardian Name should be filled.");
                            return false;
                        }
                        if (document.getElementById("addressAmend"+i).value == "")
                        {
                            alert("Address should be filled.");
                            return false;
                        }
                        if (document.getElementById("religionAmend"+i).value == "")
                        {
                            alert("Religion should be filled.");
                            return false;

                        }
                        if(document.getElementById("casteAmend"+i).value=="")
                            {
                                alert("Caste should be filled.");
                                return false;
                            }
                        if(document.getElementById("qualificationAmend"+i).value=="")
                            {
                                alert("Qualification should be filled.");
                                return false;
                            }
                    }
                    catch(e){

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

            function checkop()
            {
                if (document.getElementById("checkOption").value == "create")
                {
                    document.getElementById('create').style.display = 'block';
                    document.getElementById('memberTable').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('memberTable').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 = "MemberDetails.jsp";
                var lovKey = "MemberDetails"
                popWin = open('/PacsApplication/CommonSearchInformationShgLOV.jsp?shgSearch=' + shgSearch + '&screenName=' + screenName + '&lovKey=' + lovKey, 'MemberDetails', attr);
                popWin.focus();

            }
            function ShowParent()
            {
                document.forms[0].action = "${pageContext.request.contextPath}/Shg_JSP/MemberDetails.jsp";
                document.forms[0].submit();
            }
            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 = "MemberDetails.jsp";
                var lovKey = "MemberDetailscode"
                popWin = open('/PacsApplication/CommonSearchInformationShgLOV.jsp?shgcodeSearch=' + shgcodeSearch + '&screenName=' + screenName + '&lovKey=' + lovKey, 'MemberDetailscode', attr);
                popWin.focus();

            }
            function SearchCIF(width, height, textIndex)
            {
                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 accNo = document.getElementById("cif"+textIndex).value;
                var screenName = "MemberDetails.jsp";
                var lovKey = "PickUPCustomer";

                popWin = open('${pageContext.request.contextPath}/CommonSearchInfoLOVNew.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo + '&textIndex=' + textIndex, 'AccountSearch', attr);
                popWin.focus();
            }
            function SearchCIFAmend(width, height, textIndex)
            {
                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 accNo = document.getElementById("cifAmend"+textIndex).value;
                var screenName = "MemberDetails.jsp";
                var lovKey = "PickUPCustomerAmend";

                popWin = open('${pageContext.request.contextPath}/CommonSearchInfoLOVNew.jsp?screenName=' + screenName+'&lovKey='+lovKey + '&accNo=' + accNo + '&textIndex=' + textIndex, 'AccountSearch', attr);
                popWin.focus();
            }

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

            function genderChange()
            {
                var maleCount=0;
                var femaleCount=0;
                var otherCount=0;
                var rowCount=document.forms[0].rowCounter.value;
                var gender=0;

                for (var i=1;i<=rowCount;i++) {

                    try{

                        gender=document.getElementById("gender"+i).value;

                        if (gender=="Male"){

                            maleCount++;
                        }

                        else if (gender=="Female"){

                            femaleCount++;
                        }
                        else if (gender=="Other"){

                            otherCount++;
                        }

                    }catch (e){

                    }
                }

                document.forms[0].total.value=maleCount+femaleCount+otherCount;
                document.forms[0].male.value=maleCount;
                document.forms[0].female.value=femaleCount;
                document.forms[0].other.value=otherCount;

            }
            function genderAmendChange() {

                var maleCount=0;
                var femaleCount=0;
                var otherCount=0;
                var rowCount=document.forms[0].rowCounter.value;
                var gender=0;

                for (var i=1;i<=rowCount;i++) {

                    try{
                        // alert("gender"+i);
                        gender=document.getElementById("genderAmend"+i).value;

                        if (gender=="Male"){

                            maleCount++;
                        }

                        else if (gender=="Female"){

                            femaleCount++;
                        }
                        else if (gender=="Other"){

                            otherCount++;
                        }

                    }catch (e){

                    }
                }

                document.forms[0].total.value=maleCount+femaleCount+otherCount;
                document.forms[0].male.value=maleCount;
                document.forms[0].female.value=femaleCount;
                document.forms[0].other.value=otherCount;

            }
            function religionChange(){
                var muslimCount=0;
                var christianCount=0;
                var buddhistCount=0;
                var sikhCount=0;
                var parsiCount=0;
                var jainCount=0;
                var othersCount=0;
                var rowCount=document.forms[0].rowCounter.value;

                var religion=0;
                for (var i=1;i<=rowCount;i++) {

                    try{
                        religion=document.getElementById("religion"+i).value;
                        if (religion=="Muslim")
                        {

                            muslimCount++;
                        }
                        else if (religion=="Christian")
                        {

                            christianCount++;
                        }
                        else if (religion=="Buddhist")
                        {

                            buddhistCount++;
                        }
                        else if (religion=="Sikh")
                        {

                            sikhCount++;
                        }
                        else if (religion=="Parsi")
                        {

                            parsiCount++;
                        }
                        else if (religion=="Jain")
                        {

                            jainCount++;
                        }
                        else if (religion=="Others")
                        {

                            othersCount++;
                        }

                    }catch (e)
                    {

                    }
                }
                document.forms[0].muslim.value=muslimCount;
                document.forms[0].christian.value=christianCount;
                document.forms[0].buddhist.value=buddhistCount;
                document.forms[0].sikh.value=sikhCount;
                document.forms[0].parsi.value=parsiCount;
                document.forms[0].jain.value=jainCount;
                document.forms[0].others.value=othersCount;

            }
            function religionAmendChange(){
                var muslimCount=0;
                var christianCount=0;
                var buddhistCount=0;
                var sikhCount=0;
                var parsiCount=0;
                var jainCount=0;
                var othersCount=0;
                var rowCount=document.forms[0].rowCounter.value;
                var religion=0;
                for (var i=1;i<=rowCount;i++) {

                    try{
                        // alert("religion"+i);
                        religion=document.getElementById("religionAmend"+i).value;
                        if (religion=="Muslim")
                        {

                            muslimCount++;
                        }
                        else if (religion=="Christian")
                        {

                            christianCount++;
                        }
                        else if (religion=="Buddhist")
                        {

                            buddhistCount++;
                        }
                        else if (religion=="Sikh")
                        {

                            sikhCount++;
                        }
                        else if (religion=="Parsi")
                        {

                            parsiCount++;
                        }
                        else if (religion=="Jain")
                        {

                            jainCount++;
                        }
                        else if (religion=="Others")
                        {

                            othersCount++;
                        }

                    }catch (e)
                    {

                    }
                }
                document.forms[0].muslim.value=muslimCount;
                document.forms[0].christian.value=christianCount;
                document.forms[0].buddhist.value=buddhistCount;
                document.forms[0].sikh.value=sikhCount;
                document.forms[0].parsi.value=parsiCount;
                document.forms[0].jain.value=jainCount;
                document.forms[0].others.value=othersCount;

            }
            function lettersOnly(e) {

                    
                var unicode=e.charCode? e.charCode : e.keyCode
                if ((unicode!=8)&&(unicode!=32)){
                   if (unicode > 31 && (unicode < 65 || unicode > 90) &&
                    (unicode < 97 || unicode > 122)) {

                    return false;
                }}
                return true;
            }
            function ShowCalenderAmend(i){

                getCalendar(document.getElementById("dobAmend"+i));
            }
            function ShowCalender(i){

                getCalendar(document.getElementById("dob"+i));
            }
            
            // to restrict back button
            history.pushState(null, null, location.href);
            window.addEventListener('popstate', function(event) {
                history.pushState(null, null, location.href);
            });

        </script>
        <%
                    int count = 1;
                    String error_msg = "";
                    Object error = request.getAttribute("message");
                    if (error != null) {
                        error_msg = error.toString();
                    }
        %>
        <%
                    int malecount = 0;
                    int femalecount = 0;
                    int othercount = 0;
                    int totalcount = 0;
                    int muslimcount = 0;
                    int christiancount = 0;
                    int sikhcount = 0;
                    int parsicount = 0;
                    int buddhistcount = 0;
                    int jaincount = 0;
                    int otherscount = 0;

        %>
        <%
                    Object oMemberDetailsBeanObj = request.getAttribute("MemberDetailsBeanObj");
                    MemberDetailsBean oMemberDetailsBean = new MemberDetailsBean();
                    if (oMemberDetailsBeanObj != null) {
                        oMemberDetailsBean = (MemberDetailsBean) request.getAttribute("MemberDetailsBeanObj");

                    }
        %>
        <%
                    Object alMemberDetailsBeanObj = request.getAttribute("alMemberDetailsBean");
                    ArrayList<MemberDetailsBean> alMemberDetailsBean = new ArrayList<MemberDetailsBean>();
                    if (alMemberDetailsBeanObj != null) {
                        alMemberDetailsBean = (ArrayList<MemberDetailsBean>) request.getAttribute("alMemberDetailsBean");

                    }
        %>
        <%
                    String displayFlag = "";
                    Object display = request.getAttribute("displayFlag");
                    if (display != null) {
                        displayFlag = display.toString();
                    }
        %>
        <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">Member Details</legend>
            <form name="MemberDetailsform" method="post" action="MemberDetailsServlet">

                <%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;" > </td>
                            <td> <input type="button" name="Search Code" value="Search" onclick="javascript:searchShgcode(500, 220, document.MemberDetailsform.shgcode.value)" > </td></tr>
                        <tr></tr>
                        <tr></tr>
                        <tr><td><hr></td></tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td><b>No of Group Member: </b></td></tr>
                        <tr></tr>
                        <tr></tr>
                        <tr><td>&nbsp&nbsp Male:</td><td><input type="text" style="text-align:right;" id="male"  name="male" readOnly value="<%=malecount%>"  onKeyPress="return numbersonly( event)"></td></tr>
                        <tr></tr>
                        <tr></tr> <tr><td>&nbsp&nbsp Female:</td><td><input type="text" style="text-align:right;" id="female"  name="female" value="<%=femalecount%>" readOnly onKeyPress="return numbersonly( event)"></td></tr>
                        <tr></tr>
                        <tr><td>&nbsp&nbsp Other:</td><td><input type="text" style="text-align:right;" id="other"  name="other" readOnly value="<%=othercount%>"  onKeyPress="return numbersonly( event)"></td></tr>
                        <tr></tr>

                        <tr></tr> <tr><td>&nbsp&nbsp Total:</td><td><input type="text" style="text-align:right;" id="total"  name="total" readOnly value="<%=totalcount%>" onKeyPress="return numbersonly( event)"></td></tr>

                        <tr></tr>
                        <tr></tr>
                        <tr><td><hr></td></tr>
                        <tr></tr>
                        <tr></tr>
                        <tr>
                            <td><b>No of Minority: </b></td>
                        <tr></tr>
                        <tr></tr>

                        <tr><td>&nbsp&nbspMuslim:</td><td><input type="text" style="text-align:right;" id="muslim"  name="muslim" readOnly value="<%=muslimcount%>" onKeyPress="return numbersonly( event)"></td></tr>
                        <tr></tr>
                        <tr></tr>
                        <tr><td>&nbsp&nbspChristian:</td><td><input type="text" style="text-align:right;" value="<%=christiancount%>" id="christian"  name="christian" readOnly onKeyPress="return numbersonly( event)"></td></tr>
                        <tr></tr>
                        <tr></tr>
                        <tr><td>&nbsp&nbspBuddhist:</td><td><input type="text" style="text-align:right;" value="<%=buddhistcount%>" id="buddhist"  name="buddhist" readOnly onKeyPress="return numbersonly( event)"></td></tr>
                        <tr></tr>
                        <tr></tr>
                        <tr><td>&nbsp&nbspSikh:</td><td><input type="text" style="text-align:right;" id="sikh" value="<%=sikhcount%>" name="sikh" readOnly onKeyPress="return numbersonly( event)"></td></tr>
                        <tr></tr>

                        <tr>
                        <tr><td>&nbsp&nbspParsi:</td><td><input type="text" style="text-align:right;" id="parsi" value="<%=parsicount%>" name="parsi" readOnly onKeyPress="return numbersonly( event)"></td></tr>
                        <tr></tr>
                        <tr></tr>
                        <tr><td>&nbsp&nbspJain:</td><td><input type="text" style="text-align:right;" id="jain" value="<%=jaincount%>" name="jain" readOnly onKeyPress="return numbersonly( event)"></td></tr>
                        <tr></tr>
                        <tr></tr>
                        <tr><td>&nbsp&nbspOthers:</td><td><input type="text" style="text-align:right;" id="others" value="<%=otherscount%>" name="others" readOnly onKeyPress="return numbersonly( event)"></td></tr>
                        <tr></tr>
                        <tr></tr>
                    </table>
                    <br><br>
                    <br><br>
                </div>
                <div id="memberTable" style="display:none;">

                    <center>
                        <table id="mem_details"  border="2" cellspacing="1" cellpadding="1" style="text-align: center ;overflow-y: scroll; font-size: 15px; width: 100%;" >
                            <thead  class="CSSTableGenerator" >
                                <tr>
                                    <td></td>
                                    <td colspan="2">CIF Number</td>
                                    <td>Member Name</td>
                                    <td>Gender</td>
                                    <td>Date Of Birth</td>
                                    <td>Guardian Name</td>
                                    <td>Address</td>
                                    <td>Religion</td>
                                    <td>Caste</td>
                                    <td>Qualification</td>


                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td><input type="checkbox" name="chckbox<%=count%>" id="chckbox<%=count%>" onclick="return checkboxTrue(<%=count%>)"/></td>
                                    <td><input  type="text" name="cif<%=count%>" id="cif<%=count%>" /></td>
                                    <td><input type="button" style="width: 70px" name="SearchCIF<%=count%>" id="SearchCIF<%=count%>" value="Search"  onclick="javascript:SearchCIF(550,240,<%=count%>);" /></td>
                                    <td><input type="text" readonly onKeyPress="return lettersOnly(event)" name="membername<%=count%>" id="membername<%=count%>" /></td>
                                    <td><select style="width: 120px" id="gender<%=count%>" name="gender<%=count%>"  onchange="return genderChange()" >
                                            <option value="" selected disabled>--Select--</option>
                                            <option value="Male">Male</option>
                                            <option value="Female">Female</option>
                                            <option value="Other">Other</option></select></td>
                                    <td><input type="text" style="text-align:center;" name="dob<%=count%>" id="dob<%=count%>" readonly  /><a href="#" onclick="return getCalendar(document.forms[0].dob<%=count%>);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" id="imgr" border="0" width="18" height="18" /></a></td>
                                    <td><input type="text" readonly onKeyPress="return lettersOnly(event)"  name="guardianname<%=count%>" id="guardianname<%=count%>"/></td>
                                    <td><textarea readonly name="address<%=count%>" id="address<%=count%>"></textarea></td>
                                    <td><select style="width: 120px" name="religion<%=count%>" id="religion<%=count%>" class="textColor" onchange="return religionChange()">
                                            <option value="" selected disabled>--Select--</option>
                                            <option value="Hindu" >Hindu</option>
                                            <option value="Muslim" id="muslim<%=count%>" name="muslim<%=count%>"  >Muslim</option>
                                            <option value="Christian" id="christian<%=count%>" name="christian<%=count%>"  >Christian</option>
                                            <option value="Buddhist" id="buddhist<%=count%>" name="buddhist<%=count%>"  > Buddhist</option>
                                            <option value="Sikh" id="sikh<%=count%>" name="sikh<%=count%>"  >Sikh</option>
                                            <option value="Parsi" id="parsi<%=count%>" name="parsi<%=count%>" >Parsi</option>
                                            <option value="Jain" id="jain<%=count%>" name="jain<%=count%>" >Jain</option>
                                            <option value="Others" id="others<%=count%>" name="others<%=count%>">Others</option>
                                        </select></td>
                                    <td><select style="width: 120px" name="caste<%=count%>" id="caste<%=count%>" class="textColor" onchange="return casteChange()">
                                            <option value="" disabled selected>--Select--</option>
                                            <option value="1" >General</option>
                                            <option value="2">SC</option>
                                            <option value="3">ST</option>
                                            <option value="4">OBC</option>
                                        </select></td>

                                      <td><textarea  name="qualification<%=count%>" id="qualification<%=count%>"></textarea></td>
                                </tr>
                            </tbody>
                        </table>
                    </center>
                    <br/><br/>
                    <lable style=" font-family: Berlin Sans FB; font-weight:  normal;">All fields are mandatory</lable>
                    <center>
                        <input type="button" id="addRow" value="Add Row"/>
                        <input type="button" id="deleteRow" value="Delete Row"/>
                        <input type="button" value="Submit" onclick="javascript:submitform(MemberDetailsform)"/>
                        <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<font color="red" >*</font>: </lable>
                        <input type="text" name="shgSearch" readonly id="shgSearch" style="text-align:right;"/>
                        <input type="button"  value="Search" onclick="javascript:searchShg(220, 180, document.MemberDetailsform.shgSearch.value)" />

                        <input type="button"  value="Submit" onclick="javascript:getDetails()" />
                    </center>
                </div>

                <%if (displayFlag.equalsIgnoreCase("Y")) {
                %>
                <script>
                    document.getElementById('create').style.display = 'block';
                    document.forms[0].shgcode.value="<%=blankNull(oMemberDetailsBean.getShgcode())%>"
                </script>

                <div id="amend2" >
                    <center>

                        <table id="mem_details-Amend"  border="2" cellspacing="1" cellpadding="1" style="text-align: center ;overflow-y: scroll; font-size: 15px; width: 100%;" >
                            <thead  class="CSSTableGenerator" >
                                <tr>
                                    <td></td>
                                    <td colspan="2">CIF Number</td>
                                    <td>Member Name</td>
                                    <td>Gender</td>
                                    <td>Date Of Birth</td>
                                    <td>Guardian Name</td>
                                    <td>Address</td>
                                    <td>Religion</td>
                                    <td>Caste</td>
                                    <td>Qualification</td>
                                    <td>Entry Date</td>
                                </tr>
                            </thead>
                            <tbody>
                                <%
                                    oMemberDetailsBean = new MemberDetailsBean();
                                    count = 0;
                                    String lastUpdate="";

                                    for (int i = 0; i < alMemberDetailsBean.size(); i++) {
                                        oMemberDetailsBean = alMemberDetailsBean.get(i);
                                        lastUpdate=blankNull(oMemberDetailsBean.getAmend_date());
                                        count++;

                                %>
                                <tr>
                                    <td><input type="checkbox" name="chckboxAmend<%=count%>" id="chckboxAmend<%=count%>" onclick="return checkboxTrueAmend(<%=count%>)"  value="<%=blankNull(oMemberDetailsBean.getMemberID())%>" /></td>
                                    <td><input  type="text" name="cifAmend<%=count%>" id="cifAmend<%=count%>" value="<%=blankNull(oMemberDetailsBean.getCif())%>"/></td>
                                    <td><input type="button" style="width: 70px" name="SearchCIFAmend<%=count%>" id="SearchCIFAmend<%=count%>" value="Search"  onclick="javascript:SearchCIFAmend(550,240,<%=count%>);" /></td>
                                    <td><input type="text"  onKeyPress="return lettersOnly( event)" name="membernameAmend<%=count%>" id="membernameAmend<%=count%>" value="<%=blankNull(oMemberDetailsBean.getMembername())%>"/></td>
                                    <td><select style="width: 120px"  id="genderAmend<%=count%>" onchange="return genderAmendChange()" name="genderAmend<%=count%>" ><option value="" selected disabled>--Select--</option><option value="Male" <%if (oMemberDetailsBean.getGender().equalsIgnoreCase("Male")) {%> selected <%}%> >Male</option><option value="Female" <%if (oMemberDetailsBean.getGender().equalsIgnoreCase("Female")) {%> selected <%}%> >Female</option><option value="Other" <%if (oMemberDetailsBean.getGender().equalsIgnoreCase("Other")) {%> selected <%}%>>Other</option></select></td>
                                    <td><input type="text" style="text-align:center;" name="dobAmend<%=count%>" id="dobAmend<%=count%>" value="<%=blankNull(oMemberDetailsBean.getDob())%>" readonly  /><a href="#" onclick="return getCalendar(document.forms[0].dobAmend<%=count%>);" ><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" id="imgr" border="0" width="15" height="20" /></a></td>
                                    <td><input type="text"  onKeyPress="return lettersOnly( event)"  name="guardiannameAmend<%=count%>" id="guardiannameAmend<%=count%>"  value="<%=blankNull(oMemberDetailsBean.getGuardianname())%>"/></td>
                                    <td><textarea  name="addressAmend<%=count%>" id="addressAmend<%=count%>"><%=blankNull(oMemberDetailsBean.getAddress())%></textarea></td>
                                    <td><select style="width: 120px" name="religionAmend<%=count%>" id="religionAmend<%=count%>" onchange="return religionAmendChange()"  class="textColor">
                                            <option value="" selected disabled>--Select--</option>
                                            <option value="Hindu" <%if (oMemberDetailsBean.getReligion().equalsIgnoreCase("Hindu")) {%> selected <%}%> >Hindu</option>
                                            <option value="Muslim" <%if (oMemberDetailsBean.getReligion().equalsIgnoreCase("Muslim")) {%> selected <%}%> >Muslim</option>
                                            <option value="Christian" <%if (oMemberDetailsBean.getReligion().equalsIgnoreCase("Christian")) {%> selected <%}%> >Christian</option>
                                            <option value="Buddhist" <%if (oMemberDetailsBean.getReligion().equalsIgnoreCase("Buddhist")) {%> selected <%}%> >Buddhist</option>
                                            <option value="Sikh" <%if (oMemberDetailsBean.getReligion().equalsIgnoreCase("Sikh")) {%> selected <%}%>  >Sikh</option>
                                            <option value="Parsi" <%if (oMemberDetailsBean.getReligion().equalsIgnoreCase("Parsi")) {%> selected <%}%> >Parsi</option>
                                            <option value="Jain" <%if (oMemberDetailsBean.getReligion().equalsIgnoreCase("Jain")) {%> selected <%}%> >Jain</option>
                                            <option value="Others" <%if (oMemberDetailsBean.getReligion().equalsIgnoreCase("Others")) {%> selected <%}%> >Others</option>
                                        </select></td>
                                    <td><select style="width: 120px" name="casteAmend<%=count%>" id="casteAmend<%=count%>" onchange="return casteAmendChange()"  class="textColor">
                                            <option value="" selected disabled>--Select--</option>
                                            <option value="1" <%if (oMemberDetailsBean.getCaste().equalsIgnoreCase("1")) {%> selected <%}%> >General</option>
                                            <option value="2" <%if (oMemberDetailsBean.getCaste().equalsIgnoreCase("2")) {%> selected <%}%> >SC</option>
                                            <option value="3" <%if (oMemberDetailsBean.getCaste().equalsIgnoreCase("3")) {%> selected <%}%> >ST</option>
                                            <option value="4" <%if (oMemberDetailsBean.getCaste().equalsIgnoreCase("4")) {%> selected <%}%> >OBC</option>
                                        </select></td>
                                        <td><textarea  name="qualificationAmend<%=count%>" id="qualificationAmend<%=count%>"><%=blankNull(oMemberDetailsBean.getQualification())%></textarea></td>
                                        <td><input type="text" style="text-align:center;" readonly id="entry_date<%=count%>" name="entry_date<%=count%>" value="<%=blankNull(oMemberDetailsBean.getEntry_date())%>"</td>

                                    <td style="display:none;"><input type="hidden" name="rowStatus<%=count%>" id="rowStatus<%=count%>" value="A"/></td>
                                    <td style="display:none;"><input type="hidden" name="memberIDAmend<%=count%>" id="memberIDAmend<%=count%>" value="<%=blankNull(oMemberDetailsBean.getMemberID())%>" /></td>

                                </tr>
                                <%}%>
                            </tbody>

                        </table>
                    </center>
                            <br>
                            <label>Last Updated :  </label><%=blankNull(oMemberDetailsBean.getAmend_date())%>
                    <br/><br/>
                    <lable style=" font-family: Berlin Sans FB; font-weight:  normal;">All fields are mandatory</lable>
                    <center>
                        <input type="button" id="addRowAmend" value="Add Row"/>
                        <input type="button" id="deleteRowAmend" value="Delete Row"/>
                        <input type="button" value="Update" onclick="javascript:updateform(MemberDetailsform)">
                        <input type="button" value="Reset" name="reset" onclick="ShowParent();" />
                        <input type="hidden" name="shg_id" value="<%=blankNull(oMemberDetailsBean.getShg_id())%>"/>

                    </center>
                    <br><br>
                </div>
                <% }%>
                <input type="hidden" name="rowCounterDelete" id="rowCounterDelete" value="<%=count%>">
                <input type="hidden" name="deletedRows" id="deletedRows" value=""/>
                <input type="hidden" name="rowCounter" id="rowCounter" value="<%=count%>">
                <input type="hidden" name="chkboxCounter" id="chkboxCounter" value="0">


                <input name="handle_id" id="handle_id" type="hidden" value="" />
            </form>
            <script>
                if (document.getElementById("checkOption").value != "create")
                { 
                    genderAmendChange();
                    religionAmendChange();}
                $("#addRow").click(function () {
                    var counter = $("#rowCounter").val();
                    var counterdelete = $("#rowCounterDelete").val();
                    counterdelete++;
                    counter++;
                    $("#rowCounter").val(counter);
                    $("#rowCounterDelete").val(counterdelete);
                    $('#mem_details tr:last').after('<tr> <td align="center"><input type="checkbox" onclick="return checkboxTrue('+counter+')" name="chckbox' + counter + '" id="chckbox' + counter + '"/></td>\n\\n\
                                 <td><input  type="text"  name="cif' + counter + '" id="cif' + counter + '"/></td>\n\\n\
                                 <td><input type="button" name="SearchCIF' + counter + '" id="SearchCIF' + counter + '" value="Search"  onclick="SearchCIF(280,240,'+counter+')" /></td> \n\\n\
                                 <td><input type="text"  onKeyPress="return lettersOnly( event)" name="membername' + counter + '" id="membername' + counter + '" /></td>\n\\n\
                                 <td><select style="width: 120px" id="gender' + counter + '" name="gender' + counter + '" onchange="genderChange()" ><option value="" selected disabled>[Please Choose]</option><option value="Male">Male</option><option value="Female">Female</option><option value="Other">Other</option></select></td>\n\\n\
                                  <td><input type="text" id="dob' + counter + '" name="dob' + counter + '" readonly/><a href="#" onclick="ShowCalender(' + counter + ')"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" border="0" width="15" height="20" /></a></td>\n\\n\
                                  <td><input type="text" onKeyPress="return lettersOnly( event)"  id="guardianname' + counter + '" name="guardianname' + counter + '"/></td>\n\
                                 <td><textarea id="address' + counter + '" name="address' + counter + '"></textarea></td>\n\
                                 <td><select style="width: 120px" id="religion' + counter + '" name="religion' + counter + '" onchange="return religionChange()"><option value="" selected disabled>[Please Choose]</option><option value="Hindu">Hindu</option><option value="Muslim">Muslim</option><option value="Christian">Christian</option><option value="Buddhist">Buddhist</option><option value="Sikh">Sikh</option><option value="Parsi">Parsi</option><option value="Jain">Jain</option><option value="Others">Others</option></select></td>\n\\n\
                                 <td><select style="width: 120px" id="caste' + counter + '" name="caste' + counter + '"><option value="" selected disabled>[Please Choose]</option><option value="1">General</option><option value="2">SC</option><option value="3">ST</option><option value="4">OBC</option></select></td>\n\\n\
                                 <td><textarea id="qualification' + counter + '" name="qualification' + counter + '"></textarea></td>\n\\n\
                                 <td style="display:none;"><input type="hidden" name="rowStatus' + counter + '" id="rowStatus' + counter + '" value="N"/></td>\n\
               \n\n\n</tr>');
                });
                $("#addRowAmend").click(function () 
                {
                    var counter = $("#rowCounter").val();
                    var counterdelete = $("#rowCounterDelete").val();
                    counterdelete++;
                    counter++;
                    $("#rowCounter").val(counter);
                    $("#rowCounterDelete").val(counterdelete);
                    $('#mem_details-Amend tr:last').after('<tr> <td align="center"><input type="checkbox" onclick="return checkboxTrue('+counter+')"name="chckbox' + counter + '" id="chckbox' + counter + '"/></td>\n\\n\
                                 <td><input  type="text"  name="cifAmend' + counter + '" id="cifAmend' + counter + '"/></td>\n\\n\
                                 <td><input type="button" name="SearchCIFAmend' + counter + '" id="SearchCIFAmend' + counter + '" value="Search"  onclick="SearchCIFAmend(280,240,'+ counter +')" /></td> \n\\n\
                                 <td><input type="text"  onKeyPress="return lettersOnly( event)" name="membernameAmend' + counter + '" id="membernameAmend' + counter + '" /></td>\n\\n\
                                 <td><select style="width: 120px" id="genderAmend' + counter + '" name="genderAmend' + counter + '" onchange="genderAmendChange()" ><option value="" selected disabled>[Please Choose]</option><option value="Male">Male</option><option value="Female">Female</option><option value="Other">Other</option></select></td>\n\\n\
                                  <td><input type="text" id="dobAmend' + counter + '" name="dobAmend' + counter + '" readonly/><a href="#" onclick="ShowCalenderAmend(' + counter + ')"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" border="0" width="15" height="20" /></a></td>\n\\n\
                                  <td><input type="text" onKeyPress="return lettersOnly( event)"  id="guardiannameAmend' + counter + '" name="guardiannameAmend' + counter + '"/></td>\n\
                                 <td><textarea id="addressAmend' + counter + '" name="addressAmend' + counter + '"></textarea></td>\n\
                                 <td><select style="width: 120px" id="religionAmend' + counter + '" name="religionAmend' + counter + '" onchange="return religionAmendChange()"><option value="" selected disabled>[Please Choose]</option><option value="Hindu">Hindu</option><option value="Muslim">Muslim</option><option value="Christian">Christian</option><option value="Buddhist">Buddhist</option><option value="Sikh">Sikh</option><option value="Parsi">Parsi</option><option value="Jain">Jain</option><option value="Others">Others</option></select></td>\n\\n\\n\
                                 <td><select style="width: 120px" id="casteAmend' + counter + '" name="casteAmend' + counter + '"><option value="" selected disabled>[Please Choose]</option><option value="1">General</option><option value="2">SC</option><option value="3">ST</option><option value="4">OBC</option></select></td>\n\\n\
                                 <td><textarea id="qualificationAmend' + counter + '" name="qualificationAmend' + counter + '"></textarea></td>\n\\n\
                                 <td><input type="text" readonly  id="entry_dateAmend' + counter + '" name="entry_dateAmend' + counter + '"/></td>\n\\n\
                              <td style="display:none;"><input type="hidden" name="rowStatus' + counter + '" id="rowStatus' + counter + '" value="N"/></td>\n\\n\
                              <td style="display:none;"><input type="hidden" name="memberIDAmend' + counter + '" id="memberIDAmend' + counter + '" value="" /></td>\n\
                \n\n\n</tr>');
                });

                $( "#deleteRow" ).click(function() {
                    var counter = $("#rowCounterDelete").val();
                    var chkboxCounter=$("#chkboxCounter").val();

                    counterDelete=counter-chkboxCounter;

                    if (counterDelete==0)
                    {

                        alert("All rows cannot be deleted");
                    }

                    else{

                        $('input:checkbox:checked').closest('tr').remove();
                        religionChange();
                        genderChange();
                        $("#rowCounterDelete").val(counterDelete);
                        chkboxCounter=0;
                        $("#chkboxCounter").val(chkboxCounter);


                    }



                });


                $( "#deleteRowAmend" ).click(function() {


                    var counter =$("#rowCounterDelete").val();
                    var chkboxCounter=$("#chkboxCounter").val();
                    var counterDelete=counter-chkboxCounter;

                    if (counterDelete==0){

                        alert("All rows cannot be deleted");
                    }
                    else{

                        var selchbox = [];        // array that will store the value of selected checkboxes

                        selchbox= getSelectedChbox(MemberDetailsform);
                        $("#deletedRows").val(selchbox);

                        $('input:checkbox:checked').closest('tr').remove();

                        $("#rowCounterDelete").val(counterDelete);
                        genderAmendChange();
                        religionAmendChange();
                        chkboxCounter=0;
                        $("#chkboxCounter").val(chkboxCounter);


                    }


                });
                function getSelectedChbox(MemberDetailsform) {

                    var selchbox = [];        // array that will store the value of selected checkboxes

                    // gets all the input tags in frm, and their number
                    var inpfields = MemberDetailsform.getElementsByTagName('input');
                    var nr_inpfields = inpfields.length;

                    // traverse the inpfields elements, and adds the value of selected (checked) checkbox in selchbox
                    for(var i=0; i<nr_inpfields; i++) {
                        if(inpfields[i].type == 'checkbox' && inpfields[i].checked == true){
                            if  (inpfields[i].value!=null || inpfields[i].value!="" ){

                                selchbox.push(inpfields[i].value);

                            }

                        }

                    }

                    return selchbox;
                }

                function checkboxTrueAmend(i){

                    if(document.getElementById("chckboxAmend"+i).checked==true){

                        var counter = $("#chkboxCounter").val();
                        counter++;
                        $("#chkboxCounter").val(counter);
                    }

                    else{

                        var counter = $("#chkboxCounter").val();
                        counter--;
                        $("#chkboxCounter").val(counter);
                    }

                }
                function checkboxTrue(i){

                    if(document.getElementById("chckbox"+i).checked==true){

                        var counter = $("#chkboxCounter").val();
                        counter++;
                        $("#chkboxCounter").val(counter);
                    }

                    else{

                        var counter = $("#chkboxCounter").val();
                        counter--;
                        $("#chkboxCounter").val(counter);
                    }

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