<?php

include_once('header.php'); 

?>

<form method="post">
<fieldset>
<legend>Nova kategorie</legend>
<input type="text" name="new_name" size="100"> : new_name<br>
<input type="text" name="title" size="100"> : title<br>
<input type="text" name="description" size="100"> : description<br>
<input type="text" name="name" size="100"> : name<br>
<select name="parent_id"><option value="0">koren</option>
	<?php
	foreach($allkategorie as $k2 => $v2)
	{
		echo '<option value="'.$v2['id'].'" style="padding-left: '.($v2['level']*2).'0px">'.$v2['new_name'].'</option>';
	}
	?>
</select> : parent
<hr>
<input type="submit" name="nova" value="Pridat kategorii">
<hr></fieldset>
</form>

<?php
if(!empty($kategoria[0]))echo '<a href="/admin/kategorie/'.$kategoria[0]['parent_id'].'/">nadkategoria</a><hr>';
echo '<form name="kategorie" method="post">';
foreach($kategorie as $k => $v)
{
	echo '<input type="text" name="kat['.$v['id'].'][new_name]" value="'.$v['new_name'].'" size="100"><br>';
	echo '<input type="text" name="kat['.$v['id'].'][title]" value="'.$v['title'].'" size="100">'.strlen($v['title']).'<br>';
	echo '<input type="text" name="kat['.$v['id'].'][description]" value="'.$v['description'].'" size="100">'.strlen($v['description']).'<br>';
	echo '<input type="text" name="kat['.$v['id'].'][name]" value="'.$v['name'].'" size="100"><br>';
	echo '<select name="kat['.$v['id'].'][parent_id]"><option value="0">koren</option>';
	foreach($allkategorie as $k2 => $v2)
	{
		echo '<option value="'.$v2['id'].'" style="padding-left: '.($v2['level']*2).'0px"';
		if($v2['id'] == $v['parent_id'])echo ' selected ';
		echo '>'.$v2['new_name'].'</option>';
	}
	echo '</select>';
	echo '<a href="/admin/kategorie/'.$v['id'].'/">podkategorie</a> <a href="/admin/xdeletekat/'.$v['id'].'/" onclick="return window.confirm(\'Naozaj??\')">smazat</a><hr>';
}
echo '<input type="submit"><input type="submit" id="submit"></form>';

include_once('footer.php'); 

?>