File: /home/awaldron/_accomods/apidev.accomods.com/admin/users.php
<?php
include '_helpers.php';
$accessSet = 0;
if (isset($_GET['access'])) {
$accessSet = set_user_access( $_GET['access'], $_GET['uid'] );
}
// GET THE USERS
$db = connectDB();
$sql = "SELECT id, email, fname, lname, phone, school_code, school_name, expires, access, date_registered FROM users ORDER BY lname ASC, fname ASC";
$result = $db->query($sql);
include '_header.php';
?>
<style>
.btn { font-size: 12px; padding: 2px 8px; }
table { margin-bottom: 100px; }
tr.striked td { color: #777; text-decoration: line-through; }
td.expired { color: #CC0000; font-weight: bold; }
</style>
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1>Manage Users</h1>
<p><a href="/admin">Back to Admin Panel</a></p>
<hr/>
<p><a href="/admin/users_edit.php?uid=new" class="btn btn-success">Create New User</a></p>
<?php
if ($accessSet === 1) { echo '<div class="alert alert-success"><b>User '.($_GET['access']==0 ? 'Disabled' : 'Enabled').' Successfully</b></div>'; }
if ($accessSet === -1) { echo '<div class="alert alert-danger"><b>User Update Failed - Please Try Again</b></div>'; }
?>
<table class="table table-striped table-hover" style="font-size:14px;">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Last</th>
<th scope="col">First</th>
<th scope="col">Email</th>
<th scope="col">Phone</th>
<th scope="col">School</th>
<th scope="col">Expires</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
<?php
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$expires = str_replace('-', '', $row['expires']);
$today = date('Ymd');
$expired = $today > $expires;
echo '<tr class="'.($row['access']==0 ? 'striked' : '').'">';
echo '<td>'.$row['id'].'</td>';
echo '<td>'.$row['lname'].'</td>';
echo '<td>'.$row['fname'].'</td>';
echo '<td>'.$row['email'].'</td>';
echo '<td>'.$row['phone'].'</td>';
echo '<td>'.$row['school_name'].'</td>';
echo '<td nowrap="nowrap" class="'.($expired ? 'expired' : '').'">'.$row['expires'].'</td>';
echo '<td nowrap="nowrap">';
echo '<a href="/admin/users_edit.php?uid='.$row['id'].'" class="btn btn-success btn-sm">Edit</a> ';
if ($row['access']==1) echo '<a href="/admin/users.php?access=0&uid='.$row['id'].'" class="btn btn-danger btn-sm">Disable</a>';
if ($row['access']==0) echo '<a href="/admin/users.php?access=1&uid='.$row['id'].'" class="btn btn-primary btn-sm">Re-Enable</a>';
echo '</td>';
echo '</tr>';
}
} else {
echo "0 results";
}
?>
</tbody>
</table>
</div>
</div>
</div>
<?php
$db->close();
include '_footer.php';
?>