140 lines
6.1 KiB
PHP
140 lines
6.1 KiB
PHP
<?php
|
|
session_start();
|
|
|
|
// --- Authentication Check ---
|
|
$is_logged_in = isset($_SESSION['isAdmin']) && $_SESSION['isAdmin'] === true;
|
|
if (!$is_logged_in) {
|
|
header('Location: admin.php');
|
|
exit;
|
|
}
|
|
|
|
require_once __DIR__ . '/db/config.php';
|
|
|
|
// --- Data Fetching ---
|
|
$subscription = null;
|
|
$error_message = null;
|
|
|
|
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
|
|
$error_message = "Invalid application ID.";
|
|
} else {
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("SELECT * FROM subscriptions WHERE id = :id");
|
|
$stmt->bindParam(':id', $_GET['id'], PDO::PARAM_INT);
|
|
$stmt->execute();
|
|
$subscription = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if (!$subscription) {
|
|
$error_message = "Application not found.";
|
|
}
|
|
} catch (PDOException $e) {
|
|
$error_message = "Database error: " . $e->getMessage();
|
|
}
|
|
}
|
|
|
|
function get_specific_coverage_details_html($sub) {
|
|
$type = $sub['insuranceType'] ?? 'N/A';
|
|
$output = '';
|
|
switch ($type) {
|
|
case 'Car':
|
|
$output .= "<p><strong>Car Make:</strong> " . htmlspecialchars($sub['carMake']) . "</p>";
|
|
$output .= "<p><strong>Car Model:</strong> " . htmlspecialchars($sub['carModel']) . "</p>";
|
|
$output .= "<p><strong>Year of Manufacture:</strong> " . htmlspecialchars($sub['carYear']) . "</p>";
|
|
break;
|
|
case 'Health':
|
|
$output .= "<p><strong>Number of Dependents:</strong> " . htmlspecialchars($sub['healthDependents']) . "</p>";
|
|
break;
|
|
case 'Life':
|
|
$output .= "<p><strong>Coverage Amount:</strong> $" . number_format($sub['lifeCoverage'], 2) . "</p>";
|
|
break;
|
|
case 'Home':
|
|
$output .= "<p><strong>Property Type:</strong> " . htmlspecialchars($sub['homeType']) . "</p>";
|
|
break;
|
|
}
|
|
return $output;
|
|
}
|
|
|
|
// --- Page Setup ---
|
|
$page_title = "Application Details";
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?php echo htmlspecialchars($page_title); ?> - SecureLife</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
</head>
|
|
<body>
|
|
|
|
<header class="navbar navbar-expand-lg navbar-light bg-white shadow-sm">
|
|
<div class="container">
|
|
<a class="navbar-brand" href="index.php">SecureLife</a>
|
|
<ul class="navbar-nav">
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="admin.php?action=logout">Logout</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</header>
|
|
|
|
<main class="container my-5">
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h1 class="h3 fw-bold">Application #<?php echo htmlspecialchars($subscription['id'] ?? ''); ?></h1>
|
|
<a href="admin.php" class="btn btn-outline-secondary"> ← Back to Dashboard</a>
|
|
</div>
|
|
|
|
<?php if ($error_message): ?>
|
|
<div class="alert alert-danger"><?php echo htmlspecialchars($error_message); ?></div>
|
|
<?php elseif ($subscription): ?>
|
|
<div class="card shadow-sm border-0" style="border-radius: 0.75rem;">
|
|
<div class="card-header bg-white p-4 border-0">
|
|
<div class="d-flex justify-content-between">
|
|
<h2 class="h5 fw-bold mb-0">Details</h2>
|
|
<?php
|
|
$status = $subscription['status'];
|
|
$badge_class = 'bg-secondary'; // Default
|
|
if ($status === 'Pending') {
|
|
$badge_class = 'bg-warning text-dark';
|
|
} elseif ($status === 'Approved') {
|
|
$badge_class = 'bg-success';
|
|
} elseif ($status === 'Rejected') {
|
|
$badge_class = 'bg-danger';
|
|
}
|
|
?>
|
|
<p class="mb-0"><strong>Status:</strong> <span class="badge <?php echo $badge_class; ?>"><?php echo htmlspecialchars($status); ?></span></p>
|
|
</div>
|
|
</div>
|
|
<div class="card-body p-4">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<h5 class="fw-bold">Personal Information</h5>
|
|
<p><strong>Full Name:</strong> <?php echo htmlspecialchars($subscription['fullName']); ?></p>
|
|
<p><strong>Email:</strong> <?php echo htmlspecialchars($subscription['email']); ?></p>
|
|
<p><strong>Phone:</strong> <?php echo htmlspecialchars($subscription['phone']); ?></p>
|
|
<p><strong>Submitted At:</strong> <?php echo date("F j, Y, g:i a", strtotime($subscription['created_at'])); ?></p>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h5 class="fw-bold">Insurance Details</h5>
|
|
<p><strong>Insurance Type:</strong> <?php echo htmlspecialchars($subscription['insuranceType']); ?></p>
|
|
<?php echo get_specific_coverage_details_html($subscription); ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</main>
|
|
|
|
<footer class="text-center py-4 mt-auto bg-dark text-white">
|
|
<p class="mb-0">© <?php echo date("Y"); ?> SecureLife. All Rights Reserved.</p>
|
|
</footer>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|