-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
140 lines (118 loc) · 3.71 KB
/
admin.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html>
<html>
<head>
<title>Admin Page</title>
<style>
.table {
width: 100%;
border-collapse: collapse;
margin-bottom: 30px;
}
/* th, td {
padding: 10px;
text-align: left;
border-bottom: 1px solid #ddd;
} */
tr:hover {
background-color: #f5f5f5;
}
.action-buttons {
display: flex;
justify-content: center;
}
.action-buttons button {
margin: 0 5px;
padding: 8px 16px;
font-size: 14px;
cursor: pointer;
}
.approve-btn {
background-color: #4CAF50;
color: white;
border: none;
}
.reject-btn {
background-color: #f44336;
color: white;
border: none;
}
</style>
</head>
<body>
<?php
include_once'includes/header.php';
?>
<h1>Admin Page</h1>
<h2>Pending Campaigns</h2>
<table class="table">
<tr>
<th>Title</th>
<th>Category</th>
<th>Goal</th>
<th>Action</th>
</tr>
<?php
require_once 'includes/conn.inc.php';
// Fetch all pending campaigns from the database
$sql = "SELECT * FROM donees WHERE status = 'pending'";
$result = mysqli_query($conn, $sql);
// Loop through each pending campaign and display information
// Loop through each pending campaign and display information
while ($row = mysqli_fetch_assoc($result)) {
$campaignId = '';
foreach ($row as $key => $value) {
if ($key === 'campaign_id') {
$campaignId = $value;
break;
}
}
$id = $row['id'];
$title = $row['tittle'];
$category = $row['category'];
$goal = $row['goal'];
echo '<tr>
<td>' . $title . '</td>
<td>' . $category . '</td>
<td>$' . $goal . '</td>
<!-- ... -->
<form action="includes/approve.inc.php" method="POST">
<td class="action-buttons">
<button name="update" class="approve-btn" value="'.$id.'">Approve</button>
<button class="reject-btn" onclick="rejectCampaign(<?php echo $campaignId; ?>)">Reject</button>
</td>
</form>
</tr>';
}
// Close database connection
mysqli_close($conn);
?>
<script>
function approveCampaign(campaignId) {
console.log('Campaign approved: ' + campaignId);
// Make an AJAX request or perform other actions with the campaign ID
}
function rejectCampaign(campaignId) {
console.log('Campaign rejected: ' + campaignId);
// Make an AJAX request or perform other actions with the campaign ID
}
</script>
</table>
<script>
// Add event listeners to the buttons
var approveButtons = document.querySelectorAll('.approve-btn');
var rejectButtons = document.querySelectorAll('.reject-btn');
approveButtons.forEach(function(button) {
button.addEventListener('click', function() {
// Handle approve button click
console.log('Campaign approved');
});
});
rejectButtons.forEach(function(button) {
button.addEventListener('click', function() {
// Handle reject button click
console.log('Campaign rejected');
});
});
</script>
</body>
</html>