<?php
	
	require_once "config/database.php";
        require_once ("config/db.php");//Contiene las variables de configuracion para conectar a la base de datos
	require_once ("config/conexion.php");//Contiene funcion que conecta a la base de datos
	
	$query = mysqli_query($mysqli, "SELECT user_id, firstname, lastname,user_name,permiso FROM users WHERE user_id='$_SESSION[user_id]'")
                                or die('error: '.mysqli_error($mysqli));
	
	$data = mysqli_fetch_assoc($query);
	
	?>
	<?php
		if (isset($title))
		{
	?>
	
<nav class="navbar navbar-default ">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">BONUSTRADE</a>
	   
	  
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
	<?php
	if  ($data['permiso'] == 1|| $data['permiso'] ==4 )     {
		?>
	  
	    <ul class="nav navbar-nav">
                <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true"><i class='glyphicon glyphicon-list-alt'></i>  <span class="nav-label">Documentos</span> <span class="caret"></span></a>
                <ul class="dropdown-menu">
                <li class="<?php echo $active_nueva_facturas_admin;?>"><a href="nueva_factura _admin.php"><i class='glyphicon glyphicon-pencil'></i> Nueva <span class="sr-only">(current)</span></a></li>
                <li class="<?php echo $active_facturas_admin;?>"><a href="facturas _admin.php"><i class='glyphicon glyphicon-file'></i> Por Bonificar <span class="sr-only">(current)</span></a></li>
                <li class="<?php echo $active_bonificadas;?>"><a href="bonificadas.php"><i class='glyphicon glyphicon-ok'></i> Bonificadas <span class="sr-only">(current)</span></a></li>
                <li class="<?php echo $active_canceladas;?>"><a href="canceladas.php"><i class='glyphicon glyphicon-remove'></i> Canceladas <span class="sr-only">(current)</span></a></li>

                </ul>
                </li>
            </ul>
			
			<?php
								
			}else {
			?>
			    <ul class="nav navbar-nav">
                <li class="dropdown">
			    <li class="<?php echo $active_facturas;?>"><a href="nueva_factura.php"><i class='glyphicon glyphicon-pencil'></i> Nueva <span class="sr-only">(current)</span></a></li>
                <li class="<?php echo $active_facturas;?>"><a href="facturas.php"><i class='glyphicon glyphicon-file'></i> Por Bonificar <span class="sr-only">(current)</span></a></li>
                <li class="<?php echo $active_bonificadas;?>"><a href="bonificadas.php"><i class='glyphicon glyphicon-ok'></i> Bonificadas <span class="sr-only">(current)</span></a></li>
                <li class="<?php echo $active_canceladas;?>"><a href="canceladas.php"><i class='glyphicon glyphicon-remove'></i> Canceladas <span class="sr-only">(current)</span></a></li>
			    </ul>
                </li>
                </ul>
			
			<?php
								
			}
			?>
			
        
        <?php
        
       
        
        if  ($data['permiso'] == 1   )     {
                
                ?>
                
                    <ul class="nav navbar-nav">
                 <li class="dropdown">
                 <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true"><i class='glyphicon glyphicon-equalizer'></i>  <span class="nav-label">Reportes</span> <span class="caret"></span></a>
                 <ul class="dropdown-menu">
                 <li class="<?php echo $active_rep_mes_ejeutivo;?>"><a href="repmesEjecutivo.php"><i class="glyphicon glyphicon-transfer"></i> Reporte por ejecutivo</a></li>
                 <li class="<?php echo $active_rep_mes;?>">         <a href="repmesBimestre.php">        <i class="glyphicon glyphicon-calendar"></i> Reporte por bimestre</a></li>
                 <li class="<?php echo $active_rep_gral;?>">         <a href="repGeneral.php">        <i class="glyphicon glyphicon-signal"></i> Reporte por bimestre y tipo (Costo, Caja, Botella)</a></li>
         

                </ul>
                </li>
            </ul>
		
	     <ul class="nav navbar-nav">
                 <li class="dropdown">
                 <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true"><i class='glyphicon glyphicon-cog'></i>  <span class="nav-label">Catalogos</span> <span class="caret"></span></a>
                 <ul class="dropdown-menu">
                 <li class="<?php echo $active_productos;?>"><a href="productos.php"><i class='glyphicon glyphicon-tag'></i> Productos</a></li>
                 <li class="<?php echo $active_porcentaje;?>"><a href="porcentaje.php"><i class='glyphicon glyphicon-piggy-bank'></i> Porcentajes de bonificacion</a></li>
                 <li class="<?php echo $active_anio;?>"><a href="anio.php"><i class='glyphicon glyphicon-calendar'></i>Periodo anual</a></li>
                 <li class="<?php echo $active_periodo;?>"><a href="periodo.php"><i class='glyphicon glyphicon-hourglass'></i>Periodos mensuales / bimestrales</a></li>
                 <li class="<?php echo $active_clientes;?>"><a href="clientes.php"><i class='glyphicon glyphicon-shopping-cart'></i> Clientes</a></li>
                 <li class="<?php echo $active_mayorista;?>"><a href="mayoristas.php"><i  class='glyphicon glyphicon-scale'></i> Mayoristas</a></li>
                 <li class="<?php echo $active_poblacion;?>"><a href="zonas.php"><i  class='glyphicon glyphicon-tree-conifer'></i> Zonas </a></li>
                 <li class="<?php echo $active_usuarios;?>"><a href="usuarios.php"><i  class='glyphicon glyphicon-user'></i> Usuarios </a></li>
                 
               <!--  <li class="<?php echo $active_cierre;?>"><a href="cierre.php"><i  class='glyphicon glyphicon-lock'></i> Cierre temporal </a></li>
                 <li class="<?php echo $active_respaldar;?>"><a href="respaldosFuncional.php"><i  class='glyphicon glyphicon-floppy-save'></i> Descargar respaldo de base de datos </a></li>
                 <li class="<?php if(isset($active_perfil)){echo $active_perfil;}?>"><a href="perfil.php"><i  class='glyphicon glyphicon-cog'></i> Configuracion</a></li>-->
                 
                 

                </ul>
                </li>
            </ul>
            
            <ul class="nav navbar-nav">
                 <li class="dropdown">
                 <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true"><i class='glyphicon glyphicon-cog'></i>  <span class="nav-label">Configuraciones</span> <span class="caret"></span></a>
                 <ul class="dropdown-menu">
                
                 <li class="<?php echo $active_cierre;?>"><a href="cierre.php"><i  class='glyphicon glyphicon-lock'></i> Cierre temporal </a></li>
                 <li class="<?php echo $active_respaldar;?>"><a href="respaldosFuncional.php"><i  class='glyphicon glyphicon-floppy-save'></i> Descargar respaldo de base de datos </a></li>
                 <li class="<?php if(isset($active_perfil)){echo $active_perfil;}?>"><a href="perfil.php"><i  class='glyphicon glyphicon-cog'></i> Configuracion</a></li>
                 
                 

                </ul>
                </li>
            </ul>
            
         
        
        <?php
								
								}
								
								elseif ($data['permiso'] == 2   ) {
								?>
        
        <ul class="nav navbar-nav">
                 <li class="dropdown">
                 <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true"><i class='glyphicon glyphicon-cog'></i>  <span class="nav-label">Catalogos</span> <span class="caret"></span></a>
                 <ul class="dropdown-menu">
                 <li class="<?php echo $active_productos;?>"><a href="productos.php"><i class='glyphicon glyphicon-tag'></i> Productos</a></li>
                 <li class="<?php echo $active_clientes;?>"><a href="clientes.php"><i class='glyphicon glyphicon-shopping-cart'></i> Centros de consumo</a></li>
                 <li class="<?php echo $active_mayorista;?>"><a href="mayoristas.php"><i  class='glyphicon glyphicon-scale'></i> Mayoristas</a></li>
                 <li class="<?php echo $active_poblacion;?>"><a href="zonas.php"><i  class='glyphicon glyphicon-tree-conifer'></i> Zonas </a></li>
                

                </ul>
                </li>
            </ul>
			<?php
								
								}elseif ($data['permiso'] == 4   ) {
								?>
        
        <ul class="nav navbar-nav">
                 <li class="dropdown">
                 <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true"><i class='glyphicon glyphicon-cog'></i>  <span class="nav-label">Catalogos</span> <span class="caret"></span></a>
                 <ul class="dropdown-menu">
                 <li class="<?php echo $active_productos;?>"><a href="productos.php"><i class='glyphicon glyphicon-tag'></i> Productos</a></li>
                 <li class="<?php echo $active_clientes;?>"><a href="clientes.php"><i class='glyphicon glyphicon-shopping-cart'></i> Centros de consumo</a></li>
                 <li class="<?php echo $active_mayorista;?>"><a href="mayoristas.php"><i  class='glyphicon glyphicon-scale'></i> Mayoristas</a></li>
                 <li class="<?php echo $active_poblacion;?>"><a href="zonas.php"><i  class='glyphicon glyphicon-tree-conifer'></i> Zonas </a></li>
          

                </ul>
                </li>
            </ul>
        
        
        <?php
								
								}else {
								?>
        
         <ul class="nav navbar-nav">
            
                </ul>
                </li>
            </ul>
        
        <?php		
            }	
         ?>  
         
         	
	 <?php
        
       
        
        if  ($data['permiso'] == 1   )     {
                
                ?>
		
	    
        
        <?php
								
								}
								
						
								?>

	
	
      <ul class="nav navbar-nav navbar-right">
        <li><a href="http://www.toolsnet.mx" target='_blank'><i class='glyphicon glyphicon-envelope'></i> Soporte</a></li>
		<li><a href="https://bonustrade.casatequilaarandas.com/login.php?logout"><i class='glyphicon glyphicon-off'></i> Salir</a></li>
		<li><a><i class='glyphicon glyphicon-user'></i> <?php echo $data['firstname']; ?></a></li>
		
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
	<?php
		}
	?>