Spaces:
Configuration error
Configuration error
Download verifications.php from brucelloyd1/lost-found-tracker-pro: direct link, hf CLI and curl.
- Browser
- Download file 13.6 kB
-
https://huggingface.co/spaces/brucelloyd1/lost-found-tracker-pro/resolve/main/verifications.php
- Command line
-
hf download hf://spaces/brucelloyd1/lost-found-tracker-pro/verifications.php
-
curl -L -o verifications.php https://huggingface.co/spaces/brucelloyd1/lost-found-tracker-pro/resolve/main/verifications.php
13.6 kB
| ```php | |
| include 'includes/auth.php'; | |
| redirectIfNotAdmin(); | |
| include 'config/database.php'; | |
| $db = new Database(); | |
| $connection = $db->getConnection(); | |
| // Handle verification actions | |
| if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
| $verificationID = $_POST['verificationID']; | |
| $result = $_POST['result']; | |
| $notes = $_POST['notes'] ?? ''; | |
| $adminId = $_SESSION['admin_id']; | |
| try { | |
| $connection->beginTransaction(); | |
| // Update verification | |
| $updateQuery = "UPDATE verifications SET result = :result, notes = :notes, adminId = :adminId, vDate = NOW() | |
| WHERE verificationID = :verificationID"; | |
| $updateStmt = $connection->prepare($updateQuery); | |
| $updateStmt->bindParam(':result', $result); | |
| $updateStmt->bindParam(':notes', $notes); | |
| $updateStmt->bindParam(':adminId', $adminId); | |
| $updateStmt->bindParam(':verificationID', $verificationID); | |
| $updateStmt->execute(); | |
| // Get verification details for notifications | |
| $detailsQuery = "SELECT v.reportID, v.itemID, r.userId, i.description | |
| FROM verifications v | |
| JOIN reports r ON v.reportID = r.reportID | |
| JOIN items i ON v.itemID = i.itemID | |
| WHERE v.verificationID = :verificationID"; | |
| $detailsStmt = $connection->prepare($detailsQuery); | |
| $detailsStmt->bindParam(':verificationID', $verificationID); | |
| $detailsStmt->execute(); | |
| $details = $detailsStmt->fetch(PDO::FETCH_ASSOC); | |
| // Update report status | |
| $reportStatus = $result == 'approved' ? 'verified' : 'rejected'; | |
| $reportQuery = "UPDATE reports SET status = :status WHERE reportID = :reportID"; | |
| $reportStmt = $connection->prepare($reportQuery); | |
| $reportStmt->bindParam(':status', $reportStatus); | |
| $reportStmt->bindParam(':reportID', $details['reportID']); | |
| $reportStmt->execute(); | |
| // Update item status | |
| $itemStatus = $result == 'approved' ? 'available' : 'lost'; | |
| $itemQuery = "UPDATE items SET status = :status WHERE itemID = :itemID"; | |
| $itemStmt = $connection->prepare($itemQuery); | |
| $itemStmt->bindParam(':status', $itemStatus); | |
| $itemStmt->bindParam(':itemID', $details['itemID']); | |
| $itemStmt->execute(); | |
| // Create notification | |
| $message = $result == 'approved' | |
| ? "Your report #{$details['reportID']} for '{$details['description']}' has been approved. The item is now available for claiming." | |
| : "Your report #{$details['reportID']} for '{$details['description']}' has been rejected. Reason: $notes"; | |
| $notificationQuery = "INSERT INTO notifications (userId, message) VALUES (:userId, :message)"; | |
| $notificationStmt = $connection->prepare($notificationQuery); | |
| $notificationStmt->bindParam(':userId', $details['userId']); | |
| $notificationStmt->bindParam(':message', $message); | |
| $notificationStmt->execute(); | |
| $connection->commit(); | |
| $success = "Verification updated successfully!"; | |
| } catch (Exception $e) { | |
| $connection->rollBack(); | |
| $error = "Error updating verification: " . $e->getMessage(); | |
| } | |
| } | |
| // Get pending verifications | |
| $verificationsQuery = " | |
| SELECT v.*, r.locationFound, r.notes as reportNotes, i.description, i.category, i.imagePath, | |
| u.name as finderName, u.email as finderEmail | |
| FROM verifications v | |
| JOIN reports r ON v.reportID = r.reportID | |
| JOIN items i ON v.itemID = i.itemID | |
| JOIN users u ON r.userId = u.userId | |
| WHERE v.result = 'pending' | |
| ORDER BY v.vDate ASC | |
| "; | |
| $verificationsStmt = $connection->prepare($verificationsQuery); | |
| $verificationsStmt->execute(); | |
| $pendingVerifications = $verificationsStmt->fetchAll(PDO::FETCH_ASSOC); | |
| // Get pending claims | |
| $claimsQuery = " | |
| SELECT c.*, i.description, i.category, i.imagePath, u.name as ownerName, u.email as ownerEmail | |
| FROM claims c | |
| JOIN items i ON c.itemID = i.itemID | |
| JOIN users u ON c.ownerUserId = u.userId | |
| WHERE c.status = 'pending' | |
| ORDER BY c.createdAt ASC | |
| "; | |
| $claimsStmt = $connection->prepare($claimsQuery); | |
| $claimsStmt->execute(); | |
| $pendingClaims = $claimsStmt->fetchAll(PDO::FETCH_ASSOC); | |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Verifications - Lost & Found</title> | |
| <link rel="stylesheet" href="style.css"> | |
| </head> | |
| <body> | |
| <header> | |
| <div class="container"> | |
| <nav> | |
| <div class="logo">Lost & Found Pro</div> | |
| <ul class="nav-links"> | |
| <li><a href="home.php">Home</a></li> | |
| <li><a href="dashboard.php">Dashboard</a></li> | |
| <li><a href="admin.php">Admin</a></li> | |
| <li><a href="verifications.php">Verifications</a></li> | |
| <li><a href="storage.php">Storage</a></li> | |
| <li><a href="notifications.php">Notifications</a></li> | |
| <li><a href="profile.php">Profile</a></li> | |
| <li><a href="logout.php">Logout</a></li> | |
| </ul> | |
| </nav> | |
| </div> | |
| </header> | |
| <main class="container"> | |
| <div class="card"> | |
| <div class="card-header"> | |
| <h1>Verification Queue</h1> | |
| <p>Review and approve/reject pending verifications and claims</p> | |
| </div> | |
| <?php if (isset($success)): ?> | |
| <div style="background: #D1FAE5; color: #065F46; padding: 1rem; border-radius: 5px; margin-bottom: 1rem;"> | |
| <?php echo $success; ?> | |
| </div> | |
| <?php endif; ?> | |
| <?php if (isset($error)): ?> | |
| <div style="background: #FEE2E2; color: #DC2626; padding: 1rem; border-radius: 5px; margin-bottom: 1rem;"> | |
| <?php echo $error; ?> | |
| </div> | |
| <?php endif; ?> | |
| <!-- Pending Report Verifications --> | |
| <div class="mt-4"> | |
| <h3>Pending Report Verifications (<?php echo count($pendingVerifications); ?>)</h3> | |
| <?php if (empty($pendingVerifications)): ?> | |
| <p>No pending verifications.</p> | |
| <?php else: ?> | |
| <?php foreach ($pendingVerifications as $verification): ?> | |
| <div class="card mt-2"> | |
| <div class="row"> | |
| <div class="col-3"> | |
| <?php if ($verification['imagePath']): ?> | |
| <img src="<?php echo $verification['imagePath']; ?>" alt="<?php echo $verification['description']; ?>" | |
| style="width: 100%; height: 150px; object-fit: cover; border-radius: 5px;"> | |
| <?php else: ?> | |
| <div style="width: 100%; height: 150px; background: #e9ecef; display: flex; align-items: center; justify-content: center; border-radius: 5px;"> | |
| <span>No Image</span> | |
| </div> | |
| <?php endif; ?> | |
| </div> | |
| <div class="col-6"> | |
| <h4><?php echo $verification['category']; ?></h4> | |
| <p><strong>Description:</strong> <?php echo $verification['description']; ?></p> | |
| <p><strong>Found Location:</strong> <?php echo $verification['locationFound']; ?></p> | |
| <p><strong>Reported by:</strong> <?php echo $verification['finderName']; ?> (<?php echo $verification['finderEmail']; ?>)</p> | |
| <p><strong>Report Notes:</strong> <?php echo $verification['reportNotes']; ?></p> | |
| </div> | |
| <div class="col-3"> | |
| <form method="POST"> | |
| <input type="hidden" name="verificationID" value="<?php echo $verification['verificationID']; ?>"> | |
| <div class="form-group"> | |
| <label>Action:</label> | |
| <select name="result" class="form-control" required> | |
| <option value="approved">Approve</option> | |
| <option value="rejected">Reject</option> | |
| </select> | |
| </div> | |
| <div class="form-group"> | |
| <label>Notes:</label> | |
| <textarea name="notes" class="form-control" rows="3" placeholder="Additional notes..."></textarea> | |
| </div> | |
| <button type="submit" class="btn btn-primary w-full">Submit Verification</button> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| <?php endforeach; ?> | |
| <?php endif; ?> | |
| </div> | |
| <!-- Pending Claims --> | |
| <div class="mt-4"> | |
| <h3>Pending Claims (<?php echo count($pendingClaims); ?>)</h3> | |
| <?php if (empty($pendingClaims)): ?> | |
| <p>No pending claims.</p> | |
| <?php else: ?> | |
| <?php foreach ($pendingClaims as $claim): ?> | |
| <div class="card mt-2"> | |
| <div class="row"> | |
| <div class="col-3"> | |
| <?php if ($claim['imagePath']): ?> | |
| <img src="<?php echo $claim['imagePath']; ?>" alt="<?php echo $claim['description']; ?>" | |
| style="width: 100%; height: 150px; object-fit: cover; border-radius: 5px;"> | |
| <?php else: ?> | |
| <div style="width: 100%; height: 150px; background: #e9ecef; display: flex; align-items: center; justify-content: center; border-radius: 5px;"> | |
| <span>No Image</span> | |
| </div> | |
| <?php endif; ?> | |
| </div> | |
| <div class="col-6"> | |
| <h4><?php echo $claim['category']; ?></h4> | |
| <p><strong>Description:</strong> <?php echo $claim['description']; ?></p> | |
| <p><strong>Claimed by:</strong> <?php echo $claim['ownerName']; ?> (<?php echo $claim['ownerEmail']; ?>)</p> | |
| <?php if ($claim['proofPath']): ?> | |
| <p><strong>Proof Provided:</strong> | |
| <a href="<?php echo $claim['proofPath']; ?>" target="_blank">View Proof</a> | |
| </p> | |
| <?php endif; ?> | |
| <p><strong>Claim Date:</strong> <?php echo date('M j, Y g:i A', strtotime($claim['createdAt'])); ?></p> | |
| </div> | |
| <div class="col-3"> | |
| <form method="POST" action="process_claim.php"> | |
| <input type="hidden" name="claimID" value="<?php echo $claim['claimId']; ?>"> | |
| <div class="form-group"> | |
| <label>Action:</label> | |
| <select name="status" class="form-control" required> | |
| <option value="approved">Approve Claim</option> | |
| <option value="rejected">Reject Claim</option> | |
| </select> | |
| </div> | |
| <div class="form-group"> | |
| <label>Notes:</label> | |
| <textarea name="notes" class="form-control" rows="3" placeholder="Reason for decision..."></textarea> | |
| </div> | |
| <button type="submit" class="btn btn-primary w-full">Process Claim</button> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| <?php endforeach; ?> | |
| <?php endif; ?> | |
| </div> | |
| </div> | |
| </main> | |
| <footer> | |
| <div class="container"> | |
| <div class="footer-content"> | |
| <div class="logo">Lost & Found Pro</div> | |
| <p>© 2024 Lost & Found Management System. All rights reserved.</p> | |
| </div> | |
| </div> | |
| </footer> | |
| </body> | |
| </html> | |
| ``` |