-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_clients.php
More file actions
147 lines (135 loc) · 7.22 KB
/
admin_clients.php
File metadata and controls
147 lines (135 loc) · 7.22 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
<?php
// admin_clients.php - Manage All Clients
require_once 'auth_check.php';
require_admin();
// Handle status changes
if (isset($_POST['update_status'])) {
$client_id = intval($_POST['client_id']);
$new_status = $_POST['status'];
$stmt = $conn->prepare("UPDATE staff SET status = ? WHERE id = ? AND role = 'client'");
$stmt->bind_param("si", $new_status, $client_id);
if ($stmt->execute()) {
set_flash_message("Client status updated successfully.", "success");
} else {
set_flash_message("Failed to update client status.", "error");
}
$stmt->close();
header("Location: admin_clients.php");
exit;
}
// Fetch all clients
$clients_query = "SELECT id, client_name, name, user_id, status
FROM staff
WHERE role = 'client'
ORDER BY id DESC";
$clients_result = $conn->query($clients_query);
// Check if query failed
if (!$clients_result) {
die("Query failed: " . $conn->error);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Manage Clients - DS Diamonds</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" />
<style>
body {
font-family: 'Inter', sans-serif;
}
</style>
</head>
<body class="bg-gray-50">
<?php include 'sidebar.php'; ?>
<div class="main-content ml-64 p-8">
<!-- Header -->
<div class="flex justify-between items-center mb-8">
<div>
<h1 class="text-3xl font-bold text-gray-800 mb-2">Manage Clients</h1>
<p class="text-gray-600">View and manage all client accounts</p>
</div>
<a href="staff_app.php"
class="bg-gradient-to-r from-purple-600 to-pink-600 text-white px-6 py-3 rounded-lg font-semibold hover:shadow-lg transition">
<i class="fas fa-user-plus mr-2"></i>Add New Client
</a>
</div>
<?php echo get_flash_message(); ?>
<!-- Clients Table -->
<div class="bg-white rounded-xl shadow-md overflow-hidden">
<div class="overflow-x-auto">
<table class="w-full">
<thead class="bg-gray-50 border-b border-gray-200">
<tr>
<th
class="px-6 py-4 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Company</th>
<th
class="px-6 py-4 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Contact Person</th>
<th
class="px-6 py-4 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Username</th>
<th
class="px-6 py-4 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Status</th>
<th
class="px-6 py-4 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
<?php while ($client = $clients_result->fetch_assoc()): ?>
<tr class="hover:bg-gray-50 transition">
<td class="px-6 py-4">
<div class="font-semibold text-gray-800"><?php echo h($client['client_name']); ?></div>
</td>
<td class="px-6 py-4">
<div class="text-gray-700"><?php echo h($client['name']); ?></div>
</td>
<td class="px-6 py-4">
<div class="text-gray-600 font-mono text-sm"><?php echo h($client['user_id']); ?></div>
</td>
<td class="px-6 py-4">
<form method="POST" class="inline">
<input type="hidden" name="client_id" value="<?php echo $client['id']; ?>">
<input type="hidden" name="update_status" value="1">
<select name="status" onchange="this.form.submit()"
class="text-xs px-3 py-1 rounded-full border-0 font-semibold cursor-pointer
<?php echo $client['status'] == 'Enable' ? 'bg-green-100 text-green-700' :
($client['status'] == 'Pending' ? 'bg-yellow-100 text-yellow-700' : 'bg-red-100 text-red-700'); ?>">
<option value="Enable" <?php echo $client['status'] == 'Enable' ? 'selected' : ''; ?>>Active</option>
<option value="Disable" <?php echo $client['status'] == 'Disable' ? 'selected' : ''; ?>>Disabled</option>
<option value="Pending" <?php echo $client['status'] == 'Pending' ? 'selected' : ''; ?>>Pending</option>
</select>
</form>
</td>
<td class="px-6 py-4">
<div class="flex gap-2">
<a href="staff_edit.php?id=<?php echo $client['id']; ?>"
class="text-blue-600 hover:text-blue-800 transition" title="Edit">
<i class="fas fa-edit"></i>
</a>
<a href="staff_reset_password.php?id=<?php echo $client['id']; ?>"
class="text-purple-600 hover:text-purple-800 transition" title="Reset Password">
<i class="fas fa-key"></i>
</a>
<a href="staff_delete.php?id=<?php echo $client['id']; ?>"
class="text-red-600 hover:text-red-800 transition" title="Delete"
onclick="return confirm('Are you sure you want to delete this client?');">
<i class="fas fa-trash"></i>
</a>
</div>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>