<?php
global $Route;
global $Conf;
global $Session;

$menu = "";
switch ($Route->_script) {
  case "users":
  case "interface":
    $menu = "gestion";
    break;
}
?>
<nav class="navbar" role="navigation">
  <div class="navbar-header">
    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1" aria-expanded="false">
      <span class="sr-only">Navigation</span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </button>
    <a class="navbar-brand" href="/accueil"><img src="/pub/res/img/logo/cleo_150.png" alt="logo <?= $Conf->_brandname; ?>"/></a>
    <p class="navbar-text"><?php echo $Session->_user["prenom"] . " " . $Session->_user["libelle"]; ?></p>
    <?php if ($Route->_script == "devis") {
      ?>
      <a href="#" title="SideBar" class="navbar-text" id="btnSideBarDevis">
        <svg>
          <use xlink:href="pub/res/svg/icons.svg#layout-sidebar-inset" width="18" height="18" style="fill: yellow;"/>
        </svg>
      </a>
      <?php
    }
    ?>
  </div>

  <div class="collapse navbar-collapse" id="navbar-collapse-1">
    <ul class="nav navbar-nav navbar-right" role="navigation">
      <?php
      echo '<li ' . ($Route->_script == "accueil" ? 'class="active">' : '>') . '<a href="/accueil" title="Accueil"><svg><use xlink:href="pub/res/svg/icons.svg#house" style="fill: white;"/></svg></a></li>';

      if ($Session->_user["fk_role"] == 90) {
        echo '<li ' . ($Route->_script == "clients" ? 'class="active">' : '>') . '<a href="/clients" title="Clients"><svg><use xlink:href="pub/res/svg/icons.svg#address-book" style="fill: white;"/></svg> CLIENTS</a></li>';
        echo '<li ' . ($Route->_script == "marches" ? 'class="active">' : '>') . '<a href="/marches" title="Marchés"><svg><use xlink:href="pub/res/svg/icons.svg#cubes" style="fill: white;"/></svg> MARCHES</a></li>';
      }
      if ($Session->_user["fk_role"] == 90 || $Session->_user["fk_role"] == 20) {
        echo '<li ' . ($Route->_script == "sap" ? 'class="active">' : '>') . '<a href="/sap" title="SAP"><svg><use xlink:href="pub/res/svg/icons.svg#gears" style="fill: white;"/></svg> GESTION SAP</a></li>';
      }
      echo '<li ' . ($Route->_script == "devis" ? 'class="active">' : '>') . '<a href="/devis" title="Devis"><svg><use xlink:href="pub/res/svg/icons.svg#file-invoice" style="fill: white;" /></svg> DEVIS</a></li>';

      if ($Session->_user["fk_role"] == 90) {
        echo '<li class="dropdown ' . ($menu == "gestion" ? 'active">' : '">') . '<a href="#" class="dropdown-toggle" data-toggle="dropdown" title="Gestion"><svg><use xlink:href="pub/res/svg/icons.svg#gauge" style="fill: white;" /></svg> GESTION <span class="caret"></span></a>';
        echo '<ul class="dropdown-menu" role="menu">';
        echo '<li><a href="/users" title="Gestion des utilisateurs"><i class="fa fa-users"></i> Utilisateurs</a></li>';
        echo '<li class="divider"></li>';
        echo '<li><a href="/interface" title="Gestion de l\'interface"><i class="fa fa-file"></i> Interface</a></li>';
        echo '</ul>';
        echo '</li>';
      }
      echo '<li class="divider"></li>';
      echo '<li style="background: transparent;"><a href="/login" title="Se déconnecter"><i class="fa fa-power-off"></i></a></li>';
      ?>
    </ul>
  </div>
</nav>
<div class="clearfix"></div>
