<?php $r="../";
require_once($r."inc/funciones.php");
validNotSession($r);
$spe=$_SESSION['perfil'];
$mysqli = connectDB($r);
roleaccess(12);
$row1 = $mysqli->query("SELECT * FROM z_pedidos WHERE  (estado=2 OR estado=3) AND pago<2 ORDER by codigopedido DESC");
?>
<!DOCTYPE html>
<html lang="es">
  <?php include $r."inc/head.php"; ?>
<body class="fixed-nav sidenav-toggled sticky-footer bg-dark" id="page-top">
  <div class="container">
    <div id="mensaje" style="position:fixed;width:90%;padding-left:10%;top:20px;left:0px;margin:0 auto;z-index:9999;"></div>
  </div>
  <?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>  PEDIDOS PENDIENTES POR COBRAR</div>
        <div class="card-body">
          <div class="table-responsive">
            <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
              <thead>
                <tr>
                  <th>Domiciliario</th>
                  <th>Cliente</th>
                  <th>Fecha entrega</th>
                  <th>Código</th>
                  <th>estado</th>
                  <th>Abono</th>
                  <th>Valor a cobrar</th>
                  <th></th>
                </tr>
              </thead>
              <tfoot>
                <tr>
                  <th>Domiciliario</th>
                  <th>Cliente</th>
                  <th>Fecha entrega</th>
                  <th>Código</th>
                  <th>estado</th>
                  <th>Abono</th>
                  <th>Valor a cobrar</th>
                  <th></th>
                </tr>
              </tfoot>
              <tbody>
                    <?php
                    
                    while($row2 = $row1->fetch_assoc()) {
                    ?>
                      <tr>
                        <td><?php $usuario = sinfo('z_usuarios',$row2["idrutero"]); echo $usuario['nombre']; ?></td>
                        <td><?php $cliente = sinfo('z_clientes',$row2["idcliente"]); echo $cliente['nombre'];?></td>
                        <td><?= $row2["fechaentrega"] ?></td>
                        <td><?= '<b>'.$row2['tipopedido'].'</b> '.$row2['codigopedido']; ?></td>
                        <?php $infopago = sinfo('z_epagos',$row2['pago']); ?><td class="<?= $infopago['color']; ?> h6"><?= $infopago['estado']; ?></td>
                        <td class="text-right h6"><? if(!empty($row2["abono"])){ echo moneda($row2["abono"]); } ?></td>
                        <? $total = ((int)$row2['total']+(int)$row2['adicional']); ?>
                        <td class="h6 <? if($total<0){echo 'text-danger';}elseif($total>0){echo 'text-success';}elseif($total=0){echo 'text-warning';}?> text-right"><?= moneda($total) ?></td>
                        <td><a title="clic aquí para cobrar el pedido" class="btn_default pagado h3 p-0 m-0" href="acciones.php?pago=<? echo $total; ?>&code=<?= $row2["codigopedido"] ?>"><i class="fa fa-money text-success"></i></a></td>
                        </tr>
                    <?php
                    }
                    ?>
              <tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>
  <?php include $r."inc/foot.php"; ?>
</body>
</html>    