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

{% block metas %}
    <meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">
{% endblock %}

{% 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/misJs/titulacion.js') }}"></script>
    <script src="{{ asset('js/tablefilter/tablefilter.js') }}" type="text/javascript"></script>
    <script src="{{ asset('js/misJs/titulacionEstatusV2.js') }}"></script>
    <script data-config>
        var filtersConfig = {
            base_path: 'tablefilter/',
            filters_row_index: 1,
            highlight_keywords: true,
            col_0: 'NONE',
            col_1: 'NONE',
            col_4: 'select',
            col_5: 'select',
            col_6: 'NONE',
            col_7: 'NONE',
            col_8: 'select',
            col_9: 'select',
            col_10: 'select',
            col_11: 'NONE',
            col_12: 'NONE',
            clear_filter_text: '< Todos >',
            auto_filter: true,
            auto_filter_delay: 200, //milliseconds
            toolbar: {
                target_id: 'toolBar'
            },
            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('demo', filtersConfig, 1);
        tf.init();

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

{% block content %}
    {% set externo = app.session.get('externo') %}
    {% set tipoUsuario = app.session.get('rol') %}

    <div class="container-fluid">
        <h1 class="mt-4">
            {% if ban == 1 %}
                TITULACIÓN ESCOLARIZADO
                <a class="btn btn-xs btn-info" data-toggle="modal" data-target="#myModalExcel"
                   onclick="cargarBaseT(1);">EXPORTAR</a>
            {% elseif ban == 2 %}
                TITULACIÓN DIRECTA*
                <a class="btn btn-xs btn-info" data-toggle="modal" data-target="#myModalExcel"
                   onclick="cargarBaseT(2);">EXPORTAR</a>
                {% if tipoUsuario == 99 or tipoUsuario == 77 %}
                    <button class="btn btn-xs btn-warning" onclick="oficioCertificacionDirecta();">
                        OFICIO CERTIFICACIÓN
                    </button>
                {% else %}
                    (-)
                {% endif %}

            {% endif %}
        </h1>
        <ol class="breadcrumb mb-2">
            <li class="breadcrumb-item"><a href="{{ path('cm_homepage') }}">Tablero</a></li>
            <li class="breadcrumb-item active">
                {% if ban == 1 %}
                    Titulación Escolarizado
                {% elseif ban == 2 %}
                    Titulación Directa
                {% endif %}
            </li>
        </ol>
        <div class="row">
            <div class="col-lg-12">
                <div class="card border-info mb-1">
                    <div class="card-header bg-info border-info text-white">
                        <i class="fas fa-database mr-1"></i>
                        Base
                        <a class="btn btn-warning btn-xs" href="{{ path('generar_excel_base_titulacion') }}"
                           target="_blank">GENERAR EXCEL</a>
                    </div>
                    <div class="card-body">
                        <div class="row">

                            <div class="col-lg-12" id="toolBar">

                            </div>
                            <div class="col-lg-12 table-responsive" id="contenedor-tabla-titulacion-directa">
                                <table class="table table-bordered table-condensed table-hover"
                                       style="font-size: x-small;" id="demo">
                                    <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>#</th>
                                        <th>CLAVE</th>
                                        <th>NOMBRE</th>
                                        <th>NIVEL</th>
                                        <th>ESPECIALIDAD</th>
                                        <th style="white-space: nowrap;">COSTO TOTAL</th>
                                        <th>DEPÓSITO</th>
                                        <th>DEBE</th>
                                        <th>ESTATUS</th>
                                        <th style="white-space: nowrap;">EGRESADO DE:</th>
                                        <th style="white-space: nowrap;">INGRESADO A:</th>
                                        <th>#</th>
                                        <th>CURP</th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    {% for t in titulaciones %}
                                        <tr>
                                            <td class="text-right" style="vertical-align: middle;">{{ loop.index }}</td>
                                            <td>
                                                <div class="form-check">
                                                    <input class="form-check-input border-danger" type="checkbox"
                                                           id="check_{{ t[0]['ideAlu'] }}" style="font-size: large;"
                                                           onclick="agregarListaOperaciones({{ t[0]['ideAlu'] }});">
                                                </div>
                                            </td>
                                            <td style="white-space: nowrap;vertical-align: middle;">
                                                <a href="{{ path('consulta_alumno_dos', {ideAlu: t[0]['ideAlu']} ) }}"
                                                   target="_blank"
                                                   style="color: black;font-weight: bolder;">{{ t[0]['cveCtl'] }}</a>
                                                {% if externo == 1 %}
                                                {% else %}
                                                    <a href="{{ path('vista_pago',{cveCtl:t[0]['cveCtl']}) }}"
                                                       class="btn btn-xs btn-success text-right" target="_blank"
                                                       data-toggle="tooltip" title="Ir a Caja..."
                                                       data-placement="right">$</a>
                                                {% endif %}

                                                {% if t[0]['estatus'] != 1 %}
                                                    <a class="btn btn-xs btn-info" data-toggle="tooltip"
                                                       title="Detalles" data-placement="right">+</a>
                                                {% else %}

                                                {% endif %}
                                            </td>
                                            <td style="white-space: nowrap;vertical-align: middle;">
                                                {{ t[0]['apePat'] }} {{ t[0]['apeMat'] }} <i
                                                        style="font-weight: bolder;">{{ t[0]['nomAlu'] }}</i>
                                            </td>
                                            {% set nivel = t[0]['tipoAlumno'] %}
                                            <td style="white-space: nowrap;vertical-align: middle;">
                                                {% if nivel == 1 %}
                                                    <i style="color: red;">TE BACHILLERATO ESCOLARIZADO</i>
                                                {% elseif nivel == 2 %}
                                                    <i style="color: red;">TE EXAMEN ÚNICO</i>
                                                {% elseif nivel == 3 %}
                                                    TE LIC.
                                                {% elseif nivel == 4 %}
                                                    TE MTRÍA.
                                                {% elseif nivel == 5 %}
                                                    TE DOC.
                                                {% elseif nivel == 8 %}
                                                    {% if t[3].tipoAlumno == 3 %}
                                                        TD LIC.
                                                    {% elseif t[3].tipoAlumno == 4 %}
                                                        TD MTRÍA.
                                                    {% elseif t[3].tipoAlumno == 5 %}
                                                        TD DOC.
                                                    {% elseif t[3].tipoAlumno == 13 %}
                                                        TD ESP.
                                                    {% else %}
                                                        <i style="color: red;">TD NO ESPECIFICADO #2 \\(°o°)//</i>
                                                    {% endif %}
                                                {% else %}
                                                    <i style="color: red;">TE NO ESPECIFICADO #1 \\(°o°)//</i>
                                                {% endif %}
                                            </td>
                                            <td style="vertical-align: middle;white-space: nowrap;">
                                                {% if nivel != 8 %}
                                                    {{ t[0]['nomLic'] }}
                                                {% else %}
                                                    {% if t[4] != NULL %}
                                                        {{ t[4].nomLic }}
                                                    {% else %}
                                                        <i style="color: red;">ERROR</i>
                                                    {% endif %}
                                                {% endif %}
                                            </td>
                                            <td class="text-right" style="vertical-align: middle;white-space: nowrap;">
                                                ${{ t[0].costoTramite | number_format(2,".",",") }}
                                            </td>
                                            {% set sumaDeposito = t[1] %}

                                            {% if sumaDeposito == t[0].costoTramite %}
                                                <td class="text-right"
                                                    style="background-color: lightgreen;vertical-align: middle;">
                                                    ${{ sumaDeposito | number_format(2,".",",") }}
                                                </td>
                                            {% elseif sumaDeposito > 0 and sumaDeposito < 5000 %}
                                                <td class="text-right"
                                                    style="background-color: lightsalmon;vertical-align: middle;">
                                                    ${{ sumaDeposito | number_format(2,".",",") }}
                                                </td>
                                            {% elseif sumaDeposito >= 5000 %}
                                                <td class="text-right"
                                                    style="background-color: lightblue;vertical-align: middle;">
                                                    ${{ sumaDeposito | number_format(2,".",",") }}
                                                </td>
                                            {% else %}
                                                <td class="text-right"
                                                    style="background-color: lightyellow;vertical-align: middle;white-space: nowrap;">
                                                    SIN PAGO.
                                                </td>
                                            {% endif %}
                                            <td class="text-right" style="vertical-align: middle;">
                                                ${{ (t[0].costoTramite - sumaDeposito) | number_format(2,".",",") }}
                                            </td>
                                            <td style="vertical-align: middle;">
                                                <div class="col-lg-12" style="padding: 0px;">
                                                    {% set estatus = t[3].estatus %}
                                                    {% if estatus == 1 %}
                                                        SIN INGRESAR
                                                    {% elseif estatus == 2 %}
                                                        <i style="font-weight: bolder;">INGRESADO</i>
                                                    {% elseif estatus == 3 %}
                                                        INVASIÓN
                                                    {% elseif estatus == 4 %}
                                                        ENTREGADO
                                                    {% elseif estatus == 5 %}
                                                        DOCUMENTACIÓN INCOMPLETA
                                                    {% elseif estatus == 6 %}
                                                        POR PAGO
                                                    {% elseif estatus == 7 %}
                                                        ESTÁ AQUÍ
                                                    {% elseif estatus == 8 %}
                                                        <b style="color: red;">BAJA</b>
                                                    {% elseif estatus == 9 %}
                                                        <b style="color: lightblue;">EN TRÁMITE</b>
                                                    {% endif %}
                                                </div>
                                                <div class="col-lg-12 text-right" style="padding: 0px;">
                                                    <a class="btn btn-xs btn-warning" data-toggle="modal"
                                                       data-target="#myModalEstatus"
                                                       onclick="cargarEstatusTitulacion({{ t[0]['ideAlu'] }}, {{ ban }});"
                                                       data-toggle="tooltip" data-placement="left" title="Cambiar">
                                                        <i class="fa fa-edit fw"></i>
                                                    </a>
                                                </div>
                                            </td>
                                            <td style="vertical-align: middle;">
                                                {% if nivel != 8 %}
                                                    {{ t[0].cveAlu.cvePla.nomenclatura }}
                                                {% else %}
                                                    {{ t[5].nomCor }}
                                                {% endif %}
                                            </td>
                                            <td style="vertical-align: middle;">
                                                {% if tipoUsuario == 99 %}
                                                {% else %}
                                                    {% if t[0]['cveIngresado'] == NULL %}
                                                        <a class="btn btn-xs btn-info" data-toggle="modal"
                                                           data-target="#myModal"
                                                           onclick="cargarPlanteles({{ t[0]['ideAlu'] }})">
                                                            <i class="fa fa-assistive-listening-systems fw"></i>
                                                        </a>
                                                    {% else %}
                                                        {{ t[2].nomIns }}
                                                    {% endif %}
                                                {% endif %}
                                                <a class="btn btn-xs btn-success" target="_blank"
                                                   href="{{ path('subir_documentos_titulacion',{ideAlu:t[0]['ideAlu']}) }}"
                                                   data-toggle="tooltip" data-placement="left" title="Documentación">
                                                    <i class="fa fa-folder-open fw"></i>
                                                </a>
                                            </td>
                                            <td class="text-right" style="vertical-align: middle;white-space: nowrap;">
                                                {#
                                                {% for d in t[6] %}
                                                {% if d.estatus == 1 %}
                                                    <a class="btn btn-warning btn-xs disabled">
                                                        <i class="fa fa-print fa-fw"></i>{{ d.cveDoc.nomDoc }}
                                                    </a>
                                                {% elseif d.estatus == 2 %}
                                                    <a class="btn btn-success btn-xs" href="{{ asset(d.archivo) }}"
                                                       target="_blank">
                                                        <i class="fa fa-print fa-fw"></i>{{ d.cveDoc.nomDoc }}
                                                    </a>
                                                {% elseif d.estatus == 3 %}
                                                    <a class="btn btn-primary btn-xs" href="{{ asset(d.archivo) }}"
                                                       target="_blank">
                                                        <i class="fa fa-print fa-fw"></i>{{ d.cveDoc.nomDoc }}
                                                    </a>
                                                {% else %}
                                                {% endif %}
                                            {% else %}
                                                <i style="color: red;font-weight: bold;">SIN DOCUMENTOS DE
                                                    TITULACIÓN</i>
                                            {% endfor %}
                                                #}

                                            </td>
                                            <td>
                                                {{ t[0].curp }}
                                            </td>
                                        </tr>
                                    {% else %}
                                        <tr>
                                            <td colspan="11">SIN DATOS</td>
                                        </tr>
                                    {% endfor %}
                                    </tbody>
                                </table>
                            </div><!-- FIN DIV col-lg-12 table-responsive -->


                        </div><!-- FIN row -->
                    </div><!-- FIN card-body -->
                </div><!-- FIN card -->
            </div><!-- FIN col-lg-12 -->
        </div><!-- FIN row -->

    </div><!-- FIN container-fluid -->

    <!-- 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">ASIGNAR TRÁMITE A UN PLANTEL</h4>
                </div>
                <div class="modal-body" style="padding-top: 0px;">
                    <div class="row">
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="contenedor-general-titulacion"
                             style="padding-left: 0px;padding-right: 0px;">

                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="btnGuardarAsignarPlantel">GUARDAR</button>
                    <button type="button" class="btn btn-danger" data-dismiss="modal" id="btnModCancelarAsignarPlantel">
                        CANCELAR
                    </button>
                </div>
            </div>

        </div>
    </div> <!-- FIN MODAL -->
    <!-- Modal Estatus Titulación-->
    <div id="myModalEstatus" 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">CAMBIAR EL ESTATUS DEL TRAMITE</h4>
                </div>
                <div class="modal-body" style="padding-top: 0px;">
                    <div class="row">
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="contenedor-estatus-titulacion"
                             style="padding-left: 0px;padding-right: 0px;">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="btnGuardarEstatusTitulacion">GUARDAR ESTATUS
                    </button>
                    <button type="button" class="btn btn-danger" data-dismiss="modal"
                            id="btnModCancelarEstatusTitulacion">CERRAR
                    </button>
                </div>
            </div>

        </div>
    </div> <!-- FIN MODAL ESTATUS -->
    <!-- Modal EXCEL-->
    <div id="myModalExcel" 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">EXPORTAR EXCEL</h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="contenedor-excel">

                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-danger" data-dismiss="modal" id="btnCerrarModalExcel">CERRAR
                    </button>
                </div>
            </div>

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


{% endblock %}