190 lines
6.9 KiB
PHTML
190 lines
6.9 KiB
PHTML
<?php
|
|
$this->headTitle($this->config->title->site);
|
|
$this->headTitle('后台管理');
|
|
$this->headTitle()->setSeparator(' - ');
|
|
$this->headLink()->appendStylesheet('/css/admin.css');
|
|
$this->headScript()->appendFile('/static/js/jquery-1.7.2.min.js');
|
|
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
|
|
$this->headLink()->appendStylesheet('/css/colorbox.css');
|
|
$this->breadcrumb('<a href="/">首页</a>');
|
|
$this->breadcrumb('<a href="/admin/">后台首页</a>');
|
|
$this->breadcrumb('<a href="/admin/user">用户管理</a>');
|
|
$this->breadcrumb()->setSeparator(' > ');
|
|
?>
|
|
<div class="row">
|
|
<div class="hidden-sm hidden-xs col-md-2">
|
|
<?= $this->partial('user/left.phtml'); ?>
|
|
</div>
|
|
<?php if ($this->msg or $this->messages) :?>
|
|
<div id="message" class="alert alert-info">
|
|
<?php if ($this->msg) : ?>
|
|
<p><?php echo $this->msg; ?></p>
|
|
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
|
|
<p><?php echo $msg; ?></p>
|
|
<?php endforeach;endif; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<div class="col-md-10 col-sm-12">
|
|
<h4>用户组</h4>
|
|
<hr />
|
|
<div class="form-group">
|
|
<button type="button" class="btn btn-primary" onclick="showaddform()">添加用户组</button>
|
|
<button type="button" class="btn btn-primary" onclick="showuserform()">添加用户到组</button>
|
|
</div><!-- search DIV -->
|
|
<div id="addform" style="margin-bottom:9px;display: none;" class="form-group">
|
|
<form id="groupadd" class="form-inline">
|
|
<label class="control-label" for="name">组名: </label>
|
|
<input type="text" name="name" class="form-control" />
|
|
<input type="hidden" name="ac" value="add"/>
|
|
<i id="checkbtn">
|
|
<input type="button" class="btn" onclick="Submit()" value="添加" />
|
|
</i>
|
|
</form>
|
|
</div>
|
|
<div id="userform" style="margin-bottom:9px; display:none;" class="form-group">
|
|
<form id="userform" class="form-inline">
|
|
<label class="control-label" for="addUserInputUid">用户ID(数字) : </label>
|
|
<input type="text" id="addUserInputUid" name="uid" class="form-control" />
|
|
<label class="control-label" for="addUserInputGid"> 组ID(数字) : </label>
|
|
<input type="text" id="addUserInputGid" name="gid" class="form-control" />
|
|
<input type="hidden" name="ac" value="adduser" />
|
|
<i id="checkbtn_addUser">
|
|
<input type="button" class="btn" onclick="SubmitUser()" value="添加" />
|
|
</i>
|
|
</form>
|
|
</div>
|
|
|
|
<table class="stylized table table-bordered table-striped table-hover">
|
|
<thead>
|
|
<tr>
|
|
<td width='150'>组ID</td>
|
|
<td width='250'>用户组</td>
|
|
<td width='150'>操作</td>
|
|
</tr>
|
|
</thead><!-- table's head -->
|
|
<?php if (count($this->paginator)): ?>
|
|
<?php $autoindex=0;?>
|
|
<?php foreach ($this->paginator as $item): ?>
|
|
<?php $autoindex++;?>
|
|
<tr>
|
|
<td><?= $item['id']?></td>
|
|
<td class="form-inline" id="name_<?= $item['id']?>"><?= $item['name']; ?></td>
|
|
<td>
|
|
<i id="del_chectbtn_<?= $item['id']?>"><a href='javascript:del(<?= $item['id'];?>);' onclick="return confirm('确定将此记录删除?')">删除</a></i>
|
|
<a href="javascript:;" onclick="showinput(<?= $item['id']?>);">编辑</a>
|
|
<a href='/admin/user/group/ac/show/id/<?= $item['id'];?>'>查看用户</a>
|
|
<a href="/admin/user/groupauth/gid/<?= $item['id'];?>">权限</a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</table>
|
|
<div class="pagenavi"><?= $this->paginator; ?></div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
//<-- group manage
|
|
|
|
function showaddform(){
|
|
$('#addform').toggle();
|
|
}
|
|
function Submit(){
|
|
$.ajax({
|
|
'type': "POST",
|
|
'url': "/admin/user/group/",
|
|
'data': $('#groupadd').serialize(),
|
|
'success': function(data){
|
|
if($.isEmptyObject(data)){Alert('遇到错误,请重试');return false;}
|
|
if(data.error!=null){Alert(data.error);return false;}
|
|
if(data.status==1){top.location=top.location;}
|
|
},
|
|
'beforeSend':function(){$('#checkbtn').html('<img src="/images/ajax-load-small.gif" />');},
|
|
'complete':function(){$('#checkbtn').html('<input type="button" class="btn btn-green" onclick="Submit()" value="添加" />')},
|
|
'timeout': 20000,
|
|
'dataType': 'json',
|
|
'error': function(){Alert('处理中出现问题,请重试');}
|
|
});
|
|
}
|
|
function del(id){
|
|
html = $('#del_chectbtn_'+id).html();
|
|
$.ajax({
|
|
'type': "POST",
|
|
'url': "/admin/user/group/",
|
|
'data': 'ac=del&id='+id,
|
|
'success': function(data){
|
|
if($.isEmptyObject(data)){Alert('遇到错误,请重试');return false;}
|
|
if(data.error!=null){Alert(data.error);return false;}
|
|
if(data.status==1){top.location=top.location;}
|
|
},
|
|
'beforeSend':function(){$('#del_chectbtn_'+id).html('<img src="/images/ajax-load-small.gif" />');},
|
|
'complete':function(){$('#del_chectbtn_'+id).html(html)},
|
|
'timeout': 20000,
|
|
'dataType': 'json',
|
|
'error': function(){Alert('处理中出现问题,请重试');}
|
|
});
|
|
}
|
|
function showinput(id){
|
|
var val = $('#name_'+id).html();
|
|
var input = '<input type="text" value="'+val+'" id="input_'+id+'" class="form-control" />';
|
|
input += ' <button type="button" class="btn btn-primary" onclick="edit('+id+')">修改</button>';
|
|
$('#name_'+id).html(input);
|
|
}
|
|
function edit(id){
|
|
html = $('#name_').html();
|
|
dom = '#name_'+id;
|
|
$.ajax({
|
|
'type': "POST",
|
|
'url': "/admin/user/group/",
|
|
'data': 'ac=edit&id='+id+'&name='+$('#input_'+id).val(),
|
|
'success': function(data){
|
|
if($.isEmptyObject(data)){Alert('遇到错误,请重试');return false;}
|
|
if(data.error!=null){Alert(data.error);return false;}
|
|
if(data.status==1){html = data.name}
|
|
},
|
|
'beforeSend':function(){$(dom).html('<img src="/images/ajax-load-small.gif" />');},
|
|
'complete':function(){$(dom).html(html)},
|
|
'timeout': 20000,
|
|
'dataType': 'json',
|
|
'error': function(){Alert('处理中出现问题,请重试');}
|
|
});
|
|
}
|
|
|
|
// group manage -->
|
|
|
|
//<-- users
|
|
|
|
function showuserform(){
|
|
$('#userform').toggle();
|
|
}
|
|
function SubmitUser(){
|
|
uid = $('#addUserInputUid').val();
|
|
gid = $('#addUserInputGid').val();
|
|
dom = '#checkbtn_addUser';
|
|
addUserToGroup(dom,uid,gid);
|
|
}
|
|
function addUserToGroup(dom,uid,gid){
|
|
html = $(dom).html();
|
|
$.ajax({
|
|
'type': "POST",
|
|
'url': "/admin/user/group/",
|
|
'data': 'ac=adduser&uid='+uid+'&gid='+gid,
|
|
'success': function(data){
|
|
if($.isEmptyObject(data)){Alert('遇到错误,请重试');return false;}
|
|
if(data.error!=null){Alert(data.error);return false;}
|
|
if(data.status==1){Alert('添加成功!');return true;}
|
|
},
|
|
'beforeSend':function(){$(dom).html('<img src="/images/ajax-load-small.gif" />');},
|
|
'complete':function(){$(dom).html(html)},
|
|
'timeout': 20000,
|
|
'dataType': 'json',
|
|
'error': function(){Alert('处理中出现问题,请重试');return false;}
|
|
});
|
|
}
|
|
|
|
// users -->
|
|
|
|
function Alert(html){
|
|
$.colorbox({'innerWidth':'50%','html':'<h4>'+html+'</h4>'});
|
|
}
|
|
</script>
|