-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrants.php
60 lines (49 loc) · 2.23 KB
/
grants.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
<?php
include 'header.php';
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit();
}
$user_id = $_SESSION['user_id'];
$query = "
SELECT g.*, gu.role
FROM grants g
JOIN grant_users gu ON g.id = gu.grant_id
WHERE gu.user_id = ?
";
$stmt = $conn->prepare($query);
$stmt->bind_param('i', $user_id);
$stmt->execute();
$grants = $stmt->get_result();
if (!$grants) {
die("Error fetching grants: " . $conn->error);
}
?>
<h2>Your Grants</h2>
<ul>
<?php while ($row = $grants->fetch_assoc()): ?>
<li style="background-color: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 15px; margin-bottom: 10px;
display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);">
<div style="font-weight: bold; font-size: 18px; color: #2c3e50;"><?php echo $row['title']; ?></div>
<div style="display: flex; gap: 10px;">
<span style="color: #7f8c8d; font-size: 16px; margin-top: 8px;"><?php echo '(' . $row['agency'] . ')'; ?></span>
<?php if ($row['role'] === 'PI'): ?>
<a href="add_budget.php?grant_id=<?php echo $row['id']; ?>" style="text-decoration: none; padding: 8px 12px;
background-color: #3498db; color: white; border-radius: 5px; font-size: 14px;">Manage Budget</a>
<?php endif; ?>
<?php if ($row['role'] === 'PI' || $row['role'] === 'CO-PI'): ?>
<a href="download.php?grant_id=<?php echo $row['id']; ?>" style="text-decoration: none; padding: 8px 12px;
background-color: #2ecc71; color: white; border-radius: 5px; font-size: 14px;">Download as Excel</a>
<?php endif; ?>
<?php if ($row['role'] === 'PI'): ?>
<a href="delete_grant.php?grant_id=<?php echo $row['id']; ?>"
onclick="return confirm('Are you sure you want to remove this grant?');" style="text-decoration: none; padding: 8px 12px;
background-color: #e74c3c; color: white; border-radius: 5px; font-size: 14px;">Remove</a>
<?php endif; ?>
</div>
</li>
<?php endwhile; ?>
</ul>
<?php
include 'footer.php';
?>