37684-vm/dashboard.php
2026-02-28 19:00:07 +00:00

139 lines
9.0 KiB
PHP

<?php
require_once 'db/config.php';
$project_name = $_SERVER['PROJECT_NAME'] ?? 'LPA Builder';
$lpas = [];
try {
$stmt = db()->prepare("SELECT * FROM lpa_applications ORDER BY created_at DESC");
$stmt->execute();
$lpas = $stmt->fetchAll();
} catch (PDOException $e) {
error_log($e->getMessage());
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Customer Dashboard — <?php echo htmlspecialchars($project_name); ?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/css/custom.css" rel="stylesheet">
</head>
<body class="bg-light">
<nav class="navbar navbar-expand-lg bg-white border-bottom shadow-sm">
<div class="container">
<a class="navbar-brand d-flex align-items-center" href="/">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="me-2 text-primary"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>
<span class="fw-bold"><?php echo htmlspecialchars($project_name); ?></span>
</a>
<div class="d-flex align-items-center">
<span class="me-3 d-none d-md-inline text-muted small">Practice: Elite Estate Planning</span>
<a href="/apply.php" class="btn btn-primary btn-sm px-3">Start New LPA</a>
</div>
</div>
</nav>
<div class="container py-5">
<div class="row align-items-center mb-5">
<div class="col">
<h1 class="h3 fw-bold mb-1">Your Applications</h1>
<p class="text-muted small mb-0">Track and manage your Lasting Powers of Attorney progress.</p>
</div>
<div class="col-auto">
<?php if (count($lpas) > 0): ?>
<a href="/apply.php" class="btn btn-outline-primary px-4">New Application</a>
<?php endif; ?>
</div>
</div>
<?php if (isset($_GET['completed_step'])): ?>
<div class="alert alert-success alert-dismissible fade show border-0 shadow-sm mb-4" role="alert">
<div class="d-flex align-items-center">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="me-2"><polyline points="20 6 9 17 4 12"></polyline></svg>
<span>Step <?php echo (int)$_GET['completed_step']; ?> saved successfully! You can continue where you left off.</span>
</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php elseif (isset($_GET['new_lpa'])): ?>
<div class="alert alert-success alert-dismissible fade show border-0 shadow-sm mb-4" role="alert">
<div class="d-flex align-items-center">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="me-2"><polyline points="20 6 9 17 4 12"></polyline></svg>
<span>LPA application started successfully! Our practice has been notified of your progress.</span>
</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php endif; ?>
<div class="card border-0 shadow-sm overflow-hidden">
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead class="bg-light">
<tr class="small text-uppercase tracking-wider">
<th class="ps-4 py-3 border-bottom-0">Type</th>
<th class="py-3 border-bottom-0">Donor</th>
<th class="py-3 border-bottom-0">Progress</th>
<th class="py-3 border-bottom-0">Status</th>
<th class="py-3 border-bottom-0 text-end pe-4">Actions</th>
</tr>
</thead>
<tbody>
<?php if (count($lpas) > 0): ?>
<?php foreach ($lpas as $lpa): ?>
<tr>
<td class="ps-4 py-4">
<div class="d-flex align-items-center">
<div class="me-3 text-primary bg-primary-subtle p-2 rounded">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>
</div>
<div>
<div class="fw-bold text-dark mb-0"><?php echo htmlspecialchars($lpa['lpa_type']); ?></div>
<div class="text-muted small">Started <?php echo date('M d, Y', strtotime($lpa['created_at'])); ?></div>
</div>
</div>
</td>
<td>
<div class="fw-medium text-dark"><?php echo htmlspecialchars($lpa['donor_name']); ?></div>
<div class="text-muted small"><?php echo htmlspecialchars($lpa['customer_email']); ?></div>
</td>
<td style="width: 200px;">
<div class="d-flex align-items-center">
<div class="progress flex-grow-1 me-2" style="height: 6px;">
<?php $percent = round(($lpa['step_reached'] / 4) * 100); ?>
<div class="progress-bar bg-primary" role="progressbar" style="width: <?php echo $percent; ?>%" aria-valuenow="<?php echo $percent; ?>" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<span class="small text-muted"><?php echo $percent; ?>%</span>
</div>
</td>
<td>
<span class="status-badge status-draft"><?php echo ucfirst($lpa['status']); ?></span>
</td>
<td class="text-end pe-4">
<?php
$next_step = ($lpa['step_reached'] < 4) ? $lpa['step_reached'] + 1 : 4;
?>
<a href="/apply.php?step=<?php echo $next_step; ?>&id=<?php echo $lpa['id']; ?>" class="btn btn-sm btn-outline-secondary px-3">Continue</a>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="5" class="py-5 text-center">
<div class="mb-3">
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="text-muted"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>
</div>
<h5 class="fw-bold text-dark">No applications yet</h5>
<p class="text-muted small mb-4">Start your first LPA application to secure your future.</p>
<a href="/apply.php" class="btn btn-primary px-4">Start Application</a>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>