-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview_user.php
More file actions
437 lines (394 loc) · 18.2 KB
/
view_user.php
File metadata and controls
437 lines (394 loc) · 18.2 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
<?php
session_start();
include 'db.php';
// Check if the user is logged in
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
header("Location: splash.php");
exit;
}
// Get user ID and ensure it's an integer
$userId = isset($_GET['id']) ? (int)$_GET['id'] : 0;
try {
// Prepare and execute the query
$stmt = $conn->prepare("SELECT * FROM user_accounts WHERE id = :id");
$stmt->bindParam(':id', $userId, PDO::PARAM_INT);
$stmt->execute();
// Fetch the user data
$userData = $stmt->fetch(PDO::FETCH_ASSOC);
// If no user is found, redirect
if (!$userData) {
$_SESSION['error_message'] = "User not found";
header("Location: users.php");
exit;
}
} catch (PDOException $e) {
$_SESSION['error_message'] = "Database error: " . $e->getMessage();
header("Location: users.php");
exit;
}
// Handle status update
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['status'])) {
try {
$newStatus = $_POST['status'];
if (in_array($newStatus, ['pending', 'verified', 'rejected'], true)) {
$updateStmt = $conn->prepare("UPDATE user_accounts SET status = ? WHERE id = ?");
$updateStmt->execute([$newStatus, $userId]);
$_SESSION['success_message'] = "Status updated successfully";
} else {
$_SESSION['error_message'] = "Invalid status value";
}
header("Location: users.php");
exit;
} catch (PDOException $e) {
$_SESSION['error_message'] = "Update failed: " . $e->getMessage();
header("Location: users.php");
exit;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>View User Details | Post Proper Southside</title>
<link rel="stylesheet" href="css/view_users.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<link rel="icon" type="image/png" href="assets/Southside.png">
</head>
<body>
<?php
$pageTitle = "Verify User";
include 'header.php'; ?>
<?php include 'sidebar.php'; ?>
<div class="main-container">
<div class="container">
<!-- Header Section -->
<div class="header-section">
<button onclick="history.back()" class="btn-secondary">
<i class="fas fa-arrow-left"></i>
<span>Back</span>
</button>
<h1 class="page-title">User Details</h1>
</div>
<!-- Main Content Grid -->
<div class="content-grid">
<!-- Left Column - Profile & ID -->
<div class="profile-column">
<!-- Profile Section -->
<div class="profile-section">
<div class="section-header">
<i class="fas fa-user"></i>
<h2>Profile Picture</h2>
</div>
<div class="profile-picture-container">
<?php if (!empty($userData['user_profile_picture'])): ?>
<img src="<?php echo htmlspecialchars($userData['user_profile_picture']); ?>"
alt="Profile Picture"
class="profile-image"
onclick="openImageModal(this.src)">
<?php else: ?>
<div class="no-profile-message">
<i class="fas fa-camera"></i>
<p>No profile picture uploaded</p>
</div>
<?php endif; ?>
</div>
</div>
<!-- ID Section -->
<div class="id-section mt-4">
<div class="section-header">
<i class="fas fa-id-card"></i>
<h2>Valid ID</h2>
</div>
<div class="id-grid">
<!-- Front ID -->
<div class="id-container">
<h3>Front</h3>
<?php if (!empty($userData['user_valid_id'])): ?>
<div class="id-image-wrapper" onclick="openImageModal('<?php echo htmlspecialchars($userData['user_valid_id']); ?>')">
<img src="<?php echo htmlspecialchars($userData['user_valid_id']); ?>"
alt="Valid ID Front"
class="id-image">
<div class="image-overlay">
<i class="fas fa-search-plus"></i>
</div>
</div>
<?php else: ?>
<div class="no-id-placeholder">
<i class="fas fa-id-card"></i>
<p>No front ID uploaded</p>
</div>
<?php endif; ?>
</div>
<!-- Back ID -->
<div class="id-container">
<h3>Back</h3>
<?php if (!empty($userData['user_valid_id_back'])): ?>
<div class="id-image-wrapper" onclick="openImageModal('<?php echo htmlspecialchars($userData['user_valid_id_back']); ?>')">
<img src="<?php echo htmlspecialchars($userData['user_valid_id_back']); ?>"
alt="Valid ID Back"
class="id-image">
<div class="image-overlay">
<i class="fas fa-search-plus"></i>
</div>
</div>
<?php else: ?>
<div class="no-id-placeholder">
<i class="fas fa-id-card"></i>
<p>No back ID uploaded</p>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<!-- Right Column - User Details -->
<div class="details-column">
<div class="details-card">
<div class="details-grid">
<!-- Personal Information Section -->
<div class="info-section">
<h2>Personal Information</h2>
<div class="info-group">
<label>Full Name</label>
<div class="info-value">
<i class="fas fa-user"></i>
<?php echo htmlspecialchars($userData['firstName'] . ' ' . $userData['lastName']); ?>
</div>
</div>
<div class="info-group">
<label>Username</label>
<div class="info-value">
<i class="fas fa-at"></i>
<?php echo htmlspecialchars($userData['username']); ?>
</div>
</div>
<div class="info-group">
<label>Address</label>
<div class="info-value">
<i class="fas fa-map-marker-alt"></i>
<?php
$address = $userData['adrHouseNo'] . ' ' . $userData['adrStreet'] . ', Zone ' . $userData['adrZone'];
echo htmlspecialchars($address);
?>
</div>
</div>
<div class="info-group">
<label>Birthdate</label>
<div class="info-value">
<i class="fas fa-birthday-cake"></i>
<?php echo date('F d, Y', strtotime($userData['birthday'])); ?>
</div>
</div>
</div>
<!-- Account Information Section -->
<div class="info-section">
<h2>Account Information</h2>
<div class="info-group">
<label>Last Active</label>
<div class="info-value">
<i class="fas fa-clock"></i>
<?php echo $userData['last_active'] ? date('F d, Y g:i A', strtotime($userData['last_active'])) : 'Never'; ?>
</div>
</div>
<?php
// Calculate age
$birthDate = new DateTime($userData['birthday']);
$today = new DateTime('today');
$age = $birthDate->diff($today)->y;
?>
<div class="info-group">
<label>Age</label>
<div class="info-value">
<i class="fas fa-user-clock"></i>
<?php echo $age; ?> years old
</div>
</div>
<div class="info-group">
<label>Account Status</label>
<form method="POST" id="statusForm">
<div class="status-select-wrapper">
<select name="status" class="status-select" id="statusSelect">
<option value="pending" <?php echo ($userData['status'] === 'pending') ? 'selected' : ''; ?>>
Pending
</option>
<option value="verified" <?php echo ($userData['status'] === 'verified') ? 'selected' : ''; ?>>
Verified
</option>
<option value="rejected" <?php echo ($userData['status'] === 'rejected') ? 'selected' : ''; ?>>
Rejected
</option>
</select>
<i class="fas fa-chevron-down select-icon"></i>
</div>
</form>
</div>
<div class="button-container">
<button class="btn-save" onclick="confirmUpdate()">
<i class="fas fa-save"></i>
Save Changes
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Image Preview Modal -->
<div id="imageModal" class="modal image-modal">
<div class="modal-content">
<div class="modal-header">
<h3>Image Preview</h3>
<div class="modal-controls">
<button class="zoom-btn" onclick="zoomIn()" title="Zoom In">
<i class="fas fa-search-plus"></i>
</button>
<button class="zoom-btn" onclick="zoomOut()" title="Zoom Out">
<i class="fas fa-search-minus"></i>
</button>
<button class="zoom-btn" onclick="resetZoom()" title="Reset">
<i class="fas fa-sync-alt"></i>
</button>
<button class="close-modal" onclick="closeImageModal()" title="Close">
<i class="fas fa-times"></i>
</button>
</div>
</div>
<div class="modal-body">
<div class="image-container" id="imageContainer">
<img id="modalImage" src="" alt="Preview" draggable="false">
</div>
</div>
</div>
</div>
<!-- Confirm Changes Modal -->
<div id="confirmModal" class="modal confirm-modal">
<div class="modal-content">
<div class="modal-header">
<h3>Confirm Changes</h3>
<button class="close-modal" onclick="closeConfirmModal()">
<i class="fas fa-times"></i>
</button>
</div>
<div class="modal-body">
<p>Are you sure you want to update this user's status?</p>
<div class="modal-buttons">
<button class="btn-cancel" onclick="closeConfirmModal()">Cancel</button>
<button class="btn-confirm" onclick="submitForm()">Confirm</button>
</div>
</div>
</div>
</div>
<script>
let currentZoom = 1;
const ZOOM_STEP = 0.5;
const MAX_ZOOM = 4;
const MIN_ZOOM = 1;
let isDragging = false;
let startX, startY, translateX = 0, translateY = 0;
// Open image modal
function openImageModal(src) {
const modalImage = document.getElementById('modalImage');
const imageContainer = document.getElementById('imageContainer');
modalImage.src = src;
document.getElementById('imageModal').classList.add('show');
resetZoom();
// Reset transform when opening new image
imageContainer.style.transform = 'translate(0, 0)';
translateX = 0;
translateY = 0;
}
// Close image modal
function closeImageModal() {
document.getElementById('imageModal').classList.remove('show');
resetZoom();
}
// Zoom in
function zoomIn() {
if (currentZoom < MAX_ZOOM) {
currentZoom += ZOOM_STEP;
updateZoom();
}
}
// Zoom out
function zoomOut() {
if (currentZoom > MIN_ZOOM) {
currentZoom -= ZOOM_STEP;
updateZoom();
}
}
// Reset zoom
function resetZoom() {
currentZoom = 1;
updateZoom();
const imageContainer = document.getElementById('imageContainer');
imageContainer.style.transform = 'translate(0, 0)';
translateX = 0;
translateY = 0;
}
// Update zoom level
function updateZoom() {
const modalImage = document.getElementById('modalImage');
modalImage.style.transform = `scale(${currentZoom})`;
}
// Mouse down handler
function handleMouseDown(e) {
if (currentZoom > 1) {
isDragging = true;
startX = e.clientX - translateX;
startY = e.clientY - translateY;
document.getElementById('imageContainer').style.cursor = 'grabbing';
}
}
// Mouse move handler
function handleMouseMove(e) {
if (!isDragging) return;
translateX = e.clientX - startX;
translateY = e.clientY - startY;
const imageContainer = document.getElementById('imageContainer');
imageContainer.style.transform = `translate(${translateX}px, ${translateY}px)`;
}
// Mouse up handler
function handleMouseUp() {
isDragging = false;
document.getElementById('imageContainer').style.cursor = 'grab';
}
// Add event listeners for dragging
document.getElementById('imageContainer').addEventListener('mousedown', handleMouseDown);
document.addEventListener('mousemove', handleMouseMove);
document.addEventListener('mouseup', handleMouseUp);
// Mouse wheel zoom
document.getElementById('modalBody').addEventListener('wheel', function(e) {
e.preventDefault();
if (e.deltaY < 0) {
zoomIn();
} else {
zoomOut();
}
});
// Confirmation modal functions
function confirmUpdate() {
document.getElementById('confirmModal').classList.add('show');
}
function closeConfirmModal() {
document.getElementById('confirmModal').classList.remove('show');
}
function submitForm() {
document.getElementById('statusForm').submit();
}
// Close modals when clicking outside
window.onclick = function(event) {
if (event.target.classList.contains('modal')) {
if (event.target.id === 'imageModal') {
closeImageModal();
} else if (event.target.id === 'confirmModal') {
closeConfirmModal();
}
}
}
</script>
</body>
</html>