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

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

    <link rel="stylesheet" href="{{ asset('tablefilter/tablefilter.css') }}">

    <style>
        div.tot span {
            font-weight: 1000;
            font-size: initial;
        }
    </style>

{% endblock %}

{% block javascripts %}
    <script src="{{ asset('js/chosen/chosen.jquery2.min.js') }}" type="text/javascript"></script>
    <script src="{{ asset('js/chosen/docsupport/prism.js') }}" type="text/javascript" charset="utf-8"></script>
    <script src="{{ asset('js/chosen/docsupport/init.js') }}" type="text/javascript" charset="utf-8"></script>

    <script src="{{ asset('js/popper.min.js') }}" type="text/javascript" charset="utf-8"></script>

    <script>
        // Chosen touch support.
        if ($('.chosen-container').length > 0) {
            $('.chosen-container').on('touchstart', function (e) {
                e.stopPropagation();
                e.preventDefault();
                // Trigger the mousedown event.
                $(this).trigger('mousedown');
            });
        }
    </script>

    <script src="{{ asset('tablefilter/tablefilter.js') }}" type="text/javascript"></script>
    <script data-config>
        var filtersConfig = {
            base_path: 'tablefilter/',
            filters_row_index: 1,
            highlight_keywords: true,
            col_0: 'NONE',
            col_1: 'NONE',
            col_5: 'select',
            col_6: 'select',
            col_7: 'select',
            col_8: 'select',
            col_9: 'select',
            col_10: 'select',
            col_11: 'NONE',
            col_12: 'select',
            col_13: 'NONE',
            col_14: 'NONE',
            col_15: 'NONE',
            clear_filter_text: '< Todos >',
            auto_filter: true,
            auto_filter_delay: 200, //milliseconds
            ignore_diacritics: true,
            load_filters_on_demand: true,
            responsive: true,
            toolbar: {
                target_id: 'externalToolbar'
            },
            loader: true,
            loader: {
                text: 'Cargando...'
            },
            status_bar: {
                target_id: 'externalToolbar'
            },
            rows_counter: {
                text: 'NUMERO DE REGISTROS: '
            },
            btn_reset: true,
            msg_filter: 'Filtrando...',
            alternate_rows: true,
            mark_active_columns: {
                highlight_column: true
            },
            /* SkyBlue theme */
            themes: [{name: 'skyblue'}],
            /*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', filtersConfig, 1);
        tf.init();

        $(document).ready(function () {
            $('[data-toggle="tooltip"]').tooltip();
        });


    </script>

    <script src="{{ asset('js/misJs/alumnosDA.js') }}" type="text/javascript" charset="utf-8"></script>
    <script src="{{ asset('js/misJs/cambiarCuatri.js') }}" type="text/javascript" charset="utf-8"></script>
    <script src="{{ asset('js/misJs/bhs/bhs.js') }}" type="text/javascript" charset="utf-8"></script>
    <script src="{{ asset('js/misJs/bg/accionesMasivas.js') }}" type="text/javascript" charset="utf-8"></script>

    <script src="{{ asset('js/jsxlsx/FileSaver.min.js') }}"></script>
    <script src="{{ asset('js/jsxlsx/xlsx.full.min.js') }}"></script>
    <script src="{{ asset('js/jsxlsx/tableexport.min.js') }}"></script>
    <script src="{{ asset('js/jsxlsx/script.js') }}"></script>

    <script>
        $(function () {
            $('[data-toggle="popover"]').popover()
        })
    </script>
{% endblock %}

{% block content %}
    <div class="container-fluid">
        <h1 class="mt-4">BASE GENERAL DE ALUMNOS</h1>
        {% set tipoUsuario = app.session.get('rol') %}
        {#
        <button id="btnExportar" class="btn btn-info btn-sm">Exportar</button>
        #}
        <a href="{{ path('alumnos_base_general_exportar') }}" target="_blank" class="btn btn-info btn-sm">
            CREAR EXCEL
        </a>
        <input type="hidden" id="nombre-tabla" value="Matricual Activa Ceepam">
        {% if tipoUsuario == 333 %}
            <button class="btn btn-warning btn-sm" data-toggle="modal" data-target="#myModal">
                OPERACIONES
            </button>
        {% else %}
        {% endif %}

        <ol class="breadcrumb mb-2">
            <li class="breadcrumb-item"><a href="{{ path('cm_homepage') }}">Tablero</a></li>
            <li class="breadcrumb-item active">BG</li>
        </ol>

        <div class="row">
            <div class="col-lg-12">
                <div id="externalToolbar">
                </div>
            </div>


            <div class="col-lg-12 table-responsive">
                <table style="font-size: xx-small;" id="tabla">
                    <thead>
                    <tr>
                        <th>N.C.</th>
                        <th>#</th>
                        <th>MATRICULA</th>
                        <th>CURP</th>
                        <th>NOMBRE</th>
                        <th>NIVEL</th>
                        <th>ESPECIALIDAD</th>
                        <th>SISTEMA</th>
                        <th>GRADO</th>
                        <th>PLANTEL</th>
                        <th>GÉNERO</th>
                        <th>EDAD</th>
                        <th>ESCUELA</th>
                        <th>BAUHAUS</th>
                        <th>*</th>
                        {# <th>ACTA NAC.</th>
                                <th>CER. PRE.</th>
                                <th>CURP</th> #}
                    </tr>

                    </thead>
                    <tbody>
                    {% for a in alumnos %}
                        <tr>
                            <td style="vertical-align: middle;text-align: right;">{{ loop.index }}</td>
                            <td>
                                <div class="form-check">
                                    <input class="form-check-input border-danger" type="checkbox"
                                           id="check_{{ a.ideAlu }}" style="font-size: large;"
                                           onclick="agregarListaOperacionesMasivas({{ a.ideAlu }});">
                                </div>
                            </td>
                            <td style="vertical-align: middle;">
                                    <span style="font-weight: bolder;">
                                        <a href="{{ path('consulta_alumno_dos', {ideAlu: a.ideAlu} ) }}" target="_blank"
                                           style="color: black;">{{ a.cveCtl }}</a>
                                    </span>
                            </td>
                            <td style="vertical-align: middle;">
                                {{ a.curp }}
                            </td>
                            <td style="vertical-align: middle;white-space: nowrap;">
                                {{ a.apePat }} {{ a.apeMat }} <i style="font-weight: bolder;">{{ a.nomAlu }}</i>

                                {% if tipoUsuario == 99 %}
                                    <a href="{{ path('vista_pago',{cveCtl:a.cveCtl}) }}" class="btn btn-xs btn-success"
                                       target="_blank" data-toggle="tooltip" title="Ir a Caja..."
                                       data-placement="right">$</a>
                                {% endif %}
                            </td>
                            {% if a.tipoAlumno == 1 %}
                                <td style="vertical-align: middle;">BACHILLERATO</td>
                            {% elseif a.tipoAlumno == 2 %}
                                <td style="vertical-align: middle;">EXAMEN UNICO</td>
                            {% elseif a.tipoAlumno == 3 %}
                                <td style="vertical-align: middle;">LICENCIATURA</td>
                            {% elseif a.tipoAlumno == 4 %}
                                <td style="vertical-align: middle;">MAESTRÍA</td>
                            {% elseif a.tipoAlumno == 5 %}
                                <td style="vertical-align: middle;">DOCTORADO</td>
                            {% elseif a.tipoAlumno == 6 %}
                            {% elseif a.tipoAlumno == 9 %}
                                <td style="vertical-align: middle;">MATERNAL</td>
                            {% elseif a.tipoAlumno == 10 %}
                                <td style="vertical-align: middle;">PREESCOLAR</td>
                            {% elseif a.tipoAlumno == 11 %}
                                <td style="vertical-align: middle;">PRIMARIA</td>
                            {% elseif a.tipoAlumno == 12 %}
                                <td style="vertical-align: middle;">SECUNDARIA</td>
                            {% elseif a.tipoAlumno == 13 %}
                                <td style="vertical-align: middle;">ESPECIALIDAD</td>
                            {% endif %}
                            {% if a.cveLic != null %}
                                <td style="vertical-align: middle;">{{ a.cveLic.nomLic }}</td>
                            {% else %}
                                <td style="vertical-align: middle;background-color: red;">---INDETERMINADO---</td>
                            {% endif %}
                            <td style="vertical-align: middle;">{{ a.modalidad }}</td>
                            <td style="vertical-align: middle;text-align: center;">
                                <div class="row">
                                    <div class="col-lg-12">
                                        {{ a.numero }}
                                    </div>


                                    {% if tipoUsuario == 333 %}
                                        <div class="col-lg-6" style="padding: 0px;">
                                            <input style="height: 22px;" type="number" id="numCuatri-{{ a.ideAlu }}"
                                                   name="numCuatri-{{ a.ideAlu }}" value="{{ a.numero }}" min="1"
                                                   max="10">
                                        </div>
                                        <div class="col-lg-6" style="vertical-align: middle;"
                                             id="conCambiarCuatri_{{ a.ideAlu }}">
                                            <button type="button" class="btn btn-info btn-xs"
                                                    onclick="cambiarCuatri({{ a.ideAlu }})">
                                                <i class="fa fa-sync-alt fw"></i>
                                            </button>
                                        </div>
                                    {% endif %}
                                </div>
                            </td>
                            <td style="vertical-align: middle;">{{ a.cvePla.nomPla }}</td>

                            <td>
                                {% if a.sexo == 1 %}
                                    MUJER
                                {% else %}
                                    HOMBRE
                                {% endif %}
                            </td>
                            <td>
                                {{ a.edad }}
                            </td>
                            <td style="white-space: nowrap;">
                                {% if a.cveInstitucion is null %}
                                    SIN ASIGNAR
                                {% else %}
                                    {{ a.cveInstitucion.abreviatura }}
                                {% endif %}

                            </td>
                            <td class="text-center" style="vertical-align: middle;">
                                {% if a.cveLic != null %}
                                    {% if a.cveLic.ideLic == 10 %}
                                        {% if a.recargos == 1 %}
                                            <div class="form-check">
                                                {% if tipoUsuario == 333 %}
                                                    <input class="form-check-input" type="checkbox"
                                                           id="check-bhs-{{ a.ideAlu }}" style="font-size: large;"
                                                           onchange="validarBHS({{ a.ideAlu }});" checked="true">
                                                {% else %}
                                                    <input class="form-check-input" type="checkbox"
                                                           id="check-bhs-{{ a.ideAlu }}" style="font-size: large;"
                                                           onchange="validarBHS({{ a.ideAlu }});" checked="true"
                                                           readonly disabled>
                                                {% endif %}

                                            </div>
                                        {% else %}
                                            <div class="form-check">
                                                <input class="form-check-input" type="checkbox"
                                                       id="check-bhs-{{ a.ideAlu }}" style="font-size: large;"
                                                       onchange="validarBHS({{ a.ideAlu }});">
                                            </div>
                                        {% endif %}
                                    {% endif %}
                                {% else %}
                                    <b style="color: red;">ERROR</b>
                                {% endif %}

                            </td>
                            <td id="cont-resp-bhs-{{ a.ideAlu }}">
                            </td>
                            {#
                            <td>
                                {% if a.actNac == null and a.actNacCopia == null %}
                                    --
                                {% elseif a.actNac == null and a.actNacCopia == 1 %}
                                    C
                                {% elseif a.actNac == 1 or a.actNacCopia == 1 %}
                                    X
                                {% endif %}
                            </td>
                            <td>
                                {% if a.cerPre == null and a.cerPreCopia == null %}
                                    --
                                {% elseif a.cerPre == null and a.cerPreCopia == 1 %}
                                    C
                                {% elseif a.cerPre == 1 or a.cerPreCopia == 1 %}
                                    X
                                {% endif %}
                            </td>
                            <td>
                                {% if a.copCurpCopia== null %}
                                    --
                                {% elseif a.copCurpCopia == 1 %}
                                    X
                                {% endif %}
                            </td>
                            #}

                        </tr>
                    {% else %}
                        <tr>
                            <td colspan="9">NO HAY REGISTROS DE ALUMNOS __(°o°)__</td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div><!-- FIN DIV class=ROW -->

    <div class="row">
        <div class="col-lg-6">
            <!-- Modal -->
            <div class="modal fade" id="exampleModal" role="dialog" tabindex="-1">
                <div class="modal-dialog modal-lg" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="modal-body">
                            <div class="row">
                                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 table-responsive"
                                     id="contenedor-alumno" style="border: solid 1px #f1f1f1;">
                                </div>
                            </div><!-- FIN ROW -->
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                            <button type="button" class="btn btn-primary">Save changes</button>
                        </div>
                    </div>
                </div>
            </div><!-- FIN MODAL EXAMPLEmODAL -->
        </div>
    </div>

    <div class="row">
        <div class="col-lg-6">
            <!-- Modal -->
            <div class="modal fade" data-backdrop="static" data-keyboard="false" tabindex="-1"
                 aria-labelledby="staticBackdropLabel" aria-hidden="true" role="dialog" id="myModal">
                <div class="modal-dialog modal-xl" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="exampleModalLabel">ACCIONES MASIVAS</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="modal-body">
                            <div class="row">
                                <div class="col-lg-6">
                                    <div class="row">
                                        <div class="col-lg-8">
                                            <label class="control-label" for="ideEst">
                                                NUEVO ESTATUS
                                            </label>
                                            <select class="form-select form-control-sm" id="ideEst" name="ideEst">
                                                <option value="default">--Selecciona--</option>
                                                {% for e in estatus %}
                                                    <option value="{{ e.ideEst }}">{{ e.desEst }}</option>
                                                {% else %}
                                                    <option value="default">--Aún sin registros--</option>
                                                {% endfor %}
                                            </select>
                                        </div>
                                        <div class="col-lg-4">
                                            <label class="control-label text-center" for="btnCambiarEstatus">
                                                *
                                            </label>
                                            <button class="btn btn-info btn-sm btn-block" id="btnCambiarEstatus"
                                                    onclick="ejecutarOperacionesMasivas(1);">
                                                Cambiar
                                            </button>
                                        </div>
                                    </div>
                                </div><!-- FIN col-lg-6 -->
                                <div class="col-lg-6">
                                    <div class="row">
                                        <div class="col-lg-9">
                                            <label class="control-label" for="ideEst">
                                                ASINGAR ESCUELA DE MATRICULACIÓN
                                            </label>
                                            <select class="form-select form-control-sm" id="ideInsMatriculacion"
                                                    name="ideInsMatriculacion">
                                                <option value="default">--Selecciona--</option>
                                                {% for im in institucionesMatriculacion %}
                                                    <option value="{{ im.ideIns }}">{{ im.abreviatura }}</option>
                                                {% else %}
                                                    <option value="default">--Aún sin registros--</option>
                                                {% endfor %}
                                            </select>
                                        </div>
                                        <div class="col-lg-3">
                                            <label class="control-label text-center" for="btnCambiarEstatus">
                                                *
                                            </label>
                                            <button class="btn btn-info btn-sm btn-block" id="btnCambiarEstatus"
                                                    onclick="ejecutarOperacionesMasivas(2);">
                                                Cambiar
                                            </button>
                                        </div>
                                    </div>
                                </div><!-- FIN col-lg-6 -->

                                <div class="col-lg-12" id="con-respuesta-operaciones-masivas">

                                </div>
                            </div><!-- FIN ROW -->
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal" id="btnModCerrar"
                                    onclick="cargarDatos();">Cerrar
                            </button>
                        </div>
                    </div>
                </div>
            </div><!-- FIN MODAL EXAMPLEmODAL -->
        </div>
    </div>
{% endblock %}
