<?php
$response = $this->response;

//nacteni vsech uzivatelu
$tableUsers = new Application_Model_Users();
$users = $tableUsers->fetchAll(null, "username");

//prevedeni uzivatelu ve skupine na pole obsahujici pouze id
$groupedUsers = array();

foreach ($response["users"] as $user) {
	$groupedUsers[] = $user["id"];
}

?>
<h1>Skupina - <?php echo $response["group"]->group_name; ?></h1>
<form action="/group/put/<?php echo $response["group"]->id . "_" . $response["group"]->group_name; ?>.html" method="post">
	<p>
	<?php echo $this->formLabel("group[group_name]", "Jméno skupiny"); ?>: 
	<?php echo $this->formText("group[group_name]", $response["group"]->group_name); ?>
	<h2>Uživatelé</h2>
	<ul>
		<?php 
		foreach ($users as $user) {
			$checked = in_array($user->id, $groupedUsers);
			
			?>
			<li><?php echo $this->formCheckbox("group[user][$user->id]", 1, array("checked" => $checked)); ?> <a href="/user/get/<?php echo $user->username; ?>.html"><?php echo $user->username; ?></a></li>
			<?php 
		}
		?>
	</ul>
	<p>
		<?php echo $this->formSubmit("group[submit]", "Uložit"); ?>
	</p>
</form>