-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview_assignment.php
More file actions
136 lines (115 loc) · 3.17 KB
/
Copy pathview_assignment.php
File metadata and controls
136 lines (115 loc) · 3.17 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
<?php
session_start();
if (!isset($_SESSION['role']) || $_SESSION['role'] != 'admin') {
header("Location: login.php");
exit();
}
$conn = new mysqli("localhost", "root", "", "classify_db");
// ========== VALIDATION ==========
if (!isset($_GET['faculty_id'])) {
die("Missing faculty ID.");
}
$faculty_id = intval($_GET['faculty_id']);
// Get faculty info
$faculty = $conn->query("SELECT * FROM faculty WHERE id=$faculty_id")->fetch_assoc();
if (!$faculty) die("Faculty not found.");
// Get assignment list
$sql = "
SELECT a.*, s.code, s.name AS subject_name, sec.section_name, sec.year_level AS sec_year
FROM assignments a
JOIN subjects s ON a.subject_id = s.id
LEFT JOIN sections sec ON a.section_id = sec.id
WHERE a.faculty_id = $faculty_id
ORDER BY a.id DESC
";
$res = $conn->query($sql);
?>
<!DOCTYPE html>
<html>
<head>
<title>Faculty Assignments</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/remixicon/fonts/remixicon.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.29/jspdf.plugin.autotable.min.js"></script>
<style>
body{
font-family: Arial, sans-serif;
background: #f0f2f5;
padding: 20px;
}
.container{
background: white;
padding: 20px;
border-radius: 10px;
width: 900px;
margin: auto;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
table{
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
table th, table td{
border: 1px solid #ccc;
padding: 10px;
text-align: center;
}
.btn{
padding: 10px 14px;
background: #0067ff;
color: white;
text-decoration: none;
border-radius: 6px;
display: inline-block;
}
.btn:hover{
background:#004fcc;
}
</style>
</head>
<body>
<div class="container">
<h2>Faculty Assignment List</h2>
<h3><?= $faculty['name'] ?></h3>
<button class="btn" onclick="exportPDF()">Export PDF</button>
<table id="assignTable">
<thead>
<tr>
<th>ID</th>
<th>Subject Code</th>
<th>Subject Name</th>
<th>Year Level</th>
<th>Section</th>
<th>Days</th>
<th>Time</th>
</tr>
</thead>
<tbody>
<?php while($row = $res->fetch_assoc()): ?>
<tr>
<td><?= $row['id'] ?></td>
<td><?= $row['code'] ?></td>
<td><?= $row['subject_name'] ?></td>
<td><?= $row['year_level'] ?></td>
<td><?= $row['section_name'] ?: 'N/A' ?></td>
<td><?= $row['days'] ?></td>
<td><?= $row['time_start'] ?> - <?= $row['time_end'] ?></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
<br>
<a href="admin_dashboard.php" class="btn">Back</a>
</div>
<script>
function exportPDF() {
const { jsPDF } = window.jspdf;
const pdf = new jsPDF("landscape");
pdf.text("Faculty Assignment List - <?= $faculty['name'] ?>", 14, 15);
pdf.autoTable({ html: "#assignTable", startY: 20 });
pdf.save("Faculty_Assignments.pdf");
}
</script>
</body>
</html>