<?php $r="../";
require_once($r."inc/funciones.php");
$titlepage = 'Pedidos por Remesar';
validNotSession($r);
$spe=$_SESSION['perfil'];
$mysqli = connectDB($r);
roleaccess(1430);
$row1 = $mysqli->query("SELECT * FROM z_pedidos WHERE remesa='0' ORDER by codigopedido DESC");
?>

  <?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 EN REMESA</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>Fecha entrega</th>
                  <th>Código</th>
                  <th>Estado</th>
                  <th></th>
                </tr>
              </thead>
              <tfoot>
                <tr>
                  <th>Cliente</th>
                  <th>Fecha entrega</th>
                  <th>Código</th>
                  <th>Estado</th>
                  <th></th>
                </tr>
              </tfoot>
              <tbody>
                    <?php
                    
                    while($row2 = $row1->fetch_assoc()) {
                    ?>
                      <tr>
                        <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><a title="REMESAR <?=$row2['codigopedido']; ?>" class="btn h3 p-0 m-0" onclick="mremesa('<?= $row2['codigopedido']; ?>',<?= $row2['pago']; ?>)"><i class="fa fa-tag text-primary"></i></a></td>
                        </tr>
                    <?php } ?>
              <tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>
  <!-- Modal -->
    <div class="modal fade" id="Minforemesa" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">REMESA <span id="nremesa"></span></h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span>
            </button>
          </div>
           <form id="formremesa" action="acciones.php" method="POST">
              <div class="modal-body">
                <input type="hidden" name="coderemesa" value="">
                <label>Nota:</label>
                <textarea name="notaremesa" class="form-control" required></textarea>
                
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">CERRAR</button>
                <button type="submit" class="btn btn-success pag" name="pag">GUARDAR Y COBRAR</button>
                <button type="submit" class="btn btn-primary" name="sog">GUARDAR</button>
              </div>
          </form>
        </div>
      </div>
    </div>
  <?php include $r."inc/foot.php"; ?>
  <script>
      function mremesa(code,pago){
          $('button.pag').addClass('d-none');
          $('#Minforemesa').modal('show');
          $('#nremesa').html(code);
          $('input[name=coderemesa]').val(code);
          if(pago != 2){
            $('button.pag').removeClass('d-none');
          }
      }
  </script>
</body>
</html>    