
<aside class="main-sidebar">

  <!-- sidebar: style can be found in sidebar.less -->
  <section class="sidebar">

    <!-- sidebar menu: : style can be found in sidebar.less -->
    <ul class="sidebar-menu" data-widget="tree">
      <li id="dashboardMainMenu">
        
        <a href="<?php echo base_url('/') ?>">
          <i class="fa fa-dashboard"></i> <span>Dashboard</span>
        </a>
      </li>

      <?php if ($user_permission): ?>
        <?php if (in_array('createUser', $user_permission) || in_array('updateUser', $user_permission) || in_array('viewUser', $user_permission) || in_array('deleteUser', $user_permission)): ?>
          <li class="treeview" id="mainUserNav">
            <a href="#">
              <i class="fa fa-users"></i>
              <span>Utilisateurs</span>
              <span class="pull-right-container">
                <i class="fa fa-angle-left pull-right"></i>
              </span>
            </a>
            <ul class="treeview-menu">
              <!-- <?php if (in_array('createUser', $user_permission)): ?>
              <li id="createUserNav"><a href="<?php echo base_url('users/create') ?>"><i class="fa fa-circle"></i> Nouvelle utilisateur</a></li>
              <?php endif; ?> -->

              <?php if (in_array('updateUser', $user_permission) || in_array('viewUser', $user_permission) || in_array('deleteUser', $user_permission)): ?>
                <li id="manageUserNav"><a href="<?php echo base_url('users') ?>"><i class="fa fa-circle"></i> Gérer</a></li>
              <?php endif; ?>
              <?php if (in_array('updateGroup', $user_permission) || in_array('viewGroup', $user_permission) || in_array('deleteGroup', $user_permission)): ?>
                <li id="manageGroupNav"><a href="<?php echo base_url('groups') ?>"><i class="fa fa-circle"></i> Gérer Rôles</a></li>
              <?php endif; ?>
            </ul>
          </li>
        <?php endif; ?>

        <!-- <?php if (in_array('createGroup', $user_permission) || in_array('updateGroup', $user_permission) || in_array('viewGroup', $user_permission) || in_array('deleteGroup', $user_permission)): ?>
          <li class="treeview" id="mainGroupNav">
            <a href="#">
              <i class="fa fa-file"></i>
              <span>Rôles</span>
              <span class="pull-right-container">
                <i class="fa fa-angle-left pull-right"></i>
              </span>
            </a>
            <ul class="treeview-menu">
              <?php if (in_array('createGroup', $user_permission)): ?>
                  <li id="addGroupNav"><a href="<?php echo base_url('groups/create') ?>"><i class="fa fa-circle"></i> Nouveau Rôle</a></li>
                <?php endif; ?>
              <?php if (in_array('updateGroup', $user_permission) || in_array('viewGroup', $user_permission) || in_array('deleteGroup', $user_permission)): ?>
                <li id="manageGroupNav"><a href="<?php echo base_url('groups') ?>"><i class="fa fa-circle"></i> Gérer Rôles</a></li>
              <?php endif; ?>
            </ul>
          </li>
        <?php endif; ?> -->


        <!-- <?php if (in_array('createBrand', $user_permission) || in_array('updateBrand', $user_permission) || in_array('viewBrand', $user_permission) || in_array('deleteBrand', $user_permission)): ?>
          <li id="brandNav">
            <a href="<?php echo base_url('brands/') ?>">
              <i class="glyphicon glyphicon-tags"></i> <span>Marques</span>
            </a>
          </li>
        <?php endif; ?> -->

        <!-- <?php if (in_array('createCategory', $user_permission) || in_array('updateCategory', $user_permission) || in_array('viewCategory', $user_permission) || in_array('deleteCategory', $user_permission)): ?>
          <li id="categoryNav">
            <a href="<?php echo base_url('category/') ?>">
              <i class="fa fa-file"></i> <span>categorie</span>
            </a>
          </li>
        <?php endif; ?> -->

        <!--debut espace commerciale -->

        <?php if (in_array('viewCom', $user_permission) || in_array('updateCom', $user_permission)): ?>
  <li class="treeview" id="espaceMainMenu">
    <a href="#">
      <i class="fa fa-shopping-cart"></i>
      <span>Espace commercial</span>
      <span class="pull-right-container">
        <i class="fa fa-angle-left pull-right"></i>
      </span>
    </a>
    <ul class="treeview-menu">
      <li><a href="<?php echo base_url('/ventes') ?>"><i class="fa fa-circle"></i> Produits Disponibles</a></li>

      <?php if (in_array('createOrder', $user_permission) || in_array('updateOrder', $user_permission) || in_array('viewOrder', $user_permission) || in_array('deleteOrder', $user_permission)): ?>
        <li><a href="<?php echo base_url('orders') ?>"><i class="fa fa-circle"></i> Commandes</a></li>
      <?php endif; ?>

      <?php if (in_array('viewAvance', $user_permission)): ?>
        <li><a href="<?php echo base_url('avances/') ?>"><i class="fa fa-circle"></i> Avances</a></li>
      <?php endif; ?>
    </ul>
  </li>
<?php endif; ?>

<!-- historique -->

<?php if (in_array('viewhistorique', $user_permission) || in_array('updatehistorique', $user_permission)): ?>
  <li class="treeview" id="espaceMainMenu">
    <a href="#">
      <i class="class= fa fa-history"></i>
      <span>Historique</span>
      <span class="pull-right-container">
        <i class="fa fa-angle-left pull-right"></i>
      </span>
    </a>
    <ul class="treeview-menu">

      <!-- Lien principal vers l'index de l'historique -->
      <li><a href="<?php echo base_url('historique') ?>"><i class="fa fa-circle"></i> Historiques des Produits</a></li>

      <!-- Lien vers les statistiques (optionnel)
      <li><a href="<?php echo base_url('historique/stats') ?>"><i class="fa fa-circle"></i> Statistiques</a></li> -->

    </ul>
  </li>
<?php endif; ?>



<!-- rapport statistique  -->

<!-- fin espace commerciale -->

        <?php if (in_array('validateSecurite', $user_permission) || in_array('viewSecurite', $user_permission)): ?>
          <li id="securiteNav">
            <a href="<?php echo base_url('/validateSecurite') ?>">
            
              <i class="fa fa-lock"></i> <span> Espace Securite</span>
            </a>
          </li>
        <?php endif; ?>

        <?php if (in_array('createStore', $user_permission) || in_array('updateStore', $user_permission) || in_array('viewStore', $user_permission) || in_array('deleteStore', $user_permission)): ?>
          <li id="storeNav">
            <a href="<?php echo base_url('stores/') ?>">
              <i class="fa fa-home"></i> <span>Point de Ventes</span>
            </a>
          </li>
        <?php endif; ?>

        <?php if (in_array('createEncaissement', $user_permission) || in_array('updateEncaissement', $user_permission) || in_array('viewEncaissement', $user_permission) || in_array('deleteEncaissement', $user_permission)): ?>
          <li id="storeNav">
            <a href="<?php echo base_url('encaissements/') ?>">
              <i class="fa fa-money"></i> <span>Autres Encaissements </span>
            </a>
          </li>
        <?php endif; ?>

        <?php if (in_array('createRecouvrement', $user_permission) ||  in_array('viewRecouvrement', $user_permission) || in_array('updateRecouvrement', $user_permission)  || in_array('deleteRecouvrement', $user_permission)): ?>
          <li id="recouvrement">
            <a href="<?php echo base_url('recouvrement/') ?>">
              <i class="fa fa-usd"></i> <span>Recouvrement</span>
            </a>
          </li>
        <?php endif; ?>
        <?php if (in_array('createMecanicien', $user_permission) || in_array('updateMecanicien', $user_permission) || in_array('viewMecanicien', $user_permission) || in_array('deleteMecanicien', $user_permission)): ?>
          <li id="mecanicNav">
            <a href="<?php echo base_url('mecanicien/') ?>">
              <i class="fa fa-cog"></i> <span>Réparations</span>
            </a>
          </li>
        <?php endif; ?>

        <?php if (in_array('createProduct', $user_permission) || in_array('updateProduct', $user_permission) || in_array('viewProduct', $user_permission) || in_array('deleteProduct', $user_permission)): ?>
          <li class="treeview" id="mainProductNav">
            <a href="#">
              <i class="fa fa-cube"></i>
              <span>Produit</span>
              <span class="pull-right-container">
                <i class="fa fa-angle-left pull-right"></i>
              </span>
            </a>
            <ul class="treeview-menu">
              <!-- <?php if (in_array('createProduct', $user_permission)): ?>
                  <li id="addProductNav"><a href="<?php echo base_url('products/create') ?>"><i class="fa fa-circle"></i> Nouveau Produit</a></li>
                <?php endif; ?> -->
              <?php if (in_array('updateProduct', $user_permission) || in_array('viewProduct', $user_permission) || in_array('deleteProduct', $user_permission)): ?>
                <li id="manageProductNav"><a href="<?php echo base_url('products') ?>"><i class="fa fa-circle"></i> Gestion de Moto</a></li>
              <?php endif; ?>
              <!-- <?php if (in_array('updateProduct', $user_permission) || in_array('viewProduct', $user_permission) || in_array('deleteProduct', $user_permission)): ?>
                <li id="manageProductNav"><a href="<?php echo base_url('products') ?>"><i class="fa fa-circle"></i> Gestion des Pieces</a></li>
                <?php endif; ?> -->

              <?php if (in_array('createBrand', $user_permission) || in_array('updateBrand', $user_permission) || in_array('viewBrand', $user_permission) || in_array('deleteBrand', $user_permission)): ?>
                <li id="brandNav">
                  <a href="<?php echo base_url('brands/') ?>">
                    <i class="glyphicon glyphicon-tags"></i> <span>Marques</span>
                  </a>
                </li>
              <?php endif; ?>

              <?php if (in_array('createCategory', $user_permission) || in_array('updateCategory', $user_permission) || in_array('viewCategory', $user_permission) || in_array('deleteCategory', $user_permission)): ?>
                <li id="categoryNav">
                  <a href="<?php echo base_url('category/') ?>">
                    <i class="fa fa-file"></i> <span>Catégorie</span>
                  </a>
                </li>
              <?php endif; ?>

              <!-- <?php if (in_array('createAttribute', $user_permission) || in_array('updateAttribute', $user_permission) || in_array('viewAttribute', $user_permission) || in_array('deleteAttribute', $user_permission)): ?>
                <li id="attributeNav">
                  <a href="<?php echo base_url('attributes/') ?>">
                    <i class="fa fa-file"></i> <span>Attribut</span>
                  </a>
                </li>
              <?php endif; ?> -->
            </ul>
          </li>
        <?php endif; ?>


        <!-- <?php if (in_array('createOrder', $user_permission) || in_array('updateOrder', $user_permission) || in_array('viewOrder', $user_permission) || in_array('deleteOrder', $user_permission)): ?>
          <li class="treeview" id="mainOrdersNav">
            <a href="#">
              <i class="fa fa-dollar"></i>
              <span>Commandes</span>
              <span class="pull-right-container">
                <i class="fa fa-angle-left pull-right"></i>
              </span>
            </a>
            <ul class="treeview-menu">
               <?php if (in_array('createOrder', $user_permission)): ?>
                  <li id="addOrderNav"><a href="<?php echo base_url('orders/create') ?>"><i class="fa fa-circle"></i> Nouveau Commande</a></li>
                <?php endif; ?> 
              <?php if (in_array('updateOrder', $user_permission) || in_array('viewOrder', $user_permission) || in_array('deleteOrder', $user_permission)): ?>
                <li id="manageOrdersNav"><a href="<?php echo base_url('orders') ?>"><i class="fa fa-circle"></i> Gestion de Commande</a></li>
              <?php endif; ?>
            </ul>
          </li>
        <?php endif; ?> -->

        <?php if (in_array('createSortieCaisse', $user_permission) || in_array('updateSortieCaisse', $user_permission) || in_array('viewSortieCaisse', $user_permission)): ?>
          <li id="sortie_caisse_menu">
            <a href="<?php echo base_url('sortieCaisse/') ?>">
            <i class="fa fa-arrow-circle-down"></i> <span>Décaissement</span>
            </a>
          </li>
        <?php endif; ?>

        <?php if (in_array('validateRemise', $user_permission) || in_array('refusedRemise', $user_permission) || in_array('viewRemise', $user_permission)): ?>
          <li id="remise_menu">
            <a href="<?php echo base_url('remise/') ?>">
            <i class="fa fa-percent"></i> <span>Remise</span>
            </a>
          </li>
        <?php endif; ?>

        <!-- <//?php if (in_array('viewPerformance', $user_permission)): ?>
          <li id="performance_menu">
            <a href="<//?php echo base_url('performance/') ?>">
            <i class="fa fa-user-tie"></i> <span>Performance</span>
            </a>
          </li>
        <//?php endif; ?> -->

        <!-- <?php if (in_array('createAttribute', $user_permission) || in_array('updateAttribute', $user_permission) || in_array('viewAttribute', $user_permission) || in_array('deleteAttribute', $user_permission)): ?>
          <li id="attributeNav">
            <a href="<?php echo base_url('attributes/') ?>">
              <i class="fa fa-file"></i> <span>Attribut</span>
            </a>
          </li>
        <?php endif; ?> -->

        <?php if (in_array('viewReports', $user_permission)): ?>
          <li id="reportNav">
            <a href="<?php echo base_url('reports/') ?>">
              <i class="glyphicon glyphicon-stats"></i> <span>Rapports</span>
              <span class="tooltip">Rapports</span>
            </a>
          </li>
        <?php endif; ?>

        <!-- <?php if (in_array('viewAvance', $user_permission)): ?>
          <li id="avance_menu">
            <a href="<?php echo base_url('avances/') ?>">
            <i class="fas fa-hand-holding-dollar"></i> <span>Avances</span>
            </a>
          </li>
        <?php endif; ?> -->

        <?php if (in_array('updateCompany', $user_permission)): ?>
          <li id="companyNav"><a href="<?php echo base_url('company/') ?>"><i class="fa fa-building"></i> <span>Entreprise</span></a></li>
        <?php endif; ?>



        <!-- <li class="header">Settings</li> -->

        <?php if (in_array('viewProfile', $user_permission)): ?>
          <li><a href="<?php echo base_url('users/profile/') ?>"><i class="fa fa-user"></i> <span>Profile</span></a></li>
        <?php endif; ?>
        <?php if (in_array('updateSetting', $user_permission)): ?>
          <li><a href="<?php echo base_url('users/setting/') ?>"><i class="fa fa-wrench"></i> <span>Paramètre</span></a></li>
        <?php endif; ?>

      <?php endif; ?>

      <!-- user permission info -->
      <li><a href="<?php echo base_url('logout') ?>"><i class="glyphicon glyphicon-log-out"></i> <span>Déconnection</span></a></li>

    </ul>
  </section>
  <!-- /.sidebar -->
</aside>