<?php
session_start();
require_once('../conexion.php');
require_once('../include/sesiones.php');
?>
<div class="table-responsive">
    <table class="table table-striped table-bordered">
        <thead>
            <tr>
                <th width="1%"></th>
                <th>N°</th>
                <th>FECHA</th>
                <th>TIPO DE MOVIMIENTO</th>
                <th>DETALLE</th>
                <th>PAGO</th>
                <th>BANCO</th>
                <th>TOTAL</th>
                <th width="8%"></th>
            </tr>
        </thead>
        <?php  
            $registros=mysqli_query($con,"SELECT *
            FROM movimientos where empresa='$empresa' and mov_apertura='$apertura' and mov_usuario='$usu_id' and sucursal='$sucursal' and estado<>'anulado' order by mov_numero DESC ") or die(mysqli_error($con));
            while ($reg=mysqli_fetch_array($registros)){
            $mov_id=$reg['mov_id'];

            $ban=mysqli_query($con,"SELECT * FROM egresos where mov_id='$mov_id' and empresa='$empresa'") or die(mysqli_error($con));
            $reg1=mysqli_fetch_array($ban)
        ?>
        <tr>
            <td>
                <?php if($reg['estado']=='salida'){ ?>
                <i class="btn-icon-only icon-long-arrow-left alert-danger fa-2x"></i>
                <?php } else if($reg['estado']=='entrada'){ ?>
                <i class="btn-icon-only icon-long-arrow-right alert-success fa-2x"></i>
                <?php } else if($reg['estado']=='anulado'){ ?>
                <i class="btn-icon-only icon-remove-circle alert-danger fa-2x"></i>
                <?php } ?>
            </td>
            <td><?php echo $reg['mov_numero']; ?></td>
            <td><?php echo $reg['mov_fecha']; ?></td>
            <td><?php echo $reg['mov_tipo_movimiento']; ?></td>
            <td><?php echo $reg['mov_detalle']; ?></td>
            <td><?php echo $reg['forma_pago']; ?></td>
            <td><?php echo $reg['medio_pago']; ?></td>
            <td><p class="pull-right"><?php echo number_format($reg['mov_total'],0); ?></p></td>
            <td>
            <?php
                if ($reg['mov_tipo_movimiento']=='Base de Apertura' or $reg['mov_tipo_movimiento']=='Anulado'){ } else { ?> 
                   <a href="#" onclick="eliminar('<?php echo $reg['mov_id'];?>')" title="Eliminar" class="btn btn-xs btn-danger"> <i class="btn-icon-only icon-remove"></i></a>
           
                <?php } if($fac_tamano=='Carta') { ?>

                    <a href="libraries/tcpdf/documentos/recibos_de_pago.php?mov_id=<?php echo $reg['mov_id']; ?>" title="Imprimir Recibo" class="btn btn-xs btn-success" target="_blank"> <i class="btn-icon-only icon-print"></i></a>

                <?php  } else { ?>
                    <a href="tirillas/tirilla_movimientos.php?mov_id=<?php echo $reg['mov_id']; ?>" class="btn btn-success btn-xs" target="_blank" title="Imprimir"><i class="btn-icon-only icon-print"></i></a>
            <?php }  //include ('modificar_movimientos.php'); ?>
            </td>
        </tr>
        <?php } ?>
    </table> 
</div>
<script>
function eliminar (mov_id)
{
    if (confirm("Realmente deseas eliminar?")){ 
    $.ajax({
        type: "GET",
        url: "php_movimientos/eliminar_movimientos.php",
        data: "mov_id="+mov_id,
        beforeSend: function(objeto){
         $('#resultados').html('<center><img src="./img/ajax-loader.gif"> CARGANDO...</center>');
        },
        success: function(datos){
        $("#resultados").html(datos);
        load(1);
        }
        });
    }
}
</script>