<?php
	session_name('library');
	session_start();
	
	include("functions.php");
	
	
	
	head('Users List');
?>

<body>
<div id="main">

	<?php
		include("header.php");
		include("menu.php");
	?>

		
	

<div id="entire_panel">
		<h1>Výpis používateľov</h1>
		<?php
			 

if ($_SESSION['admin'] == 1) {
	
					$link = connect_db();
					$sql = "SELECT * FROM users";
					$result = mysql_query($sql, $link);
					if ($result) {
						echo '<table border="1" class="center_page">';
						echo '<tr><th>&nbsp;USERNAME&nbsp;</th><th>&nbsp;NAME AND SURNAME&nbsp;</th><th>&nbsp;EMAIL&nbsp;</th><th>&nbsp;C&nbsp;</th><th>&nbsp;A&nbsp;</th><th>&nbsp;S&nbsp;</th><th>&nbsp;REGISTERED&nbsp;</th><th>&nbsp;AKCIA&nbsp;</th></tr>';
						while ($row = mysql_fetch_assoc($result)) {
							echo '<tr><td>&nbsp;' . $row['username'] . '&nbsp;</td><td>&nbsp;' . $row['name'] . '&nbsp;' . $row['surname'] . '&nbsp;</td><td>&nbsp;' . $row['email'] . '&nbsp;</td><td>&nbsp;' . $row['actual_count'] . '&nbsp;</td><td>&nbsp;' . $row['admin'] . '&nbsp;</td><td>&nbsp;' . $row['status'] . '&nbsp;</td><td>&nbsp;' . $row['date_registered'] . '&nbsp;</td>';
							echo '<td>';
						echo '<a href="change_info.php?id=' . $row['uid'] . '" title="Uprav"><img src="images/edit.png" height="32" width="32"></a>';
						echo '<a href="remove_user.php?id=' . $row['uid'] . '" title="Vymaž"><img src="images/delete.png" height="32" width="32"></a>';
						echo '</td></tr>';
						}
						echo '</table><br /><br />';
						echo '<p id="bold">Celkový počet používateľov: ' . mysql_num_rows($result) . '</p><br/>';
						mysql_free_result($result);
					} else {
						echo '<p id="red">Nastal problém pri získavaní údajov z databázy - ' . mysql_errno($link) . ': ' . mysql_error($link) . '</p>';
					}
				mysql_close($link);
	
} else {
	echo '<p id="red">K tejto stránke nemáte dostatočné oprávnenia</p>';
}    
		?>				
</div>

	<?php include("footer.php"); ?>

</div>
</body>
</html>

