count('orders'); $todayOrders = db()->count('orders', 'DATE(created_at) = CURDATE()'); $totalRevenue = db()->fetch("SELECT COALESCE(SUM(total), 0) as total FROM orders WHERE payment_status = 'paid'")['total'] ?? 0; $todayRevenue = db()->fetch("SELECT COALESCE(SUM(total), 0) as total FROM orders WHERE payment_status = 'paid' AND DATE(created_at) = CURDATE()")['total'] ?? 0; $totalCustomers = db()->count('customers'); $totalProducts = db()->count('products', 'is_active = 1'); $lowStockProducts = db()->count('products', 'stock <= low_stock_threshold AND is_active = 1'); $pendingOrders = db()->count('orders', "order_status = 'pending'"); // Recent orders $recentOrders = db()->fetchAll( "SELECT * FROM orders ORDER BY created_at DESC LIMIT 10" ); // Low stock products $lowStockItems = db()->fetchAll( "SELECT * FROM products WHERE stock <= low_stock_threshold AND is_active = 1 ORDER BY stock ASC LIMIT 5" ); ?>
| Order | Customer | Total | Status | Date |
|---|---|---|---|---|
| No orders yet | ||||
| = htmlspecialchars($order['order_number']) ?> | = htmlspecialchars($order['customer_name'] ?? $order['customer_email']) ?> | = formatCurrency($order['total']) ?> | 'warning', 'confirmed', 'processing' => 'primary', 'shipped', 'delivered' => 'success', 'cancelled', 'refunded' => 'error', default => 'primary' }; ?> = ucfirst($order['order_status']) ?> | = formatDate($order['created_at']) ?> |