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

if (!$response->success) {
	?>
	<h1>Chyba při updatu projektu</h1>
	<p>
		Chybová hláška: <strong><?php echo $response->status; ?></strong>
	</p>
	<p>
		Chybový kód: <strong><?php echo $response->statusCode; ?></strong>
	</p>
	<?php 
	return;
}
?>
<h1>Obrazy projetku</h1>
<p>
	Identifikační číslo projektu: <strong><a href="/project/get/<?php echo $this->project->directory_id; ?>.html"><?php echo $this->project->directory_id; ?></a></strong>
</p>
<p>
	Jméno projektu: <strong><?php echo $this->project->project_name; ?></strong>
</p>
<h2>Vytvořit nový obraz</h2>
<form action="/project/label/<?php echo $this->project->directory_id; ?>.html" method="post">
	<p>
		Jméno obrazu: <?php echo $this->formText("label[label_name]") ?> 
	</p>
	<p>
		Komentář: <br />
		<textarea rows="5" cols="100" name="label[comment]"></textarea>
	</p>
	<p>
		<?php echo $this->formSubmit("submit", "Vytvořit"); ?>
	</p>
</form>
<h2>Vytvořené obrazy</h2>
<table>
	<thead>
		<tr>
			<th>
			#
			</th>
			<th>
			Jméno
			</th>
			<th>
			Komentář
			</th>
			<th>
			Vytvořil
			</th>
			<th>
			Datum
			</th>
		</tr>
	</thead>
	<tbody>
	<?php 
	//cache uzivatelu
	$users = array();
	
	foreach ($response["label"] as $label) {
		//kontorla nacteni uzivatele
		if (!isset($users[$label->user_id])) {
			$users[$label->user_id] = $label->findParentRow("Application_Model_Users", "user");
		}
		
		?>
		<tr>
			<td>
			<a href="/project/label/<?php echo $label->id; ?>.zip"><?php echo $label->id; ?></a>
			</td>
			<td>
			<?php echo $label->label_name; ?>
			</td>
			<td>
			<?php echo $label->comment; ?>
			</td>
			<td>
			<a href="/user/get/<?php echo $users[$label->user_id]->username; ?>.html"><?php echo $users[$label->user_id]->username; ?></a>
			</td>
			<td>
			<?php echo $label->created_at; ?>
			</td>
		</tr>
		<?php 
	}
	?>
	</tbody>
</table>