<div class="col-lg-12" style="margin-bottom: 3px;">
    <button class="btn btn-primary btn-xs" onclick="hacerTablaConvenio(document.getElementById('modoConvenio').value)">ACTUALIZAR</button>
    <button class="btn btn-success btn-xs" onclick="guardarTablaConvenio()" data-dismiss="modal">GUARDAR CONVENIO</button>
</div>
<div class="col-lg-12">
    <table class="table table-condensed table-bordered table-striped table-hover table-responsive">
        <thead>
            <tr>
                <th>#</th>
                <th>FECHA</th>
                <th>MONTO</th>
            </tr>
        </thead>
        <tbody>
            {% set total = 0 %}
            {% set registros = 0 %}
            {% set montoPagoInicial = 0 %}
            {% for lp in listaPagos %}
                {% set registros = loop.length %}
            {% else %}
            {% endfor %}

            {% for lp in listaPagos %}
                {% if loop.index == 1 %}
                    <tr style="background-color: orange;color: white;">
                        <td>{{loop.index}}</td>
                        <td>
                            {{lp[1]}}
                        </td>
                        <td>${{lp[0] | number_format(2,".",",")}}</td>
                        {% set total = total + lp[0] %}
                        {% set montoPagoInicial = montoPagoInicial + lp[0] %}
                    </tr>
                {% else %}
                    <tr>
                        <td>{{loop.index}}</td>
                        <td>
                            {{lp[1]}}
                        </td>
                        <td>${{lp[0] | number_format(2,".",",")}}</td>
                        {% set total = total + lp[0] %}
                    </tr>
                {% endif %}
            {% else %}
                <tr>
                    <td colspan="3">POR ALGÚN MOTIVO RARO, USTED ESTÁ VIENDO ESTO</td>
                </tr>
            {% endfor %}
            {% if listaPagos is defined and listaPagos != null %}
                <tr style="background-color: #0CB7F2;color: white;">
                    <td colspan="2">TOTAL A PAGAR</td>
                    <td>${{ total | number_format(2,".",",")}}</td>
                </tr>
            {% endif %}
        </tbody>
    </table>
</div>
<div class="col-lg-12">
    {% if montoPagoInicial == 0 %}
        {% set montoPagoInicial = (total / 2) %}
        DEBE CUBRIR UNA CANTIDAD INICIAL DE: <strong style="background-color: orange;">${{montoPagoInicial | number_format(2,".",",") }}</strong>
    {% else %}
        DEBE CUBRIR UNA CANTIDAD INICIAL DE: <strong style="background-color: orange;">${{montoPagoInicial | number_format(2,".",",") }}</strong>
    {% endif %}
</div>