<?php
if ( $_SESSION['IsAdmin'] )
	{
		$sql1		= "SELECT * FROM User WHERE userId != '1' AND userIsAdmin = 'Y' ORDER BY userLastname ASC, userFirstname ASC;";
		$result1	= $db->query($sql1);
		$anz1		= $result1->num_rows;
		$sql2		= "SELECT * FROM User WHERE userId != '1' AND userIsBuero = 'Y' ORDER BY userLastname ASC, userFirstname ASC;";
		$result2	= $db->query($sql2);
		$anz2		= $result2->num_rows;
		$sql3		= "SELECT * FROM User WHERE userId != '1' AND userIsAdmin = 'N' AND userIsBuero = 'N' AND userDeact = 'N' ORDER BY userLastname ASC, userFirstname ASC;";
		$result3	= $db->query($sql3);
		$anz3		= $result3->num_rows;
		$sql4		= "SELECT * FROM User WHERE userId != '1' AND userIsAdmin = 'N' AND userIsBuero = 'N' AND userDeact = 'Y' ORDER BY userLastname ASC, userFirstname ASC;";
		$result4	= $db->query($sql4);
		$anz4		= $result4->num_rows;
		
		$anz		= $anz1 + $anz2 + $anz3 + $anz4;
?>
<table border="0">
	<colgroup>
		<col width="55" />
		<col width="310" />
		<col width="365" />
		<col width="30" />
	</colgroup>
	<tr height="30">
		<th style="text-align:right;padding-right:10px;"><?php echo $anz; ?></th>
		<th style="text-align:left;">Nachname, Vorname</th>
		<th colspan="2" style="text-align:left;">Email</th>
	</tr>
	<tr height="24">
		<td style="text-align:right;padding-right:10px;"><?php echo $anz1; ?></td>
		<td colspan="3">Administratoren</td>
	</tr>
<?php
		while ( $nt1 = $result1->fetch_assoc() )
			{
?>
	<tr>
		<form name="Edit<?php echo $nt1['userId']; ?>" action="index.php?<?php echo $_SERVER['QUERY_STRING']; ?>" method="post" />
			<input type="hidden" name="ID" value="<?php echo $nt1['userId']; ?>" />
			<input type="hidden" name="action" value="Bearbeiten" />
		</form>
		<td>&nbsp;</td>
		<td><a href="#" onclick="document.Edit<?php echo $nt1['userId']; ?>.submit();"><?php echo $nt1['userLastname'] . ", " . $nt1['userFirstname']; ?></a></td>
		<td colspan="2"><?php echo $nt1['userEmail']; ?></td>
	</tr>
<?php
			}
?>
	<tr height="24">
		<td colspan="4">&nbsp;</td>
	</tr>
	<tr height="24">
		<td style="text-align:right;padding-right:10px;"><?php echo $anz2; ?></td>
		<td colspan="3">Bürokräfte</td>
	</tr>
<?php
		while ( $nt2 = $result2->fetch_assoc() )
			{
?>
	<tr>
		<form name="Edit<?php echo $nt2['userId']; ?>" action="index.php?<?php echo $_SERVER['QUERY_STRING']; ?>" method="post" />
			<input type="hidden" name="ID" value="<?php echo $nt2['userId']; ?>" />
			<input type="hidden" name="action" value="Bearbeiten" />
		</form>
		<td>&nbsp;</td>
		<td><a href="#" onclick="document.Edit<?php echo $nt2['userId']; ?>.submit();"><?php echo $nt2['userLastname'] . ", " . $nt2['userFirstname']; ?></a></td>
		<td><?php echo $nt2['userEmail']; ?></td>
	</tr>
<?php
			}
?>
	<tr height="24">
		<td colspan="4">&nbsp;</td>
	</tr>
	<tr height="24">
		<td style="text-align:right;padding-right:10px;"><?php echo $anz3; ?></td>
		<td colspan="2">Aktive Benutzer</td>
		<form name="Deakt_All" action="index.php?<?php echo $_SERVER['QUERY_STRING']; ?>" method="post" />
			<input type="hidden" name="ID" value="All" />
			<input type="hidden" name="action" value="Deakt_All" />
		</form>
		<td><img style="cursor:pointer;" src="../img/0.png" title="Alle Deaktivieren" onclick="document.Deakt_All.submit();" /></td>
	</tr>
<?php
		while ( $nt3 = $result3->fetch_assoc() )
			{
?>
	<tr>
		<form name="Edit<?php echo $nt3['userId']; ?>" action="index.php?<?php echo $_SERVER['QUERY_STRING']; ?>" method="post" />
			<input type="hidden" name="ID" value="<?php echo $nt3['userId']; ?>" />
			<input type="hidden" name="action" value="Bearbeiten" />
		</form>
		<form name="Deaktiv<?php echo $nt3['userId']; ?>" action="index.php?<?php echo $_SERVER['QUERY_STRING']; ?>" method="post" />
			<input type="hidden" name="ID" value="<?php echo $nt3['userId']; ?>" />
			<input type="hidden" name="action" value="Deaktivieren" />
		</form>
		<td style="border-bottom:1px solid gray;">&nbsp;</td>
		<td style="border-bottom:1px solid gray;"><a href="#" onclick="document.Edit<?php echo $nt3['userId']; ?>.submit();"><?php echo $nt3['userLastname'] . ", " . $nt3['userFirstname']; ?></a></td>
		<td style="border-bottom:1px solid gray;"><?php echo $nt3['userEmail']; ?></td>
		<td style="border-bottom:1px solid gray;"><img style="cursor:pointer;" src="../img/0.png" title="deaktivieren" onclick="document.Deaktiv<?php echo $nt3['userId']; ?>.submit();" /></td>
	</tr>
<?php
			}
?>
	<tr height="24">
		<td colspan="4">&nbsp;</td>
	</tr>
	<tr height="24">
		<td style="text-align:right;padding-right:10px;"><?php echo $anz4; ?></td>
		<td colspan="2">Deaktivierte Benutzer</td>
		<form name="Akt_All" action="index.php?<?php echo $_SERVER['QUERY_STRING']; ?>" method="post" />
			<input type="hidden" name="ID" value="All" />
			<input type="hidden" name="action" value="Akt_All" />
		</form>
		<td><img style="cursor:pointer;" src="../img/1.png" title="Alle Aktivieren" onclick="document.Akt_All.submit();" /></td>
	</tr>
<?php
		while ( $nt4 = $result4->fetch_assoc() )
			{
?>
	<tr>
		<form name="Edit<?php echo $nt4['userId']; ?>" action="index.php?<?php echo $_SERVER['QUERY_STRING']; ?>" method="post" />
			<input type="hidden" name="ID" value="<?php echo $nt4['userId']; ?>" />
			<input type="hidden" name="action" value="Bearbeiten" />
		</form>
		<form name="Aktiv<?php echo $nt4['userId']; ?>" action="index.php?<?php echo $_SERVER['QUERY_STRING']; ?>" method="post" />
			<input type="hidden" name="ID" value="<?php echo $nt4['userId']; ?>" />
			<input type="hidden" name="action" value="Aktivieren" />
		</form>
		<td style="border-bottom:1px solid gray;">&nbsp;</td>
		<td style="border-bottom:1px solid gray;"><a href="#" onclick="document.Edit<?php echo $nt4['userId']; ?>.submit();"><?php echo $nt4['userLastname'] . ", " . $nt4['userFirstname']; ?></a></td>
		<td style="border-bottom:1px solid gray;"><?php echo $nt4['userEmail']; ?></td>
		<td style="border-bottom:1px solid gray;"><img style="cursor:pointer;" src="../img/1.png" title="aktivieren" onclick="document.Aktiv<?php echo $nt4['userId']; ?>.submit();" /></td>
	</tr>
<?php
			}
?>
	<tr>
		<form name="Neu1" action="index.php?<?php echo $_SERVER['QUERY_STRING']; ?>" method="post">
			<input type="hidden" name="action" value="Anlegen" />
		</form>
		<td>&nbsp;</td>
		<td style="padding-top:50px;" colspan="3"><a href="#" onclick="document.Neu1.submit();">neuen Benutzer anlegen</a></td>
	</tr>
</table>
<?php
	}
?>