<?php include $this->admin_tpl('meta', 'admin');?>
<title>微信用户管理 - YzmCMS内容管理系统</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</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="Hui-iconfont">&#xe68f;</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:110px;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:110px;height:30px;" id="end" name="end" value="<?php if(isset($_GET['end']) &&  $_GET['end'] != '') echo $_GET['end']; else echo date('Y-m-d'); ?>">
     <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="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>	
		</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" type="submit" value="1"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
	 </form>
	</div>
	<form method="post" action="<?php echo U('move_user_group');?>" id="myform">
	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="member_remove()" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe67a;</i> 移动分组</a> <a href="javascript:;" onclick="synchronization()" class="btn btn-success radius"><i class="Hui-iconfont">&#xe68f;</i> 同步微信服务器用户</a></span></div>
	<table class="table table-border table-bordered 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>
				<td><img src="<?php echo $val['headimgurl'];?>" height="25" class="radius"> <?php echo $val['nickname'];?></td>
				<td><?php echo $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']));?>',600,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-secondary ml-5" style="text-decoration:none">发送消息</a></td>
			</tr>			  
			<?php 
			   }		 
			?>	
		</tbody>
	</table>
	</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('第一次同步数据后，本地数据会自动和微信同步（已认证的公众号），不建议频繁使用！',function(index){
		yzm_open('同步微信服务器用户','<?php echo U('synchronization');?>',600,300);
	});
}

var start = {
	elem: '#start',
	format: 'YYYY-MM-DD',
	min: '1999-01-01', //设定最小日期
	max: '2099-01-01', //最大日期
	istime: false,
	istoday: false,
	choose: function(datas){
		 end.min = datas; //开始日选好后，重置结束日的最小日期
		 end.start = datas //将结束日的初始值设定为开始日
	}
};

var end = {
	elem: '#end',
	format: 'YYYY-MM-DD',
	min: '1999-01-01',
	max: '2099-01-01',
	istime: false,
	istoday: false,
	choose: function(datas){
		start.max = datas; //结束日选好后，充值开始日的最大日期
	}
};
laydate(start);
laydate(end);

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