-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage_donations.php
125 lines (108 loc) · 3.87 KB
/
manage_donations.php
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
<?php
session_start();
// Database connection
$mysqli = new mysqli("localhost", "root", "", "platepromise");
if ($mysqli->connect_error) {
die("Connection failed: " . $mysqli->connect_error);
}
// Fetch all donations from the current restaurant
$restaurant_id = $_SESSION['restaurant_id']; // Assume the restaurant ID is stored in session
$query = "SELECT * FROM food_donations WHERE restaurant_id = ?";
$stmt = $mysqli->prepare($query);
$stmt->bind_param("i", $restaurant_id);
$stmt->execute();
$result = $stmt->get_result();
// Fetch all data for displaying
$donations = [];
while ($row = $result->fetch_assoc()) {
$donations[] = $row;
}
// Close the database connection
$mysqli->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Manage Donations</title>
<link rel="icon" href="Screenshot 2024-11-23 154406.png" type="image/x-icon" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<style>
body {
background-color: #000;
color: white;
font-family: Arial, sans-serif;
padding: 50px;
}
.table {
background-color: rgba(0, 0, 0, 0.7);
border-radius: 10px;
}
.table th,
.table td {
text-align: center;
color: white;
}
.btn-custom {
background-color: #ff5722;
color: white;
padding: 10px 20px;
border-radius: 5px;
}
.btn-custom:hover {
background-color: #e64a19;
}
.btn-delete {
background-color: #f44336;
}
.btn-delete:hover {
background-color: #d32f2f;
}
</style>
</head>
<body>
<div class="container">
<h1 class="display-4 text-center">Manage Donations</h1>
<p class="lead text-center">Here you can view, edit or delete your food donations.</p>
<!-- Donations Table -->
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Food Name</th>
<th>Quantity (kg)</th>
<th>Description</th>
<th>Location</th>
<th>Contact Person</th>
<th>Contact Number</th>
<th>Donation Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
if (count($donations) > 0) {
foreach ($donations as $donation) {
echo "<tr>
<td>{$donation['food_name']}</td>
<td>{$donation['quantity']}</td>
<td>{$donation['description']}</td>
<td>{$donation['location']}</td>
<td>{$donation['contact_person']}</td>
<td>{$donation['contact_number']}</td>
<td>{$donation['donation_date']}</td>
<td>
<a href='edit_donation.php?id={$donation['id']}' class='btn btn-custom'>Edit</a>
<a href='delete_donation.php?id={$donation['id']}' class='btn btn-delete' onclick='return confirm(\"Are you sure you want to delete this donation?\");'>Delete</a>
</td>
</tr>";
}
} else {
echo "<tr><td colspan='8'>No donations found.</td></tr>";
}
?>
</tbody>
</table>
</div>
</body>
</html>