{include "header.inc.html"}
{$linksLang = $lang.admin.links.form}
<div class="content_box">
	<div class="toolbar_box">
		<div class="toolbar"> <span> <strong>{$lang.admin.links.name}</strong><br />
		<span class="english">{$lang.admin.links.name_en}</span> </span>
				<div class="toolbar_menu">
			<a href="{$adminUrl}links">友情链接管理</a>
			<a href="{$adminUrl}links/act/add">添加友情链接</a>
			<a href="{$adminUrl}linkscat">友情链接分类管理</a>
			<a href="{$adminUrl}linkscat/act/add">添加友情链接分类</a>
		</div>
	</div>
	</div>
<div class="tool">
{if $smarty.get.act=="list" || $smarty.get.act==""}
<a id="deleteChecked">删除所选</a>
{/if}
</div>

{if $smarty.get.act=="edit" || $smarty.get.act=="add"}
<div class="linksForm">
<form class="form" action="" method="post">
<input type="hidden" name="act" value="{$smarty.get.act}" />
{if $smarty.get.act=="edit"}
<input type="hidden" name="id" value="{$smarty.get.id}" />
{/if}
<div class="form-line"><label class="label">分类名称：</label><div class="element"><input type="text" class="text w300" name="name" value="{$linksInfo.name}" /></div></div>

<div class="form-line"><label class="label"></label><div class="element"><input class="btn_sub" type="submit" value="{$lang.form.submit}"></div></div>
</form>

{else}
<table class="table-ca table_1" id="tInfo">
<tr>
<th class="w30"><input type="checkbox" value="1" name="allid" id="checkall" /></th><th class="w60">分类ID</th><th class="">分类名称</th><th class="w120">添加时间</th><th class="w100">{$lang.form.operate}</th>
</tr>
{linkscat limit=15}
<tr>
<td><input type="checkbox" name="id[]" value="{$item.id}" /></td><td>{$item.id}</td><td>{$item.name}</td><td>{$item.posttime|date_format:"Y-m-d H:i:s"}</td><td><a href="{$adminUrl}linkscat/act/edit/id/{$item.id}" class="modBtn">{$lang.edit}</a> <a href="javascript:void(0)" class="delBtn">{$lang.del}</a></td>
</tr>
{/linkscat}
</table>
<div class="page">
	<div class="pagin fr">{pager allCount=$allCount url='/qkadmin/linkscat/page' number="false"}</div>
</div>


<script type="text/javascript">
$(function(){
	$("a#deleteChecked").button().click(function(){
		if(!confirm(lang[4])){ return false; }		
		var id = [];
		$("input[name='id[]']:checkbox:checked").each(function(index){
			id[index] = $(this).val();
			var sid = $(this).val();
			if(sid){
				var tr = $(this).parent("td").parent("tr");
				var sdata = "inajax=1&act=del&id="+sid;
				$.ajax({
					type:"POST",
					url:"{$adminUrl}linkscat",
					data:sdata,
					dataType:"json",
					success:function(data){
						if(data.success){
							tr.fadeOut("slow").remove();
						}else{
							alert(data.message);
						}
					}
				});			
			}
		});
		
	});
	$(".delBtn").click(function(){
		if(!confirm(lang[4])){ return false; }
			var tr = $(this).parent("td").parent("tr");
			var id = tr.find("td").eq(1).text();
			if(parseInt(id,10)){
				var sdata = "inajax=1&act=del&id="+id;
				$.ajax({
					type:"POST",
					url:"{$adminUrl}linkscat",
					data:sdata,
					dataType:"json",
					success:function(data){
						if(data.success){
							tr.fadeOut("slow").remove();
						}else{
							alert(data.message);
						}
					}
				});
			}
		return false;
	});
})
</script>

{/if}

{include "footer.inc.html"}