<?php TPL::output('admin/global/header.tpl.htm'); ?>
<!--left-->
<?php TPL::output('admin/global/left.tpl.htm'); ?>
<!--left-->
<!-- main -->

<div id="body-wrapper">
	<div id="main-content">
		<div class="clear"></div>
		<div class="content-box">
			<div class="content-box-header">
				<h3><?php echo $this->crumb['last']['name']; ?></h3>
				<ul class="content-box-tabs">
				</ul>
				<div class="clear"></div>
			</div>
			<div style="width:950px;">
				<form id="category_form" action="admin/category/sort_ajax/" method="post">
				<div class="content-box-content" style="padding-bottom:3px; padding-top:12px;">
					<p groupid="11" name="category_enable" style="height:20px;">
						<span style="float:left;">Whether to use the classification function:</span>
						<label style="float:left;">
						<input type="radio" name="category_enable" value="Y" <?php if ($this->setting['category_enable'] == 'Y'){ ?> checked="true"<?php } ?>/>
						Yes
						</label>
						<label style=" float:left;">
						<input type="radio" name="category_enable" value="N" <?php if ($this->setting['category_enable'] == 'N'){ ?> checked="true"<?php } ?>/>
						No
						</label>
					<span style="color:#999; float:left; margin-left:16px;">(Classification function is not used, the question will be sent to the [Default Category])</span>
					</p>
				</div>
				<div style="clear:both"></div>
				<div class="content-box-content" style="width:500px;float:left;padding-top:0;margin-top:5px;">
					<?php if($this->category_position){ ?>
					<p>
						<label> <b>Category Navigation:</b></label>
						<?php foreach($this->category_position as $key => $val){ ?>
						<a href="admin/category/list/parent_id-<?php echo $val['id'];?>"><?php echo $val['title']; ?></a> >
						<?php } ?>
						</label>
					</p>
					<?php } ?>
					<?php if(!$this->list){ ?>
					<div class="notification attention png_bg">
						<div>No classification</div>
					</div>
					<?php }else{ ?>
						<table class="list">
							<thead>
								<tr>
									<th style="width:34px;">Sort</th>
									<th>Category title</th>
									<th>Subcategories</th>
									<th>Movement</th>
									<th>Operation</th>
								</tr>
							</thead>
							<tbody style="border-bottom: 1px solid #ddd;">
								<?php foreach ($this->list AS $key => $val) { ?>
								<tr valign="middle">
									<td  style="width:60px;"><input type="text" value="<?php echo $val['sort']; ?>" class="text-input medium-input" maxlength="3" style="width:60px;" name="category[<?php echo $val['id']; ?>][sort]"></td>
									<td><a href="admin/category/edit/category_id-<?php echo $val['id']; ?>"><?php echo $val['title']; ?></a></td>
									<td><?php if($val['child_count'] > 0){ ?>
										<a href="admin/category/list/parent_id-<?php echo $val['id']; ?>"><?php echo $val['child_count']; ?>Subcategories</a>
										<?php }else{ ?>
										No
										<?php } ?></td>
									<td><a href="admin/category/question_move/category_id-<?php echo $val['id']; ?>" title="Move by group">Move by group</a> &nbsp; </td>
									<td><a href="admin/category/edit/category_id-<?php echo $val['id']; ?>" title="Modify Category"><img src="<?php echo GET_STATIC_URL;?>/admin/images/icons/pencil.png"/></a> &nbsp; <a href="javascript:void(0);" onClick="category_remove(<?php echo $val['id'];?>)" name="remove" rel="<?php echo $val['topic_id']; ?>" title="Delete Topic"><img src="<?php echo GET_STATIC_URL;?>/admin/images/icons/cross.png" alt="Delete" /></a> </td>
								</tr>
								<?php } ?>
							</tbody>
						</table>
						<p style="margin-top:10px;">
							<input type="button" value="Save setting" onClick="ajax_post($('#category_form'), _form_process);" class="button">
						</p>
					<?php } ?>
					</div>
					</form>
				<div style="border:1px solid rgb(204, 204, 204); margin-left:10px; padding-top:0; width:350px; float:left;margin-top:5px;">
				<div style="width: 100%; cursor: s-resize;" class="content-tgbox-header">
					<h4>Add to category</h4>
				</div>
				
					<div class="tab-content default-tab" style="padding:10px;<?php if ($this->setting['category_enable'] == 'N'){ ?>display:none;<?php } ?>" id="tab1">
						<form id="_save_form" action="admin/category/save_ajax/" method="post">
							<p>
								<label>Category Title:</label>
								<input type="text" value="" class="text-input medium-input" name="title">
							</p>
							<p>
								<label>Parent Category:</label>
								<select name="parent_id" style="width:200px;">
									<option value="0">No</option>
									<?php echo $this->category_option; ?>
								</select>
							</p>
							<p>
								<label>
								<input name="add_nav_menu" type="checkbox" checked="true">
								Add to navigation menu</label>
								</label>
							</p>
							<p>
								<input class="button" type="button" onClick="ajax_post($('#_save_form'), _form_process);" value="Add a new category" />
							</p>
						</form>
					</div>
				</div>
			</div>
			<!-- footer -->
			<?php TPL::output('admin/global/footer.tpl.htm'); ?>
			<!-- footer -->
		</div>
	</div>
	<div class="clear"></div>
</div>
<!-- main -->
</div>

<script type="text/javascript">

$('#_save_form').find('select[name=parent_id]').change(function (i)
{
	if($(this).val() != 0)
	{
		$(':input[name=add_nav_menu]').removeAttr('checked');
	}
	else
	{
		$(':input[name=add_nav_menu]').attr('checked', 'checked');
	}
});

</script>

</body>
</html>