<?php
require __DIR__ . '/includes/functions.php';
customer_require_login();
$currentPage = 'account';
$pageTitle = 'My Custom Sofa Quotes | Furnify';
$customer = customer_current();
$rows = array();
$pdo = db();
if ($pdo) {
    try {
        $stmt = $pdo->prepare('SELECT * FROM custom_sofa_quotes WHERE customer_id = ? OR customer_email = ? ORDER BY created_at DESC');
        $stmt->execute(array((int) $customer['id'], $customer['email']));
        $rows = $stmt->fetchAll();
    } catch (Exception $e) {}
}
require __DIR__ . '/includes/header.php';
?>
<section class="page-section"><div class="container"><div class="section-heading split-heading"><div><p class="eyebrow">My account</p><h1>My Custom Sofa Quotes</h1><p class="lead">Track personalized sofa design requests and admin final quotations.</p></div><a class="btn btn-primary" href="custom-sofa.php">New Custom Quote</a></div><div class="premium-panel p-4"><div class="table-responsive"><table class="table align-middle"><thead><tr><th>Request</th><th>Sofa</th><th>Material</th><th>Estimate / Quote</th><th>Status</th><th>Date</th></tr></thead><tbody><?php foreach ($rows as $row): ?><tr><td><?= e($row['request_number']) ?></td><td><?= e($row['sofa_type']) ?><br><span class="small text-muted"><?= e($row['design_style']) ?></span></td><td><?= e($row['material_preference']) ?></td><td><?= $row['final_quote'] !== null ? money($row['final_quote']) : money($row['estimate_low']) . ' - ' . money($row['estimate_high']) ?></td><td><span class="badge text-bg-light"><?= e($row['status']) ?></span></td><td><?= e(date('M d, Y', strtotime($row['created_at']))) ?></td></tr><?php endforeach; ?><?php if (!$rows): ?><tr><td colspan="6" class="text-center text-muted py-5">No custom sofa requests yet.</td></tr><?php endif; ?></tbody></table></div></div></div></section>
<?php require __DIR__ . '/includes/footer.php'; ?>
