<?php
require_once __DIR__ . '/config.php';
require_login();
$user = get_current_user_data();
?>
<!doctype html>
<html lang="hr">
<head>
    <meta charset="utf-8">
    <title>Evidencija materijala</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">
    <link rel="icon" type="image/x-icon" href="assets/img/favicon.ico">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark shadow-sm mb-3">
  <div class="container-fluid">
    <a class="navbar-brand" href="index.php">Materijali</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse"
            data-bs-target="#mainNav" aria-controls="mainNav" aria-expanded="false"
            aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="mainNav">
      <ul class="navbar-nav me-auto mb-2 mb-lg-0 gap-lg-1">
        <?php if (user_can('projects')): ?>
        <li class="nav-item">
            <a class="nav-link" href="projects.php">Projekti</a>
        </li>
        <?php endif; ?>
        <?php if (user_can('orders')): ?>
        <li class="nav-item">
            <a class="nav-link" href="orders.php">Nalozi</a>
        </li>
        <?php endif; ?>
        <?php if (user_can('items')): ?>
        <li class="nav-item">
            <a class="nav-link" href="items.php">Artikli</a>
        </li>
        <?php endif; ?>        
        <?php if (user_can('suppliers')): ?>
        <li class="nav-item">
            <a class="nav-link" href="suppliers.php">Dobavljači</a>
        </li>
        <?php endif; ?>
        <?php if (user_can('receipts')): ?>
        <li class="nav-item">
            <a class="nav-link" href="receipts.php">Primke</a>
        </li>
        <?php endif; ?>
        <?php if (user_can('stock')): ?>
        <li class="nav-item">
            <a class="nav-link" href="stock.php">Stanje</a>
        </li>
        <?php endif; ?>
        <?php if (user_can('employees')): ?>
  <a class="nav-link" href="employees.php">
    <i class="fa-solid fa-users me-1"></i> Djelatnici
  </a>
<?php endif; ?>

        <?php if ($user && $user['role'] === 'admin'): ?>
        <li class="nav-item">
            <a class="nav-link" href="users.php">Korisnici</a>
        </li>
        <?php endif; ?>
      </ul>
      <span class="navbar-text me-3 small">
        <?php echo htmlspecialchars($user['username'] ?? ''); ?>
        (<?php echo htmlspecialchars($user['role'] ?? ''); ?>)
      </span>
      <a href="logout.php" class="btn btn-outline-light btn-sm">Odjava</a>
    </div>
  </div>
</nav>
<div class="container pb-4">
