<!-- Main Sidebar Container -->
<aside class="main-sidebar sidebar-dark-primary elevation-4">
  <!-- Brand Logo -->
  <a href="<?=$base;?>" class="brand-link">
    <img src="<?=$base;?>/assets/images/logo_left.jpg" class="brand-image img-circle elevation-3" style="opacity: .8">
    <span class="font-weight-light" style="font-size: 16px;">Supporte Agronegócios</span>
  </a>

  <!-- Sidebar -->
  <div class="sidebar">
    <!-- Sidebar user panel (optional) -->
    <div class="user-panel mt-3 pb-3 mb-3 d-flex">
      <div class="info">
        <a href="#" class="d-block"><?=$loggedUser->name;?></a>
      </div>
    </div>

    <!-- Sidebar Menu -->
    <nav class="mt-2">
      <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
        <!-- Add icons to the links using the .nav-icon class
             with font-awesome or any other icon font library -->
        <li class="nav-item has-treeview">
          <a href="<?=$base;?>" class="nav-link <?= ($pageActive == 'home')?'active':'' ?>">
          	<i class="nav-icon fas fa-solid fa-house-user"></i>
          	<p>Home</p>              	
          </a>
        </li>

        <?php if(in_array('dashboard_view', $permissions)): ?>
        <li class="nav-item has-treeview">
          <a href="<?=$base;?>/dashboard" class="nav-link <?= ($pageActive == 'dashboard')?'active':'' ?>">
          <i class="nav-icon fas fa-tachometer-alt"></i>
            <p>
            Dashboard
            </p>
          </a>
        </li>
        <?php endif; ?>

        <?php if(in_array('clients_view', $permissions)): ?>
        <li class="nav-item has-treeview">
          <a href="<?=$base;?>/clients" class="nav-link <?= ($pageActive == 'clients')?'active':'' ?>">
            <i class="nav-icon fa fa-address-book" aria-hidden="true"></i>
            <p>
              Clientes
            </p>
          </a>
        </li>
        <?php endif; ?>

        <?php if(in_array('requests_view', $permissions)): ?>
        <li class="nav-item has-treeview">

          <a href="#" class="nav-link <?= ($pageActive == 'requests')?'active':'' ?>">
            <i class="nav-icon fa fa-shopping-basket" aria-hidden="true"></i>
            <p>
              Pedidos
              <i class="right fas fa-angle-left"></i>
            </p>
          </a>

          <ul class="nav nav-treeview" style="display: none;">

            <li class="nav-item">
              <a href="<?=$base;?>/requests" class="nav-link">
              <!-- <i class="far fa-circle nav-icon"></i> -->
              <p>Ver Todos</p>
            </a>
            </li>

            <li class="nav-item">
              <a href="<?=$base;?>/reqwithstock" class="nav-link">
              <!-- <i class="far fa-circle nav-icon"></i> -->
              <p>Criar com Estoque</p>
            </a>
            </li>

            <li class="nav-item">
              <a href="<?=$base;?>/reqnostock" class="nav-link">
              <!-- <i class="far fa-circle nav-icon"></i> -->
              <p>Criar sem Estoque</p>
            </a>
            </li>
          </ul>
        </li>
        <?php endif; ?>

        <?php if(in_array('billstoreceiver_view', $permissions)): ?>
        <li class="nav-item has-treeview">
          <a href="<?=$base;?>/billstoreceiver" class="nav-link <?= ($pageActive == 'billstoreceiver')?'active':'' ?>">
            <i class="nav-icon fas fa-receipt" aria-hidden="true"></i>
            <p>
              Contas a Receber
            </p>
          </a>
        </li>
        <?php endif; ?>

        <?php if(in_array('billstopay_view', $permissions)): ?>
        <li class="nav-item has-treeview">
          <a href="<?=$base;?>/billstopay" class="nav-link <?= ($pageActive == 'billstopay')?'active':'' ?>">              
            <i class="nav-icon fas fa-id-card" aria-hidden="true"></i>
            <p>
              Contas a Pagar
            </p>
          </a>
        </li>
        <?php endif; ?>

        <?php if(in_array('products_view', $permissions)): ?>
        <li class="nav-item has-treeview">
          <a href="<?=$base;?>/products" class="nav-link <?= ($pageActive == 'products')?'active':'' ?>">              
            <i class="nav-icon fa fa-database" aria-hidden="true"></i>
            <p>
              Produtos
            </p>
          </a>
        </li>
        <?php endif; ?>

        <?php if(in_array('purshases_view', $permissions)): ?>
        <li class="nav-item has-treeview">
          <a href="<?=$base;?>/purchases" class="nav-link <?= ($pageActive == 'purshases_view')?'active':'' ?>">
            <i class="nav-icon fa fa-cart-arrow-down" aria-hidden="true"></i>
            <p>
              Compras
            </p>
          </a>
        </li>
        <?php endif; ?>

        <?php if(in_array('reports_view', $permissions)): ?>
        <li class="nav-item has-treeview">
          <a href="<?=$base;?>/reports" class="nav-link <?= ($pageActive == 'reports')?'active':'' ?>">
            <i class="nav-icon far fa-chart-bar" aria-hidden="true"></i>
            <p>
              Relatórios
            </p>
          </a>
        </li>
        <?php endif; ?>

        <?php if(in_array('salesman_view', $permissions)): ?>
        <li class="nav-item has-treeview">
          <a href="<?=$base;?>/salesman" class="nav-link <?= ($pageActive == 'salesman')?'active':'' ?>">
            <i class="nav-icon fa fa-child" aria-hidden="true"></i>
            <p>
              Vendedor
            </p>
          </a>
        </li>
        <?php endif; ?>

        <?php if(in_array('providers_view', $permissions)): ?>
        <li class="nav-item has-treeview">
          <a href="<?=$base;?>/providers" class="nav-link <?= ($pageActive == 'providers')?'active':'' ?>">
            <i class="nav-icon fa fa-industry" aria-hidden="true"></i>
            <p>
              Fornecedor
            </p>
          </a>
        </li>
        <?php endif; ?>

        <?php if(in_array('providers_view', $permissions)): ?>
        <li class="nav-item has-treeview">
          <a href="<?=$base;?>/providerservice" class="nav-link <?= ($pageActive == 'providerservice')?'active':'' ?>">
            <i class="nav-icon fa fa-business-time" aria-hidden="true"></i>
            <p>
              Fornecedor de Serviços
            </p>
          </a>
        </li>
        <?php endif; ?>            

        <?php if(in_array('shippings_view', $permissions)): ?>
        <li class="nav-item has-treeview">
          <a href="<?=$base;?>/shippingcompany" class="nav-link <?= ($pageActive == 'shippings')?'active':'' ?>">
            <i class="nav-icon fa fa-truck" aria-hidden="true"></i>

            <p>
              Transportador
            </p>
          </a>
        </li>
        <?php endif; ?>

        <?php if(in_array('users_view', $permissions)): ?>
        <li class="nav-item has-treeview">
          <a href="<?=$base;?>/users" class="nav-link <?= ($pageActive == 'users')?'active':'' ?>">
            <i class="nav-icon fa fa-users" aria-hidden="true"></i>
            <p>Usuários</p>
          </a>
        </li>
        <?php endif; ?>

        <?php if(in_array('permissions_view', $permissions)): ?>
        <li class="nav-item has-treeview">
          <a href="<?=$base;?>/permissions" class="nav-link <?= ($pageActive == 'permissions')?'active':'' ?>">
            <i class="nav-icon fas fa-user-times"></i>
            <p>
              Permissões
            </p>
          </a>
        </li>
        <?php endif; ?>        

        <?php if(in_array('config_view', $permissions)): ?>
        <li class="nav-item has-treeview">
          <a href="<?=$base;?>/configuration" class="nav-link <?= ($pageActive == 'config')?'active':'' ?>">
            <i class="nav-icon fas fa-cog" aria-hidden="true"></i>
            <p>
              Configurações
            </p>
          </a>
        </li>
        <?php endif; ?>

        <?php if(in_array('crm_view', $permissions)): ?>
        <li class="nav-item has-treeview">
          <a href="<?=$base;?>/crm" class="nav-link <?= ($pageActive == 'crm')?'active':'' ?>">
            <i class="nav-icon fas fa-regular fa-comments" aria-hidden="true"></i>
            <p>
              CRM
            </p>
          </a>
        </li>
        <?php endif; ?>

        <?php if(in_array('crm_administrative', $permissions)): ?>
        <li class="nav-item has-treeview">
          <a href="<?=$base;?>/crmadm" class="nav-link <?= ($pageActive == 'crm_administrative')?'active':'' ?>">
            <i class="nav-icon fas fa-regular fa-comments" aria-hidden="true"></i>
            <p>
              CRM Administrativo
            </p>
          </a>
        </li>
        <?php endif; ?>

      </ul>
    </nav>
    <!-- /.sidebar-menu -->
  </div>
  <!-- /.sidebar -->
</aside>