query('SELECT COUNT(*) as total FROM customers'); $total_customers = $stmt_customers->fetch()['total']; // Fetch total bookings $stmt_bookings = $pdo->query('SELECT COUNT(*) as total FROM bookings'); $total_bookings = $stmt_bookings->fetch()['total']; // Fetch total revenue $stmt_revenue = $pdo->query("SELECT SUM(actual_revenue) as total FROM bookings WHERE status = 'completed'"); $total_revenue = $stmt_revenue->fetch()['total'] ?? 0; // Fetch recent bookings $stmt_recent_bookings = $pdo->query('SELECT * FROM bookings ORDER BY created_at DESC LIMIT 5'); $recent_bookings = $stmt_recent_bookings->fetchAll(); // --- API Key Management --- // Handle API key generation if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['generate_api_key'])) { $new_key = 'hvac_' . bin2hex(random_bytes(16)); $stmt_insert_key = $pdo->prepare("INSERT INTO api_keys (api_key) VALUES (?)"); $stmt_insert_key->execute([$new_key]); // Redirect to avoid form resubmission header("Location: " . $_SERVER['PHP_SELF']); exit; } // Fetch all API keys $stmt_api_keys = $pdo->query('SELECT * FROM api_keys ORDER BY created_at DESC'); $api_keys = $stmt_api_keys->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"; $project_description = "Central dashboard for managing your HVAC business operations."; ?> <?= htmlspecialchars($project_name) ?>

Total Customers

View All
Total Bookings

View All
Completed Revenue

$

API Keys
API Key Status Created On Actions
No API keys found.
Recent Bookings
Date Customer Service Urgency Status Est. Revenue
$
No recent bookings found.