<?php defined('APP_NAME') || exit('Access Denied'); 
?><!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="Author" content="QQ:401421567" />
<link rel="stylesheet" href="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/css/bootstrap.min.css" />
<link rel="stylesheet" href="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/css/me.css" />
<script>var admin_static = "<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>" , cookie_pre = "<?php echo(isset($C['cookie_pre']) ? $C['cookie_pre'] : ''); ?>",_vip_key = "<?php echo(isset($vip['_key']) ? $vip['_key'] : ''); ?>",api_url = "<?php echo(isset($vip['api_url']) ? $vip['api_url'] : ''); ?>",_control = "<?php echo(isset($_GET['control']) ? $_GET['control'] : ''); ?>",_action = "<?php echo(isset($_GET['action']) ? $_GET['action'] : ''); ?>",version = '<?php echo(isset($vip['version']) ? $vip['version'] : ''); ?>',release = '<?php echo(isset($vip['release']) ? $vip['release'] : ''); ?>',vip_key = _vip_key;</script>
<script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/js/jquery.js"></script>
<script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/js/bootstrap.min.js"></script>
<script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>js/layer/layer.js"></script>
<script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/js/global.js"></script>
<!--[if lt IE 9]>
  <script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/js/html5.js"></script>
  <script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/js/respond.min.js"></script>
<![endif]-->
<script type="text/javascript">
	var webdir = '<?php echo(isset($pp['webdir']) ? $pp['webdir'] : ''); ?>';
	layer.config({
		extend: 'extend/layer.ext.js',
		shift: -1
	});
	var pKey = "<?php echo(isset($_pkey) ? $_pkey : ''); ?>", urlKey = "<?php echo(isset($_ukey) ? $_ukey : ''); ?>", place = "<?php echo(isset($_place) ? $_place : ''); ?>";
	//全选与全不选
	function selectall(name,obj) {
		if ($(obj).is(':checked')) {
			$("input[name='"+name+"']").each(function() {
				$(this).prop('checked', true);
			});
		} else {
			$("input[name='"+name+"']").each(function() {
				$(this).prop('checked', false);
			});
		}
	}
</script>
<title><?php echo(isset($_title) ? $_title : ''); ?></title>
</head>
<body>
<div class="container-fluid">
	<div class="panel panel-default">
		<div class="panel-heading">
			<div class="row">
				<div class="col-xs-3">
				<form class="search" method="post" action="index.php?u=user-index">
					<div class="input-group">
						<input type="text" name="username" value="<?php echo(isset($condition['username']) ? $condition['username'] : ''); ?>" class="form-control">
						<span class="input-group-btn"><button class="btn btn-default" type="submit">搜索</button></span>
					</div>
				</form>
				</div>
				<div class="col-xs-6 text-right">
				
				</div>
				<div class="col-xs-2 text-right">
					<select name="groupid" id="groupid" class="form-control" autocomplete="off">
						<option value="">所有会员</option>
					<?php if(isset($user_group_list) && is_array($user_group_list)) { foreach($user_group_list as &$v) { ?>
						<option value="<?php echo(isset($v['groupid']) ? $v['groupid'] : ''); ?>" <?php if ($v['groupid']==$condition['groupid']) { ?>selected<?php } ?>><?php echo(isset($v['groupname']) ? $v['groupname'] : ''); ?></option>
					<?php }} ?>
					</select>
				</div>
				<div class="col-xs-1 text-right">
					<a id="add" class="btn btn-info pull-right" href="javascript:;"><span class="glyphicon glyphicon-plus"></span> 增加</a>
				</div>
			</div>
		</div>

			<?php if (empty($list)) { ?>
			<div class="panel-body"><div class="alert alert-warning sky"><i class="glyphicon glyphicon-warning-sign"></i> <b>暂无内容</b></div></div>
			<?php }else{ ?>
			<table class="table table-bordered table-hover">
				<tr>
					<th class="text-center">UID</th>
					<th class="text-center">用户名</th>
					<th class="text-center">现金</th>
					<th class="text-center">订单</th>
					<th class="text-center">邮箱</th>
					<th class="text-center">手机</th>
					<th class="text-center">所属组</th>
					<th class="text-center">状态</th>
					<th class="text-center">注册时间</th>
					<th class="text-center">注册IP</th>
					<th class="text-center"><a href="index.php?u=user-index<?php if (!empty($_order)) { }else{ ?>-order-1<?php } ?>">最后登录时间</a></th>
					<th class="text-center">最后登录IP</th>
					<th width="180" class="text-center">操作</th>
				</tr>
				<?php if(isset($list) && is_array($list)) { foreach($list as &$v) { ?>
				<tr>
					<td class="text-center"><?php echo(isset($v['uid']) ? $v['uid'] : ''); ?></td>
					<td><?php echo(isset($v['username']) ? $v['username'] : ''); ?></td>
					<td id="money_<?php echo(isset($v['uid']) ? $v['uid'] : ''); ?>" class="text-right"><?php if ($v['money']>0) { echo(isset($v['money']) ? $v['money'] : ''); } ?></td>
					<td class="text-center"><b><?php if (!empty($v['ordernum'])) { ?><a href="javascript:booklist(<?php echo(isset($v['uid']) ? $v['uid'] : ''); ?>,1);"><?php echo(isset($v['ordernum']) ? $v['ordernum'] : ''); ?></a><?php } ?></b></td>
					<td><?php if ($v['email_staus']) { ?>√ <?php } echo(isset($v['email']) ? $v['email'] : ''); ?></td>
					<td><?php if ($v['mobile_staus']) { ?>√ <?php } echo(isset($v['mobile']) ? $v['mobile'] : ''); ?></td>
					<td><?php echo(isset($v['groupname']) ? $v['groupname'] : ''); ?></td>
					<td class="text-center"><?php echo(isset($v['status']) ? $v['status'] : ''); ?></td>
					<td class="text-center"><?php echo(isset($v['regdate']) ? $v['regdate'] : ''); ?></td>
					<td class="text-center"><a href="http://www.baidu.com/s?wd=<?php echo(isset($v['regip']) ? $v['regip'] : ''); ?>" target="_blank"><?php echo(isset($v['regip']) ? $v['regip'] : ''); ?></a></td>
					<td class="text-center"><?php if ($v['logindate']>0) { echo(isset($v['logindate']) ? $v['logindate'] : ''); } ?></td>
					<td class="text-center"><a href="http://www.baidu.com/s?wd=<?php echo(isset($v['loginip']) ? $v['loginip'] : ''); ?>" target="_blank"><?php if ($v['loginip']) { echo(isset($v['loginip']) ? $v['loginip'] : ''); } ?></a></td>
					<td class="text-center">
						<?php if ($v['groupid']>1) { ?>
						<a class="but3" href="javascript:;" onclick="deposit(<?php echo(isset($v['uid']) ? $v['uid'] : ''); ?>);">充值</a>
						<a class="but3" href="javascript:edit(<?php echo(isset($v['uid']) ? $v['uid'] : ''); ?>);">编辑</a>
							<?php if ($v['status_num']==2) { ?>
								<a class="but3" href="javascript:set_status(<?php echo(isset($v['uid']) ? $v['uid'] : ''); ?>,1);">解禁</a>
							<?php }else{ ?>
								<a class="text-danger" href="javascript:set_status(<?php echo(isset($v['uid']) ? $v['uid'] : ''); ?>,2);">禁止</a>
							<?php } ?>
						<a class="text-danger" href="javascript:del(<?php echo(isset($v['uid']) ? $v['uid'] : ''); ?>);">删除</a>
						<?php } ?>
					</td>
				</tr>
				<?php }} ?>
			</table>
			<div class="panel-footer text-center"><nav><ul class="pagination"><?php echo(isset($pages) ? $pages : ''); ?></ul></nav></div>
			<?php } ?>
		</div>
	</div>
</div>
<div id="deposit" style="display:none;">
	<table class="table noborder">
	<tr>
		<th class="text-right">原来</th>
		<td><input id="oldmoney" type="text" class="form-control" value="" readonly='readonly' autocomplete="off" /></td>
	</tr>
	<tr>
		<th class="text-red text-right">增加</th>
		<td>
			<div class="input-group">
				<input id="addmoney" type="text" name='add_money' class="form-control" value="" autocomplete="off" />
				<span class="input-group-addon">减少用负号如：<span class="red">-15</span></span>
			</div>
		</td>
	</tr>
	<tr>
		<th class="text-right">结果</th>
		<td><input id="lastmoney" type="text" class="form-control" value="" autocomplete="off" /></td>
	</tr>
	</table>
	<p class='text-info text-center'>直接为用户增加金额，提交前请确认已收到此款项。</p>
	<script type="text/javascript">
	$(document).ready(function(){
		$('#addmoney').on('change',function(){
			lastmoney = $('#oldmoney').val() - 0 + ($(this).val() - 0);
			$('#lastmoney').val(lastmoney);
		})
		$('#lastmoney').on('change',function(){
			addmoney = $(this).val() - 0 - ($('#oldmoney').val() - 0) ;
			$('#addmoney').val(addmoney);
		})
	});
	</script>
</div>
<div id="booklist_dialog" style="display:none;"><div id="tuan_out"></div></div>
<script type="text/javascript">
$("#groupid").change(function(){
	var index = layer.load(0,{shade:0});
	location.href = "index.php?u=user-index-groupid-"+ $(this).val();
});
function booklist(uid,page){
	ppajax.postd("index.php?u=book-get_user-page-"+page, {uid: uid},function(data) {
		if (window.ppEixt) return;
		ppajax.remove();
		load_boolistlog();
		$("#tuan_out").html(data);
	});
}
function load_boolistlog() {
	var H = Math.max(350, document.documentElement.clientHeight - 30) + 'px';
	layer.open({
		type: 1,
		title: ['订单列表', 'font-weight:bold;color:green'],
		area: ['800px', H],
		shadeClose: true,
		scrollbar: false,
		content: $('#booklist_dialog')
	});
}
function deposit(uid){
	oldmoney = $('#money_' + uid).text();
	$('#oldmoney').val(Number(oldmoney));
	var H = Math.max(350, document.documentElement.clientHeight - 30) + 'px';
	layer.open({
		type: 1,
		title: ['充值/用户余额调整', 'font-weight:bold;color:green'],
		area: ['500px', H],
		btn: ['确认保存', '取消'],
		yes: function(index, layero){
			$.ajax({
				url: 'index.php?u=user-change_money',
				type: 'POST',
				data:{'uid':uid,'money':$('#addmoney').val(),'rnum':Math.random()},
				dataType: 'json',
				success: function(res){
					if(res.err==0){
						layer.closeAll();
						$("#money_" + uid).text(Number(oldmoney) + Number($('#addmoney').val()));
					}else{
						layer.msg(res.msg);
					}
				}
			});
			return false;
		},cancel: function(index){
		},
		shadeClose: true,
		scrollbar: false,
		content: $('#deposit')
	});
}
$("#add").click(function(){parent.oneTab("添加用户","user-add","user");});
function edit(uid){parent.oneTab("编辑用户","user-edit-uid-"+uid,"user");}
function del(uid){
	ppajax.confirm("请谨慎操作，如无必要可选择“禁止”用户<br />确定删除吗？将删除用户所有相关数据！", function(){
		ppajax.postd("index.php?u=user-del-ajax-1", {"uid":uid}, function(data){
			ppajax.alert(data);
			if(window.ppdata.err==0) setTimeout(function(){ window.location.reload(); }, 1000);
		});
	});
}
function set_status(uid,status){
	var msg = '确定执行该操作？';
	ppajax.confirm(msg, function(){
		ppajax.postd("index.php?u=user-set_status-ajax-1", {"uid":uid,"status":status}, function(data){
			ppajax.alert(data);
			if(window.ppdata.err==0) setTimeout(function(){ window.location.reload(); }, 1000);
		});
	});
}
</script>
</body>
</html>