<?
$r = "../";
require_once($r."inc/funciones.php");
$titlepage = "Pedidos por Asignar";
validNotSession($r);
$spe=$_SESSION['perfil'];
$mysqli = connectDB($r);
roleaccess(1450);
$actionexcel = viewroleaccess(1125);
$row1 = $mysqli->query("SELECT * FROM z_pedidos WHERE codigofactura IS NULL AND fechaaprovacion IS NOT NULL  AND soporte IS NULL");
?>
<!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="h3 card-header">
          <i class="fa fa-table"></i> Pedios por Asignar</div>
        <div class="card-body">
          <div class="table-responsive">
            <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
              <thead>
                <tr>
                  <th>Cliente</th>
                  <th style="width:83px">Fecha</th>
                  <th style="width:60px">Codigo</th>
                  <th style="width:25px">tipo</th>
                  <th style="width:20px"></th>
                </tr>
              </thead>
              <tfoot>
                <tr>
                  <td>Cliente</td>
                  <td>Fecha</td>
                  <td>Codigo</td>
                  <td>tipo</td>
                  <td></td>
                </tr>
              </tfoot>
              <tbody>
                    <?php
                    while($row2 = $row1->fetch_assoc()) {
                    ?>
                      <tr>
                          <td><? $cliente=sclien($row2[idcliente]); echo $cliente[nombre]; ?></td>
                          <td><? echo substr($row2[fecha], 0, 10); ?></td>
                          <td><b><? echo $row2[codigopedido]; ?></b></td>
                          <td><? echo $row2[tipopedido]; ?></td>
                          <td><? if($row2[tipopedido]==F){ ?><a class="p-1" href="assignar-codigo.php?id=<? echo $row2[codigopedido]; ?>"><i class="fa fa-pencil"></i></a><? }else{ ?><a class="text-warning" href="assignar-soporte.php?id=<? echo $row2[codigopedido]; ?>"><i class="fa fa-file"></i></a><? } ?></td>
                      </tr>
                    <?php
                    }
                    ?>
              <tbody>
            </table>
          </div>
        </div><? echo $subtotal;?>
      </div>
      <input type="button" class="btn btn-primary float-left" value="Atras" name="Back2" onclick="history.back()" />
    </div>
  </div>
  <?php include $r."inc/foot.php"; ?>
 
<script>
    function popitup(url){
	    newwindow=window.open(url,'name','height=600,width=320'); 
	    if (window.focus) {newwindow.print();}
	    return false; 
    }
</script> 
<script>
$('#dataTable').DataTable( {
        "stateSave": true,
        "order": [[ 2, "desc" ]],
        "lengthMenu": [[10, 50, 100, -1], [10, 50, 100, "Todos"]],
        <?php if($actionexcel){?>"dom": '<"top"lfB>rt<"bottom"ip><"clear">', // Agrega B para los botones
        "buttons": [
            'copy', 'csv', 'excel', 'pdf', 'print'
        // Puedes agregar más botones según tus necesidades
        ],
        <? } ?>
    } );
  </script>
</body>
</html>   