<?php
// templates/sidebar.php
$user = $_SESSION['user'] ?? null;
$role = $user['role_name'] ?? '';
?>
<aside class="col-12 col-md-3 col-lg-2 bg-white border-end min-vh-100 p-0">
  <div class="list-group list-group-flush">
    <a href="dashboard.php" class="list-group-item list-group-item-action">Dashboard</a>

    <?php if ($role === 'admin' || $role === 'staff'): ?>
      <a href="products.php" class="list-group-item list-group-item-action">Products</a>
      <a href="stock_in.php" class="list-group-item list-group-item-action">Stock IN</a>
      <a href="stock_out.php" class="list-group-item list-group-item-action">Stock OUT</a>
      <a href="stock_summary.php" class="list-group-item list-group-item-action">Stock Summary</a>
      <a href="adjust_stock.php" class="list-group-item list-group-item-action">Adjust Stock</a>
      <a href="deliveries.php" class="list-group-item list-group-item-action">Deliveries</a>
      <a href="suppliers.php" class="list-group-item list-group-item-action">Suppliers</a>

      <a href="reports.php" class="list-group-item list-group-item-action">Reports</a>
      <a href="product_categories.php" class="list-group-item list-group-item-action">Product Categories</a>

      <?php if ($role === 'admin'): ?>
  <a href="customers.php" class="list-group-item list-group-item-action">Customers</a>
<?php endif; ?>


<?php if ($role === 'admin'): ?>
  <a href="users.php" class="list-group-item list-group-item-action">Users</a>
  <a href="audit_logs.php" class="list-group-item list-group-item-action">Audit Logs</a>
<?php endif; ?>


<?php if ($role === 'staff'): ?>
  <a href="staff_dashboard.php" class="list-group-item list-group-item-action">Staff Dashboard</a>
<?php endif; ?>

<?php if ($role === 'driver'): ?>
  <a href="driver_app.php" class="list-group-item list-group-item-action">Driver App</a>
<?php endif; ?>


    <?php endif; ?>

    <?php if ($role === 'admin'): ?>
      <a href="users.php" class="list-group-item list-group-item-action">Users</a>
      <a href="audit_logs.php" class="list-group-item list-group-item-action">Audit Logs</a>
    <?php endif; ?>

    <?php if ($role === 'driver'): ?>
      <a href="driver_app.php" class="list-group-item list-group-item-action">Driver App</a>
    <?php endif; ?>

    <?php if ($role === 'staff'): ?>
      <a href="staff_dashboard.php" class="list-group-item list-group-item-action">Staff Dashboard</a>
    <?php endif; ?>

    <?php if ($role === 'admin'): ?>
      <a href="live_map.php" class="list-group-item list-group-item-action">Live Map</a>
    <?php endif; ?>
    
    <?php if ($role === 'admin'): ?>
      <a href="qr_sheets.php" class="list-group-item list-group-item-action">QR Codes</a>
    <?php endif; ?>

  </div>
</aside>
