<?
$title = $this->title;
$form = $this->Form;

$title->elem('a')->href('#')->cssClass('slideDown')->name($this->Language('Add menu'));
$title->create($this->Language('Admin menus'));

$form->option('parent_id', 0, 'none');
while($row = $this->main_menus->Assoc()){

	$form->option('parent_id', $row['id'], $row['name']);
	$form->option('parent_name', $row['id'], $row['name']);
}
?>

<form method="post" class="slideDownBox">
<table class="header">
<?
$columns = array('name', 'parent_id', 'url', 'clickAble' => 'click able', 'is_enabled', 'add_menu' => '');
$form->input($columns);
$form->select('parent_id');

$form->clickAble(array('type=checkbox', 'value="1"', 'checked=checked'));
$form->is_enabled(array('type=checkbox', 'value=1', 'checked=checked'));
$form->add_menu(array('type=submit', 'value='.$this->Language('Insert')));
$form->url(array('value=http://'));

$form->trHeaderList($columns);
?>
</table>
</form>


<form method="post">
<table class="content menu">
<?
$columns = array('name', 'parent_name', 'url', 'clickAble', 'is_enabled', 'update_admin_menu,cancel' => '');
$form->trHeader($columns, array('th' => 'id="{this.name}"', 'th(5)' => '', 'tr' => 'class="nodrag"'));
if(is_array($this->menus->Rows)){

	foreach($this->menus->Rows as $row){

		$row['clickAble'] = $row['class'];

		if($_GET['action'] == 'edit' && $_GET['id'] == $row['id']){

			$form->input($columns);
			$form->select('parent_name')->selected('parent_name', $row['parent_id']);
			$form->a('cancel');

			$form->clickAble(array('type=checkbox', 'value="1"', ($row['class'] == '' ? 'checked="checked"' : '')));
			$form->is_enabled(array('type=checkbox', 'value=1', ($row['is_enabled'] == 1 ? 'checked="checked"' : '')));
			$form->update_admin_menu(array('type=submit', 'value='.$this->Language('Update')));
			$form->cancel(array('href='.$this->Link(), 'value='.$this->Language('Cancel')));

			$form->tr($columns, $row, array('tr' => 'id="row-'.$row['id'].'"', 'td(0)' => 'style="padding-left:'.($row['counter'] > 1 ? $row['counter']*13 : 0).'px;"'));
		}
		else{

			$row['name'] = '<a href="'.$this->Link('?action=edit&id='.$row['id']).'">'.$row['name'].'</a>';
			$form->exception('is_enabled', array(0 => $this->Language('no'), 1 => $this->Language('yes')));
			$form->exception('clickAble', array('no-click' => $this->Language('no'), '' => $this->Language('yes')));
			$form->tr($columns, $row, array('tr' => 'id="row-'.$row['id'].'"', 'td(0)' => 'style="padding-left:'.($row['counter'] > 1 ? $row['counter']*13 : 0).'px;"'));
		}
	}
}
?>
</table>
</form>