<?php include $this->admin_tpl('meta', 'admin');?>
<title>微信用户管理 - YzmCMS内容管理系统</title>
</head>
<body>
<nav class="breadcrumb"><i class="yzm-iconfont yzm-iconai-home"></i> 首页 <span class="c-gray en">&gt;</span> 微信管理 <span class="c-gray en">&gt;</span> 微信用户 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="yzm-iconfont yzm-iconshuaxin"></i></a></nav>
<div class="page-container">
	<div> 
    <form action="<?php echo U('search');?>" method="get" id="search">
	 <input type="hidden" value="<?php echo ROUTE_M;?>" name="m">
	 <input type="hidden" value="<?php echo ROUTE_C;?>" name="c">
	 <input type="hidden" value="search" name="a">
     关注时间：<input type="text" class="input-text laydate-icon" style="width:170px;height:30px;" id="start" name="start" <?php if(isset($_GET['start']) && $_GET['start'] != '') echo 'value="'.$_GET['start'].'"'; ?>>
     至 <input type="text" class="input-text laydate-icon" style="width:170px;height:30px;" id="end" name="end" value="<?php if(isset($_GET['end']) &&  $_GET['end'] != '') echo $_GET['end']; else echo date('Y-m-d H:i:s'); ?>">
     <span class="select-box inline">
		<select name="status" class="select">
			<option value="99">状态</option>
			<option value="1" <?php if(isset($_GET['status']) && $_GET['status']=='1'){?> selected <?php }?>>已关注</option>
			<option value="0" <?php if(isset($_GET['status']) && $_GET['status']=='0'){?> selected <?php }?>>未关注</option>
		</select>
	</span>
    <span class="select-box inline">
		<select name="groupid" class="select">
			<option value="99">微信分组</option>
			<?php 
				foreach($wechat_group as $val){
					$str = $val['id']==$groupid ? 'selected' : '';
					echo '<option value="'.$val['id'].'" '.$str.'>'.$val['name'].'</option>';
				}
			?>
		</select>
	</span>
	<span class="select-box inline">
		<select name="sex" class="select">
			<option value="99">性别</option>
			<option value="0" <?php if(isset($_GET['sex']) && $_GET['sex']=='0'){?> selected <?php }?>>未知</option>
			<option value="1" <?php if(isset($_GET['sex']) && $_GET['sex']=='1'){?> selected <?php }?>>男</option>
			<option value="2" <?php if(isset($_GET['sex']) && $_GET['sex']=='2'){?> selected <?php }?>>女</option>
		</select>
	</span>
    <span class="select-box inline">
		<select name="type" class="select">
		<option <?php if(isset($_GET['type']) && $_GET['type']=='1'){?> selected <?php }?> value="1">OpenID</option>
		<option <?php if(isset($_GET['type']) && $_GET['type']=='2'){?> selected <?php }?> value="2">来源场景</option>	
		<option <?php if(isset($_GET['type']) && $_GET['type']=='3'){?> selected <?php }?> value="3">微信昵称</option>	
		<option <?php if(isset($_GET['type']) && $_GET['type']=='4'){?> selected <?php }?> value="4">用户备注</option>	
		</select>
	</span>
     <input type="text" name="searinfo" class="input-text" style="width:170px" value="<?php if(isset($_GET['searinfo'])) echo $_GET['searinfo'];?>"><button name="dosubmit" class="btn btn-success btn-search" type="submit" value="1"><i class="yzm-iconfont yzm-iconsousuo"></i> 搜索</button>
     <a href="<?php echo U('init');?>" class="btn btn-primary radius"><i class="yzm-iconfont yzm-iconshuaxin"></i> 重置</a>
	 </form>
	</div>
	<form method="post" action="<?php echo U('move_user_group');?>" id="myform">
	<div class="cl mt-15 tb-top"> <span class="l"><a href="javascript:;" onclick="member_remove()" class="btn btn-primary radius"><i class="yzm-iconfont yzm-iconyidong"></i> 移动分组</a> <a href="javascript:;" onclick="synchronization()" class="btn btn-success radius"><i class="yzm-iconfont yzm-iconshuaxin"></i> 同步微信服务器用户</a></span></div>
	<table class="table table-border table-bg table-hover yzm-table-sort">
		<thead>
			<tr class="text-c">
				<th width="25"><input type="checkbox"></th>
				<th>OpenID<?php echo field_order('openid');?></th>
				<th>微信昵称</th>
				<th>用户备注</th>
				<th>分组名称<?php echo field_order('groupid');?></th>
				<th>性别<?php echo field_order('sex');?></th>
				<th>地区</th>
				<th>状态<?php echo field_order('subscribe');?></th>
				<th width="125">关注时间<?php echo field_order('subscribe_time');?></th>		
				<th width="60">来源场景</th>		
				<th width="150">管理操作</th>
			</tr>
		</thead>
		<tbody>
			<?php 
			   foreach($data as $val){
			 ?>
			<tr class="text-c">
				<td><input type="checkbox" class="checkbox" value="<?php echo $val['openid']?>" name="ids[<?php echo $val['wechatid']?>]"></td>
				<td><?php echo $val['openid'];?></td>
				<?php if($val['nickname']){ ?>
				<td class="text-l">
					<img src="<?php echo $val['headimgurl'];?>" height="25" class="radius"> <?php echo $val['nickname'];?>
				</td>
				<?php }else{ ?>
				<td>/</td>
				<?php } ?>
				<td><?php echo $val['remark'] ? $val['remark'] : '/';?></td>
				<td><?php echo $this->get_groupname($wechat_group, $val['groupid']);?></td>
				<td><?php echo $val['sex']==2 ? '女' : ($val['sex'] ? '男' : '未知');?></td>
				<td><?php echo $val['province'];?>-<?php echo $val['city'];?></td>
				<td><?php echo $val['subscribe'] ? '已关注' : '<span class="c-red">未关注</span>';?></td>
				<td><?php echo date("Y-m-d H:i:s",$val['subscribe_time'])?></td>
				<td><?php echo $val['scan'] ? $val['scan'] : '无';?></td>
				<td class="td-manage"><a title="修改备注" href="javascript:;" onclick="yzm_open('修改备注','<?php echo U('set_userremark',array('id'=>$val['wechatid']));?>',450,270)" class="btn-mini btn-success ml-5" style="text-decoration:none">修改备注</a> <a title="发送消息" href="<?php echo U('message/send_message',array('openid'=>$val['openid']));?>" class="btn-mini btn-primary ml-5" style="text-decoration:none">发送消息</a></td>
			</tr>			  
			<?php 
			   }		 
			?>	
		</tbody>
	</table>
	<?php if(!$data){ ?><div class="yzm_no_data"><i class="yzm-iconfont yzm-iconshuoming"></i> 暂无数据</div><?php } ?>
	</form>
  <div id="page"><span class="page_left">共<?php echo $total?>条记录，共<?php echo $page->total()?>页，当前显示第<?php echo $page->getpage()?>页</span>
  <span class="page_right"><?php echo $page->getfull();?></span></div>
</div>

<?php include $this->admin_tpl('footer', 'admin');?>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/laydate/1.1/laydate.js"></script>
<script type="text/javascript">

	function member_remove(){
		if ($(".checkbox:checked").length<1){
		   layer.alert('请选择要操作的内容！');
		   return false;
		}	
		document.getElementById('myform').action='<?php echo U('move_user_group');?>';
		document.getElementById('myform').submit();

	}

	function synchronization(){
		layer.confirm('第一次同步数据后，本地数据会自动和微信同步（已认证的公众号），<br>不建议频繁使用本功能！', {title:"操作提示"}, function(index){
			yzm_open('同步微信服务器用户','<?php echo U('synchronization');?>',600,300);
		});
	}

	var start = {elem:'#start',format:'YYYY-MM-DD hh:mm:ss',min:'1999-01-01',max:'2099-01-01',istime:true,istoday:false,choose:function(datas){end.min = datas;end.start = datas}
	};
	var end = {elem:'#end',format:'YYYY-MM-DD hh:mm:ss',min:'1999-01-01',max:'2099-01-01',istime:true,istoday:false,choose:function(datas){start.max = datas;}};
	laydate(start);
	laydate(end);

</script>
</body>
</html>