<div class="col-lg-12">
    <table class="table table-condensed table-bordered table-striped table-hover table-responsive">
        <thead>
            <tr>
                <th>#</th>
                <th>CONV.</th>
                <th>MES</th>
                <th>MONTO</th>
                <th>ABONADO</th>
                <th></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.numConvenio}}</td>
                        <td>
                            {{lp.fecIni | date('d') }}-{{lp.nomMes}}-{{lp.fecIni | date('Y') }}
                        </td>
                        <td>${{lp.monto | number_format(2,".",",")}}</td>
                        {% set total = total + lp.monto %}
                        {% set montoPagoInicial = montoPagoInicial + lp.monto %}
                        <td>${{lp.deposito | number_format(2,".",",")}}</td>
                        <td>
                            {% if lp.monto == lp.deposito %}
                                <a class="btn btn-success btn-xs" data-toggle="modal" data-backdrop="static" data-keyboard="true" data-target="#myModalAbonarConvenioOK" onclick="cargarAbonosConvenioOK({{lp.idePagCon}})">Ver pagos</a>
                            {% else %}
                                <a class="btn btn-info btn-xs" data-toggle="modal" data-backdrop="static" data-keyboard="true" data-target="#myModalAbonarConvenio" onclick="cargarAbonosConvenio({{lp.idePagCon}},1)">Abonar</a>
                            {% endif %}
                        </td>
                    </tr>
                {% else %}
                    <tr>
                        <td>{{loop.index}}</td>
                        <td>#{{lp.numConvenio}}</td>
                        <td>
                            {{lp.fecIni | date('d') }}-{{lp.nomMes}}-{{lp.fecIni | date('Y') }}
                        </td>
                        <td>${{lp.monto | number_format(2,".",",")}}</td>
                        {% set total = total + lp.monto %}
                        <td>${{lp.deposito | number_format(2,".",",")}}</td>
                        <td>
                            {% if lp.monto == lp.deposito %}
                                <a class="btn btn-success btn-xs" data-toggle="modal" data-backdrop="static" data-keyboard="true" data-target="#myModalAbonarConvenioOK" onclick="cargarAbonosConvenioOK({{lp.idePagCon}})">Ver pagos</a>
                            {% else %}
                                <a class="btn btn-info btn-xs" data-toggle="modal" data-backdrop="static" data-keyboard="true" data-target="#myModalAbonarConvenio" onclick="cargarAbonosConvenio({{lp.idePagCon}})">Abonar</a>
                            {% endif %}
                        </td>
                    </tr>
                {% endif %}
            {% else %}
                <tr>
                    <td colspan="5">POR ALGÚN MOTIVO RARO, USTED ESTÁ VIENDO ESTO</td>
                </tr>
            {% endfor %}
            {% if listaPagos is defined and listaPagos != null %}
                <tr>
                    <td colspan="3">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>