-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
111 lines (93 loc) · 3.36 KB
/
Copy pathadmin.php
File metadata and controls
111 lines (93 loc) · 3.36 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
<?php
include("vendor/autoload.php");
use Libs\Database\MySQL;
use Libs\Database\UsersTable;
use Helpers\Auth;
$table = new UsersTable(new MySQL);
$all = $table->getAll();
$auth = Auth::check();
?>
<!DOCTYPE html>
<html lang="en">
<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">
<title>Admin | User Management</title>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- Bootstrap JS -->
<script src="js/bootstrap.bundle.min.js" defer></script>
</head>
<body>
<div class="container">
<div class="float-end">
<a href="profile.php" class="btn btn-sm btn-success">Profile</a>
<a href="_actions/logout.php" class="btn btn-sm btn-danger">Logout</a>
</div>
<h1 class="mt-5 mb-4">
Manage Users
<span class="badge bg-danger text-white">
<?= count($all) ?>
</span>
</h1>
<table class="table table-striped table-bordered">
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>Role</th>
<th>Actions</th>
</tr>
<?php foreach($all as $user) : ?>
<tr>
<td><?= $user->id ?></td>
<td><?= $user->name ?></td>
<td><?= $user->email ?></td>
<td><?= $user->phone ?></td>
<td>
<?php if($user->value === 1) : ?>
<span class="badge bg-secondary">
<?= $user->role ?>
</span>
<?php elseif($user->value === 2) : ?>
<span class="badge bg-primary">
<?= $user->role ?>
</span>
<?php else : ?>
<span class="badge bg-success">
<?= $user->role ?>
</span>
<?php endif ?>
</td>
<td>
<?php if($auth->value > 1) : ?>
<div class="btn-group dropdown">
<a href="#" class="btn btn-sm btn-outline-primary dropdown-toggle" data-bs-toggle="dropdown">Change Role</a>
<div class="dropdown-menu dropdown-menu-dark">
<a href="_actions/role.php?id=<?= $user->id ?>&role=1" class="dropdown-item">User</a>
<a href="_actions/role.php?id=<?= $user->id ?>&role=2" class="dropdown-item">Manager</a>
<a href="_actions/role.php?id=<?= $user->id ?>&role=3" class="dropdown-item">Admin</a>
</div>
<?php if($user->id !== $auth->id) : ?>
<?php if($user->suspended) : ?>
<a href="_actions/unsuspend.php?id=<?= $user->id ?>" class="ms-1 btn btn-sm btn-danger">Suspended</a>
<?php else : ?>
<a href="_actions/suspend.php?id=<?= $user->id ?>" class="ms-1 btn btn-sm btn-outline-success">Activate</a>
<?php endif ?>
<?php if($auth->value > 2) : ?>
<a href="_actions/delete.php?id=<?= $user->id ?>" class="ms-1 btn btn-sm btn-outline-danger" onClick="return confirm('Are you sure?')">Delete</a>
<?php endif ?>
<?php endif ?>
</div>
<?php else : ?>
###
<?php endif ?>
</td>
</tr>
<?php endforeach ?>
</table>
</div>
</body>
</html>