<?php $r="../";
require_once($r."inc/funciones.php");
validNotSession($r);

$spe=$_SESSION['perfil'];
$mysqli = connectDB($r);
roleaccess(2400);
$actioneditar = viewroleaccess(2400) ;
?>

<!DOCTYPE html>
<html lang="es">
  <?php include $r."inc/head.php"; ?>
  <style>
      .container-fluid{padding-right:5px;padding-left:5px;}
  </style>
<body class="fixed-nav sticky-footer sidenav-toggled bg-dark" id="page-top">
  <?php include $r."inc/nav.php"; ?>
 
  <div class="content-wrapper">
    <div class="container-fluid">
      <!-- Example DataTables Card-->
      <div class="card mb-3">
        <div class="card-header">
          <i class="fa fa-table"></i> Lista de Rutas
          <a href="nueva.php" title="Nueva Ruta" class="fa fa-plus fa-lg btn float-right"></a>
          </div>
        <div class="card-body">
          <div class="table-responsive">
            <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
              <thead>
                <tr>
                  <th>Nombre</th>
                  <th>Domiciliario</th>
                  <?php if($actioneditar){?><th></th><? } ?>
                </tr>
              </thead>
              <tfoot>
                <tr>
                  <th>Nombre</th>
                  <th>Domiciliario</th>
                  <?php if($actioneditar){?><th></th><? } ?>
                </tr>
              </tfoot>
              <tbody>
                     <?php
                     $sqlrutas = $mysqli->query("SELECT * FROM z_ruta WHERE eliminado=0");
                    while($rowrutas = $sqlrutas->fetch_assoc()) {
                    ?>
                      <tr>
                        <td><?php echo $rowrutas["nombre"] ?></td>
                        <td><?php $idrutero=$rowrutas["idrutero"]; $rutero=srute($idrutero); echo $rutero['nombre']; ?></td>
                        <?php if($actioneditar){?>
                        <td width="50px" class="text-center h5 p-05"><a class="text-primary d-inline" title="Editar Ruta" href="editar.php?id=<?php echo $rowrutas["id"] ?>"><i class="fa fa-pencil"></i></a> </td>
                        <? } ?>
                        </tr>
                    <?php
                    }
                    ?>
              <tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>
  <?php include $r."inc/foot.php"; ?>
  <script>
      $('#dataTable').DataTable( {
        "lengthMenu": [[25, 50, 100, 500, -1], [25, 50, 100, 500, "All"]]
    } );
  </script>
</body>
</html>    
    