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

if (!$response->success) {
	?>
	<h1>Chyba při načítní seznamu dokumentace</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>Výpis dokumentace</h1>
<p>
	Typ objektu: <strong><?php ($this->type == "document") ? "dokument" : "adresář"; ?></strong>
</p>
<div>
	Objekt je dokumentovaný:
	<table>
		<thead>
			<tr>
				<th>
				#
				</th>
				<th>
				Dokumentace
				</th>
			</tr>
		</thead>
		<tbody>
		<?php 
		foreach ($response["documentedBy"] as $doc) {
			?>
			<tr>
				<td>
				<a href="/documentation/get/<?php echo $doc->id; ?>.html"><?php echo $doc->id; ?></a>
				</td>
				<td>
				<a href="/document/get/<?php echo $doc->documentation_document_uuid; ?>.html"><?php echo $doc->documentation_document_uuid; ?></a>
				</td>
			</tr>
			<?php 
		}
		?>
		</tbody>
	</table>
</div>
<?php 
if ($this->type == "directory") {
?>
<div>
	Objekt dokumentuje:
	<table>
		<thead>
			<tr>
				<th>
				#
				</th>
				<th>
				Typ
				</th>
				<th>
				Objekt
				</th>
			</tr>
		</thead>
		<tbody>
			<?php 
			foreach ($response["documentationFor"] as $doc) {
				?>
			<tr>
				<td>
				<a href="/documentation/get/<?php echo $doc->id; ?>.html"><?php echo $doc->id; ?></a>
				</td>
				<td>
				<?php echo $doc->documented_document_id ? "Dokument" : "Adresář"; ?>
				</td>
				<td>
				<?php 
				if ($doc->documented_document_id) {
					?>
					<a href="/document/get/<?php echo $doc->documentation_document_uuid; ?>.html"><?php echo $doc->documentation_document_uuid; ?></a>
					<?php 
				} else {
					?>
					<a href="/directory/get/<?php echo $doc->documentation_directory_id; ?>.html"><?php echo $doc->documentation_directory_id; ?></a>
					<?php 
				} 
				?>
				</td>
			</tr>
				<?php 
			}
			?>
		</tbody>
	</table>
</div>
<?php 
}
?>