121 lines
5.0 KiB
PHP
121 lines
5.0 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
try {
|
|
$pdo = db();
|
|
|
|
// Fetch all customers
|
|
$stmt_customers = $pdo->query('SELECT * FROM customers ORDER BY created_at DESC');
|
|
$customers = $stmt_customers->fetchAll();
|
|
|
|
} catch (PDOException $e) {
|
|
// For production, you would log this error and show a user-friendly message.
|
|
$error = "Database error: " . $e->getMessage();
|
|
}
|
|
|
|
$project_name = "HVAC Command Center";
|
|
$page_title = "Customers";
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title><?= htmlspecialchars($page_title) ?> | <?= htmlspecialchars($project_name) ?></title>
|
|
|
|
<!-- Styles -->
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
|
|
<!-- Fonts -->
|
|
<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=Montserrat:wght@700&family=Roboto:wght@400;500&display=swap" rel="stylesheet">
|
|
</head>
|
|
<body>
|
|
|
|
<header class="header text-white">
|
|
<div class="container-fluid">
|
|
<h1 class="display-6 m-0"><?= htmlspecialchars($project_name) ?></h1>
|
|
</div>
|
|
</header>
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand" href="index.php">Dashboard</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav">
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="customers.php">Customers</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="bookings.php">Bookings</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="ai-call-logs.php">AI Call Logs</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<main class="container-fluid mt-4">
|
|
|
|
<?php if (isset($error)): ?>
|
|
<div class="alert alert-danger">
|
|
<i class="bi bi-exclamation-triangle-fill"></i> <?= htmlspecialchars($error) ?>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="card shadow-sm">
|
|
<div class="card-header">
|
|
<h5 class="m-0"><i class="bi bi-people-fill me-2"></i>All Customers</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover align-middle">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Phone</th>
|
|
<th>Email</th>
|
|
<th>Address</th>
|
|
<th>Member Since</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($customers as $customer): ?>
|
|
<tr>
|
|
<td><?= htmlspecialchars($customer['name']) ?></td>
|
|
<td><?= htmlspecialchars($customer['phone']) ?></td>
|
|
<td><?= htmlspecialchars($customer['email']) ?></td>
|
|
<td><?= htmlspecialchars($customer['address']) ?></td>
|
|
<td><?= htmlspecialchars(date("M d, Y", strtotime($customer['created_at']))) ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php if (empty($customers)): ?>
|
|
<tr>
|
|
<td colspan="5" class="text-center text-muted">No customers found.</td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</main>
|
|
|
|
<footer class="container-fluid text-center text-muted py-3 mt-4">
|
|
<small>Powered by Flatlogic</small>
|
|
</footer>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
|
</body>
|
|
</html>
|