<h4 style="background-color: lightgreen;">INGRESOS</h4>
<table class="table table-bordered table-striped table-responsive table-condensed table-hover">
    <thead>
        <tr>
            <th>#</th>
            <th>FECHA</th>
            <th>No. RECIBO</th>
            <th>DESCRIPCIÓN</th>
            <th>MONTO</th>
            <th>RECARGOS</th>
            <th>TOTAL</th>
            <th>*</th>
        </tr>
    </thead>
    <tbody>
        {% set totalEfectivo = 0 %}
        {% set totalBoucher = 0 %}
        {% set totalTransferencia = 0 %}
        {% set totalTerminal = 0 %}

        {% set cEfectivo = 0 %}
        {% set cBoucher = 0 %}
        {% set cTransferencia = 0 %}
        {% set cTerminal = 0 %}

        {% for i in ingresos %}
            <tr>
                <td>{{loop.index}}</td>
                <td>{{i.fecMov | date('d-m-Y') }}</td>
                <td>{{i.numRecibo }}</td>
                <td>{{i.descripcion }}</td>
                <td>${{ (i.monto - i.recargos) | number_format(2,".",",") }}</td>
                <td>${{i.recargos | number_format(2,".",",") }}</td>
                <td>${{i.total | number_format(2,".",",") }}</td>
                {% if i.tipPag == 1 %}
                    <td>EFECTIVO</td>
                    {% set totalEfectivo = totalEfectivo +  i.total %}
                    {% set cEfectivo = cEfectivo + 1 %}
                {% elseif i.tipPag == 0 %}
                    <td>BOUCHER</td>
                    {% set totalBoucher = totalBoucher + i.total %}
                    {% set cBoucher = cBoucher + 1 %}
                {% elseif i.tipPag == "" %}
                    <td style="background-color: red;">ESTO ES RARO</td>
                {% elseif i.tipPag == 2 %}
                    <td>TRANSFERENCIA</td>
                    {% set totalTransferencia = totalTransferencia + i.total %}
                    {% set cTransferencia = cTransferencia + 1 %}
                {% elseif i.tipPag == 3 %}
                    <td>TERMINAL</td>
                    {% set totalTerminal = totalTerminal + i.total %}
                    {% set cTerminal = cTerminal + 1 %}
                {% elseif i.tipPag == 99 %}
                    <td>EXCEL</td>
                {% elseif i.tipPag == 69 %}
                    <td>CONVENIO</td>
                {% endif %}
            </tr>
        {% else %}
            <tr style="background-color: lightblue;">
                <td colspan="8" class="text-center">
                    NO HAY REGISTROS EN EL SISTEMA
                </td>
            </tr>
        {% endfor %}
    </tbody>
</table>
{% if ingresos is defined and ingresos != null %}
    <table class="table table-bordered table-condensed table-striped table-responsive table-hover">
        <thead>

        </thead>
        <tbody>
            <tr>
                <td style="background-color: lightblue;" class="text-right"><strong>EFECTIVO = {{cEfectivo}}</strong></td>
                <td style="background-color: lightblue;" class="text-right"><strong>$ {{totalEfectivo | number_format(2,".",",") }}</strong></td>
                <td class="text-right">BOUCHER = {{cBoucher}}</td>
                <td class="text-right">$ {{totalBoucher | number_format(2,".",",") }}</td>
            </tr>
            <tr>
                <td class="text-right">TERMINAL = {{cTerminal}}</td>
                <td class="text-right">$ {{totalTerminal | number_format(2,".",",") }}</td>
                <td class="text-right">TRANSFERENCIA = {{cTransferencia}}</td>
                <td class="text-right">$ {{totalTransferencia | number_format(2,".",",") }}</td>
            </tr>
        </tbody>
    </table>
{% endif %}

<h4 style="background-color: lightsalmon;">EGRESOS</h4>
<table class="table table-bordered table-striped table-responsive table-condensed table-hover">
    <thead>
        <tr>
            <th>#</th>
            <th>FECHA</th>
            <th>No. RECIBO</th>
            <th>DESCRIPCIÓN</th>
            <th>MONTO</th>
        </tr>
    </thead>
    <tbody>
        {% set totalEgresos = 0 %}
        {% set cEgresos = 0 %}
        {% for e in egresos %}
            <tr>
                <td>{{loop.index}}</td>
                <td>{{e.fecMov | date('d-m-Y') }}</td>
                <td>{{e.numRecibo }}</td>
                <td>{{e.descripcion }}</td>
                <td class="text-right">$ {{e.monto | number_format(2,".",",") }}</td>
            </tr>
            {% set totalEgresos = totalEgresos + e.monto %}
            {% set cEgresos = cEgresos + 1 %}
        {% else %}
            <tr style="background-color: orange;">
                <td colspan="5" class="text-center">
                    NO HAY REGISTROS EN EL SISTEMA
                </td>
            </tr>
        {% endfor %}
        {% if egresos is defined and egresos != null %}
            <tr>
                <td colspan="4" class="text-right"><strong>TOTAL</strong></td>
                <td class="text-right"><strong>$ {{totalEgresos | number_format(2,".",",") }}</strong></td>
            </tr>
        {% endif %}
    </tbody>
</table>
<h4 class="text-center" style="background-color: lightseagreen;">TABLA RESUMEN</h4>
<table class="table table-bordered table-condensed table-striped table-responsive table-hover">
    <thead>
    </thead>
    <tbody>
        <tr>
            <td style="background-color: lightblue;" class="text-right"><strong>INGRESOS EN EFECTIVO = {{cEfectivo}}</strong></td>
            <td style="background-color: lightblue;" class="text-right"><strong>$ {{totalEfectivo | number_format(2,".",",") }}</strong></td>
            <td class="text-right">SALIDAS = {{cEgresos}}</td>
            <td class="text-right">$ {{totalEgresos | number_format(2,".",",") }}</td>
        </tr>
        <tr>
            <td class="text-right" colspan="2">EN CAJA</td>
            <td class="text-right" colspan="2">$ {{(totalEfectivo - totalEgresos) | number_format(2,".",",") }}</td>
        </tr>
    </tbody>
</table>