diff --git a/customers.php b/customers.php index 0815e26..00dbd18 100644 --- a/customers.php +++ b/customers.php @@ -1,127 +1,81 @@ query('SELECT id, name, email, plan, status FROM customers ORDER BY id'); - $customers = $stmt->fetchAll(); + $stmt = $pdo->query('SELECT id, name, email, status, created_at FROM customers ORDER BY created_at DESC'); + $customers = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { - // For development, you might want to log this error or display a generic message - // For production, log the error and show a user-friendly message. - error_log('Database error: ' . $e->getMessage()); - $customers = []; // Ensure $customers is an empty array on error - // Optionally, set an error message to display to the user - $errorMessage = 'Could not retrieve customer data. Please try again later.'; -} - -function getStatusBadgeClass($status) { - switch (strtolower($status)) { - case 'active': - return 'bg-success'; - case 'suspended': - return 'bg-warning text-dark'; - case 'deactivated': - return 'bg-danger'; - default: - return 'bg-secondary'; - } + $customers = []; + $error_message = "Error: Could not fetch customer data."; } ?> - - - - - - Customers - CableCRM - - - - - - - - - -