requireLogin(); $page_title = 'Dashboard'; // Fetch real statistics try { // Sales statistics $stmt = $pdo->prepare(" SELECT COUNT(*) as total_sales_count, COALESCE(SUM(total_amount), 0) as total_sales_amount, COALESCE(SUM(CASE WHEN payment_status = 'pending' THEN total_amount ELSE 0 END), 0) as pending_amount FROM sales "); $stmt->execute(); $sales_stats = $stmt->fetch(PDO::FETCH_ASSOC); // Products/Services count $stmt = $pdo->prepare("SELECT COUNT(*) as count FROM products_services WHERE status = 'active'"); $stmt->execute(); $products_count = $stmt->fetchColumn(); // Recent sales for activity - now showing bills with their items $stmt = $pdo->prepare(" SELECT s.*, (SELECT GROUP_CONCAT(CONCAT(ps.name, ' (', si.quantity, ' ', u.unit_symbol, ')') SEPARATOR ', ') FROM sales_items si JOIN products_services ps ON si.product_service_id = ps.id JOIN units u ON ps.unit_id = u.id WHERE si.sale_id = s.id) as items_summary FROM sales s ORDER BY s.created_at DESC LIMIT 5 "); $stmt->execute(); $recent_sales = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $sales_stats = ['total_sales_count' => 0, 'total_sales_amount' => 0, 'pending_amount' => 0]; $products_count = 0; $recent_sales = []; } include 'includes/header.php'; ?>
Welcome to Kayal Aqua Fish Business Management System
| Bill# | Date | Items | Amount | Customer |
|---|---|---|---|---|
| ₹ | - |
| User Role | getUserRole())); ?> |
| Login Time | |
| System Status | Active |