<h4>Adeudos</h4>
<table class="table table-condensed table-bordered table-striped table-hover table-responsive">
    <thead>
        <tr>
            <th>#</th>
            <th>MES</th>
            <th>MONTO</th>
            <th>RECARGOS</th>
            <th>TOTAL</th>
        </tr>
    </thead>
    <tbody>
        {% set total = 0 %}
        {% set sumaTotal = 0 %}
        {% for p in pagos %}
            {% set total = 0 %}
            <tr>
                <td>{{loop.index}}</td>
                <td class="text-right">
                    {% if p.numero == 0 %}
                        {% if p.semestre > 1 %}
                            {% if a.modalidad == 'SEMESTRAL' %}
                                Reinscripcion: SEMESTRE #{{ p.semestre }}
                            {% else %}
                                Reinscripcion: CUATRIMESTRE #{{ p.semestre }}
                            {% endif %}
                        {% else %}
                            {% if a.modalidad == 'SEMESTRAL' %}
                                Inscripcion: SEMESTRE #{{ p.semestre }}
                            {% else %}
                                Inscripcion: CUATRIMESTRE #{{ p.semestre }}
                            {% endif %}
                        {% endif %}
                    {% else %}
                        {{p.nomMes}} {{p.fecIni | date('Y')}}
                    {% endif %}
                </td>
                <td class="text-right">
                    {% if p.numero == 0 %}
                        {% if p.semestre > 1 %}
                            ${{ a.costoReinscripciones | number_format(2,".",",") }}
                            {% set total = total + a.costoReinscripciones %}
                        {% else %}
                            ${{ a.costoInscripcion | number_format(2,".",",") }}
                            {% set total = total + a.costoInscripcion %}
                        {% endif %}
                    {% else %}
                        ${{a.costoMensualidad | number_format(2,".",",") }}
                        {% set total = total + a.costoMensualidad %}
                    {% endif %}
                </td>
                <td class="text-right">
                    {% if p.numero == 0 %}
                        {% if p.semestre > 1 %}
                            $100.00
                            {% set total = total + 100 %}
                        {% else %}
                            $100.00
                            {% set total = total + 100 %}
                        {% endif %}
                    {% else %}
                        $200.00
                        {% set total = total + 200 %}
                    {% endif %}
                </td>
                <td class="text-right">
                    ${{total | number_format(2,".",",") }}
                    {% set sumaTotal = sumaTotal + total %}
                </td>
            </tr>
        {% else %}
            <tr>
                <td colspan="6" class="text-center" style="background-color: lightgreen;">
                    NO ES CANDIDATO PARA HACER CONVENIO
                    <input type="hidden" value="1" id="banderaConvenio" name="banderaConvenio">
                    <a href="{{path('no_adeudo',{ideAlu:a.ideAlu})}}" target="_blank" class="btn btn-primary btn-sm">IMPRIMIR OFICIO</a>
                </td>
            </tr>
        {% endfor %}
        {% if pagos is defined and pagos != null %}
            <tr>
                <td colspan="4" class="text-right">
                    TOTAL A PAGAR
                </td>
                <td class="text-right" style="background-color: lightgreen;">
                    ${{sumaTotal | number_format(2,".",",") }}
                    <input type="hidden" value="{{sumaTotal}}" id="totalConvenioAPagar" name="totalConvenioAPagar">
                </td>
                <td>
                    <a href="{{path('si_adeudo',{ideAlu:a.ideAlu})}}" target="_blank" class="btn btn-primary btn-sm">IMPRIMIR OFICIO</a>
                </td>
            </tr>
        {% endif %}
    </tbody>
</table>
<div class="col-lg-12">
    <div class="col-lg-6">
        <div class="col-lg-6">
            <label>ELIGE UN PLAZO:</label>
            <select id="mesesConvenio" name="mesesConvenio" class="form-control">
                <option value="1" selected="true">1 mes</option>
                <option value="2">2 meses</option>
                <option value="3">3 meses</option>
                <option value="4">4 meses</option>
                <option value="5">5 meses</option>
                <option value="6">6 meses</option>
            </select>
        </div>
        <div class="col-lg-6">
            <label>MODO DE PAGO:</label>
            <select id="modoConvenio" name="modoConvenio" class="form-control" onchange="hacerTablaConvenio(this.value)">
                <option value="default" selected="true">Selecciona</option>
                <option value="4">Semanal</option>
                <option value="2">Quincenal</option>
                <option value="1">Mensual</option>
            </select>
        </div>
        <div class="col-lg-12 text-right" style="margin-top: 3px;">
            <button class="btn btn-primary btn-xs" onclick="hacerTablaConvenio(document.getElementById('modoConvenio').value)">ACTUALIZAR</button>
        </div>
    </div>
    <div class="col-lg-6" id="contenedor-tabla-convenio">
    </div>
</div>
