<?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>


	function get_all_catelist(id)
	{
		var url ="index.php?con="+adminpath+"&act=get_all_catelist";
		$.getJSON(url,function(data){

				var cate = $("#small_catelist-"+id).val(); 
				var node ="<select id="+id+" onchange='update_catelist("+id+")'>";
					node +="<option value='0' >未分类</option>";;	
				for(i = 0;i<data.length;i++)
				{
					if(cate == data[i]['id'])
					{
						node +="<option value="+data[i]['id']+"  selected >"+data[i]['catename']+"</option>";
					}else{

						node +="<option value="+data[i]['id']+">"+data[i]['catename']+"</option>";	
					}
				}

				node+="<select>";
				$("#select_cate-"+id).html(node);

				$("#small_catelist_catename-"+id).hide();
				$("#select_cate-"+id).show();
        })
	}

	function get_all_cityid(id)
	{
		var url ="index.php?con="+adminpath+"&act=get_all_cityid";
		$.getJSON(url,function(data){

				var cityid = $("#cityid-"+id).val(); 
				var node ="<select id='cityid_"+id+"_city'  onchange='update_cityid("+id+")'>";
		
				for(i = 0;i<data.length;i++)
				{
					if(cityid == data[i]['cityid'])
					{
						node +="<option value="+data[i]['cityid']+"  selected >"+data[i]['cityid']+"-"+data[i]['cityname']+"</option>";
					}else{
						node +="<option value="+data[i]['cityid']+">"+data[i]['cityid']+"-"+data[i]['cityname']+"</option>";	
					}
				}

				node+="<select>";
				$("#select_cityid-"+id).html(node);

				$("#showcityid-"+id).hide();
				$("#select_cityid-"+id).show();
        })
	}
	function update_cityid(id)
	{

		var cityid= $("#cityid_"+id+"_city").val();
		var cityname = $("#cityid_"+id+"_city").find("option:selected").text();

		var url ="index.php?con="+adminpath+"&act=update_cityid&id="+id+"&cityid="+cityid+"&tag=groups";
		$.getJSON(url,function(data){
			
		})

		$("#cityid-"+id).val(cityid);
		$("#showcityid-"+id).html(cityname);


		$("#showcityid-"+id).show();
		$("#select_cityid-"+id).hide();
	}
	function update_catelist(id)
	{

		var cate= $("#"+id).val();
		var catename = $("#"+id).find("option:selected").text();

		var url ="index.php?con="+adminpath+"&act=update_cate&cate="+cate+"&id="+id+"&tag=tempsite";
		$.getJSON(url,function(data){
			
		})


		$("#small_catelist-"+id).val(cate);
		$("#small_catelist_catename-"+id).html(catename);
		$("#small_catelist_catename-"+id).show();
		$("#select_cate-"+id).hide();

	}

</script>

<table width="100%" cellspacing="0" class="search-form">
    <tbody>
		<tr>
		<td>
		<div class="explain-col">
		<form method="post" action="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=listtempsite<?php  echo $sortform; ?>"  name="searchform">
		关键字：<INPUT TYPE="text" NAME="keyword" class="input-text" value="<?php  echo $_REQUEST['keyword']; ?>" > 
		分类：<select name="cate" id="cate"  >
					<option value="-1">请选择</option>
					<option value="0" <?php   if(isset($_REQUEST['cate']) && 0== $_REQUEST['cate']){ echo "selected";  }  ?>>未分类</option>
					<?php  foreach($GLOBALS['cate'] AS $key => $val){  ?>	
					<option value="<?php  echo  $key; ?>" <?php   if($key == $_REQUEST['cate']){ echo "selected";  }  ?>  ><?php  echo  $val['catename']; ?></option>
					<?php  }  ?>
				</select>	
		城市：<select name="city" id="city" >
					<option value="0">请选择</option>
					<?php  foreach($GLOBALS['city'] AS $key => $val){  ?>	
					<option value="<?php  echo  $key;  ?>"   <?php   if($key == $_REQUEST['city']){ echo "selected";  } ?>  ><?php  echo  $key;  ?><?php  echo  $val['cityname']; ?></option>
					<?php  }  ?>
			 </select>	

	团购网站：<select name="site"  id="site" >
					<option value="0">请选择</option>
					<?php  foreach($GLOBALS['site'] AS $key => $val){  ?>	
					<option value="<?php  echo  $key; ?>"  <?php   if($key == $_REQUEST['site']){ echo "selected";  } ?> ><?php echo $val['pinyin'];?><?php  echo  $val['sitename']; ?></option>
					<?php  }  ?>
			  </select>



		所有:<input type="radio"  <?php  if($_REQUEST['timecheck']==1){  echo 'checked="checked" '; } ?> value="1" name="timecheck">
		已过期:<input type="radio" <?php  if($_REQUEST['timecheck']==2){  echo 'checked="checked" '; } ?> value="2" name="timecheck">
		未过期:<input type="radio" <?php  if($_REQUEST['timecheck']==3){  echo 'checked="checked" '; } ?> value="3" name="timecheck">
			
					<input type="submit"  class="button"  value="确定" >

		<input style="float:right;" type="button" value="自动匹配商圈及分类" class="button" onclick="window.open('index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=autocate','_self','');">

		<input style="float:right;" type="button" value="删除重复值" class="button" onclick="window.open('index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=cleanre','_self','');">
		
		</form>
			</div>
		</td>
		</tr>
    </tbody>
</table>

<div class="table-list">
<form method="post" action="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=op"  name="opform">
<TABLE cellpadding="1" cellspacing="1" width="100%">
<thead>
<TR>
    <TH>选择</TH>
	<TH width="500px" >信息标题</TH>
	<TH>网站</TH>
	<TH>信息分类</TH>
	<TH>城市</TH>
	<TH>
		<?php if( empty($_REQUEST['o_updatetime']) ){ ?>   <a href="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=listtempsite&o_updatetime=ASC<?php echo $sortlink;  ?>" >采集时间</a> <?php }  ?>   
		<?php if($_REQUEST['o_updatetime'] == "ASC"){ ?>   <a href="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=listtempsite&o_updatetime=DESC<?php echo $sortlink;  ?>" >采集时间↑</a> <?php }  ?>
		<?php if($_REQUEST['o_updatetime'] == "DESC"){ ?>  <a href="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=listtempsite&o_updatetime=ASC<?php echo $sortlink;  ?>" >采集时间↓</a> <?php }  ?>
	</TH>
	<TH>
		<?php if( empty($_REQUEST['o_recommend']) ){ ?>   <a href="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=listtempsite&o_recommend=ASC<?php echo $sortlink;  ?>" >推荐</a> <?php }  ?>   
		<?php if($_REQUEST['o_recommend'] == "ASC"){ ?>   <a href="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=listtempsite&o_recommend=DESC<?php echo $sortlink;  ?>" >推荐↑</a> <?php }  ?>
		<?php if($_REQUEST['o_recommend'] == "DESC"){ ?>  <a href="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=listtempsite&o_recommend=ASC<?php echo $sortlink;  ?>" >推荐↓</a> <?php }  ?>	
	</TH>
	<TH>
		<?php if( empty($_REQUEST['o_sortorder']) ){ ?>   <a href="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=listtempsite&o_sortorder=ASC<?php echo $sortlink;  ?>" >排序</a> <?php }  ?>   
		<?php if($_REQUEST['o_sortorder'] == "ASC"){ ?>   <a href="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=listtempsite&o_sortorder=DESC<?php echo $sortlink;  ?>" >排序↑</a> <?php }  ?>
		<?php if($_REQUEST['o_sortorder'] == "DESC"){ ?>  <a href="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=listtempsite&o_sortorder=ASC<?php echo $sortlink;  ?>" >排序↓</a> <?php }  ?>
	</TH>
	<TH>操作</TH>
</TR>
</thead>
<tbody>
<?php foreach($tempsite_info['data'] as $key=>$val){?>
<TR class="tr<?php echo $key%2;?>" id="tempsite<?php echo $val['id'];?>">
	<TD style="text-align:center;">
        <input type="checkbox" value="<?php echo $val['id'];?>"  name="tempid[]" class="checkedall">
	</TD>

	<TD style="text-align:left;">
	<div id="subject-<?php echo $val['id'];?>"  title="<?php echo $val['subject'];?>"><?php echo  sysSubStr($val['subject'],40);?></div>
	</TD>

	<TD style="text-align:center;">
	<div id="groupsite-<?php echo $val['id'];?>" ><?php echo $val['groupsite'];?></div>
	</TD>

	<TD style="text-align:center;">
	<div id="small_catelist_catename-<?php echo $val['id'];?>" onmouseover="this.style.backgroundColor='#ff8800';" onmouseout="this.style.backgroundColor='';"  onclick="get_all_catelist(<?php echo $val['id'];?>)"  > <?php  if($val['small_catelist']){  echo  $val['small_catelist_catename'];  }else if($val['big_catelist_catename']){ echo  $val['big_catelist_catename'];  } else{ echo '未分类' ;}?> </div> 
	<div id="select_cate-<?php echo $val['id'];?>"  style="display:none;" ></div>
	<input type="hidden" id="small_catelist-<?php echo $val['id'];?>"  value="<?php  echo $val['small_catelist']; ?>" >
	</TD>

	<TD style="text-align:center;">
	<div id="showcityid-<?php echo $val['id'];?>" onmouseover="this.style.backgroundColor='#ff6600';" onmouseout="this.style.backgroundColor='';"  onclick="get_all_cityid(<?php echo $val['id'];?>)"  > <?php  echo $val['cityname'];  ?> </div> 
	<div id="select_cityid-<?php echo $val['id'];?>"  style="display:none;" ></div>
	<input type="hidden" id="cityid-<?php echo $val['id'];?>"  value="<?php  echo $val['cityid']; ?>" >
	</TD>	

	<TD style="text-align:center;">
	<div id="updatetime-<?php echo $val['id'];?>"  ><?php echo  date("Y-m-d",$val['updatetime']);?></div>
	</TD>	
	
	<td  style="text-align:center;">
	<div id="recommend-<?php echo $val['id'];?>" onmouseover="this.style.backgroundColor='#ff0000';" onmouseout="this.style.backgroundColor='';" onclick="updateVal('tempsite','recommendinput-<?php echo $val['id'];?>','id','',['是','否']);">
	<?php echo $val['recommend']?'是':'否';?>
	</div>
	<INPUT TYPE="text" class="hideinput" id="recommendinput-<?php echo $val['id'];?>" value="<?php echo intval(!$val['recommend']);?>" title='nochange'>
	</td>


	<TD style="text-align:center;">
	<div id="sortorder-<?php echo $val['id'];?>" onmouseover="this.style.backgroundColor='#ff8800';" onmouseout="this.style.backgroundColor='';" onclick="modifyValue('sortorderinput-<?php echo $val['id'];?>');"><?php echo $val['sortorder'];?>
	</div>
	<input class="hideinput" id="sortorderinput-<?php echo $val['id'];?>" ondblclick="confirmValue('tempsite',this.value,'sortorderinput-<?php echo $val['id'];?>','id');">
	</TD>

	<TD style="text-align:center;">
	<A HREF="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=tempsitemodify&updateid=<?php echo $val['id'];   ?>">修改</A>
	<A HREF="javascript:deleteVal('tempsite','<?php echo $val['id'];?>','tempsite<?php echo $val['id'];?>','id')">删除</A>
	</TD>
</TR>
<?php }?>
</tbody>
</TABLE>
</div>
<div class="btn">
全选:
	<input type="checkbox" id="checkall"  onclick="checkedall()">&nbsp;&nbsp;  
	操作:
	<select name="op">
			<option value="pass">批量入库</option>
			<option value="pass_all">全部入库</option>
			<option value="delete">批量删除</option>
			<option value="delete_all">全部删除</option>
	</select>
    &nbsp;&nbsp;
	<input type="submit"  name="sub"  class="button"  value="确定" >
</div>
</form>
<script>

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

</script>



<div class="pages"><?php echo $tempsite_info['pageinfo'];?></div>

</body>
</html>
