-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmessage.php
More file actions
141 lines (131 loc) · 7.31 KB
/
message.php
File metadata and controls
141 lines (131 loc) · 7.31 KB
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
141
<?php
session_start();
$id_number = isset($_SESSION['id_number']) ? (int)$_SESSION['id_number'] : 0;
$servername = "127.0.0.1";
$username = "root";
$password = "";
$dbname = "frontend&backend";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Search functionality
$search = isset($_GET['search']) ? trim($_GET['search']) : '';
$where = "WHERE teacher_id = ?";
$params = [$id_number];
$types = "i";
if (!empty($search)) {
$where .= " AND (file_name LIKE ? OR subject_name LIKE ? OR stream LIKE ? OR admin_feedback LIKE ?)";
$params = array_merge($params, ["%$search%", "%$search%", "%$search%", "%$search%"]);
$types .= "ssss";
}
$query = "SELECT file_name, subject_name, stream, status, admin_feedback, uploaded_at, processed_at
FROM syllabus_approvals $where
ORDER BY uploaded_at DESC";
$stmt = $conn->prepare($query);
$stmt->bind_param($types, ...$params);
$stmt->execute();
$result = $stmt->get_result();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Teacher Syllabus</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-50 min-h-screen">
<div class="container mx-auto p-4 md:p-8">
<div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-6 gap-4">
<h1 class="text-2xl font-bold text-gray-800">
<i class="fas fa-file-alt mr-2"></i> My Syllabus Submissions
</h1>
<form method="GET" class="w-full md:w-96">
<div class="relative">
<input type="text" name="search" placeholder="Search submissions..."
value="<?= htmlspecialchars($search) ?>"
class="w-full pl-10 pr-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
<i class="fas fa-search absolute left-3 top-3 text-gray-400"></i>
</div>
</form>
</div>
<div class="bg-white rounded-lg shadow overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">File Name</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Subject</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Stream</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Feedback</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Uploaded</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<?php if ($result->num_rows > 0): ?>
<?php while ($row = $result->fetch_assoc()): ?>
<tr class="hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm font-medium text-gray-900"><?= htmlspecialchars($row['file_name']) ?></div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-500"><?= htmlspecialchars($row['subject_name'] ?? 'N/A') ?></div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-500"><?= htmlspecialchars($row['stream'] ?? 'N/A') ?></div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<?php if ($row['status'] == 'approved'): ?>
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
Approved
</span>
<?php elseif ($row['status'] == 'rejected'): ?>
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">
Rejected
</span>
<?php else: ?>
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-yellow-100 text-yellow-800">
Pending
</span>
<?php endif; ?>
</td>
<td class="px-6 py-4">
<div class="text-sm text-gray-500">
<?php if ($row['status'] == 'rejected' && !empty($row['admin_feedback'])): ?>
<span class="text-red-600"><?= htmlspecialchars($row['admin_feedback']) ?></span>
<?php elseif ($row['status'] == 'approved'): ?>
<span class="text-green-600">Approved</span>
<?php else: ?>
<span class="text-gray-400">Pending review</span>
<?php endif; ?>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-500">
<?= date('M j, Y g:i A', strtotime($row['uploaded_at'])) ?>
</div>
</td>
</tr>
<?php endwhile; ?>
<?php else: ?>
<tr>
<td colspan="6" class="px-6 py-4 text-center text-sm text-gray-500">
No syllabus submissions found <?= !empty($search) ? 'matching your search' : '' ?>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
<!-- Font Awesome for icons -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/js/all.min.js"></script>
</body>
</html>
<?php
$stmt->close();
$conn->close();
?>