Skip to content

Commit dbfc996

Browse files
committed
增加类目管理,增加权限,修改数据库
1 parent 2986688 commit dbfc996

11 files changed

Lines changed: 376 additions & 65 deletions

File tree

‎hoorayos.sql‎

Lines changed: 82 additions & 59 deletions
Large diffs are not rendered by default.

‎sysapp/appmanage/detail.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@
8585
$appcategory = $db->select(0, 0, 'tb_app_category', '*', '', 'tbid asc');
8686
foreach($appcategory as $ac){
8787
if($ac['tbid'] == $app['app_category_id']){
88-
echo '<option value="'.$ac['id'].'" selected>'.$ac['name'].'</option>';
88+
echo '<option value="'.$ac['tbid'].'" selected>'.$ac['name'].'</option>';
8989
}else{
90-
echo '<option value="'.$ac['id'].'">'.$ac['name'].'</option>';
90+
echo '<option value="'.$ac['tbid'].'">'.$ac['name'].'</option>';
9191
}
9292
}
9393
?>

‎sysapp/category/detail.ajax.php‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
require('../../global.php');
3+
4+
switch($ac){
5+
case 'edit':
6+
$set = array(
7+
'name = "'.$val_name.'"'
8+
);
9+
if($id == ''){
10+
$db->insert(0, 0, 'tb_app_category', $set);
11+
}else{
12+
$db->update(0, 0, 'tb_app_category', $set, 'and tbid = '.(int)$id);
13+
}
14+
echo json_encode(array(
15+
'info' => '',
16+
'status' => 'y'
17+
));
18+
break;
19+
}
20+
?>

‎sysapp/category/detail.php‎

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?php
2+
require('../../global.php');
3+
4+
//验证是否登入
5+
if(!checkLogin()){
6+
redirect('../error.php?code='.$errorcode['noLogin']);
7+
}
8+
//验证是否为管理员
9+
else if(!checkAdmin()){
10+
redirect('../error.php?code='.$errorcode['noAdmin']);
11+
}
12+
//验证是否有权限
13+
else if(!checkPermissions(5)){
14+
redirect('../error.php?code='.$errorcode['noPermissions']);
15+
}
16+
17+
if(isset($categoryid)){
18+
$category = $db->select(0, 1, 'tb_app_category', 'tbid, name', 'and tbid = '.$categoryid);
19+
}
20+
?>
21+
<!doctype html>
22+
<html>
23+
<head>
24+
<meta charset="utf-8">
25+
<title>用户管理</title>
26+
<?php include('sysapp/global_css.php'); ?>
27+
<link rel="stylesheet" href="../../img/ui/sys.css">
28+
</head>
29+
30+
<body>
31+
<form action="detail.ajax.php" method="post" name="form" id="form">
32+
<input type="hidden" name="ac" value="edit">
33+
<input type="hidden" name="id" value="<?php echo $categoryid; ?>">
34+
<div class="creatbox">
35+
<div class="middle">
36+
<p class="detile-title">
37+
<strong>编辑类目</strong>
38+
</p>
39+
<div class="input-label">
40+
<label class="label-text">类目名称:</label>
41+
<div class="label-box form-inline control-group">
42+
<input type="text" name="val_name" value="<?php echo $category['name']; ?>" datatype="*" nullmsg="请输入类目名称">
43+
<span class="help-inline"></span>
44+
</div>
45+
</div>
46+
</div>
47+
</div>
48+
<div class="bottom-bar">
49+
<div class="con">
50+
<a class="btn btn-primary fr" id="btn-submit" href="javascript:;"><i class="icon-white icon-ok"></i> 确定</a>
51+
<a class="btn fr" href="javascript:window.parent.closeDetailIframe();" style="margin-right:10px"><i class="icon-chevron-up"></i> 返回类目列表</a>
52+
</div>
53+
</div>
54+
</form>
55+
<?php include('sysapp/global_js.php'); ?>
56+
<script>
57+
$(function(){
58+
$('#form').Validform({
59+
btnSubmit: '#btn-submit',
60+
postonce: false,
61+
showAllError: true,
62+
//msg:提示信息;
63+
//o:{obj:*,type:*,curform:*}, obj指向的是当前验证的表单元素(或表单对象),type指示提示的状态,值为1、2、3、4, 1:正在检测/提交数据,2:通过验证,3:验证失败,4:提示ignore状态, curform为当前form对象;
64+
//cssctl:内置的提示信息样式控制函数,该函数需传入两个参数:显示提示信息的对象 和 当前提示的状态(既形参o中的type);
65+
tiptype: function(msg, o){
66+
if(!o.obj.is('form')){//验证表单元素时o.obj为该表单元素,全部验证通过提交表单时o.obj为该表单对象;
67+
var B = o.obj.parents('.control-group');
68+
var T = B.children('.help-inline');
69+
if(o.type == 2){
70+
B.removeClass('error');
71+
T.text('');
72+
}else{
73+
B.addClass('error');
74+
T.text(msg);
75+
}
76+
}
77+
},
78+
ajaxPost: true,
79+
callback: function(data){
80+
if($('input[name="id"]').val() != ''){
81+
if(data.status == 'y'){
82+
$.dialog({
83+
id : 'ajaxedit',
84+
content : '修改成功,是否继续修改?',
85+
okVal: '是',
86+
ok : function(){
87+
$.dialog.list['ajaxedit'].close();
88+
},
89+
cancel : function(){
90+
window.parent.closeDetailIframe(function(){
91+
window.parent.$('#pagination').trigger('currentPage');
92+
});
93+
}
94+
});
95+
}
96+
}else{
97+
if(data.status == 'y'){
98+
$.dialog({
99+
id : 'ajaxedit',
100+
content : '添加成功,是否继续添加?',
101+
okVal: '是',
102+
ok : function(){
103+
location.reload();
104+
return false;
105+
},
106+
cancel : function(){
107+
window.parent.closeDetailIframe(function(){
108+
window.parent.$('#pagination').trigger('currentPage');
109+
});
110+
}
111+
});
112+
}
113+
}
114+
}
115+
});
116+
});
117+
</script>
118+
</body>
119+
</html>

‎sysapp/category/index.ajax.php‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
require('../../global.php');
3+
4+
switch($ac){
5+
case 'getList':
6+
$orderby = 'tbid desc limit '.(int)$from.','.(int)$to;
7+
if($search_1 != ''){
8+
$sqlwhere[] = 'name like "%'.$search_1.'%"';
9+
}
10+
$c = $db->select(0, 2, 'tb_app_category', 'tbid', $sqlwhere);
11+
echo $c.'<{|*|}>';
12+
$rs = $db->select(0, 0, 'tb_app_category', '*', $sqlwhere, $orderby);
13+
if($rs != NULL){
14+
foreach($rs as $v){
15+
echo '<tr class="list-bd">';
16+
echo '<td style="text-align:left;padding-left:15px">'.$v['name'].'</td>';
17+
echo '<td><a href="javascript:openDetailIframe(\'detail.php?categoryid='.$v['tbid'].'\');" class="btn btn-mini btn-link">编辑</a><a href="javascript:;" class="btn btn-mini btn-link do-del" categoryid="'.$v['tbid'].'">删除</a></td>';
18+
echo '</tr>';
19+
}
20+
}
21+
break;
22+
case 'del':
23+
$db->delete(0, 0, 'tb_app_category', 'and tbid = '.(int)$categoryid);
24+
break;
25+
}
26+
?>

‎sysapp/category/index.php‎

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?php
2+
require('../../global.php');
3+
4+
//验证是否登入
5+
if(!checkLogin()){
6+
redirect('../error.php?code='.$errorcode['noLogin']);
7+
}
8+
//验证是否为管理员
9+
else if(!checkAdmin()){
10+
redirect('../error.php?code='.$errorcode['noAdmin']);
11+
}
12+
//验证是否有权限
13+
else if(!checkPermissions(5)){
14+
redirect('../error.php?code='.$errorcode['noPermissions']);
15+
}
16+
?>
17+
<!doctype html>
18+
<html>
19+
<head>
20+
<meta charset="utf-8">
21+
<title>类目管理</title>
22+
<?php include('sysapp/global_css.php'); ?>
23+
<link rel="stylesheet" href="../../img/ui/sys.css">
24+
<style>
25+
body{margin:10px 10px 0}
26+
</style>
27+
</head>
28+
29+
<body>
30+
<div class="well well-small" style="margin-bottom:10px">
31+
<div class="form-inline">
32+
<label>类目名称:</label>
33+
<input type="text" name="search_1" id="search_1" class="span2">
34+
<a class="btn" menu="search" href="javascript:;" style="margin-left:10px"><i class="icon-search"></i> 搜索</a>
35+
<a class="btn btn-primary fr" href="javascript:openDetailIframe('detail.php');"><i class="icon-white icon-plus"></i> 创建新类目</a>
36+
</div>
37+
</div>
38+
<table class="list-table">
39+
<thead>
40+
<tr class="col-name">
41+
<th>类目名称</th>
42+
<th style="width:150px">操作</th>
43+
</tr>
44+
<tr class="sep-row"><td colspan="100"></td></tr>
45+
<tr class="toolbar">
46+
<td colspan="100">
47+
<b style="margin:0 10px">符合条件的记录</b>有<font class="list-count">0</font>条
48+
</td>
49+
</tr>
50+
<tr class="sep-row"><td colspan="100"></td></tr>
51+
</thead>
52+
<tbody class="list-con"></tbody>
53+
<tfoot><tr><td colspan="100">
54+
<div class="pagination pagination-centered" id="pagination"></div>
55+
<?php $categorycount = $db->select(0, 2, 'tb_app_category', 'tbid'); ?>
56+
<input id="pagination_setting" type="hidden" count="<?php echo $categorycount; ?>" per="15">
57+
</td></tr></tfoot>
58+
</table>
59+
<?php include('sysapp/global_module_detailIframe.php'); ?>
60+
<?php include('sysapp/global_js.php'); ?>
61+
<script>
62+
$(function(){
63+
//加载列表
64+
getPageList(0);
65+
//删除
66+
$('.list-con').on('click', '.do-del', function(){
67+
var categoryid = $(this).attr('categoryid');
68+
var name = $(this).parent().prev().text();
69+
$.dialog({
70+
id : 'ajaxedit',
71+
content : '删除 “' + name + '” 类目时,会将该类目下的所有应用归类到「未分类」类目下,是否继续?',
72+
ok : function(){
73+
$.ajax({
74+
type : 'POST',
75+
url : 'index.ajax.php',
76+
data : 'ac=del&categoryid=' + categoryid,
77+
success : function(msg){
78+
getPageList(0);
79+
}
80+
});
81+
},
82+
cancel: true
83+
});
84+
});
85+
//搜索
86+
$('a[menu=search]').click(function(){
87+
getPageList(0);
88+
});
89+
});
90+
function initPagination(current_page){
91+
$('#pagination').pagination(parseInt($('#pagination_setting').attr('count')), {
92+
current_page : current_page,
93+
items_per_page : parseInt($('#pagination_setting').attr('per')),
94+
num_display_entries : 9,
95+
num_edge_entries : 2,
96+
callback : getPageList,
97+
prev_text : '上一页',
98+
next_text : '下一页'
99+
});
100+
}
101+
function getPageList(current_page){
102+
ZENG.msgbox.show('正在加载中,请稍后...', 6, 100000);
103+
var from = current_page * parseInt($('#pagination_setting').attr('per')), to = parseInt($('#pagination_setting').attr('per'));
104+
$.ajax({
105+
type : 'POST',
106+
url : 'index.ajax.php',
107+
data : 'ac=getList&from=' + from + '&to=' + to + '&search_1=' + $('#search_1').val(),
108+
success : function(msg){
109+
var arr = msg.split('<{|*|}>');
110+
$('#pagination_setting').attr('count', arr[0]);
111+
$('.list-count').text(arr[0]);
112+
$('.list-con').html(arr[1]);
113+
initPagination(current_page);
114+
ZENG.msgbox._hide();
115+
}
116+
});
117+
}
118+
</script>
119+
</body>
120+
</html>

‎sysapp/permission/alert_addapps.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
<body>
1414
<div class="alert_addapps">
1515
<?php
16-
$apps = $db->select(0, 0, 'tb_app', 'tbid,name,icon', 'and kindid = 1');
16+
$category = $db->select(0, 1, 'tb_app_category', 'group_concat(tbid) as tbids', 'and issystem = 1');
17+
$apps = $db->select(0, 0, 'tb_app', 'tbid, name, icon', 'and app_category_id in('.$category['tbids'].')');
1718
foreach($apps as $v){
1819
echo '<div class="app" title="'.$v['name'].'" appid="'.$v['tbid'].'">';
19-
echo '<img src="../../'.$v['icon'].'" alt="'.$v['name'].'">';
20+
echo '<img src="../../'.$v['icon'].'" alt="'.$v['name'].'" title="'.$v['name'].'">';
2021
echo '<div class="name">'.$v['name'].'</div>';
2122
echo '<span class="selected"></span>';
2223
echo '</div>';

‎sysapp/permission/detail.ajax.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
case 'updateApps':
2121
$appsrs = $db->select(0, 0, 'tb_app', 'tbid, name, icon', 'and tbid in ('.$appsid.')');
2222
foreach($appsrs as $a){
23-
echo '<div class="app" appid="'.$a['tbid'].'"><img src="../../'.$a['icon'].'" alt="'.$a['name'].'" title="'.$a['icon'].'"><span class="del">删</span></div>';
23+
echo '<div class="app" appid="'.$a['tbid'].'"><img src="../../'.$a['icon'].'" alt="'.$a['name'].'" title="'.$a['name'].'"><span class="del">删</span></div>';
2424
}
2525
break;
2626
}

‎sysapp/permission/detail.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
if(isset($permissionid)){
1818
$permission = $db->select(0, 1, 'tb_permission', '*', 'and tbid = '.$permissionid);
1919
if($permission['apps_id'] != ''){
20-
$appsrs = $db->select(0, 0, 'tb_app', 'tbid,name,icon', 'and tbid in ('.$permission['apps_id'].')');
20+
$appsrs = $db->select(0, 0, 'tb_app', 'tbid, name, icon', 'and tbid in ('.$permission['apps_id'].')');
2121
$permission['appsinfo'] = $appsrs;
2222
}
2323
}

‎sysapp/permission/index.ajax.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
if($rs != NULL){
1414
foreach($rs as $v){
1515
echo '<tr class="list-bd">';
16+
echo '<td>'.$v['tbid'].'</td>';
1617
echo '<td style="text-align:left;padding-left:15px">'.$v['name'].'</td>';
1718
echo '<td><a href="javascript:openDetailIframe(\'detail.php?permissionid='.$v['tbid'].'\');" class="btn btn-mini btn-link">编辑</a><a href="javascript:;" class="btn btn-mini btn-link do-del" permissionid="'.$v['tbid'].'">删除</a></td>';
1819
echo '</tr>';

0 commit comments

Comments
 (0)