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

$spe=$_SESSION['perfil'];
$mysqli = connectDB($r);
roleaccess(1910);
$iduser=$_SESSION['userid'];
$row1 = $mysqli->query("SELECT * FROM z_orden_compra WHERE estado=0 ");
?>
<!DOCTYPE html>
<html lang="es">
  <?php include $r."inc/head.php"; ?>
  
 
<body class="fixed-nav sidenav-toggled sticky-footer bg-dark" id="page-top">
  <?php include $r."inc/nav.php"; ?>
  <div class="content-wrapper">
    <div class="container-fluid">
      <div class="card mb-3">
        <div class="card-header">
          <a class="btn btn-primary float-right text-white m-1" href="nueva.php">Nueva Orden de Compra</a></div>
        <div class="card-body">
          <div class="table-responsive">
            <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
              <thead>
                <tr>
                  <th>Proveedor</th>
                  <th>Contacto</th>
                  <th>Telefono</th>
                  <th>Fecha</th>
                  <th>Codigo</th>
                  <th></th>
                </tr>
              </thead>
              <tfoot>
                <tr>
                  <th>Proveedor</th>
                  <th>Contacto</th>
                  <th>Telefono</th>
                  <th>Fecha</th>
                  <th>Codigo</th>
                  <th></th>
                </tr>
              </tfoot>
              <tbody>
                    <?php
                    while($row2 = $row1->fetch_assoc()) {
                    ?>
                      <tr>
                        <td><?= $row2['proveedor']; ?></td>
                        <td><?= $row2['asesor'];?></td>
                        <td><?= $row2["celular"]; ?></td>
                        <td><?= $row2["fecha"]; ?></td>
                        <td><?= $row2["id"]; ?></td>
                        <td class="p-1" width="75px">
                            <i class="btn fa fa-print fa-lg p-0 m-1 text-primary" onClick="return popitup('print-orden.php?code=<?php echo $row2["id"] ?>')"></i></a>
                            <a class="fa fa-pencil btn_default text-warning h5" href="editar.php?id=<?= $row2["id"] ?>"></a>
                        </td>
                        </tr>
                    <?php
                    }
                    ?>
              <tbody>
            </table>
          </div>
        </div>
      </div><a class="btn btn-primary btn-block" href="nueva.php" title="Nuevo Pedido">Nueva Orden de Compra</a>
    </div>
  </div>
  <?php include $r."inc/foot.php"; ?>
  
  <script>
    $('#dataTable').DataTable( {
        "order": [[ 4, "desc" ]],
        "lengthMenu": [[25, 50, 100, 500, -1], [25, 50, 100, 500, "All"]]
    } );
    
    function popitup(url){
	    newwindow=window.open(url,'name','height=1170,width=826'); 
	    if (window.focus) {newwindow.print();}
	    return false; 
    }
  </script>
</body>
</html>    
    