<?php 
$spe=$_SESSION['perfil'];
$infoperfil = sinfo('z_perfiles',$spe);
$mysqli = connectDB($r);
?>
<!-- Navigation-->
<div class="container" >
    <div id="msn-alert" style="z-index:99999;position:fixed;width:90%;padding-left:10%;bottom:40px;left:0px;margin:0 auto;">
    <? if($error!=''){ echo '<div class="alert alert-danger alert-dismissible text-center"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><h6>'.$error.'</h6></div>';} elseif($msn!=''){ echo '<div class="alert alert-success alert-dismissible text-center"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><h6>'.$msn.'</h6></div>';} ?></div>
</div>
 <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top" id="mainNav">
    <a class="navbar-brand" href="<? echo $r; ?>dashboard.php">QUIMIFOREN</a>
    <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarResponsive">
      <ul class="navbar-nav navbar-sidenav custom-scroll" id="exampleAccordion" style="overflow-y: scroll;">
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="<? echo $_SESSION['nombre']; ?> - <? echo $infoperfil['nombre']; ?>">
          <a class="nav-link"><i class="fa fa-user-circle"></i><span class="nav-link-text"> <? echo $_SESSION['nombre']; ?><br> <small><? echo $infoperfil['nombre']; ?></small></span></a>
        </li>
        
        <?php if(viewmultiroleaccess([1110,1210])){ ?>
        <!-- USUARIOS -->
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Usuarios">
          <a class="nav-link nav-link-collapse collapsed" data-toggle="collapse" href="#usuarios" data-parent="#exampleAccordion">
            <i class="fa fa-users"></i><span class="nav-link-text">  Usuarios</span>
          </a>
          <ul class="sidenav-second-level collapse" id="usuarios">
            <?php if(viewmultiroleaccess([1110,1120,1130,1140])){ ?>
            <li>
              <a class="nav-link-collapse collapsed" data-toggle="collapse" href="#clientes"><i class="fa fa-users"></i> Clientes</a>
              <ul class="sidenav-third-level collapse" id="clientes">
                <?php if(viewroleaccess(1110)){ ?><li><a href="<? echo $r; ?>usuarios/cliente/nuevo.php"><i class="fa fa-user-plus"></i> Nuevo</a></li><? } ?>
                <?php if(viewroleaccess(1120)){ ?><li><a href="<? echo $r; ?>usuarios/cliente/"><i class="fa fa-users"></i> Ver Todos</a></li><? } ?>
                <?php if(viewroleaccess(1130)){ ?><li><a href="<? echo $r; ?>usuarios/cliente/eliminados.php"><i class="fa fa-user-times"></i> Eliminados</a></li><? } ?>
                <?php /* if(viewroleaccess(1140)){ ?><li><a href="<? echo $r; ?>usuarios/cliente/consultar.php"><i class="fa fa-user-secret"></i> Consultar</a></li><? } */?>
              </ul>
            </li>
            <? } ?>
            <?php if(viewmultiroleaccess([1210,1220])){ ?>
            <li>
              <a class="nav-link-collapse collapsed" data-toggle="collapse" href="#admin"><i class="fa fa-gears"></i> Usuarios</a>
              <ul class="sidenav-third-level collapse" id="admin">
                <?php if(viewroleaccess(1210)){ ?><li><a href="<? echo $r; ?>usuarios/all/nuevo.php"><i class="fa fa-user-plus"></i> Nuevo</a></li><? } ?>
                <?php if(viewroleaccess(1220)){ ?><li><a href="<? echo $r; ?>usuarios/all/"><i class="fa fa-users"></i> Ver Todos</a></li><? } ?>
              </ul>
            </li>
            <? } ?>
            <?php if(viewmultiroleaccess([2510,2520])){ ?>
            <li>
              <a class="nav-link-collapse collapsed" data-toggle="collapse" href="#proveedor"><i class="fa fa-cog"></i> Proveedores</a>
              <ul class="sidenav-third-level collapse" id="proveedor">
                <?php if(viewroleaccess(2520)){ ?><li><a href="<? echo $r; ?>usuarios/proveedor/precios.php"><i class="fa fa-plus"></i> ver precios</a></li><? } ?>
                <?php if(viewroleaccess(2510)){ ?><li><a href="<? echo $r; ?>usuarios/proveedor/index.php"><i class="fa fa-users"></i> Ver proveedores</a></li><? } ?>
              </ul>
            </li>
            <? } ?>
          </ul>
        </li>
        <? } ?>
        <?php if(viewmultiroleaccess([1310])){ ?>
        <!-- PRODUCTOS -->
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Productos">
            <a class="nav-link nav-link-collapse collapsed" data-toggle="collapse" href="#productos" data-parent="#exampleAccordion">
                <i class="fa fa-shopping-bag"></i><span class="nav-link-text"> Productos</span>
            </a>
            <ul class="sidenav-second-level collapse" id="productos">
                <?php if(viewroleaccess(1310)){ ?><li><a href="<? echo $r; ?>productos/nuevo.php"><i class="fa fa-plus"></i> Nuevo</a></li><? } ?>
                <?php if(viewroleaccess(1320)){ ?><li><a href="<? echo $r; ?>productos/"><i class="fa fa-eye"></i> Ver Todos</a></li><? } ?>
                <?php if(viewroleaccess(1320)){ ?><li><a href="<? echo $r; ?>productos/eliminados.php"><i class="fa fa-trash"></i> Ver Eliminados</a></li><? } ?>
                <?php if(viewroleaccess(1330)){ ?><li><a href="<? echo $r; ?>productos/consultar.php"><i class="fa fa-search"></i> Consultar</a></li><? } ?>
            </ul>
        </li>
        <? } ?>
        <?php if(viewmultiroleaccess([1410,1420,1430,1440,1450,1460,1470,1480,1490,1500])){ ?>
        <!-- PEDIIDOS -->
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="pedidos">
            <a class="nav-link nav-link-collapse collapsed" data-toggle="collapse" href="#pedidos" data-parent="#exampleAccordion">
                <i class="fa fa-shopping-basket"></i><span class="nav-link-text">  Pedidos</span>
            </a>
            <ul class="sidenav-second-level collapse" id="pedidos">
                <?php if(viewroleaccess(1410)){ ?><li><a href="<? echo $r; ?>pedido/aprobar-pedido.php"><i class="fa fa-check"></i> Por Aprobar</a></li><? } ?>
                <?php if(viewmultiroleaccess([1421,1426,1427])){ ?>
                <li><a class="nav-link-collapse collapsed" data-toggle="collapse" href="#aprobar"><i class="fa fa-check-square-o"></i> Por Cobrar</a>
                    <ul class="sidenav-third-level collapse" id="aprobar">
                        <?php if(viewroleaccess(1421)){ ?><li><a href="<? echo $r; ?>pedido/cobrar.php"><i class="fa fa-list"></i> Por Pedido</a></li><? } ?>
                        <?php if(viewroleaccess(1426)){ ?><li><a href="<? echo $r; ?>pedido/cobrar-clientes.php"><i class="fa fa-users"></i> Por Cliente</a></li><? } ?>
                        <?php if(viewroleaccess(1427)){ ?><li><a href="<? echo $r; ?>pedido/cobrados.php"><i class="fa fa-book"></i> Registro de Pedidos Pagos</a></li><? } ?>
                        <?php if(viewroleaccess(1427)){ ?><li><a href="<? echo $r; ?>pedido/mis-abonos.php"><i class="fa fa-history"></i> Historico de Abonos</a></li><? } ?>
                    </ul>
                </li>
                <? } ?>
                <?php if(viewroleaccess(1430)){ ?><li><a href="<? echo $r; ?>pedido/por-remesa.php"><i class="fa fa-tags"></i> Por remesa</a></li><? } ?>
                <?php if(viewroleaccess(1440)){ ?><li><a href="<? echo $r; ?>caja/prints.php"><i class="fa fa-print"></i> Por Imprimir</a></li><? } ?>
                <?php if(viewroleaccess(1450)){ ?><li><a href="<? echo $r; ?>factura/por-assignar.php"><i class="fa fa-upload"></i> Por Asignar</a></li><? } ?>
                <?php if(viewroleaccess(1460)){ ?><li><a href="<? echo $r; ?>pedido/"><i class="fa fa-plus"></i> Nuevo</a></li><? } ?>
                <?php if(viewroleaccess(1470)){ ?><li><a href="<? echo $r; ?>pedido/mis-pedidos.php"><i class="fa fa-eye"></i> Mis Pedidos</a></li><? } ?>
                <?php if(viewroleaccess(1480)){ ?><li><a href="<? echo $r; ?>pedido/consultar.php"><i class="fa fa-search"></i> Consultar</a></li><? } ?>
                <?php if(viewroleaccess(1490)){ ?><li><a href="<? echo $r; ?>pedido/pagos_consultar.php"><i class="fa fa-search"></i> Entradas dinero</a></li><? } ?>
                <?php if(viewroleaccess(1500)){ ?><li><a href="<? echo $r; ?>pedido/domiciliario_lista_reasignar.php"><i class="fa fa-refresh"></i> Reasignar Domiciliario</a></li><? } ?>
                <?php if(viewroleaccess(1500)){ ?><li><a href="https://tracking.quimiforen.com/app/live.php" ><i class="fa fa-map-marker"></i> live trackingApp</a></li><? } ?>
                <?php if(viewroleaccess(1500)){ ?><li><a href="<? echo $r; ?>pedido/pedidos_ruta.php?estado=pendiente"><i class="fa fa-road"></i> Pedidos trackingApp</a></li><? } ?>
                <?php if(viewroleaccess(1500)){ ?><li><a href="<? echo $r; ?>pedidosweb/"><i class="fa fa-truck"></i> Pedidos WEB</a></li><? } ?>
          </ul>
        </li>
        <? } ?>
        <?php if(viewmultiroleaccess([1610,1620,1630,1640,1650])){ ?>
        <!-- BODEGA -->
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Bodega">
            <a class="nav-link nav-link-collapse collapsed" data-toggle="collapse" href="#sbodega" data-parent="#exampleAccordion">
                <i class="icon-bodega"></i><span class="nav-link-text">  Bodega</span>
            </a>
            <ul class="sidenav-second-level collapse" id="sbodega">
                <?php if(viewroleaccess(1610)){ ?><li><a href="<? echo $r; ?>bodega/index.php"><i class="fa fa-plus"></i> Entregar por Domiciliario</a></li><? } ?>
                <?php if(viewroleaccess(1620)){ ?><li><a href="<? echo $r; ?>bodega/por-entregar-pedido.php"><i class="fa fa-plus"></i> Entregar por Pedido</a></li><? } ?>
                <?php if(viewroleaccess(1630)){ ?><li><a href="<? echo $r; ?>bodega/devolucion.php"><i class="fa fa-remove"></i> Devoluciones</a></li><? } ?>
                <?php if(viewroleaccess(1640)){ ?><li><a href="<? echo $r; ?>bodega/devolucion-especial.php"><i class="fa fa-remove"></i> Devolucion especial</a></li><? } ?>
                <?php if(viewroleaccess(1650)){ ?><li><a href="<? echo $r; ?>bodega/inventario.php"><i class="icon-bodega"></i> Inventario</a></li><? } ?>
          </ul>
        </li>
        <? } ?>
        
        <?php if(viewmultiroleaccess([1710])){ ?>
        <!-- RUTAS -->
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Caja">
          <a href="<? echo $r; ?>caja" class="nav-link"><i class="fa fa-calculator "></i><span class="nav-link-text"> Caja</span></a>
        </li>
        <?php } ?>
        
        <?php if(viewmultiroleaccess([1810,1820,1830,1840])){ ?>
        <!-- REPORTES -->
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Cotizaciones">
            <a class="nav-link nav-link-collapse collapsed" data-toggle="collapse" href="#Cotizaciones" data-parent="#Cotizaciones">
                <i class="fa fa-shopping-cart "></i><span class="nav-link-text">  Cotizaciones / ProFormas</span>
            </a>
            <ul class="sidenav-second-level collapse" id="Cotizaciones">
                <?php if(viewroleaccess(1810)){ ?><li><a href="<? echo $r; ?>cotizacion/cotizaciones.php"><i class="fa fa-list"></i> Ver Cotizaciones</a></li><? } ?>
                <?php if(viewroleaccess(1820)){ ?><li><a href="<? echo $r; ?>cotizacion/nueva_remi.php"><i class="fa fa-plus"></i> Cotización Remi</a></li><? } ?>
                <?php if(viewroleaccess(1820)){ ?><li><a href="<? echo $r; ?>cotizacion/nueva_electro.php"><i class="fa fa-plus"></i> Cotización Electrónica</a></li><? } ?>
                <?php if(viewroleaccess(1830)){ ?><li><a href="<? echo $r; ?>cotizacion/proformas.php"><i class="fa fa-list"></i> Ver Pro Formas</a></li><? } ?>
          </ul>
        </li>
        <? } ?>
        <?php if(viewmultiroleaccess([1910,1920])){ ?>
        <!-- REPORTES -->
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Orden de Compra">
            <a class="nav-link nav-link-collapse collapsed" data-toggle="collapse" href="#ordencompra" data-parent="#ordencompra">
                <i class="fa fa-list-alt"></i><span class="nav-link-text">  Orden de Compra</span>
            </a>
            <ul class="sidenav-second-level collapse" id="ordencompra">
                <?php if(viewroleaccess(1910)){ ?><li><a href="<? echo $r; ?>ordencompra/index.php"><i class="fa fa-list"></i> Ver Todas</a></li><? } ?>
                <?php if(viewroleaccess(1920)){ ?><li><a href="<? echo $r; ?>ordencompra/nueva.php"><i class="fa fa-plus"></i> Nueva</a></li><? } ?>
          </ul>
        </li>
        <? } ?>
        <?php if(viewmultiroleaccess([2010,2020])){ ?>
        <!-- REPORTES -->
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="Reportes">
    <a class="nav-link nav-link-collapse collapsed" data-toggle="collapse" href="#reportes" data-parent="#sidenavAccordion">
        <i class="fa fa-line-chart"></i>
        <span class="nav-link-text"> Reportes</span>
    </a>

    <ul class="sidenav-second-level collapse" id="reportes">

        <?php if(viewroleaccess(2010)){ ?>
        <li>
            <a href="<?php echo $r; ?>reportes/general.php">
                <i class="fa fa-dashboard"></i> General
            </a>
        </li>
        <?php } ?>

        <?php if(viewroleaccess(2010)){ ?>
        <li>
            <a href="<?php echo $r; ?>reportes/productos.php">
                <i class="fa fa-cubes"></i> Productos
            </a>
        </li>
        <?php } ?>

        <?php if(viewroleaccess(2010)){ ?>
        <li>
            <a href="<?php echo $r; ?>reportes/clientes.php">
                <i class="fa fa-users"></i> Clientes
            </a>
        </li>
        <?php } ?>

        <?php if(viewroleaccess(2010)){ ?>
        <li>
            <a href="<?php echo $r; ?>reportes/vendedores.php">
                <i class="fa fa-user"></i> Vendedores
            </a>
        </li>
        <?php } ?>

        <?php if(viewroleaccess(2010)){ ?>
        <li>
            <a href="<?php echo $r; ?>reportes/comparar.php">
                <i class="fa fa-exchange"></i> Comparativo
            </a>
        </li>
        <?php } ?>

        <?php if(viewroleaccess(2010)){ ?>
        <li>
            <a href="<?php echo $r; ?>reportes/pedidos.php">
                <i class="fa fa-file-text"></i> Pedidos
            </a>
        </li>
        <?php } ?>

    </ul>
</li>

        <? } ?>
        <?php /*if(viewmultiroleaccess([31,32])){ ?>
        <!-- AZ-DIARIAS -->
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="azdiaria">
            <a class="nav-link nav-link-collapse collapsed" data-toggle="collapse" href="#azdiaria" data-parent="#exampleAccordion">
                <i class="fa fa-shopping-bag"></i><span class="nav-link-text"> AZ Diarias</span>
            </a>
            <ul class="sidenav-second-level collapse" id="azdiaria">
                <?php if(viewroleaccess(31)){ ?><li><a href="<? echo $r; ?>azdiarias/consulta.php"><i class="fa fa-plus"></i> Consulta</a></li><? } ?>
                <?php if(viewroleaccess(32)){ ?><li><a href="<? echo $r; ?>azdiarias/lista.php"><i class="fa fa-eye"></i> Az Diaria</a></li><? } ?>
          </ul>
        </li>
        <?php } */?>
        <?php if(viewmultiroleaccess([2111,2121,2210,2220,2300,2400])){ ?>
        <!-- ESTADO -->
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Configuracion">
            <a class="nav-link nav-link-collapse collapsed" data-toggle="collapse" href="#config" data-parent="#Configuracion">
                <i class="fa fa-cog"></i><span class="nav-link-text"> Configuracion</span>
            </a>
            <ul class="sidenav-second-level collapse" id="config">
                <?php if(viewmultiroleaccess([2111,2121])){ ?>
                <li><a class="nav-link-collapse collapsed" data-toggle="collapse" href="#retenciones"><i class="fa fa-usd"></i> Retenciones</a>
                    <ul class="sidenav-third-level collapse" id="retenciones">
                        <?php if(viewroleaccess(2111)){ ?><li><a href="<? echo $r; ?>retencion/ica.php"><i class="fa fa-list"></i> RTE ICA</a></li><? } ?>
                        <?php if(viewroleaccess(2121)){ ?><li><a href="<? echo $r; ?>retencion/fuente.php"><i class="fa fa-list"></i> RTE FUENTE</a></li><? }?>
                    </ul>
                </li>
                <? } ?>
                <?php if(viewmultiroleaccess([2601,2606])){ ?>
                <li><a class="nav-link-collapse collapsed" data-toggle="collapse" href="#ganancias"><i class="fa fa-percent"></i> Ganancia</a>
                    <ul class="sidenav-third-level collapse" id="ganancias">
                        <?php if(viewroleaccess(2601)){ ?><li><a href="<? echo $r; ?>config/presentaciones.php"><i class="fa fa-list"></i> Presentacion</a></li><? } ?>
                        <?php if(viewroleaccess(2606)){ ?><li><a href="<? echo $r; ?>config/clientes.php"><i class="fa fa-list"></i> tipo de cliente</a></li><? }?>
                    </ul>
                </li>
                <? } ?>
                <?php if(viewroleaccess(2200)){ ?><li><a href="<? echo $r; ?>inicio/slider.php"><i class="fa fa-home"></i> pagina Web</a></li><? } ?>
                <?php if(viewroleaccess(2300)){ ?><li><a href="<? echo $r; ?>perfiles/"><i class="fa fa-check-square-o"></i> Permisos de Perfil</a></li><? } ?>
                <?php if(viewroleaccess(2400)){ ?><li><a href="<? echo $r; ?>ruta/"><i class="fa fa-road"></i> Rutas</a></li><? } ?>
                
                
          </ul>
        </li>
        <? } ?>
      </ul>
      <ul class="navbar-nav sidenav-toggler">
        <li class="nav-item">
          <a class="nav-link text-center" id="sidenavToggler">
            <i class="text-primary fa fa-2x fa-angle-left"></i>
          </a>
        </li>
      </ul>
      <ul class="navbar-nav ml-auto">
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle mr-lg-2" id="messagesDropdown" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            <i class="fa fa-fw fa-envelope"></i>
            <span class="d-lg-none">Pedidos
              <span class="badge badge-pill badge-primary"><p id="numsn"></p></span>
            </span>
            <span class="indicator text-primary d-none d-lg-block">
              <i class="fa fa-fw fa-circle"><span class="alertnum text-white" id="numsn2"></span></i>
            </span>
          </a>
          <div class="dropdown-menu" aria-labelledby="messagesDropdown">
            <h6 class="dropdown-header">Pedidos:</h6>
            <div id="txtmsn">
                
            </div>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item small" href="#">View all messages</a>
          </div>
        </li>
        <li class="nav-item">
          <a href="<? echo $r; ?>logout.php" class="nav-link logout"><i class="fa fa-fw fa-sign-out"></i>Cerrar Session</a>
        </li>
      </ul>
    </div>
  </nav>