185 lines
6.3 KiB
PHTML
185 lines
6.3 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 id="leftPanel">
|
|
<?= $this->partial('user/left.phtml'); ?>
|
|
</div>
|
|
|
|
<?php if ($this->msg or $this->messages) :?>
|
|
<div id="message">
|
|
<?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 id="rightPanel">
|
|
<div style="font-size:16px;line-height:30px; font-weight:bold;">用户组</div>
|
|
<div class="search" style="margin:5px 0;">
|
|
<button type="button" class="btn" onclick="showaddform()">添加用户组</button>
|
|
<button type="button" class="btn" onclick="showuserform()">添加用户到组</button>
|
|
</div><!-- search DIV -->
|
|
<div id="addform" style="display: none;">
|
|
<form id="groupadd">
|
|
组名 <input type="text" name="name" />
|
|
<input type="hidden" name="ac" value="add" />
|
|
<i id="checkbtn">
|
|
<input type="button" class="btn btn-green" onclick="Submit()" value="添加" />
|
|
</i>
|
|
</form>
|
|
</div>
|
|
<div id="userform" style="margin:5px 0; display:none;">
|
|
<form id="userform" >
|
|
用户ID(数字) <input type="text" id="addUserInputUid" name="uid" />
|
|
组ID(数字) <input type="text" id="addUserInputGid" name="gid" />
|
|
<input type="hidden" name="ac" value="adduser" />
|
|
<i id="checkbtn_addUser">
|
|
<input type="button" class="btn btn-green" onclick="SubmitUser()" value="添加" />
|
|
</i>
|
|
</form>
|
|
</div>
|
|
<table>
|
|
<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 class="<?php if($autoindex%2 == 0) echo 'even'; else echo 'odd'; ?>">
|
|
<td><?= $item['id']?></td>
|
|
<td 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>
|
|
<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+'" />';
|
|
input += '<button type="button" class="btn btn-green" 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>
|