{% extends 'CmBundle:Z:baseDos.html.twig' %}

{% block stylesheet %}
    <link rel="stylesheet" href="{{asset('js/tablefilter/tablefilter.css')}}">
    <link rel="stylesheet" href="{{asset('js/tablefilter/style/tablefilter.css')}}">
{% endblock %}

{% block javascripts %}
    <script src="{{asset('js/excel/tableToExcel.js')}}"></script>

    <script src="{{asset('js/tablefilter/tablefilter.js') }}" type="text/javascript"></script>
    <script data-config>
        var filtersConfig = {
            base_path: 'tablefilter/',
            filters_row_index: 2,
            highlight_keywords: true,
            col_0: 'NONE',
            col_2: 'select',
            col_3: 'NONE',
            col_4: 'NONE',
            col_5: 'select',
            col_6: 'select',
            col_7: 'select',
            col_8: 'select',
            col_9: 'NONE',
            col_10: 'NONE',
            col_11: 'NONE',
            col_12: 'NONE',
            col_13: 'NONE',
            col_14: 'NONE',
            col_15: 'NONE',
            col_16: 'NONE',
            col_17: 'NONE',
            col_18: 'select',
            clear_filter_text: '< Todos >',
            auto_filter: true,
            auto_filter_delay: 200, //milliseconds
            status_bar: {
                target_id: 'toolBar'
            },
            rows_counter: {
                text: 'Filas: '
            },
            btn_reset: true,
            msg_filter: 'Filtrando...',
            /*paging: {
             page_text: 'Página',
             of_text: ' de ',
             toolbar_position: 'left',
             results_per_page: ['Filas: ', [5, 10, 15, 20]],
             btn_next_page_text: 'Siguiente >',
             btn_prev_page_text: '< Anterior',
             btn_last_page_text: 'Última página >>',
             btn_first_page_text: '<< Primera página'
             },*/

        };
        var tf = new TableFilter('tabla-memo', filtersConfig, 2);
        tf.init();

        $(document).ready(function () {
            $('[data-toggle="tooltip"]').tooltip();
        });
    </script>
    <script src="{{asset('js/misJs/listasEU.js')}}"></script>
{% endblock %}


{% block content %}
    <div class="row">
        <div class="panel-heading">
            ALUMNOS ACTIVOS <input type="button" onclick="tableToExcel('tabla-memo', 'W3C Example Table', 'myExcel.xlxs')" value="EXPORTAR EXCEL" class="btn btn-info btn-xs">
        </div>
        <div class="col-lg-12">
            <h1>APLICACIÓN: {{numApli}}</h1>
        </div>
        <div class="col-lg-12" id="toolBar">

        </div>
        <div class="col-lg-12 table-responsive" style="overflow-x: scroll;overflow-y: scroll;height: 450px;">
            <table class="table table-condensed table-hover table-striped table-bordered" style="font-size: x-small;width: 1500px;" id="tabla-memo">
                <thead>
                    <tr>
                        <th colspan="5" class="text-center" style="background-color: rgb(0,32,96);color: white;font-size: larger;vertical-align: middle;">DATOS GENERALES</th>
                        <th colspan="4" class="text-center" style="background-color: rgb(16,210,16);color: white;font-size: larger;vertical-align: middle;">DOCUMENTACIÓN REQUERIDA</th>
                        <th colspan="3" class="text-center" style="background-color: rgb(0,32,96);color: white;font-size: larger;vertical-align: middle;">DATOS PERSONALES</th>
                        <th colspan="6" class="text-center" style="background-color: rgb(191,143,0);color: white;font-size: larger;vertical-align: middle;">MODALIDAD DE PAGOS</th>
                        <th class="text-center" style="background-color: rgb(0,32,96);color: white;font-size: larger;vertical-align: middle;">ESTATUS DEL TRAMITE</th>
                    </tr>
                    <tr>
                        <th style="background-color: rgb(142,169,219);vertical-align: middle;" class="text-center">N.C.</th>
                        <th style="background-color: rgb(142,169,219);vertical-align: middle;" class="text-center">NOMBRE DEL ALUMNO</th>
                        <th style="background-color: rgb(142,169,219);vertical-align: middle;" class="text-center">COORD</th>
                        <th style="background-color: rgb(142,169,219);vertical-align: middle;" class="text-center">CURP</th>
                        <th style="background-color: rgb(142,169,219);vertical-align: middle;" class="text-center">FEC. TERMINO SEC.</th>
                        <th style="background-color: rgb(0,176,80);font-size: xx-small;vertical-align: middle;">CERT. SEC.</th>
                        <th style="background-color: rgb(0,176,80);font-size: xx-small;vertical-align: middle;">ACTA NAC.</th>
                        <th style="background-color: rgb(0,176,80);font-size: xx-small;vertical-align: middle;">CURP</th>
                        <th style="background-color: rgb(130,241,115);font-size: xx-small;vertical-align: middle;">DOC. DIGITAL</th>

                        <th style="background-color: rgb(130,241,115);font-size: xx-small;vertical-align: middle;" class="text-center">TELEFONOS</th>
                        <th style="background-color: rgb(130,241,115);font-size: xx-small;vertical-align: middle;" class="text-center">EDAD</th>
                        <th style="background-color: rgb(130,241,115);font-size: xx-small;vertical-align: middle;" class="text-center">CUMPLEAÑOS</th>

                        <th style="font-size: xx-small;vertical-align: middle;">COSTO EXAMEN</th>
                        <th style="font-size: xx-small;vertical-align: middle;">INSCRIPCIÓN</th>

                        <th colspan="2" style="background-color: rgb(255,230,153);font-size: xx-small;vertical-align: middle;" class="text-center">PAGO DERECHO A EXAMEN</th>
                        <th style="background-color: rgb(255,230,153);font-size: xx-small;vertical-align: middle;">TOTAL A PAGAR</th>
                        <th style="background-color: rgb(255,230,153);font-size: xx-small;vertical-align: middle;">ADEUDO A CUBRIR</th>
                        <th style="background-color: rgb(142,169,219);">ESTATUS</th>

                    </tr>
                </thead>
                <tbody>
                    {% set tipoUsuario = app.session.get('rol') %}
                    {% set adeudoTotal = 0 %}

                    {% if datos is defined and datos != null %}
                        {% set index = 0 %}
                        {% set numeroCarpeta = 0 %}
                        {% set color = 0 %}
                        {% for a in datos %}
                            {% if numeroCarpeta != a[0].cveNumApli.carpeta %}
                                {% set numeroCarpeta = a[0].cveNumApli.carpeta %}
                                {% set index = 1 %}
                                {% set color = a[0].cveNumApli.color %}
                            {% else %}
                                {% set index = index + 1 %}
                            {% endif %}
                            <tr id="alu-{{a[0].ideAlu}}">
                                <td style="vertical-align: middle;" class="text-right">{{loop.index}}</td>
                                <td style="vertical-align: middle;">
                                    {{a[0].apePat}} {{a[0].apeMat}} <i style="font-weight: bolder;">{{a[0].nomAlu}}</i>
                                    <br>
                                    <a href="{{path('consulta_alumno_dos',{ideAlu:a[0].ideAlu})}}" class="btn btn-xs btn-info" target="_blank" data-toggle="tooltip" title="{{a[0].cveCtl}}" data-placement="right">+</a>
                                    {% if tipoUsuario == 99 or tipoUsuario == 3 %}
                                        <a href="{{path('vista_pago',{cveCtl:a[0].cveCtl})}}" class="btn btn-xs btn-success" target="_blank" data-toggle="tooltip" title="Ir a Caja..." data-placement="right">$</a>
                                    {% else %}
                                    {% endif %}
                                </td>
                                <td style="vertical-align: middle;">{{a[0].coordinador}}</td>
                                <td style="vertical-align: middle;">{{a[0].curp}}</td>
                                <td style="vertical-align: middle;">
                                    {% if a[4] == null %}
                                        SIN DEFINIR
                                    {% else %}
                                        {% if a[4] <= 2 %}
                                            <i style="font-weight: bolder;color: red;">{{a[4]}} años</i>
                                        {% else %}
                                            <i style="font-weight: bolder;color: blue;">{{a[4]}} años</i>
                                        {% endif %}

                                    {% endif %}
                                    <br>
                                    {{ a[0].fecTer | date('d-F-Y') | replace({'January':'Enero','February':'Febrero','March':'Marzo',
'April':'Abril','May':'Mayo','June':'Junio','July':'Julio','August':'Agosto','September':'Septiembre','October':'Octubre','November':'Noviembre','December':'Diciembre'})}}
                                </td>
                                <td class="text-center" style="vertical-align: middle;">
                                    {% if a[0].cerSec == 1 and a[0].cerSecCopia == 1 %}
                                        X
                                    {% elseif a[0].cerSec == 1 and a[0].cerSecCopia == 0 %}
                                        X
                                    {% elseif a[0].cerSec == 0 and a[0].cerSecCopia == 1 %}
                                        C
                                    {% else %}
                                        --
                                    {% endif %}
                                </td>
                                <td class="text-center" style="vertical-align: middle;">
                                    {% if a[0].actNac == 1 and a[0].actNacCopia == 1 %}
                                        X
                                    {% elseif a[0].actNac == 1 and a[0].actNacCopia == 0 %}
                                        X
                                    {% elseif a[0].actNac == 0 and a[0].actNacCopia == 1 %}
                                        C
                                    {% else %}
                                        --
                                    {% endif %}
                                </td>
                                <td class="text-center" style="vertical-align: middle;">
                                    {% if a[0].copCurpCopia == 1 %}
                                        X
                                    {% elseif a[0].copCurpCopia == 0 %}
                                        --
                                    {% else %}
                                        --
                                    {% endif %}
                                </td>
                                <td class="text-center" style="vertical-align: middle;">
                                    {% if a[3].documentacionDigital == null or a[3].documentacionDigital == 0 %}
                                        <label style="background-color: lightsalmon;width: 100%;font-weight: bold;">NO</label>
                                    {% elseif a[3].documentacionDigital == 1 %}
                                        <label style="background-color: lightskyblue;width: 100%;font-weight: bold;">SI</label>
                                    {% endif %}
                                </td>
                                <td class="text-center" style="vertical-align: middle;">
                                    {{a[0].telefono}} - <b>{{a[0].telefonoCelular}}</b>
                                </td>
                                <td class="text-center" style="vertical-align: middle;">
                                    {{a[0].edad}} años
                                </td>
                                <td class="text-center" style="vertical-align: middle;">
                                    {{a[0].fecNac | date('d-m-Y')}}
                                </td>
                                <td class="text-center" style="vertical-align: middle;">
                                    ${{a[0].costoMensualidad | number_format(2,".",",")}}
                                </td>
                                <td class="text-center" style="vertical-align: middle;">
                                    ${{a[0].costoInscripcion | number_format(2,".",",")}}
                                </td>
                                {% set sumaDeAbonos = 0%}
                                {% for d in a[1] %}
                                    {% if d[0].monto == d[1]%}
                                        <td class="text-center" style="vertical-align: middle;background-color: greenyellow;">
                                            {{d[0].descripcion}}<br><strong>${{d[1]}}</strong>
                                        </td>
                                    {% elseif d[1] > 0 and d[0].monto > d[1] %}
                                        <td class="text-center" style="vertical-align: middle;background-color: yellow;">
                                            {{d[0].descripcion}}<br><strong>${{d[1]}}</strong>
                                        </td>
                                    {% else %}
                                        <td class="text-center" style="vertical-align: middle;background-color: lightskyblue;">
                                            {{d[0].descripcion}}<br><strong>${{d[1]}}</strong>
                                        </td>
                                    {% endif %}
                                    {% set sumaDeAbonos = sumaDeAbonos + d[1] %}
                                {% endfor %}
                                <td class="text-center" style="vertical-align: middle;">
                                    {% set totalAPagar = a[0].costoMensualidad + a[0].costoInscripcion %}
                                    ${{ totalAPagar | number_format(2,".",",")}}
                                </td>
                                {% set adeudoAPagar = totalAPagar - sumaDeAbonos %}

                                {% set adeudoTotal = adeudoTotal + adeudoAPagar %}

                                {% if adeudoAPagar == 0 %}
                                    <td class="text-center" style="vertical-align: middle;background-color: green;color: white;">
                                        ${{ adeudoAPagar | number_format(2,".",",") }}
                                    </td>
                                {% elseif adeudoAPagar > 0 %}
                                    <td class="text-center" style="vertical-align: middle;background-color: red;color: white;">
                                        ${{ adeudoAPagar | number_format(2,".",",") }}
                                    </td>
                                {% endif %}
                                <td style="vertical-align: middle;">
                                    <b>{{a[3].tramite}}</b>
                                </td>
                            </tr>
                        {% endfor %}

                    {% else %}
                        <tr>
                            <td colspan="20">NO HAY DATOS</td>
                        </tr>
                    {% endif %}
                </tbody>
            </table>
            <tr style="background-color: blue;color: white;font-size: larger;font-weight: bolder;">
                <td colspan="19" class="text-right">TOTALES</td>
                <td class="text-right">${{adeudoTotal | number_format(2,'.',',')}}</td>
            </tr>
        </div><!-- FIN DIV TABLE RESPONSIVE  -->

        <!-- Modal -->
        <div id="myModal" class="modal fade" role="dialog">
            <div class="modal-dialog modal-lg">
                <!-- Modal content-->
                <div class="modal-content">
                    <div class="modal-header" style="background-color: #C9DAE1;">
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <h4 class="modal-title">DETALLES</h4>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                <div id="gif" hidden="true" class="img-responsive" >
                                    <img src="{{asset('images/load2.gif')}}" />
                                </div>
                                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 table-responsive" id="contTablaDetallesAlu">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-danger" data-dismiss="modal"  id="btnModCerrarDetallesAlu">CERRAR</button>
                    </div>
                </div>

            </div>
        </div> <!-- FIN MODAL-->


    </div><!--  FIN ROW  -->
{% endblock %}
