prepare($sql_volunteer); $stmt_volunteer->bindParam(':volunteer_id', $volunteer_id, PDO::PARAM_INT); $stmt_volunteer->execute(); $volunteer = $stmt_volunteer->fetch(PDO::FETCH_ASSOC); // Fetch listings assigned to this volunteer $sql_listings = "SELECT l.id, l.name, l.quantity, l.status, l.pickup_by, n.name as ngo_name FROM food_listings as l JOIN volunteer_assignments as va ON l.id = va.listing_id LEFT JOIN ngos as n ON l.ngo_id = n.id WHERE va.volunteer_id = :volunteer_id ORDER BY l.pickup_by DESC"; $stmt_listings = $pdo->prepare($sql_listings); $stmt_listings->bindParam(':volunteer_id', $volunteer_id, PDO::PARAM_INT); $stmt_listings->execute(); $assignments = $stmt_listings->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $volunteer = false; $assignments = []; // error_log($e->getMessage()); } function getStatusBadge($status) { $badges = [ 'assigned' => 'Assigned', 'collected' => 'Collected', 'en-route' => 'En Route', 'delivered' => 'Delivered', ]; return $badges[$status] ?? 'Unknown'; } function getNextAction($status, $listing_id) { $actions = [ 'assigned' => '', 'collected' => '', 'en-route' => '', ]; if (isset($actions[$status])) { return '
'; } return '-'; } ?>You have no assigned pickups. Visit the Volunteer Hub to find available jobs.
| Food Item | Destination NGO | Pickup By | Status | Action |
|---|---|---|---|---|
| = htmlspecialchars($assignment['name']) ?> | = htmlspecialchars($assignment['ngo_name']) ?> | = date('M d, Y h:i A', strtotime($assignment['pickup_by'])) ?> | = getStatusBadge($assignment['status']) ?> | = getNextAction($assignment['status'], $assignment['id']) ?> |