-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
206 lines (199 loc) · 10.5 KB
/
Copy pathadmin.php
File metadata and controls
206 lines (199 loc) · 10.5 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
<?php
session_start();
include('model/config.php');
include('model/page_config.php');
$admin_role = $_SESSION['nivas_adminRole'];
$roles_query = mysqli_query($conn, "SELECT id, name FROM admin_roles WHERE status = 'active'");
$schools_query = mysqli_query($conn, "SELECT id, name FROM schools WHERE status = 'active'");
$admins_query = mysqli_query($conn, "SELECT a.*, r.name AS role_name, s.name AS school_name FROM admins a LEFT JOIN admin_roles r ON a.role = r.id LEFT JOIN schools s ON a.school = s.id");
?>
<!DOCTYPE html>
<html lang="en" class="light-style layout-menu-fixed" dir="ltr" data-theme="theme-default" data-assets-path="assets/" data-template="vertical-menu-template-free">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<title>Admins | Nivasity Command Center</title>
<meta name="description" content="" />
<?php include('partials/_head.php') ?>
</head>
<body>
<div class="layout-wrapper layout-content-navbar">
<div class="layout-container">
<?php include('partials/_sidebar.php') ?>
<div class="layout-page">
<?php include('partials/_navbar.php') ?>
<div class="content-wrapper">
<div class="container-xxl flex-grow-1 container-p-y">
<h4 class="fw-bold py-3 mb-4"><span class="text-muted fw-light">Admin Management /</span> Admins</h4>
<div class="card">
<div class="card-body">
<div class="table-responsive text-nowrap">
<table class="table">
<thead class="table-secondary">
<tr>
<th>Name</th>
<th>Email</th>
<th>Role</th>
<th>School</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody class="table-border-bottom-0" id="admins_table">
<?php while($admin = mysqli_fetch_array($admins_query)) {
$admin_status = strtolower($admin['status']);
$is_active = $admin_status === 'active';
?>
<tr>
<td class="text-uppercase"><?php echo $admin['first_name'] . ' ' . $admin['last_name']; ?></td>
<td><?php echo $admin['email']; ?></td>
<td><?php echo $admin['role_name']; ?></td>
<td><?php echo $admin['school_name'] ? $admin['school_name'] : '-'; ?></td>
<td><span class="fw-bold badge bg-label-<?php echo $admin['status'] == 'active' ? 'success' : 'danger'; ?>"><?php echo ucfirst($admin['status']); ?></span></td>
<td>
<div class="dropdown">
<button type="button" class="btn p-0 dropdown-toggle hide-arrow" data-bs-toggle="dropdown" data-bs-offset="0,8"><i class="bx bx-dots-vertical-rounded"></i></button>
<div class="dropdown-menu popper-safe-dropdown">
<a class="dropdown-item editAdmin" href="javascript:void(0);"
data-id="<?php echo $admin['id']; ?>"
data-first="<?php echo $admin['first_name']; ?>"
data-last="<?php echo $admin['last_name']; ?>"
data-email="<?php echo $admin['email']; ?>"
data-phone="<?php echo $admin['phone']; ?>"
data-gender="<?php echo $admin['gender']; ?>"
data-role="<?php echo $admin['role']; ?>"
data-school="<?php echo $admin['school'] ?? 0; ?>"
data-faculty="<?php echo $admin['faculty'] ?? 0; ?>"
data-departments="<?php echo htmlspecialchars((string)($admin['departments'] ?? ''), ENT_QUOTES); ?>">
<i class="bx bx-edit-alt me-1"></i> Edit
</a>
<a class="dropdown-item toggleAdminStatus" href="javascript:void(0);"
data-id="<?php echo $admin['id']; ?>"
data-status="<?php echo $admin_status; ?>">
<i class="bx bx-power-off me-1"></i> <?php echo $is_active ? 'Deactivate' : 'Activate'; ?>
</a>
</div>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php include('partials/_footer.php') ?>
<div class="content-backdrop fade"></div>
</div>
</div>
</div>
<div class="layout-overlay layout-menu-toggle"></div>
</div>
<button type="button" class="btn btn-primary new_formBtn">
<i class="bx bx-plus fs-3"></i>
</button>
<div class="modal fade" id="newAdminModal" tabindex="-1" aria-labelledby="newAdminModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="newAdminModalLabel">Add New Admin</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form id="adminForm">
<input type="hidden" name="admin_id" value="0">
<div class="modal-body">
<div class="row">
<div class="col-md-6 mb-3">
<label for="first_name" class="form-label">First Name</label>
<input type="text" name="first_name" class="form-control" required>
</div>
<div class="col-md-6 mb-3">
<label for="last_name" class="form-label">Last Name</label>
<input type="text" name="last_name" class="form-control" required>
</div>
<div class="col-md-6 mb-3">
<label for="email" class="form-label">Email</label>
<input type="email" name="email" class="form-control" required>
</div>
<div class="col-md-6 mb-3">
<label for="phone" class="form-label">Phone</label>
<input type="text" name="phone" class="form-control" required>
</div>
<div class="col-md-6 mb-3">
<label for="gender" class="form-label">Gender</label>
<select name="gender" class="form-select" required>
<option value="male">Male</option>
<option value="female">Female</option>
</select>
</div>
<div class="col-md-6 mb-3">
<label for="role" class="form-label">Role</label>
<select name="role" id="role" class="form-select" required>
<?php mysqli_data_seek($roles_query,0); while($role = mysqli_fetch_array($roles_query)) { ?>
<option value="<?php echo $role['id']; ?>"><?php echo $role['name']; ?></option>
<?php } ?>
</select>
</div>
<div class="col-md-6 mb-3" id="school_wrapper" style="display: none;">
<label for="school" class="form-label">School</label>
<select name="school" id="school" class="form-select">
<option value="0">All Schools</option>
<?php while($school = mysqli_fetch_array($schools_query)) { ?>
<option value="<?php echo $school['id']; ?>"><?php echo $school['name']; ?></option>
<?php } ?>
</select>
</div>
<div class="col-md-6 mb-3" id="faculty_wrapper" style="display: none;">
<label for="faculty" class="form-label">Faculty</label>
<select name="faculty" id="faculty" class="form-select">
<option value="0">All Faculties</option>
</select>
</div>
<div class="col-12 mb-3" id="departments_wrapper" style="display: none;">
<label for="departments" class="form-label">Departments</label>
<select name="departments[]" id="departments" class="form-select" multiple>
<option value="__all__" selected>All Departments</option>
</select>
<div class="form-text">
For Role 6 only. Keep <strong>All Departments</strong> selected to allow the entire faculty.
</div>
</div>
<div class="col-12 mb-3 form-password-toggle" id="password_field">
<label for="password" class="form-label">Password</label>
<div class="input-group input-group-merge">
<input
type="password"
name="password"
class="form-control"
placeholder="············"
aria-describedby="password"
>
<span class="input-group-text cursor-pointer"><i class="bx bx-hide"></i></span>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" id="submitBtn" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
<!-- Core JS -->
<script src="assets/vendor/libs/jquery/jquery.min.js"></script>
<script src="assets/vendor/js/bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/2.1.8/js/dataTables.js"></script>
<script src="https://cdn.datatables.net/2.1.8/js/dataTables.bootstrap5.js"></script>
<script src="assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script src="assets/vendor/libs/popper/popper.min.js"></script>
<script src="assets/vendor/js/menu.min.js"></script>
<!-- Main JS -->
<script src="assets/js/ui-toasts.js"></script>
<script src="assets/js/main.js"></script>
<script src="model/functions/admins.js"></script>
</body>
</html>