70 lines
2.6 KiB
PHP
70 lines
2.6 KiB
PHP
<?php
|
|
require_once 'auth_check.php';
|
|
require_once 'db/config.php';
|
|
require_once 'includes/helpers.php';
|
|
|
|
$pageTitle = 'My Change Requests';
|
|
$userId = $_SESSION['user_id'];
|
|
|
|
// Fetch requests for the logged-in user
|
|
try {
|
|
$pdoconn = db();
|
|
$stmt = $pdoconn->prepare('SELECT * FROM change_requests WHERE requester_id = :requester_id ORDER BY created_at DESC');
|
|
$stmt->bindParam(':requester_id', $userId, PDO::PARAM_INT);
|
|
$stmt->execute();
|
|
$requests = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
} catch (PDOException $e) {
|
|
// Handle DB error
|
|
$requests = [];
|
|
error_log("Database error: " . $e->getMessage());
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?= htmlspecialchars($pageTitle) ?></title>
|
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
|
<link rel="stylesheet" href="assets/css/custom.css">
|
|
</head>
|
|
<body>
|
|
<?php include 'header.php'; // Use a shared header ?>
|
|
|
|
<div class="container mt-5">
|
|
<h2>My Submitted Requests</h2>
|
|
<hr>
|
|
<?php if (empty($requests)): ?>
|
|
<div class="alert alert-info">You have not submitted any requests yet.</div>
|
|
<?php else: ?>
|
|
<table class="table table-bordered table-striped">
|
|
<thead class="thead-dark">
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Change Title</th>
|
|
<th>Status</th>
|
|
<th>Submitted On</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($requests as $request): ?>
|
|
<tr>
|
|
<td><?= htmlspecialchars($request['id']) ?></td>
|
|
<td><?= htmlspecialchars($request['change_title']) ?></td>
|
|
<td><?= displayStatusBadge($request['status']) ?></td>
|
|
<td><?= htmlspecialchars(date('Y-m-d H:i', strtotime($request['created_at']))) ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php endif; ?>
|
|
<a href="request_form.php" class="btn btn-primary">Submit New Request</a>
|
|
</div>
|
|
|
|
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.2/dist/umd/popper.min.js"></script>
|
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
|
</body>
|
|
</html>
|