-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadminpage.php
More file actions
316 lines (286 loc) · 12.7 KB
/
Copy pathadminpage.php
File metadata and controls
316 lines (286 loc) · 12.7 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
<?php
include_once "./assets/php/config.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Page</title>
<!-- Reset -->
<link rel="stylesheet" href="./assets/css/reset.css">
<!-- fonts -->
<link rel="stylesheet" href="./assets/fonts/stylesheet.css">
<!-- AdminPage css -->
<link rel="stylesheet" href="./assets/css/adminpage.css">
</head>
<body>
<?php
// Online
$ad_onl = "select isActive from userinformation";
$kq_ad_onl = mysqli_query($conn,$ad_onl);
$total_onl = 0;
while($tt = mysqli_fetch_array($kq_ad_onl))
{
if($tt["isActive"] == 1)
{
$total_onl +=1;
}
}
// Name and follow
$ad_us="select ID,UserName,isActive,Avt from userinformation";
$ad_fl="select * from followers";
$kq_ad_us = mysqli_query($conn,$ad_us);
$kq_ad_fl = mysqli_query($conn,$ad_fl);
$listfollowers = [];
while($sub_fl = mysqli_fetch_array($kq_ad_fl)) {
$listfollowers[] = $sub_fl;
}
// Report
$us_rpt =
"
select distinct userinformation.UserName, userinformation.ID
from userreport
inner join userinformation ON userreport.ReportedID = userinformation.id
";
$ad_rp =
"
select userreport.ReportedID,
case
when count(*) >= 2 then max(userreport.ReportDate)
else min(userreport.ReportDate)
end as LatestReportDate
from userreport
group by userreport.ReportedID
";
$kq_us_rpt = mysqli_query($conn,$us_rpt);
$kq_ad_rp = mysqli_query($conn,$ad_rp);
$listreports = [];
while($sub_rp = mysqli_fetch_array($kq_ad_rp)) {
$listreports[] = $sub_rp;
}
// Total Report
$tt_rp = "select * from userreport order by ID desc limit 1";
$kq_tt_rp = mysqli_query($conn,$tt_rp);
$total_rp = mysqli_fetch_array($kq_tt_rp);
// To do list
$dolist = "select * from todolist";
$kq_dolist = mysqli_query($conn,$dolist);
?>
<div class="container">
<!-- wrap nav -->
<aside class="aside">
<!-- Logo -->
<div class="logo">
<img src="./assets/img/logo.svg" alt="Flirt Zone">
<div class="logo-desc">
<img src="./assets/img/logo-desc1.svg" alt="Flirt Zone">
<img src="./assets/img/logo-desc2.svg" alt="Flirt Zone">
</div>
</div>
<!-- Mangage -->
<h2 class="title">Manage</h2>
<!-- nav -->
<nav class="nav">
<div class="nav-item">
<div class="icon">
<img src="./assets/icons/taskAdmin1.svg" alt="Dash board">
</div>
<p><a class="task" style="text-decoration: none;" href="adminpage.php">Dash board</a></p>
</div>
<div class="nav-item">
<div class="icon">
<img src="./assets/icons/taskAdmin2.svg" alt="User profile">
</div>
<p><a class="task" style="text-decoration: none;" href="adminprofileuser.php">User profile</a></p>
</div>
<div class="nav-item">
<div class="icon">
<img src="./assets/icons/taskAdmin3.svg" alt="Bin">
</div>
<p><a class="task" style="text-decoration: none;" href="adminbin.php">Bin</a></p>
</div>
</nav>
</aside>
<!-- wrap content -->
<div class="wrap">
<!-- Header -->
<header class="header">
<div class="title-intro">
<h1 class="title">Hey there!😘</h1>
<p class="desc">Here’s what happen your stored today</p>
</div>
<form class="bar-search">
<input type="text" size="31" placeholder="what are you looking for?" class="looking" id="word"
name="word">
<button>
<img src="./assets/icons/search.svg" alt="Search" class="icon-search">
</button>
</form>
</header>
<!-- main -->
<main class="main">
<!-- content left -->
<div class="main-left">
<!-- index online and report -->
<div class="access">
<div class="items">
<img src="./assets/img/decr.svg" alt="Online People" class="item-img">
<div class="item-wrap">
<p class="desc">Online People</p>
<p class="total"><?php echo $total_onl ?></p>
</div>
</div>
<div class="items">
<img src="./assets/img/incr.svg" alt="Total report" class="item-img">
<div class="item-wrap">
<p class="desc">Total report</p>
<p class="total"> <?php echo $total_rp["ID"] ?></p>
</div>
</div>
</div>
<!-- Report -->
<div class="wrap-report">
<a href="adminreport.php" class="title">Report</a>
<!-- detail report -->
<div class="frame-report">
<?php
while($q = mysqli_fetch_array($kq_us_rpt)) {?>
<div class="detail">
<img src="./assets/img/avt.jpg" alt="" class="avt-user">
<div class="info">
<h3 class="name"> <?php echo $q["UserName"]?> </h3>
<p class="user-desc">
<?php
$fl_count = 0;
foreach($listfollowers as $fl) {
if ($fl["FollowerID"] == $q["ID"]) {
$fl_count += 1;
}
}
echo $fl_count . " followers"
?>
</p>
</div>
<span class="day-re">
<?php
foreach($listreports as $rp) {
if ($rp["ReportedID"] == $q["ID"]) {
echo $rp["LatestReportDate"];
}
}
?>
</span>
</div>
<?php } ?>
</div>
</div>
</div>
<!-- content right -->
<div class="main-right">
<div class="to-do-list">
<div class="wrap-list">
<h4 class="list">To do List</h4>
<?php
while($td = mysqli_fetch_array($kq_dolist)) {?>
<form class="add-value" method="POST">
<input type="hidden" name="todolist_id" value="<?php echo $td["ID"]; ?>">
<input type="checkbox" class="check">
<input type="text" name="todolist" value="<?php echo $td["Remind"]; ?>" class="write" disabled>
</form>
<?php }?>
<div class="add-value2">
<button class="write" id="add-task">+</button>
</div>
</div>
</div>
<div class="profile">
<div class="wrap-pro">
<a href="adminprofileuser.php" class="user-pro">User Profile</a>
<?php
while($a = mysqli_fetch_array($kq_ad_us))
{ ?>
<div class="detail">
<img src="./assets/img/avt-new.jpg" alt="" class="avt-user">
<div class="info">
<h3 class="name"><?php echo $a["UserName"] ?></h3>
<p class="user-desc">
<?php
$fl_count = 0;
foreach($listfollowers as $b) {
if ($b["FollowerID"] == $a["ID"] ) {
$fl_count += 1;
}
}
echo $fl_count . " followers"
?>
</p>
</div>
<?php
if ($a["isActive"] == 1) { ?>
<div class="tick-green"></div>
<?php } else { ?>
<div class="tick-gray"></div>
<?php } ?>
</div>
<?php }?>
</div>
</div>
</div>
</div>
</main>
</div>
</div>
<script>
// Xóa To Do List
document.querySelectorAll('.check').forEach(checkbox => {
checkbox.addEventListener('change', () => {
if (checkbox.checked) {
const form = checkbox.closest('form');
const todolistId = form.querySelector('input[name="todolist_id"]').value;
// Gửi Ajax để xóa
fetch('./assets/php/delete_todo.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: 'todolist_id=' + encodeURIComponent(todolistId)
})
.then(response => response.text())
.then(data => {
console.log(data); // in thông báo server trả về (tuỳ chọn)
// Xóa form khỏi DOM
form.remove();
})
.catch(error => console.error('Lỗi:', error));
}
});
});
// Thêm form để nhập TD List
document.getElementById("add-task").addEventListener("click", function () {
// Tạo phần tử form mới
const form = document.createElement("form");
form.className = "add-value";
form.method = "POST";
form.action = "./assets/php/add_todo.php";
// Tạo checkbox
const checkbox = document.createElement("input");
checkbox.type = "checkbox";
checkbox.className = "check";
// Tạo ô nhập văn bản
const input = document.createElement("input");
input.type = "text";
input.name = "todolist";
input.placeholder = "Add...";
input.className = "write";
// Thêm các phần tử vào form
form.appendChild(checkbox);
form.appendChild(input);
// Thêm form vào danh sách trước nút "+"
const addButtonDiv = document.querySelector(".add-value2");
addButtonDiv.parentElement.insertBefore(form, addButtonDiv);
input.focus();
});
</script>
</body>
</html>