-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadminuser.php
166 lines (147 loc) · 7.96 KB
/
adminuser.php
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
<?php
session_start();
include "connection.php";
if (isset($_SESSION["au"])) {
?>
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User Management || Admin Panel</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<?php include 'adminnav.php'; ?>
<!-- header -->
<div class="header-section">
<div class="container-fluid">
<div class="row">
<div class="col-12 col-lg-12 text-center">
<h1 class="text-white fw-bold">Manage All User</h1>
</div>
</div>
</div>
</div>
<!-- end header -->
<div class="col-2 mt-4 offset-1">
<a href="adminReportUser.php"><button class="btn btn-outline-light col-12 fw-bold">User Report</button></a>
</div>
<div class="container offset-1 mt-4">
<div class="col-12">
<div class="row">
<div class="col-2 col-lg-1 bg-dark py-2 text-end">
<span class="fs-5 fw-bold text-white">User Id</span>
</div>
<div class="col-2 col-lg-2 bg-secondary py-2">
<span class="fs-5 fw-bold">First Name</span>
</div>
<div class="col-2 col-lg-2 bg-dark py-2">
<span class="fs-5 fw-bold text-white">Last Name</span>
</div>
<div class="col-2 col-lg-2 bg-secondary py-2">
<span class="fs-5 fw-bold">Email</span>
</div>
<div class="col-2 d-none d-lg-block bg-dark py-2">
<span class="fs-5 fw-bold text-white">Mobile</span>
</div>
<div class="col-2 d-none d-lg-block bg-secondary py-2">
<span class="fs-5 fw-bold">Status</span>
</div>
<?php
$query = "SELECT * FROM `users`";
$pageno = isset($_GET["page"]) ? $_GET["page"] : 1;
$user_rs = Database::search($query);
$user_num = $user_rs->num_rows;
$results_per_page = 5;
$number_of_pages = ceil($user_num / $results_per_page);
$page_results = ($pageno - 1) * $results_per_page;
$selected_rs = Database::search($query . " LIMIT " . $results_per_page . " OFFSET " . $page_results);
$selected_num = $selected_rs->num_rows;
for ($x = 0; $x < $selected_num; $x++) {
$selected_data = $selected_rs->fetch_assoc();
?>
<div class="col-12 mt-3">
<div class="row">
<div class="col-2 col-lg-1 bg-dark py-2 text-end">
<span class="fs-6 fw-bold text-white"><?php echo $x + 1; ?></span>
</div>
<div class="col-2 col-lg-2 bg-secondary py-2">
<span class="fs-6 fw-bold text-white"><?php echo $selected_data["fname"] ?></span>
</div>
<div class="col-2 col-lg-2 bg-dark py-2">
<span class="fs-6 fw-bold"><?php echo $selected_data["lname"] ?></span>
</div>
<div class="col-4 col-lg-2 bg-secondary py-2">
<span class="fs-6 fw-bold"><?php echo $selected_data["email"] ?></span>
</div>
<div class="col-2 d-none d-lg-block bg-dark py-2">
<span class="fs-6 fw-bold text-white"><?php echo $selected_data["username"] ?></span>
</div>
<div class="col-2 d-none col-lg-2 d-lg-block bg-secondary py-2">
<?php if ($selected_data["status"] == 1) { ?>
<button class="col-12 btn btn-danger" id="ub<?php echo $selected_data['email']; ?>"
onclick="blockUser('<?php echo $selected_data['email']; ?>');">Block</button>
<?php } else { ?>
<button class="btn btn-success col-12" id="ub<?php echo $selected_data['email']; ?>"
onclick="blockUser('<?php echo $selected_data['email']; ?>');">Unblock</button>
<?php } ?>
</div>
</div>
</div>
<?php
}
?>
<div class="col-12 d-flex justify-content-center mt-3">
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<li class="page-item">
<a class="page-link" href="<?php if ($pageno <= 1) {
echo "#";
} else {
echo "?page=" . ($pageno - 1);
} ?>" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<?php
for ($x = 1; $x <= $number_of_pages; $x++) {
if ($x == $pageno) { ?>
<li class="page-item active">
<a class="page-link" href="<?php echo "?page=" . $x; ?>"><?php echo $x; ?></a>
</li>
<?php } else { ?>
<li class="page-item">
<a class="page-link" href="<?php echo "?page=" . $x; ?>"><?php echo $x; ?></a>
</li>
<?php
}
}
?>
<li class="page-item">
<a class="page-link" href="<?php if ($pageno >= $number_of_pages) {
echo "#";
} else {
echo "?page=" . ($pageno + 1);
} ?>" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
</>
<script src="script.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
<?php
} else {
echo "You are not a valid user";
}
?>