114 lines
5.5 KiB
PHP
114 lines
5.5 KiB
PHP
<?php
|
|
require_once 'auth_check.php';
|
|
require_once 'db/config.php';
|
|
|
|
$pageTitle = 'View Change Request';
|
|
$requestId = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
|
|
|
|
if (!$requestId) {
|
|
header("Location: all_requests.php");
|
|
exit;
|
|
}
|
|
|
|
// Fetch the request and requester info
|
|
try {
|
|
$pdoconn = db();
|
|
$stmt = $pdoconn->prepare('SELECT cr.*, u.full_name as requester_full_name, u.username as requester_username FROM change_requests cr JOIN users u ON cr.requester_id = u.id WHERE cr.id = :id');
|
|
$stmt->bindParam(':id', $requestId, PDO::PARAM_INT);
|
|
$stmt->execute();
|
|
$request = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
} catch (PDOException $e) {
|
|
$request = null;
|
|
error_log("DB Error: " . $e->getMessage());
|
|
}
|
|
|
|
if (!$request) {
|
|
$_SESSION['error_message'] = "Request not found.";
|
|
header("Location: all_requests.php");
|
|
exit;
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?= htmlspecialchars($pageTitle) ?> - #<?= htmlspecialchars($request['id']) ?></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'; ?>
|
|
|
|
<div class="container mt-5">
|
|
<div class="card">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
<h3>Change Request #<?= htmlspecialchars($request['id']) ?></h3>
|
|
<span class="badge badge-info" style="font-size: 1rem;"><?= htmlspecialchars(ucfirst($request['status'])) ?></span>
|
|
</div>
|
|
<div class="card-body">
|
|
<h5 class="card-title"><?= htmlspecialchars($request['change_title']) ?></h5>
|
|
<hr>
|
|
|
|
<!-- Request Details -->
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<p><strong>Requester:</strong> <?= htmlspecialchars($request['requester_full_name']) ?></p>
|
|
<p><strong>Department:</strong> <?= htmlspecialchars($request['requester_dept']) ?></p>
|
|
<p><strong>System Name:</strong> <?= htmlspecialchars($request['system_name']) ?></p>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<p><strong>Submission Date:</strong> <?= date('Y-m-d H:i', strtotime($request['created_at'])) ?></p>
|
|
<p><strong>Category:</strong> <?= htmlspecialchars($request['change_category']) ?></p>
|
|
<p><strong>Program Name:</strong> <?= htmlspecialchars($request['program_name']) ?></p>
|
|
<?php if (!empty($request['related_request_no'])): ?>
|
|
<p><strong>Related Change Request No:</strong> <a href="view_request.php?id=<?= htmlspecialchars($request['related_request_no']) ?>"><?= htmlspecialchars($request['related_request_no']) ?></a></p>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mt-3">
|
|
<h6><strong>Reason for Change:</strong></h6>
|
|
<p><?= nl2br(htmlspecialchars($request['reason_for_change'])) ?></p>
|
|
</div>
|
|
|
|
<div class="mt-3">
|
|
<h6><strong>Description of Change:</strong></h6>
|
|
<p><?= nl2br(htmlspecialchars($request['description_of_change'])) ?></p>
|
|
</div>
|
|
|
|
<?php if ($_SESSION['role'] === 'admin'): ?>
|
|
<hr>
|
|
<div class="mt-4">
|
|
<h4>Approval Action</h4>
|
|
<form action="update_request_status.php" method="POST">
|
|
<input type="hidden" name="request_id" value="<?= $request['id'] ?>">
|
|
<div class="form-group">
|
|
<label for="new_status">Change Status:</label>
|
|
<select name="new_status" id="new_status" class="form-control">
|
|
<option value="Pending" <?= $request['status'] === 'Pending' ? 'selected' : '' ?>>Pending</option>
|
|
<option value="Approved" <?= $request['status'] === 'Approved' ? 'selected' : '' ?>>Approved</option>
|
|
<option value="In Development" <?= $request['status'] === 'In Development' ? 'selected' : '' ?>>In Development</option>
|
|
<option value="Completed" <?= $request['status'] === 'Completed' ? 'selected' : '' ?>>Completed</option>
|
|
<option value="Rejected" <?= $request['status'] === 'Rejected' ? 'selected' : '' ?>>Rejected</option>
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="admin_comment">Comment:</label>
|
|
<textarea name="admin_comment" id="admin_comment" class="form-control" rows="3"></textarea>
|
|
</div>
|
|
<button type="submit" class="btn btn-success">Update Status</button>
|
|
</form>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
</div>
|
|
</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>
|