-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcom_admin.php
More file actions
157 lines (152 loc) · 3.9 KB
/
com_admin.php
File metadata and controls
157 lines (152 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
// global error list
$error = array();
// Import default settings
require_once('./config.php');
session_start();
// If wasn't a admin, redirect to index.php
if ($_SESSION['COM_ADMIN'] != 1) {
header('Location: ./index.php');
}
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="manifest" href="./manifest.json">
<link rel="shortcut icon" href="./images/logo256.png">
<link rel="stylesheet" href="./reset.css">
<link rel="stylesheet" href="./manage_admin.css">
<script src="./jquery.js"></script>
<title>HiScheduler || 研修スケジューラー</title>
</head>
<script>
$(document).ready(function() {
// 社員一覧表示
function get_users() {
let data4 = {
'ajax': 4,
'area': '<?php echo $_SESSION['AREA'] ?>',
'company': '<?php echo $_SESSION['COM'] ?>',
}
$.ajax({
dataType: 'json',
url: './data.php',
type: 'post',
data: data4
})
.done(function(data, dataType) {
if (data != $('.all_users').html()) {
$('.all_users').html(data);
clicks();
}
});
}
// click functionのリフレッシュ
function clicks() {
$('.remove_user').click(function() {
if (confirm('本当にこの会社を削除しますか?')) {
delete_user($(this).attr('id'));
}
});
$('.permission_user').click(function() {
if (confirm('本当にこの社員に組織アカウント権限を与えますか?')) {
permission_user($(this).attr('id'));
}
});
$('.unpermission_user').click(function() {
if (confirm('本当にこの社員の組織アカウント権限を剥奪しますか?')) {
unpermission_user($(this).attr('id'));
}
});
}
// 社員削除処理
function delete_user(id) {
let data5 = {
'ajax': 5,
'id': id
}
$.ajax({
dataType: 'json',
url: './data.php',
type: 'post',
data: data5
})
.done(function(data, dataType) {
get_users();
});
}
// 組織アカウント権付与
function permission_user(id) {
let data6 = {
'ajax': 6,
'id': id
}
$.ajax({
dataType: 'json',
url: './data.php',
type: 'post',
data: data6
})
.done(function(data, dataType) {
get_users();
});
}
// 組織アカウント権剥奪
function unpermission_user(id) {
let data7 = {
'ajax': 7,
'id': id
}
$.ajax({
dataType: 'json',
url: './data.php',
type: 'post',
data: data7
})
.done(function(data, dataType) {
get_users();
});
}
// Delete company
function delete_company() {
let data2 = {
'ajax': 2,
'company': '<?php echo $_SESSION['COM'] ?>'
}
$.ajax({
dataType: 'json',
url: './data.php',
type: 'post',
data: data2
})
.done(function(data, dataType) {
if (data == 'success') {
location.href = './remove_all_sessions.php';
}
});
}
// 会社削除がクリックされたとき
$('.delete_company').click(function() {
if (confirm('本当に会社を削除しますか?')) {
delete_company();
}
});
// 初期実行
get_users();
clicks();
delete_company_click();
// 定期実行
setInterval(() => {
get_users();
}, 5000);
});
</script>
<body>
<a class="home_link" href="./home.php">戻る</a>
<div class="all_users"></div>
<button class="delete_company">会社を削除</button>
</body>
</html>