<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="js" uri="net.sourceforge.jsurveyor.jsurveyorlib" %>
<%@ page import="java.util.*" %>
<%@ page import="net.sourceforge.jsurveyor.*" %>
<js:noCache />
<js:login access="root" />
<js:border title="jSurveyor - Usergroups">
<form name='form' action='root_redirect.jsp' method='post'>
	<tr>
	  <td class='mainmenu_headline_unselected'><a class='tab' href='root_user_list.jsp' title='Click to manage Users'>Users</a></td>
	  <td class='mainmenu_headline'>Usergroups</td>
	  <td class='mainmenu_headline_emptyfield'>&nbsp;</td>
    </tr>
	<tr>
	  <td colspan='3' class='mainmenu_blueframe'>
	  
	  <script language='javascript' type='text/javascript'>
		function checkall( elem ){
			var form = document.form;
			for( i  =0; i<form.length; i++ ){
				if( form.elements[ i ].type == 'checkbox' ) {
					form.elements[ i ].checked = elem.checked;
				} //end if
			} //end for
		} //end function
		</script>	
	  
	    <table cellspacing='0' cellpadding='0'>
		  <tr>
		  <td class='mainmenu_workframe'>
            <table cellspacing='0'>
	<tr>
		<td class='title' width='5%'><input type='checkbox' name='gid' title='Click to select all usergroups' onClick='checkall(this)' /></td>
		<td class='title' width='61%'>Group</td>
		<td class='title' width='17%'>Subgroups</td>
		<td class='title' width='17%'>Users in group</td>			
	</tr>
	<%
      ArrayList userGroups = DataAccess.retrieveAllUserGroups();
      String tdClass = "body_odd";
      for(int i = 0; i < userGroups.size(); i++) {
            	UserGroup tempUserGroup = (UserGroup)userGroups.get(i);
            	tdClass = ( i%2 == 0 ) ?  "body_even" : "body_odd";
            	%>
				<tr>
					<td class='<%=tdClass%>'><input type='checkbox' name='userGroupID' value='<%=tempUserGroup.getUserGroupID() %>' /></td>
					<td class='<%=tdClass%>'><!-- Used to indent og collapse and expand a tree &nbsp;&nbsp;&nbsp;<a href='?' style='text-decoration:none;'>-</a>-->
																	&nbsp;<a href='root_redirect.jsp?userGroupID=<%=tempUserGroup.getUserGroupID()%>&Gbutton=Edit...' title='Click to edit this usergroup'><%=tempUserGroup.getGroupName()%></a></td>
					<td class='<%=tdClass%>'><%=(tempUserGroup.getRefChildren()).size() %></td>
					<td class='<%=tdClass%>'><%=(tempUserGroup.getRefChildren()).size() %></td>
				</tr>
            		
            	
            	<%
            //  out.print("<option value='" + tempUserGroup.getUserGroupID() + "'>" + tempUserGroup.getGroupName() + " Refchildren: " + tempUserGroup.getRefChildren() + " Refparents: " + tempUserGroup.getRefParents() + "</option>");
           //  	out.print("<option value='" + tempUserGroup.getUserGroupID() + "'>" + tempUserGroup.getGroupName()  + "</option>");
            }
            %>
	
	
	
	<!-- CC: DONT DELETE - THE OLD XHTML 1.0 example
	<tr>
		<td class='body_even'><input type='checkbox' name='gid' value='14' /></td>
		<td class='body_even'>&nbsp;&nbsp;&nbsp;<a href='?'>Gruppe 1</a></td>
		<td class='body_even'>0</td>
		<td class='body_even'>30</td>
	</tr>
	<tr>
		<td class='body_odd'><input type='checkbox' name='gid' value='1' /></td>
		<td class='body_odd'><a href='?' style='text-decoration:none;'>-</a>&nbsp;<a href='?'>Gruppe 14</a></td>
		<td class='body_odd'>2</td>
		<td class='body_odd'>70</td>
	</tr>
	<tr>
		<td class='body_even'><input type='checkbox' name='gid' value='30' /></td>
		<td class='body_even'>&nbsp;&nbsp;&nbsp;<a href='?' style='text-decoration:none;'>-</a>&nbsp;<a href='?'>Gruppe 30</a></td>
		<td class='body_even'>2</td>
		<td class='body_even'>40</td>
	</tr>
	<tr>
		<td class='body_odd'><input type='checkbox' name='gid' value='40' /></td>
		<td class='body_odd'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='?'>Gruppe 100</a></td>
		<td class='body_odd'>0</td>
		<td class='body_odd'>30</td>
	</tr>
	<tr>
		<td class='body_even'><input type='checkbox' name='gid' value='50' /></td>
		<td class='body_even'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='?'>Testgruppe</a></td>
		<td class='body_even'>0</td>
		<td class='body_even'>70</td>
	</tr>
	<tr>
		<td class='body_odd'><input type='checkbox' name='gid' value='60' /></td>
		<td class='body_odd'>&nbsp;&nbsp;&nbsp;<a href='?' style='text-decoration:none;'>+</a>&nbsp;<a href=''>Hemmelig gruppe</a></td>
		<td class='body_odd'>3</td>
		<td class='body_odd'>100</td>
	</tr>
	<tr>
		<td class='body_even'><input type='checkbox' name='gid' value='70' /></td>
		<td class='body_even'>&nbsp;&nbsp;&nbsp;<a href='?'>Hum</a></td>
		<td class='body_even'>0</td>
		<td class='body_even'>150</td>
	</tr>-->
	
	
	
</table>
            <!--
            <select name='userGroupID' style='width:100%' size='20' multiple>
            <%
            /*
            ArrayList userGroups = Data.retrieveAllUserGroups();            
            for(int i = 0; i < userGroups.size(); i++) {
            	UserGroup tempUserGroup = (UserGroup)userGroups.get(i);
            	out.print("<option value='" + tempUserGroup.getUserGroupID() + "'>" + tempUserGroup.getGroupName() + " Refchildren: " + tempUserGroup.getRefChildren() + " Refparents: " + tempUserGroup.getRefParents() + "</option>");
            }
            */
            %>
            </select> -->
            </td> <!-- Main workframe end -->
		  </tr>
	    </table>
      </td>
	</tr>
	<tr>
	<td>
	  <table><tr><td> <!-- Makes space between blue border and top of buttons -->
	  </td></tr>
	  </table>
	</td>
	</tr>

	<tr>
	  <td><input class='stdbutton' name='Gbutton' type='submit' title='Click to delete selected usergroups' value='Delete'/></td>
	  <td class='mainmenu_buttonline' colspan='3'><input class='stdbutton' name='Gbutton' type='submit' title='Click to create a new usergroup' value='Create...'/> <input class='stdbutton' name='Gbutton' type='submit' title='Click to edit the selected usergroup' value='Edit...'/></td>
    </tr>
</form>
</js:border>











