<?php
include_once 'includes/header.inc.php';
if(!$session->getRole() == 2){
header("location: login.php");
}
?>
<legend>User management</legend>
<table class="table table-striped">
<tr>
<th>Role</th>
<th>Username</th>
<th>E-mail</th>
<th>Mailinglist</th>
</tr>
<?php
$query = $database->query("SELECT `cal_users`.*, `cal_users`.`id` AS `userid`, `cal_roles`.*, `cal_roles`.`role` as `rolename` FROM `cal_users` JOIN `cal_roles` ON `cal_users`.`role` = `cal_roles`.`id` ");
while($row = mysql_fetch_assoc($query)){
?>
<tr>
<td><?php echo $row['rolename']; ?></td>
<td><a href="<?php echo $url; ?>user_edit.php?id=<?php echo $row['userid']; ?>"><?php echo $row['username']; ?></a></td>
<td><?php echo $row['email']; ?></td>
<td><?php if($row['mailinglist'] == 1){ echo "<i class='icon-ok'></i>"; } else { echo "<i class='icon-remove'></i>"; } ?></td>
</tr>
<?php
}
?>
</table>
<a href="user_add.php" class="btn">Add new user</a>
<?php include_once 'includes/footer.inc.php'; ?>