PDO::ERRMODE_EXCEPTION] ); } catch (PDOException $e) { die("Database connection failed: " . $e->getMessage()); } // Handle status update if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['update_status'])) { $quote_id = $_POST['quote_id']; $new_status = $_POST['new_status']; $stmt = $pdo->prepare("UPDATE quotes SET status = ?, updated_at = NOW() WHERE id = ?"); $stmt->execute([$new_status, $quote_id]); header('Location: index.php?updated=1'); exit; } // Get statistics $stats = getStats($pdo); // Get quotes with filtering $status_filter = $_GET['status'] ?? ''; $search = $_GET['search'] ?? ''; $quotes = getQuotes($pdo, $status_filter, $search); // Get single quote details if requested $quote_detail = null; if (isset($_GET['id'])) { $quote_detail = getQuoteDetail($pdo, $_GET['id']); } // Helper functions function getStats($pdo) { $stats = []; // Total quotes $stmt = $pdo->query("SELECT COUNT(*) FROM quotes"); $stats['total'] = $stmt->fetchColumn(); // By status $stmt = $pdo->query("SELECT status, COUNT(*) as count FROM quotes GROUP BY status"); $stats['by_status'] = $stmt->fetchAll(PDO::FETCH_KEY_PAIR); // Total monthly value (submitted quotes only) $stmt = $pdo->query("SELECT COALESCE(SUM(monthly_total), 0) FROM quotes WHERE status = 'submitted'"); $stats['total_monthly'] = $stmt->fetchColumn(); // This month $stmt = $pdo->query("SELECT COUNT(*) FROM quotes WHERE created_at >= DATE_FORMAT(NOW(), '%Y-%m-01')"); $stats['this_month'] = $stmt->fetchColumn(); return $stats; } function getQuotes($pdo, $status_filter = '', $search = '') { $sql = "SELECT q.*, (SELECT COUNT(*) FROM quote_items WHERE quote_id = q.id) as item_count FROM quotes q WHERE 1=1"; $params = []; if ($status_filter) { $sql .= " AND q.status = ?"; $params[] = $status_filter; } if ($search) { $sql .= " AND (q.company_name LIKE ? OR q.contact_name LIKE ? OR q.contact_email LIKE ?)"; $params[] = "%$search%"; $params[] = "%$search%"; $params[] = "%$search%"; } $sql .= " ORDER BY q.created_at DESC LIMIT 100"; $stmt = $pdo->prepare($sql); $stmt->execute($params); return $stmt->fetchAll(PDO::FETCH_ASSOC); } function getQuoteDetail($pdo, $id) { // Get quote $stmt = $pdo->prepare("SELECT * FROM quotes WHERE id = ?"); $stmt->execute([$id]); $quote = $stmt->fetch(PDO::FETCH_ASSOC); if (!$quote) return null; // Get items $stmt = $pdo->prepare("SELECT * FROM quote_items WHERE quote_id = ? ORDER BY category, created_at"); $stmt->execute([$id]); $quote['items'] = $stmt->fetchAll(PDO::FETCH_ASSOC); // Get activity $stmt = $pdo->prepare("SELECT * FROM quote_activity WHERE quote_id = ? ORDER BY created_at DESC"); $stmt->execute([$id]); $quote['activities'] = $stmt->fetchAll(PDO::FETCH_ASSOC); return $quote; } function showLoginPage($error = null) { ?> Quote Admin - Login

Quote Admin

'bg-gray-500', 'submitted' => 'bg-blue-500', 'viewed' => 'bg-purple-500', 'followed_up' => 'bg-yellow-500', 'converted' => 'bg-green-500', 'expired' => 'bg-red-500', ]; $color = $colors[$status] ?? 'bg-gray-500'; return "" . ucfirst(str_replace('_', ' ', $status)) . ""; } ?> Quote Admin Dashboard

Quote Admin

azcomputerguru.com
Logout
Quote status updated successfully.
Total Quotes
Submitted
Converted
Monthly Value

Quote Details

← Back to List

Contact Information

Company:
Contact:
Email:
Phone:
Employees:

Quote Summary

Status:
Monthly Total:
Setup Total:
Created:
Submitted:

Line Items

Category Product Qty Unit Price Monthly

Activity Log

| ()
Clear
Date Company Contact Status Items Monthly
No quotes found
View