-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_client_requests.php
More file actions
160 lines (143 loc) · 7.35 KB
/
admin_client_requests.php
File metadata and controls
160 lines (143 loc) · 7.35 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
<?php
// admin_client_requests.php - Review Pending Client Requests
require_once 'auth_check.php';
require_admin();
// Handle approval/rejection
if (isset($_POST['action'])) {
$client_id = intval($_POST['client_id']);
$action = $_POST['action'];
if ($action == 'approve') {
$stmt = $conn->prepare("UPDATE staff SET status = 'Enable' WHERE id = ? AND role = 'client'");
$stmt->bind_param("i", $client_id);
if ($stmt->execute()) {
set_flash_message("Client approved successfully!", "success");
// TODO: Send approval email
}
$stmt->close();
} elseif ($action == 'reject') {
$stmt = $conn->prepare("UPDATE staff SET status = 'Disable' WHERE id = ? AND role = 'client'");
$stmt->bind_param("i", $client_id);
if ($stmt->execute()) {
set_flash_message("Client request rejected.", "info");
// TODO: Send rejection email
}
$stmt->close();
}
header("Location: admin_client_requests.php");
exit;
}
// Fetch pending requests
$pending_query = "SELECT id, client_name, name, user_id
FROM staff
WHERE role = 'client' AND status = 'Pending'
ORDER BY id DESC";
$pending_result = $conn->query($pending_query);
// Check if query failed
if (!$pending_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>Client Requests - 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="mb-8">
<h1 class="text-3xl font-bold text-gray-800 mb-2">Client Requests</h1>
<p class="text-gray-600">Review and approve pending client registration requests</p>
</div>
<?php echo get_flash_message(); ?>
<?php if ($pending_result->num_rows == 0): ?>
<!-- Empty State -->
<div class="bg-white rounded-xl shadow-md p-12 text-center">
<i class="fas fa-check-circle text-6xl text-green-500 mb-4"></i>
<h2 class="text-2xl font-bold text-gray-800 mb-2">All Caught Up!</h2>
<p class="text-gray-600">No pending client requests at the moment.</p>
</div>
<?php else: ?>
<!-- Requests Grid -->
<div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
<?php while ($request = $pending_result->fetch_assoc()): ?>
<div class="bg-white rounded-xl shadow-md overflow-hidden hover:shadow-lg transition">
<!-- Header -->
<div class="bg-gradient-to-r from-yellow-400 to-orange-500 p-4 text-white">
<div class="flex items-center justify-between">
<div class="flex items-center">
<i class="fas fa-building text-2xl mr-3"></i>
<div>
<div class="font-bold text-lg"><?php echo h($request['client_name']); ?></div>
<div class="text-sm opacity-90">Pending Review</div>
</div>
</div>
<span class="bg-white/20 px-3 py-1 rounded-full text-xs font-semibold">NEW</span>
</div>
</div>
<!-- Details -->
<div class="p-6">
<div class="space-y-3 mb-6">
<div class="flex items-start">
<i class="fas fa-user text-gray-400 mt-1 mr-3 w-4"></i>
<div>
<div class="text-xs text-gray-500 uppercase">Contact Person</div>
<div class="font-semibold text-gray-800"><?php echo h($request['name']); ?></div>
</div>
</div>
<div class="flex items-start">
<i class="fas fa-user-circle text-gray-400 mt-1 mr-3 w-4"></i>
<div>
<div class="text-xs text-gray-500 uppercase">Username</div>
<div class="font-mono text-sm text-gray-800"><?php echo h($request['user_id']); ?></div>
</div>
</div>
<div class="flex items-start">
<i class="fas fa-id-badge text-gray-400 mt-1 mr-3 w-4"></i>
<div>
<div class="text-xs text-gray-500 uppercase">Client ID</div>
<div class="text-sm text-gray-800">
#<?php echo $request['id']; ?>
</div>
</div>
</div>
</div>
<!-- Actions -->
<div class="flex gap-3">
<form method="POST" class="flex-1">
<input type="hidden" name="client_id" value="<?php echo $request['id']; ?>">
<input type="hidden" name="action" value="approve">
<button type="submit"
class="w-full bg-gradient-to-r from-green-500 to-green-600 text-white py-2 px-4 rounded-lg font-semibold hover:shadow-lg transition">
<i class="fas fa-check mr-2"></i>Approve
</button>
</form>
<form method="POST" class="flex-1">
<input type="hidden" name="client_id" value="<?php echo $request['id']; ?>">
<input type="hidden" name="action" value="reject">
<button type="submit"
class="w-full bg-gradient-to-r from-red-500 to-red-600 text-white py-2 px-4 rounded-lg font-semibold hover:shadow-lg transition"
onclick="return confirm('Are you sure you want to reject this request?');">
<i class="fas fa-times mr-2"></i>Reject
</button>
</form>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
</div>
</body>
</html>