<?php /* Smarty version 2.6.17, created on 2018-05-26 11:58:06
         compiled from admin/backUser/user_list.html */ ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "./admin/header.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "./admin/left.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "./admin/nav.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>

<style>
.set-nav {
	margin: 0 auto;
}
.set-nav-hr {
	background-color: #ddd;
    height: 1px;
    position: relative;
}
.form-group label {
	font-weight: 600;
}
.checkbox-inline, .radio-inline {
	font-weight: 400!important;
}
.rowlabel {
	font-weight: 300!important;
}
.music_play_hide {
	display:none;
}
</style>

<?php if (! $this->_tpl_vars['platfrom']): ?>
请先创建一个列表。进入<a href="<?php echo $this->_tpl_vars['web_cfg']['domain']; ?>
/?c=Admin_Platform_index&a=PageList">平台列表</a>
<?php else: ?>
<div class="panel panel-default col-md-7">
	<div class="panel-body">
		<table class="table">
			<thead>
				<tr>
					<th>UID</th>
					<th>用户名</th>
					<th>权限组</th>
					<th>权限设置</th>
					<th>平台列表</th>
					<th>密码修改</th>
					<th>删除</th>
				</tr>
			</thead>
			<tbody>
				<?php if (! $this->_tpl_vars['users']): ?>
				<tr><td colspan="4" align="center">暂无用户信息</td></tr>
				<?php endif; ?>
				<?php $_from = $this->_tpl_vars['users']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['user']):
?>
				<tr>
					<td><?php echo $this->_tpl_vars['user']['uid']; ?>
</td>
					<td><?php echo $this->_tpl_vars['user']['name']; ?>
</td>
					<td><?php if ($this->_tpl_vars['user']['permission'] == 'admin'): ?> <span class="text-primary">管理员</span> <?php else: ?> 普通帐号 <?php endif; ?> </td>
					<td><a href="<?php echo $this->_tpl_vars['web_cfg']['domain']; ?>
/?c=admin_backUser&a=setPermission&uid=<?php echo $this->_tpl_vars['user']['uid']; ?>
">权限设置</a></td>
					<td><a href="<?php echo $this->_tpl_vars['web_cfg']['domain']; ?>
/?c=admin_backUser&a=SetPlatfrom&uid=<?php echo $this->_tpl_vars['user']['uid']; ?>
">平台列表</a>
					<td><a href="<?php echo $this->_tpl_vars['web_cfg']['domain']; ?>
/?c=Admin_BackUser&a=MP&uid=<?php echo $this->_tpl_vars['user']['uid']; ?>
">密码修改</a></td>
					<td><a href="javascript:;" class="deleteUser" data-uid="<?php echo $this->_tpl_vars['user']['uid']; ?>
">删除</a></td>
				</tr>
				<?php endforeach; endif; unset($_from); ?>
			</tbody>
		</table>
	</div>
</div>

<form id="create_user_form" action="<?php echo $this->_tpl_vars['web_cfg']['domain']; ?>
/?c=Admin_BackUser&a=CreateUser" method="post">
<div class="col-md-5" style="padding-left: 30px;">
	<?php if ($this->_tpl_vars['errMsg']['ok']): ?>
	<div class="tip_message_success">创建成功</div>
	<?php endif; ?>
	<?php if (! $this->_tpl_vars['errMsg']['ok'] && $this->_tpl_vars['errMsg']['msg']): ?>
	<div class="tip_message_fail">创建失败,原因:<?php echo $this->_tpl_vars['errMsg']['msg']; ?>
</div>
	<?php endif; ?>
	
	<?php if (! $this->_tpl_vars['errMsg'] || $this->_tpl_vars['errMsg']['msg']): ?>
	<div class="form-group">
		<label class="control-label">创建新帐号</label>
	</div>
	<div class="form-group">
		<label class="control-label rowlabel">用户名</label>
		<input name="name" type="text" class="form-control" value="<?php echo $this->_tpl_vars['submitData']['name']; ?>
">
	</div>
	<div class="form-group">
		<label class="control-label rowlabel">密码</label>
		<input name="password" type="password" class="form-control" value="<?php echo $this->_tpl_vars['submitData']['password']; ?>
">
	</div>
	<div class="form-group">
		<label><input name="auto_generate" type="checkbox" value="1" <?php if ($this->_tpl_vars['submitData']['auto_generate']): ?>checked<?php endif; ?>> 自动生成密码</label>
	</div>
	<div class="form-group">
		<label class="control-label rowlabel">平台列表</label>
		<div>
		<?php $_from = $this->_tpl_vars['platfrom']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['item']):
?>
		<label class="checkbox-inline"><input name="platfrom[]" type="checkbox" value="<?php echo $this->_tpl_vars['item']['id']; ?>
" > <?php echo $this->_tpl_vars['item']['name']; ?>
</label>
		<?php endforeach; endif; unset($_from); ?>
		</div>
	</div>
	<div class="form-group">
		<label class="control-label rowlabel">邮箱</label>
		<input name="email" type="text" class="form-control" value="<?php echo $this->_tpl_vars['submitData']['email']; ?>
">
	</div>
	<div class="form-group">
		<label class="control-label rowlabel">部门</label>
		<input name="division" type="text" class="form-control" value="<?php echo $this->_tpl_vars['submitData']['division']; ?>
">
	</div>
	
	<div>
		<button id="add_platform_btn" class="button button-primary button-small">创建</button>
	</div>
	<?php endif; ?>

	<?php if ($this->_tpl_vars['errMsg']['ok']): ?>
	<div class="form-group">
		<label class="control-label rowlabel">用户名:</label>
		<?php echo $this->_tpl_vars['new_user']['name']; ?>

	</div>
	<div class="form-group">
		<label class="control-label rowlabel">密码:</label>
		<?php echo $this->_tpl_vars['new_user']['password']; ?>

	</div>
	<div class="form-group">
		<label class="control-label rowlabel">平台列表:</label>
		<?php $_from = $this->_tpl_vars['submitData']['platfrom']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['platfromId']):
?>
		<?php echo $this->_tpl_vars['platfrom'][$this->_tpl_vars['platfromId']]['name']; ?>
&nbsp;
		<?php endforeach; endif; unset($_from); ?>
	</div>
	<div class="form-group">
		<label class="control-label rowlabel">邮箱:</label>
		<?php echo $this->_tpl_vars['new_user']['email']; ?>

	</div>
	<div class="form-group">
		<label class="control-label rowlabel">部门:</label>
		<?php echo $this->_tpl_vars['new_user']['division']; ?>

	</div>
	<?php endif; ?>
</div>
</form>
<?php endif; ?>
<script>
KISSY.use('node, io', function (S, Node, IO) {
	var $ = S.all;

	$('#add_platform_btn').on('click', function () {
		var name = $('input[name=name]').val();
		if (S.trim(name) == '') {
		  showError('姓名不能为空');
		  return false;
		}
	});
  
	function showError($msg) {
		alert($msg);
	}
	
	$(".deleteUser").on('click', function () {
		var uid = $(this).attr('data-uid');
		if (!uid) {
			alert('无效uid');
			return false;
		}
		
		if (!confirm('确定要删除帐号?')) {
			return false;
		}
		
		new IO({
			type: "post"
			, url: VG.conf.root_domain + '/?c=admin_backUser&a=DeleteUser'
			, data: {'uid':uid}
			, success: function (data) {
				if (data.ok) { //ok
					alert('操作成功');
					location.reload();
				} else {
					alert('操作失败,原因:'+data.msg);
				}
				return false;
			}
			, error: function (NULL, textStatus) {
				alert("请求服务器失败,原因:"+textStatus);
			}
			, dataType: "json"
		});
	});
});
</script>

<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "./admin/bottom.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>