36834-vm/admin.php
Flatlogic Bot 51894f9e94 1.1.1.1.2
2025-12-11 09:14:46 +00:00

239 lines
11 KiB
PHP

<?php
// Admin PHP logic here (e.g., session check, database operations, etc.)
$pageTitle = "Admin Dashboard";
include 'includes/header.php';
?>
<main class="container">
<div class="dashboard-header">
<h1>Admin Dashboard</h1>
</div>
<!-- Analytics Section -->
<section class="analytics-cards">
<div class="card">
<h3>Total Users</h3>
<div class="stat"><?php echo $stats['total_users']; ?></div>
</div>
<div class="card" style="border-left-color: #28a745;">
<h3>KYC Approved</h3>
<div class="stat"><?php echo $stats['kyc_approved']; ?></div>
</div>
<div class="card" style="border-left-color: #ffc107;">
<h3>KYC Pending</h3>
<div class="stat"><?php echo $stats['kyc_pending']; ?></div>
</div>
<div class="card" style="border-left-color: #dc3545;">
<h3>KYC Rejected</h3>
<div class="stat"><?php echo $stats['kyc_rejected']; ?></div>
</div>
</section>
<!-- User Management Section -->
<section class="user-management">
<div class="user-management-header">
<h2>User Management</h2>
<button class="btn btn-primary" onclick="openModal('addUserModal')">Add User</button>
</div>
<?php if ($notification): ?>
<div class="alert alert-<?php echo $notification['type']; ?>" style="padding: 1rem; border-radius: 0.25rem; color: #fff; background-color: <?php echo $notification['type'] === 'success' ? '#28a745' : '#dc3545'; ?>; margin-bottom: 1rem;">
<?php echo $notification['message']; ?>
</div>
<?php endif; ?>
<div class="table-responsive">
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>KYC Status</th>
<th>Created At</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($users as $user): ?>
<tr>
<td><?php echo htmlspecialchars($user['id']); ?></td>
<td><?php echo htmlspecialchars($user['name']); ?></td>
<td><?php echo htmlspecialchars($user['email']); ?></td>
<td>
<span class="badge badge-<?php
$status = strtolower(htmlspecialchars($user['kyc_status']));
echo $status === 'approved' ? 'success' : ($status === 'pending' ? 'warning' : 'danger');
?>">
<?php echo htmlspecialchars($user['kyc_status']); ?>
</span>
</td>
<td><?php echo htmlspecialchars($user['created_at']); ?></td>
<td>
<button class="btn btn-secondary btn-sm edit-btn"
style="background: #6c757d; color: white"
data-id="<?php echo $user['id']; ?>"
data-name="<?php echo htmlspecialchars($user['name']); ?>"
data-email="<?php echo htmlspecialchars($user['email']); ?>"
data-kyc="<?php echo htmlspecialchars($user['kyc_status']); ?>">
Edit
</button>
<button class="btn btn-danger btn-sm delete-btn"
style="background: #dc3545; color: white"
data-id="<?php echo $user['id']; ?>">
Delete
</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</section>
</main>
<!-- Add User Modal -->
<div id="addUserModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h2>Add New User</h2>
<span class="close-button" onclick="closeModal('addUserModal')">&times;</span>
</div>
<form action="admin.php" method="POST">
<input type="hidden" name="action" value="add">
<div class="modal-body">
<div class="form-group">
<label for="name">Name</label>
<input type="text" id="name" name="name" required>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" name="email" required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" name="password" required>
</div>
<div class="form-group">
<label for="kyc_status">KYC Status</label>
<select id="kyc_status" name="kyc_status">
<option>Pending</option>
<option>Approved</option>
<option>Rejected</option>
</select>
</div>
</div>
<div class="modal-footer" style="text-align: right;">
<button type="button" class="btn btn-secondary" onclick="closeModal('addUserModal')" style="background: #6c757d; color: white">Close</button>
<button type="submit" class="btn btn-primary" style="background: #007bff; color: white;">Save User</button>
</div>
</form>
</div>
</div>
<!-- Edit User Modal -->
<div id="editUserModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h2>Edit User</h2>
<span class="close-button" onclick="closeModal('editUserModal')">&times;</span>
</div>
<form action="admin.php" method="POST">
<input type="hidden" name="action" value="edit">
<input type="hidden" name="id" id="edit-user-id">
<div class="modal-body">
<div class="form-group">
<label for="edit-name">Name</label>
<input type="text" id="edit-name" name="name" required>
</div>
<div class="form-group">
<label for="edit-email">Email</label>
<input type="email" id="edit-email" name="email" required>
</div>
<div class="form-group">
<label for="edit-kyc_status">KYC Status</label>
<select id="edit-kyc_status" name="kyc_status">
<option>Pending</option>
<option>Approved</option>
<option>Rejected</option>
</select>
</div>
<div class="form-group">
<label for="edit-password">New Password (optional)</label>
<input type="password" id="edit-password" name="password">
<small>Leave blank to keep the current password.</small>
</div>
</div>
<div class="modal-footer" style="text-align: right;">
<button type="button" class="btn btn-secondary" onclick="closeModal('editUserModal')" style="background: #6c757d; color: white">Close</button>
<button type="submit" class="btn btn-primary" style="background: #007bff; color: white;">Save Changes</button>
</div>
</form>
</div>
</div>
<!-- Delete User Modal -->
<div id="deleteUserModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h2>Delete User</h2>
<span class="close-button" onclick="closeModal('deleteUserModal')">&times;</span>
</div>
<form action="admin.php" method="POST">
<input type="hidden" name="action" value="delete">
<input type="hidden" name="id" id="delete-user-id">
<div class="modal-body">
<p>Are you sure you want to delete this user? This action cannot be undone.</p>
</div>
<div class="modal-footer" style="text-align: right;">
<button type="button" class="btn btn-secondary" onclick="closeModal('deleteUserModal')" style="background: #6c757d; color: white">Cancel</button>
<button type="submit" class="btn btn-danger" style="background: #dc3545; color: white">Delete User</button>
</div>
</form>
</div>
</div>
<footer style="text-align: center; padding: 2rem; margin-top: 2rem; background-color: #e9ecef;">
<p>&copy; <?php echo date("Y"); ?> AppCo. All Rights Reserved.</p>
</footer>
<script>
function openModal(id) {
document.getElementById(id).style.display = 'block';
}
function closeModal(id) {
document.getElementById(id).style.display = 'none';
}
// Close modal if user clicks outside of it
window.onclick = function(event) {
if (event.target.className === 'modal') {
event.target.style.display = 'none';
}
}
document.addEventListener('DOMContentLoaded', function() {
// Populate edit modal
document.querySelectorAll('.edit-btn').forEach(button => {
button.addEventListener('click', function() {
document.getElementById('edit-user-id').value = this.dataset.id;
document.getElementById('edit-name').value = this.dataset.name;
document.getElementById('edit-email').value = this.dataset.email;
document.getElementById('edit-kyc_status').value = this.dataset.kyc;
openModal('editUserModal');
});
});
// Populate delete modal
document.querySelectorAll('.delete-btn').forEach(button => {
button.addEventListener('click', function() {
document.getElementById('delete-user-id').value = this.dataset.id;
openModal('deleteUserModal');
});
});
});
</script>
</body>
</html>