<?php

include 'db.php'; // make sure $conn is available

$dashboard_title = 'Manager Dashboard';
$dashboard_icon  = 'fa-user-tie'; // Manager icon

// =================== Notifications ===================
// Pending Bar Requisitions
$pending_reqs = $conn->query("
    SELECT COUNT(*) as cnt FROM bar_requisitions
    WHERE status='Pending'
")->fetch_assoc()['cnt'] ?? 0;

// Low Stock in Bar (threshold <=5)
$low_stock = $conn->query("
    SELECT COUNT(*) as cnt 
    FROM product_stock ps
    JOIN products p ON ps.product_id=p.id
    WHERE ps.store_id=2 AND ps.quantity <=5
")->fetch_assoc()['cnt'] ?? 0;

// =================== Modules for manager ===================
$module_cards = [
    ['link'=>'front_office_dashboard.php', 'icon'=>'fa-hotel', 'title'=>'Front Office', 'color'=>'bg-primary'],
    ['link'=>'restaurant.php', 'icon'=>'fa-cutlery', 'title'=>'Restaurant', 'color'=>'bg-success'],
    [
        'link'=>'bar.php', 
        'icon'=>'fa-beer', 
        'title'=>'Bar', 
        'color'=>'bg-info',
        'notification'=> $low_stock > 0 ? $low_stock : null
    ],
    ['link'=>'kitchen_dashboard.php', 'icon'=>'fa-hat-chef', 'title'=>'Kitchen', 'color'=>'bg-warning'],
    ['link'=>'accounts.php', 'icon'=>'fa-money-bill-wave', 'title'=>'Accounts', 'color'=>'bg-danger'],
    ['link'=>'products.php', 'icon'=>'fa-boxes', 'title'=>'Inventory', 'color'=>'bg-dark'],
    ['link'=>'housekeeping_dashboard.php', 'icon'=>'fa-broom', 'title'=>'Housekeeping', 'color'=>'bg-secondary'],
    [
        'link'=>'requisitions.php', 
        'icon'=>'fa-broom', 
        'title'=>'Requisitions', 
        'color'=>'bg-secondary',
        'notification'=> $pending_reqs > 0 ? $pending_reqs : null
    ],
    ['link'=>'assets.php', 'icon'=>'fa-broom', 'title'=>'Assets', 'color'=>'bg-secondary'],
        ['link'=>'meal_parameters.php', 'icon'=>'fa-broom', 'title'=>'Meal Parameters', 'color'=>'bg-secondary'],
            ['link'=>'meal_dashboard.php', 'icon'=>'fa-broom', 'title'=>'Assign Ingridients', 'color'=>'bg-secondary'],
                ['link'=>'produce_meal.php', 'icon'=>'fa-broom', 'title'=>'Meal Production', 'color'=>'bg-secondary'],

                  ['link'=>'assign_perishables.php', 'icon'=>'fa-broom', 'title'=>'Perishables', 'color'=>'bg-secondary'],
      
    ['link'=>'manager_reports.php', 'icon'=>'fa-chart-pie', 'title'=>'Reports', 'color'=>'bg-success'],
];

include 'dashboard_template.php';
?>
<div class="tips-box" align="center">
  <h4>💡Tips</h4>
  <ul>
    <li>✅ <strong>Confirm First:</strong> Click Invoice to Receive Payment  using the button below the invoice.</li>

  </ul>
</div>