<?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 addcity()
	{
		url=site_root+"/index.php?con="+adminpath+"&act=citymodify";
		$.get(url,{},
		function(data){
			$('#dialog').html(data);
		});
		$('#blurdiv').show();
		$('#blurdiv').height($(document).height());
		$('#dialog').dialog('open');
		$('#dialog').dialog({
			title:'添加城市',
			width: 500,
			height:250,
			buttons: {},
			close:function(){$('#blurdiv').hide();$('#dialog').html('');}
		});
	}

	function modifycity(id)
	{
		url="index.php?con="+adminpath+"&act=citymodify&updateid="+id;
		$.get(url,{},
		function(data){
			$('#dialog').html(data);
		});
		$('#blurdiv').show();
		$('#blurdiv').height($(document).height());
		$('#dialog').dialog('open');
		$('#dialog').dialog({
			title:'修改城市',
			width: 400,
			height:250,
			buttons: {},
			close:function(){$('#blurdiv').hide();$('#dialog').html('');}
		});
	}
	function parseMyCityData(data)
	{
		var objdata=data;
		if(objdata.dotype=='update')
		{
			$('#sortorder-'+objdata.id).html(objdata.sortorder);
			$('#cityname-'+objdata.id).html(objdata.cityname);
			$('#pinyin-'+objdata.id).html(objdata.pinyin);
			$('#isshow-'+objdata.id).html((objdata.isshow=='1'?'是':'否'));
			Dialog_close();
		}
		else
		{
			$('#city0').append('<TR class="tr1" id="city'+objdata.id+'"> <TD align="center"><INPUT TYPE="checkbox" class="cityid" NAME="cid[]" value="'+objdata.id+'"></TD><TD style="text-align:center;"  id="cityname-'+objdata.id+'" >'+objdata.cityname+'</TD><TD style="text-align:center;"   id="pinyin-'+objdata.id+'" >'+objdata.pinyin+'</TD><TD id="sortorder-'+objdata.id+'" style="text-align:center;" >'+objdata.sortorder+'</TD><TD  id="isshow-'+objdata.id+'" style="text-align:center;">'+(objdata.isshow=='1'?'是':'否')+'</TD><td align="center"><A href="javascript:modifycity('+objdata.id+');">修改</A>&nbsp;&nbsp;<A HREF="javascript:deleteVal(\'city\',\''+objdata.id+'\',\'city'+objdata.id+'\',\'cityid\')">删除</A></td></TR>');
			Dialog_close();
		}
	}

	function city2city()
	{

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

		if(boo)
		{

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

			});

		}
	}
	//-->
	</SCRIPT>
<form method="post" action="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=citylist"  name="searchform">
		<div class="subnav">
			<div class="content-menu ib-a blue line-x">
			<a href="javascript:addcity();" class="add fb"><em>添加城市</em></a>
			<a href="javascript:city2city();" class="add fb"><em>商圈城市同步</em></a>
		</div>
        <div class="table-list">
            <TABLE cellpadding="1" cellspacing="1" style="width:100%;">
                <thead>
                    <TR>
                        <TH></TH>
                        <TH>城市名称</TH>
                        <TH>城市拼音</TH>
						<TH>显示顺序</TH>
                        <TH>前台显示</TH>
                        <TH>操作</TH>
                    </TR>
                </thead>
                <tbody id="city0">
                    <?php foreach ($cityinfo['data'] as $key => $val) { ?>
                        <TR class="tr<?php echo $key % 2; ?>" id="city<?php echo $val['cityid']; ?>">
                            <TD align="center">
                               <INPUT TYPE="checkbox" class="cityid" NAME="cid[]" value="<?php echo $val['cityid'];?>">
                            </TD>
                            <TD align="center" id="cityname-<?php echo $val['cityid']; ?>">
                                <?php echo $val['cityname']; ?>
                            </TD>
                            <TD align="center" id="pinyin-<?php echo $val['cityid']; ?>">
                                <?php echo $val['pinyin']; ?>
                            </TD>
                             <TD id="sortorder-<?php echo $val['cityid'];?>" style="text-align:center;">
                               <?php echo $val['sortorder']; ?>
                            </TD>
                            <TD  align="center" id="isshow-<?php echo $val['cityid']; ?>" >
                                    <?php echo $val['isshow'] ? '是' : '否'; ?>
                            </TD>

                            <TD align="center">
								<A HREF="javascript:modifycity('<?php echo $val['cityid'];?>');">修改</A>
                                <A HREF="javascript:deleteVal('city','<?php echo $val['cityid']; ?>','city<?php echo $val['cityid']; ?>','cityid')">删除</A>
                            </TD>
                        </TR>
                    <?php } ?>
                </tbody>
            </TABLE>
        </div>
        <div class="pages" style="padding:10px;text-align:left"><?php echo $cityinfo['pageinfo']; ?></div>
		<div class="btn">
&nbsp;&nbsp;&nbsp;&nbsp;<INPUT TYPE="checkbox" NAME="" id="checkall" onclick="checkedall()">&nbsp;&nbsp;<input type="submit" class="normal_button" value="批量删除" onclick="return confirm('确认删除？');" name="confirmbutton"/></div>
</form>

<script>

function checkedall()
{
	$(".cityid").attr("checked",$('#checkall').attr('checked'));
}

</script>
<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>
