40151-vm/leads.php
2026-05-29 06:25:15 +00:00

61 lines
2.6 KiB
PHP

<?php
require_once __DIR__ . '/includes/app.php';
$leads = [];
$error = '';
try {
$leads = latest_leads(25);
} catch (Throwable $exception) {
$error = 'Leads are temporarily unavailable.';
error_log('Leads list failed: ' . $exception->getMessage());
}
page_head('Lead Inbox — ' . project_name(), 'Review captured landing page leads.');
page_nav('leads');
?>
<main class="section">
<div class="container">
<div class="d-flex flex-column flex-md-row justify-content-between align-items-md-end gap-3 mb-4">
<div>
<p class="eyebrow">Lead inbox</p>
<h1 class="page-title">Captured requests</h1>
<p class="text-muted mb-0">Newest submissions from the landing page form.</p>
</div>
<a class="btn btn-dark" href="index.php#lead-form">Add test lead</a>
</div>
<?php if ($error): ?>
<div class="alert alert-danger" role="alert"><?= e($error) ?></div>
<?php elseif (!$leads): ?>
<div class="empty-state">
<h2>No leads yet</h2>
<p>Submit the landing page form to see requests appear here.</p>
<a class="btn btn-dark" href="index.php#lead-form">Open form</a>
</div>
<?php else: ?>
<div class="table-card">
<div class="table-responsive">
<table class="table align-middle mb-0">
<caption class="visually-hidden">Captured landing page leads</caption>
<thead><tr><th>Name</th><th>Company</th><th>Budget</th><th>Status</th><th>Email</th><th>Created</th><th></th></tr></thead>
<tbody>
<?php foreach ($leads as $lead): ?>
<tr>
<td><strong><?= e($lead['name']) ?></strong><br><span class="text-muted small"><?= e(short_text($lead['message'], 54)) ?></span></td>
<td><?= e($lead['company'] ?: '—') ?></td>
<td><?= e($lead['budget'] ?: 'Not sure') ?></td>
<td><span class="badge text-bg-light border"><?= e(ucfirst($lead['status'])) ?></span></td>
<td><?= !empty($lead['email_sent']) ? '<span class="badge text-bg-success">Sent</span>' : '<span class="badge text-bg-secondary">Not sent</span>' ?></td>
<td><time datetime="<?= e($lead['created_at']) ?>"><?= e(date('M j, Y H:i', strtotime($lead['created_at']))) ?></time></td>
<td class="text-end"><a class="btn btn-outline-dark btn-sm" href="lead.php?id=<?= e((string)$lead['id']) ?>">View</a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php endif; ?>
</div>
</main>
<?php page_footer(); ?>