<?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 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=groups";
		$.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>



<div class="subnav">
    <div class="content-menu ib-a blue line-x">
        <A HREF="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=groupsmodify"  class="add fb"><em>添加团购</em></A>
	</div>
</div>
<form method="post" action="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=listgroup<?php  echo $sortform; ?>"  name="searchform">
<table width="100%" cellspacing="0" class="search-form">
    <tbody>
		<tr>
		<td>
		<div class="explain-col">
		关键字：<INPUT TYPE="text" NAME="keyword" class="input-text" value="<?php  echo $_REQUEST['keyword']; ?>" > 
		更新时间：<INPUT TYPE="text" NAME="starttime" class="input-text" value="<?php  echo $_REQUEST['starttime'];  ?>" onfocus="HS_setDate(this);"  size="10" >-<INPUT TYPE="text" NAME="endtime" class="input-text" value="<?php  echo $_REQUEST['endtime']; ?>" onfocus="HS_setDate(this);"  size="10" > 
		分类：<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&table=groups','_self','');">  
		<input style="float:right;" type="button" value="网站权重排序" class="button" onclick="window.open('index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=temporder','_self','');">
			</div>
		</td>
		</tr>
    </tbody>
</table>
</form>
<form action="index.php?con=admin&act=multigroup" method="post">
<input type="hidden" name="ext[keyword]" value="<?php  echo $_REQUEST['keyword']; ?>">
<input type="hidden" name="ext[cate]" value="<?php  echo $_REQUEST['cate']; ?>">
<input type="hidden" name="ext[city]" value="<?php  echo $_REQUEST['city']; ?>">
<input type="hidden" name="ext[site]" value="<?php  echo $_REQUEST['site']; ?>">
<input type="hidden" name="ext[timecheck]" value="<?php  echo $_REQUEST['timecheck']; ?>">
<input type="hidden" name="ext[starttime]" value="<?php  echo $_REQUEST['starttime']; ?>">
<input type="hidden" name="ext[endtime]" value="<?php  echo $_REQUEST['endtime']; ?>">
<input type="hidden" name="ext[page]" value="<?php  echo $_REQUEST['page']; ?>">
<input type="hidden" name="commit" value="1"/>
<div class="table-list">
<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=listgroup&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=listgroup&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=listgroup&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=listgroup&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=listgroup&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=listgroup&o_recommend=ASC<?php echo $sortlink;  ?>" >推荐↓</a> <?php }  ?>	
	</TH>
	<TH>
		<?php if( empty($_REQUEST['o_ispassed']) ){ ?>   <a href="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=listgroup&o_ispassed=ASC<?php echo $sortlink;  ?>" >审核通过</a> <?php }  ?>   
		<?php if($_REQUEST['o_ispassed'] == "ASC"){ ?>   <a href="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=listgroup&o_ispassed=DESC<?php echo $sortlink;  ?>" >审核通过↑</a> <?php }  ?>
		<?php if($_REQUEST['o_ispassed'] == "DESC"){ ?>  <a href="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=listgroup&o_ispassed=ASC<?php echo $sortlink;  ?>" >审核通过↓</a> <?php }  ?>	
	</TH>
	<TH>未过期</TH>
	<TH>
		<?php if( empty($_REQUEST['o_sortorder']) ){ ?>   <a href="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=listgroup&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=listgroup&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=listgroup&o_sortorder=ASC<?php echo $sortlink;  ?>" >排序↓</a> <?php }  ?>
	</TH>
	<TH>操作</TH>
</TR>
</thead>
<tbody>
<?php foreach($groups_info['data'] as $key=>$val){?>
<TR class="tr<?php echo $key%2;?>" id="groups<?php echo $val['id'];?>">
	<td> <input type="checkbox" value="<?php echo $val['id'];?>"  name="gid[]" 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='#ff6600';" 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;"><?php  echo $val['cityname'];  ?> 
	</TD>

	<!--	
	<TD style="text-align:center;">
	<div id="cityid-<?php echo $val['id'];?>" ><?php echo $val['cityname'];?></div>
	</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('groups','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="ispassed-<?php echo $val['id'];?>" onmouseover="this.style.backgroundColor='#ff0000';" onmouseout="this.style.backgroundColor='';" onclick="updateVal('groups','ispassedinput-<?php echo $val['id'];?>','id','',['是','否']);">
	<?php echo $val['ispassed']?'是':'否';?>
	</div>
	<INPUT TYPE="text" class="hideinput" id="ispassedinput-<?php echo $val['id'];?>" value="<?php echo intval(!$val['ispassed']);?>" title='nochange'>
	</td>

	<TD  style="text-align:center;"><?php if($val['lasttime'] > time() ) { echo "未过期";  }else{ echo "已过期"; }   ?></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('groups',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=groupsmodify&updateid=<?php echo $val['id'];   ?>">修改</A>
	<A HREF="javascript:deleteVal('groups','<?php echo $val['id'];?>','groups<?php echo $val['id'];?>','id')">删除</A>
	</TD>
</TR>
<?php }?>
</tbody>
</TABLE>
</div>
<div class="pages" style="padding:10px;text-align:center;"><?php echo $groups_info['pageinfo'];?></div>

<div class="btn">
<INPUT TYPE="checkbox" NAME="" id="checkall" onclick="checkedall()">&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" class="normal_button" value="批量删除" onclick="return confirm('确认删除？');" name="confirmbutton"/>
<input type="submit" class="normal_button" value="删除过期" onclick="return confirm('确认删除？');" name="confirmbutton"/>
<select name="ispassed">
<option value="1">已审核</option>
<option value="0">未审核</option>
</select>
<input type="submit" class="normal_button" value="批量审核" name="confirmbutton"/>
<input type="submit" class="normal_button" value="全部审核" name="confirmbutton"/>
<input type="submit" class="normal_button" value="全部取消审核" name="confirmbutton"/>
<SELECT NAME="recommend">
	<OPTION VALUE="1" SELECTED>推荐
	<OPTION VALUE="0">不推荐
</SELECT>
<input type="submit" class="normal_button" value="批量推荐" name="confirmbutton"/>
<input type="submit" class="normal_button" value="全部推荐" name="confirmbutton"/>
<select name="cate">
<?php foreach($catelist_info as $k=>$v){?>
<option value="<?php echo $v['id'];?>"> <?php if($v['parentid'] > 0){ echo "--"; }  ?>  <?php echo $v['catename'];?></option>
<?php }?> 
</select>

<input type="submit" class="normal_button" value="批量移动" name="confirmbutton"/>
<select name="cuscitys">
<?php foreach($GLOBALS['city'] as $k=>$v){?>
<option value="<?php echo $k;?>-<?php echo $v['cityname'];?>"><?php echo $v['cityname'];?></option>
<?php }?> 
</select>

<input type="submit" class="normal_button" value="批量移动城市" name="confirmbutton"/>
</div>
</form>
<script>

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

</script>


</body>
</html>
