<?php
session_start();
require_once ("../conexion.php");
require_once('../include/sesiones.php');
?>
<table class="table table-bordered table-hover table-striped" style="font-size: 9pt;">
    <thead>
        <tr>
            <th>BANCO</th>
            <th>APERTURA</th>
            <th>CUADRE</th>
            <th>SALDO CAJA</th>
        </tr>
    </thead>
    <tbody>
    <?php
        $ven1 = mysqli_query($con, "SELECT * FROM movimientos WHERE mov_apertura='$apertura' AND mov_detalle='Apertura de Caja' AND mov_usuario='$usu_id'");
        while ($vent1 = mysqli_fetch_array($ven1)) {
            $banco = $vent1['medio_pago'];

            $cuad = mysqli_query($con, "SELECT SUM(mov_total) AS mov_total FROM movimientos WHERE mov_apertura='$apertura' AND mov_tipo_movimiento='Cuadre de Caja' AND medio_pago='$banco' AND mov_usuario='$usu_id'");
            $cua = mysqli_fetch_array($cuad);

            $mov_total = $cua ? $cua['mov_total'] : 0;
    ?>
        <tr>
            <td><?php echo $banco; ?></td>
            <td><?php echo number_format($vent1['mov_total']); ?></td>
            <td style="color: red;"><?php echo number_format($mov_total); ?></td>
            <?php
$saldo = $vent1['mov_total'] - $mov_total;
?>
<td><?php echo number_format($saldo); ?></td>

        </tr>
    <?php } ?>
    </tbody>
</table>
