76 lines
3.1 KiB
PHP
76 lines
3.1 KiB
PHP
<?php
|
|
session_start();
|
|
|
|
if (!isset($_SESSION['user_role']) || $_SESSION['user_role'] !== 'teacher') {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
|
|
require_once __DIR__ . '/db/config.php';
|
|
require_once __DIR__ . '/includes/header.php';
|
|
|
|
$leave_requests = [];
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("SELECT leave_requests.*, users.full_name AS student_name FROM leave_requests JOIN users ON leave_requests.student_id = users.id WHERE leave_requests.status = 'pending' ORDER BY leave_requests.created_at DESC");
|
|
$stmt->execute();
|
|
$leave_requests = $stmt->fetchAll();
|
|
} catch (PDOException $e) {
|
|
// handle error
|
|
}
|
|
|
|
?>
|
|
|
|
<div class="container">
|
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
|
<h1>Teacher Dashboard</h1>
|
|
<div>
|
|
<span class="me-3">Welcome, <?php echo htmlspecialchars($_SESSION['user_full_name']); ?>!</span>
|
|
<a href="logout.php" class="btn btn-primary">Logout</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mt-4">
|
|
<div class="col-md-12">
|
|
<h2>Pending Leave Requests</h2>
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>Student Name</th>
|
|
<th>Leave Type</th>
|
|
<th>Start Date</th>
|
|
<th>End Date</th>
|
|
<th>Reason</th>
|
|
<th>Attachment</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($leave_requests as $request): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($request['student_name']); ?></td>
|
|
<td><?php echo htmlspecialchars($request['leave_type']); ?></td>
|
|
<td><?php echo htmlspecialchars($request['start_date']); ?></td>
|
|
<td><?php echo htmlspecialchars($request['end_date']); ?></td>
|
|
<td><?php echo htmlspecialchars($request['reason']); ?></td>
|
|
<td>
|
|
<?php if ($request['attachment_path']): ?>
|
|
<a href="<?php echo htmlspecialchars($request['attachment_path']); ?>" target="_blank">View Attachment</a>
|
|
<?php else: ?>
|
|
No Attachment
|
|
<?php endif; ?>
|
|
</td>
|
|
<td>
|
|
<a href="update_leave_status.php?id=<?php echo $request['id']; ?>&status=approved_by_teacher" class="btn btn-success btn-sm">Approve</a>
|
|
<a href="update_leave_status.php?id=<?php echo $request['id']; ?>&status=rejected_by_teacher" class="btn btn-danger btn-sm">Reject</a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|