<?php
/*
	[Phpup.Net!] (C)2009-2011 Phpup.net.
	This is NOT a freeware, use is subject to license terms

	$Id: admin.class.php 2010-08-24 10:42 $
*/

if(!defined('IN_PHPUP')) {
	exit('Access Denied');
}
?>
<?php include ROOT_PATH.'/views/admin/header.php';?>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!--
function addcate(id)
{
	url=site_root+"/index.php?con="+adminpath+"&act=catemodify&parentid="+id;
	$.get(url,{},
	function(data){
		$('#dialog').html(data);
	});
	$('#blurdiv').show();
	$('#blurdiv').height($(document).height());
	$('#dialog').dialog('open');
	$('#dialog').dialog({
		title:'添加分类',
		width: 500,
		height:350,
		buttons: {},
		close:function(){$('#blurdiv').hide();$('#dialog').html('');}
	});
}
function modifycate(id)
{
	url="index.php?con="+adminpath+"&act=catemodify&updateid="+id;
		$.get(url,{},
		function(data){
			$('#dialog').html(data);
		});
		$('#blurdiv').show();
		$('#blurdiv').height($(document).height());
		$('#dialog').dialog('open');
		$('#dialog').dialog({
			title:'修改分类',
			width: 400,
			height:350,
			buttons: {},
			close:function(){$('#blurdiv').hide();$('#dialog').html('');}
		});
}
function parseMyCateData(data)
{
	var objdata=data;
	if(objdata.dotype=='add')
	{
		var catename=objdata.parentid>0?'<div style="padding-left:10px;">'+objdata.catename+'</div>':objdata.catename;
		$('#cate'+objdata.parentid).after('<TR class="tr1" id="cate'+objdata.id+'"><TD>'+catename+'</TD><TD >'+objdata.sortorder+'</TD><td align="center"><A HREF="javascript:deleteVal(\'catelist\',\''+objdata.id+'\',\'cate'+objdata.id+'\')">删除</A> <a href="javascript:modifycate('+objdata.id+')">修改</a></td></TR>');
		Dialog_close();
	}
	else
	{
		$('#catename-'+objdata.id).html(objdata.catename);
		$('#sortorder-'+objdata.id).html(objdata.sortorder);
		Dialog_close();
	}
}



function cate2cate()
{

	var boo = confirm('同步数据，会将本地的数据覆盖，您确定这样做吗？')

	if(boo)
	{
		var  url="index.php?con="+adminpath+"&act=cate2cate"; 
		$.get(url,function(data){
		
			if(data == "true")
			{
					alert("同步成功,请更新缓存！");
					location.reload();
			}else{
					alert("同步失败！");
			}
		});

	}
}


//-->
</SCRIPT>
<div class="subnav">
	<div class="content-menu ib-a blue line-x">
	<a href="javascript:addcate(0);" class="add fb"><em>添加分类</em></a>
	<a href="javascript:cate2cate();" class="add fb"><em>服务器同步</em></a>
	</div>
</div>
<div class="table-list">
<TABLE cellpadding="1" cellspacing="1" style="width:500px;">
<thead>
<TR>
	<TH>类别</TH>
	<TH>排序</TH>
	<TH>操作</TH>
</TR>
</thead>
<tbody>
<tr id="cate0"><td colspan="3"></td></tr>
<?php foreach($GLOBALS['cate'] as $key=>$val){?>
<TR class="tr1" id="cate<?php echo $key;?>">
	<TD id="catename-<?php echo $key;?>">
	<?php echo $val['catename'];?> 
	</TD>
	<TD id="sortorder-<?php echo $key;?>">
	<?php echo $val['sortorder'];?>
	</TD>
	<td width="170px" align="center">
	<A HREF="javascript:deleteVal('catelist','<?php echo $key;?>','cate<?php echo $key;?>')">删除</A>
	<a href="javascript:modifycate('<?php echo $key;?>')">修改</a> <A HREF="javascript:addcate(<?php echo $key;?>);">添加子分类</A>
	</td>
</TR>
<?php if($catelist[$key]){foreach($catelist[$key] as $cates){?>
<TR class="tr1" id="cate<?php echo $cates['id'];?>">
	<TD id="catename-<?php echo $cates['id'];?>">
	<DIV style="padding-left:10px;">
		<?php echo $cates['catename'];?>
	</DIV>
	</TD>
	<TD width="80px" id="sortorder-<?php echo $cates['id'];?>" >
	<?php echo $cates['sortorder'];?>
	</TD>
	<td width="170px" align="center">
	<A HREF="javascript:deleteVal('catelist','<?php echo $cates['id'];?>','cate<?php echo $cates['id'];?>')">删除</A>
	<a href="javascript:modifycate('<?php echo $cates['id'];?>')">修改</a>
	</td>
</TR>
<?php }}?>
<?php }?>
</tbody>
</TABLE>
</div>
<div id="dialog" style="display:none;"><IMG SRC="<?php echo STATIC_ROOT;?>/views/js/i/032.gif" WIDTH="32" HEIGHT="32" BORDER="0" ALT=""></div>
<div style="z-index: 1000; background-color: rgb(0, 0, 0); visibility: visible; display: none; position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px; width:100%;filter:alpha(opacity=50); opacity: 0.5; -moz-opacity:0.5;" id="blurdiv"></div>
</body>
</html>
