<div class="row">
    <div class="col-lg-12 text-center">
        <h5>PLANTEL: {{ plantel.nomPla }}</h5>
    </div><!-- FIN col-lg-12 -->
    <div class="col-lg-12 table-responsive" style="height: 300px;">
        <table class="table table-bordered table-condensed table-hover small">
            <thead class="thead-light">
            <tr class="text-center">
                <th class="estatico text-center">N.C.</th>
                <th class="estatico text-center">ESPECIALIDAD</th>
                <th class="estatico text-center">MAT.</th>
                <th class="estatico text-center">$ ALUMNO</th>
                <th class="estatico text-center">$ TOTAL</th>
                <th class="estatico text-center">*</th>
            </tr>
            </thead>
            <tbody>
            {% set total = 0 %}
            {% set costoTotal = 0 %}
            {% for d in datos %}
                {% set nivel = "" %}
                {% if d[0]['tipoAlumno']==3 %}
                    {% set nivel = "LICENCIATURA EN " %}
                {% elseif d[0]['tipoAlumno']==4 %}
                    {% set nivel = "MAESTRÍA EN " %}
                {% elseif d[0]['tipoAlumno']==5 %}
                    {% set nivel = "DOCTORADO EN " %}
                {% endif %}


                <tr>
                    <td class="text-right">{{ loop.index }}</td>
                    <td class="text-left">{{ nivel }}{{ d[0]['nomLic'] }}</td>
                    <td class="text-center">{{ d[0]['total'] }}</td>
                    {% set total = total + d[0]['total'] %}
                    <td class="text-right">
                        {% if d[1] != null %}
                            ${{ d[1] }}
                            <!-- Button trigger modal -->
                            <button type="button" class="btn btn-warning btn-xs" data-bs-toggle="modal"
                                    data-bs-target="#ventanaModal"
                                    onclick="verTabulador({{ plantel.idePla }},{{ d[0]['cveLic'] }} );">
                                <i class="fa fa-coins fw"></i>
                            </button>
                        {% else %}
                            <i style="color: red;">SIN TABULADOR</i>
                            <!-- Button trigger modal -->
                            <button type="button" class="btn btn-warning btn-xs" data-bs-toggle="modal"
                                    data-bs-target="#ventanaModal"
                                    onclick="verTabulador({{ plantel.idePla }},{{ d[0]['cveLic'] }} );">
                                <i class="fa fa-coins fw"></i>
                            </button>
                        {% endif %}
                    </td>
                    <td class="text-right">
                        {% if d[2] != null %}
                            ${{ d[2] | number_format(2,".",",") }}
                            {% set costoTotal = costoTotal + (d[2]*1) %}
                        {% else %}
                            <i style="color: red;">$ 0.00</i>
                            {% set costoTotal = costoTotal + (0*1) %}
                        {% endif %}
                    </td>
                    <td class="text-center">
                        <!-- Button trigger modal -->
                        <button type="button" class="btn btn-primary btn-xs" data-bs-toggle="modal"
                                data-bs-target="#ventanaModal"
                                onclick="detallesEspecialidad({{ plantel.idePla }},{{ d[0]['cveLic'] }} );"
                                style="font-size: xx-small;">
                            <i class="fa fa-eye fw"></i>
                        </button>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
            <tfoot>
            <tr style="background-color: #e9ecef;font-weight: bold;">
                <td colspan="2" class="text-right">TOTAL DE ALUMNOS</td>
                <td class="text-center">{{ total }}</td>
                <td class="text-right">PAGO MENSUAL</td>
                <td class="text-right">${{ costoTotal  | number_format(2,".",",") }}</td>
                <td></td>
            </tr>
            </tfoot>
        </table>

    </div><!-- FIN col-lg-12 -->
    <div class="col-lg-12">
        <h5>GUARDAR EL DATO DE MATRICULACIÓN</h5>
    </div><!-- FIN col-lg-12 -->
    <div class="col-lg-12">
        <div class="row">
            <div class="col-lg-4">
                <label class="control-label" for="mesMatriculacion">Selecciona el Mes</label>
                <input type="month" id="mesMatriculacion" name="mesMatriculacion" class="form-control form-control-sm">
            </div>
            <div class="col-lg-2 text-center">
                <label class="control-label" for="mesMatriculacion">*</label>
                <button type="button" class="btn btn-success btn-sm btn-block" id="mesMatriculacion"
                        onclick="guardarMesMatriculacion({{ plantel.idePla }});">
                    Guardar
                </button>
            </div>
            <div class="col-lg-6" id="con_res_matriculacion">

            </div>
        </div>
    </div><!-- FIN col-lg-12 -->
    <div class="col-lg-12 mt-3">
        <h5>HISTORIAL DE PAGOS DE MATRICULACIÓN</h5>
    </div><!-- FIN col-lg-12 -->
    <div class="col-lg-12 table-responsive" id="cont_historial_mat" style="height: 300px;">
        <table class="table table-condensed table-bordered table-hover">
            <thead>
            <tr style="background-color: rgb(51, 99, 117);color: white;">
                <th class="text-center estatico" style="">#</th>
                <th class="text-center estatico">MES</th>
                <th class="text-center estatico">TOTAL A PAGAR</th>
                <th class="text-center estatico">ABONADO</th>
                <th class="text-center estatico">DEBE</th>
                <th class="text-center estatico"><i class="fa fa-eye fw"></i></th>
                <th class="text-center estatico"><i class="fa fa-edit fw"></i></th>
                <th class="text-center estatico"><i class="fa fa-money-bill-wave fw"></i></th>
                <th class="text-center estatico"><i class="fa fa-trash-alt fw"></i></th>
            </tr>
            </thead>
            <tbody>
            {% set total = 0 %}
            {% set abonado = 0 %}
            {% set debe = 0 %}

            {% set anio = "" %}

            {% for p in pagosMat %}
                {% if anio == ( p.fecMat | date('Y') ) %}

                {% else %}
                    {% set anio = ( p.fecMat | date('Y') ) %}

                    <tr>
                        <td colspan="9"
                            style="background-color: lightskyblue;color: black;font-size: small;padding: 0px;"
                            class="text-center">
                            <b>{{ anio }}</b>
                        </td>
                    </tr>
                {% endif %}
                <tr>
                    <td>{{ loop.index }}</td>
                    <td>{{ p.mesMatriculacion }}-{{ p.fecMat | date('Y') }}</td>
                    <td class="text-right">${{ p.monto | number_format(2,".",",") }}</td>
                    <td class="text-right">${{ p.abonado | number_format(2,".",",") }}</td>
                    <td class="text-right">
                        {% if p.estatus == 0 %}
                            <b style="color: green;">
                                ${{ p.debe | number_format(2,".",",") }}
                            </b>
                        {% else %}
                            <b style="color: red;">
                                ${{ p.debe | number_format(2,".",",") }}
                            </b>
                        {% endif %}
                    </td>
                    {% set total = total + p.monto %}
                    {% set abonado = abonado + p.abonado %}
                    {% set debe = debe + p.debe %}
                    <td class="text-center">
                        <button type="button" class="btn btn-info btn-xs" id="btn_ver_mes_mat{{ p.idePagMat }}"
                                style="font-size: xx-small;">
                            <i class="fa fa-eye fw"></i>
                        </button>
                    </td>
                    <td class="text-center">
                        <button type="button" class="btn btn-warning btn-xs" id="btn_editar_mes_mat{{ p.idePagMat }}"
                                data-bs-toggle="modal" data-bs-target="#ventanaModal"
                                onclick="editarPagoMesMatriculacion({{ p.idePagMat }});" style="font-size: xx-small;">
                            <i class="fa fa-edit fw"></i>
                        </button>
                    </td>
                    <td class="text-center">
                        <button type="button" class="btn btn-success btn-xs"
                                id="btn_agregar_pago_mes_mat{{ p.idePagMat }}" data-bs-toggle="modal"
                                data-bs-target="#ventanaModal" onclick="agregarPagoMesMatriculacion({{ p.idePagMat }});"
                                style="font-size: xx-small;">
                            <i class="fa fa-money-bill-wave fw"></i>
                        </button>
                    </td>
                    <td class="text-center">
                        <button type="button" class="btn btn-danger btn-xs" id="borrarMesMatriculacion"
                                onclick="eliminarMesMat({{ p.idePagMat }},{{ p.cvePla.idePla }} );"
                                style="font-size: xx-small;">
                            <i class="fa fa-trash-alt fw"></i>
                        </button>
                    </td>

                </tr>
            {% endfor %}
            </tbody>
            <tfoot>
            <tr style="font-weight: bold;">
                <td class="text-right" colspan="2">TOTALES</td>
                <td class="text-right">$ {{ total | number_format(2,".",",") }}</td>
                <td class="text-right">$ {{ abonado | number_format(2,".",",") }}</td>
                <td class="text-right" style="background-color: yellow;">$ {{ debe | number_format(2,".",",") }}</td>
                <td class="text-center" colspan="4">
                    {% if total > 0 %}
                        {{ ( (debe * 100)/total ) | number_format(2,".",",") }}%
                    {% else %}
                        0.00%
                    {% endif %}

                </td>
            </tr>
            </tfoot>
        </table>
    </div><!-- FIN col-lg-12 -->
</div><!-- FIN row -->


