prepare($sql_ngo); $stmt_ngo->bindParam(':ngo_id', $ngo_id, PDO::PARAM_INT); $stmt_ngo->execute(); $ngo = $stmt_ngo->fetch(PDO::FETCH_ASSOC); // Fetch listings claimed by this NGO $sql_listings = "SELECT l.id, l.name, l.quantity, l.status, l.pickup_by, v.name as volunteer_name FROM food_listings as l LEFT JOIN volunteer_assignments as va ON l.id = va.listing_id LEFT JOIN volunteers as v ON va.volunteer_id = v.id WHERE l.ngo_id = :ngo_id ORDER BY l.pickup_by DESC"; $stmt_listings = $pdo->prepare($sql_listings); $stmt_listings->bindParam(':ngo_id', $ngo_id, PDO::PARAM_INT); $stmt_listings->execute(); $listings = $stmt_listings->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $ngo = false; $listings = []; // error_log($e->getMessage()); } function getStatusBadge($status) { switch ($status) { case 'claimed': return 'Awaiting Volunteer'; case 'assigned': return 'Volunteer Assigned'; case 'collected': return 'Collected'; default: return 'Unknown'; } } ?>
You have not claimed any donations yet. Visit the public listings to find available food.
| Food Item | Quantity | Pickup By | Status | Volunteer |
|---|---|---|---|---|
| = htmlspecialchars($listing['name']) ?> | = htmlspecialchars($listing['quantity']) ?> | = date('M d, Y h:i A', strtotime($listing['pickup_by'])) ?> | = getStatusBadge($listing['status']) ?> | = $listing['volunteer_name'] ? htmlspecialchars($listing['volunteer_name']) : '-' ?> |