94 lines
4.7 KiB
PHP
94 lines
4.7 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
try {
|
|
$pdo = db();
|
|
|
|
// Fetch claimed listings
|
|
$sql_listings = "SELECT id, name, quantity, pickup_by FROM food_listings WHERE status = 'claimed' ORDER BY pickup_by ASC";
|
|
$stmt_listings = $pdo->query($sql_listings);
|
|
$listings = $stmt_listings->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
// Simulate a logged-in volunteer by fetching the first volunteer
|
|
$sql_volunteer = "SELECT id, name FROM volunteers ORDER BY id ASC LIMIT 1";
|
|
$stmt_volunteer = $pdo->query($sql_volunteer);
|
|
$volunteer = $stmt_volunteer->fetch(PDO::FETCH_ASSOC);
|
|
|
|
} catch (PDOException $e) {
|
|
$listings = [];
|
|
$volunteer = false;
|
|
// error_log($e->getMessage());
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Volunteer Hub - Food Rescue</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
|
|
<style>
|
|
body { font-family: 'Poppins', sans-serif; background-color: #f8f9fa; }
|
|
.navbar { box-shadow: 0 2px 4px rgba(0,0,0,.1); }
|
|
.card { border-radius: 0.5rem; border: none; box-shadow: 0 4px 8px rgba(0,0,0,.1); }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-white sticky-top">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand" href="index.php" style="font-weight: 600;">Food Rescue</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"><span class="navbar-toggler-icon"></span></button>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav ms-auto">
|
|
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="add_listing.php">Add Listing</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="ngo_dashboard.php">NGO Dashboard</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="volunteer_signup.php">Volunteer Signup</a></li>
|
|
<li class="nav-item"><a class="nav-link active" href="volunteer_hub.php">Volunteer Hub</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="distribution_map.php">Distribution Map</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="ngo_signup.php">NGO Signup</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="container my-5">
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h1 class="h2">Available for Pickup</h1>
|
|
<?php if ($volunteer): ?>
|
|
<span class="badge bg-primary">Logged in as: <?= htmlspecialchars($volunteer['name']) ?></span>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php if (!$volunteer): ?>
|
|
<div class="alert alert-warning">Please <a href="volunteer_signup.php">sign up as a volunteer</a> to see and accept pickups.</div>
|
|
<?php elseif (empty($listings)): ?>
|
|
<div class="card p-5 text-center">
|
|
<p class="mb-0 text-muted">There are no donations ready for pickup right now.</p>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="list-group">
|
|
<?php foreach ($listings as $listing): ?>
|
|
<div class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<h5 class="mb-1"><?= htmlspecialchars($listing['name']) ?> (<?= htmlspecialchars($listing['quantity']) ?>)</h5>
|
|
<small>Pickup by: <?= date('M d, Y h:i A', strtotime($listing['pickup_by'])) ?></small>
|
|
</div>
|
|
<form action="assign_pickup.php" method="POST">
|
|
<input type="hidden" name="listing_id" value="<?= $listing['id'] ?>">
|
|
<input type="hidden" name="volunteer_id" value="<?= $volunteer['id'] ?>">
|
|
<button type="submit" class="btn btn-sm btn-info">Assign to Me</button>
|
|
</form>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|