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

{% block stylesheet %}
    <style type="text/css">
        thead tr th {
            position: sticky;
            top: 0;
            z-index: 10;
            background-color: #ffffff;
        }

        .table-responsive {
            height: 400px;
            overflow: scroll;
        }
    </style>
{% endblock %}

{% block javascripts %}
{% endblock %}


{% block content %}
    <div class="container-fluid">
        <h1 class="mt-4">Reporte CVTP</h1>
        <ol class="breadcrumb mb-2">
            <li class="breadcrumb-item"><a href="{{ path('cm_homepage') }}">Tablero</a></li>
            <li class="breadcrumb-item active">CVTP</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-building mr-1"></i>
                        TRAMITES ESCOLARIZADOS
                        <a href="{{ path('cartera_vencida_tramites_planteles_exportar',{'tipoReporte' : 1}) }}"
                           class="btn btn-primary btn-sm" target="_blank">
                            DESCARGAR CUADRO GENERAL
                            <i class="fa fa-download fw"></i>
                        </a>
                    </div>
                    <div class="card-body">
                        <div class="row small">
                            <div class="col-lg-12 table-responsive">
                                <table class="table table-bordered table-condensed table-hover">
                                    <thead class="thead-light">
                                    <tr class="text-center small">
                                        <th class="text-center" style="vertical-align: middle;">N.C.</th>
                                        <th class="text-center" style="vertical-align: middle;white-space: nowrap;">
                                            NOMBRE DEL PLANTEL
                                        </th>
                                        <th class="text-center" style="vertical-align: middle;white-space: nowrap;">
                                            TOTAL DE TRÁMITES
                                        </th>
                                        {% for e in estatus %}
                                            <th class="text-center"
                                                style="vertical-align: middle;white-space: nowrap;background-color: #0A650C;color: white;">
                                                {{ e }}
                                            </th>
                                            <th style="vertical-align: middle;">TOTAL</th>
                                            <th style="vertical-align: middle;">ABONADO</th>
                                            <th style="vertical-align: middle;">DEBE</th>
                                        {% endfor %}
                                        <th class="text-center" style="vertical-align: middle;">
                                            VALIDACIÓN
                                        </th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {% for key , e in escolarizado %}
                                        <tr id="{{ key }}" class="filaPlantel"
                                            onclick="cambiarColorFila(this.id);">
                                            <td style="vertical-align: middle;">{{ loop.index }}</td>
                                            <td style="vertical-align: middle;white-space: nowrap;">
                                                <div class="row">
                                                    <div class="col-lg-8">
                                                        {{ e['nomenclatura'] }}
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <a href="{{ path('cartera_vencida_tramites_por_planteles_exportar',{'tipoReporte' : 1,'p' : e['idePla']}) }}"
                                                           class="btn btn-primary btn-xs" target="_blank">
                                                            <i class="fa fa-download fw"></i>
                                                        </a>
                                                    </div>
                                                </div>
                                            </td>
                                            <td class="text-center"
                                                style="vertical-align: middle;">
                                                {{ e['total'] }}
                                            </td>
                                            {% set sumaEstatus = 0 %}
                                            {% for k, ee in e['estatus'] %}
                                                <td class="text-center"
                                                    style="vertical-align: middle;background-color: lightblue;">
                                                    {% if ee['total'] > 0 %}
                                                        <b style="color: darkred;">{{ ee['total'] }}</b>
                                                    {% else %}
                                                        {{ ee['total'] }}
                                                    {% endif %}
                                                </td>
                                                <td class="text-right" style="vertical-align: middle;">
                                                    ${{ ee['pagos']['total'] | number_format(2,'.',',') }}
                                                </td>
                                                <td class="text-right" style="vertical-align: middle;">
                                                    ${{ ee['pagos']['abonado'] | number_format(2,'.',',') }}
                                                </td>
                                                <td class="text-right" style="vertical-align: middle;">
                                                    {% if ee['pagos']['debe'] > 0 %}
                                                        <b style="color: red;">${{ ee['pagos']['debe'] | number_format(2,'.',',') }}</b>
                                                    {% else %}
                                                        ${{ ee['pagos']['debe'] | number_format(2,'.',',') }}
                                                    {% endif %}
                                                </td>
                                                {% set sumaEstatus = sumaEstatus + ee['total'] %}
                                            {% endfor %}
                                            <td class="text-center" style="vertical-align: middle;">
                                                {% if sumaEstatus == e['total'] %}
                                                    <b style="color: darkgreen;">{{ sumaEstatus }}</b>
                                                {% else %}
                                                    <b style="color: red;">{{ sumaEstatus }}</b>
                                                {% endif %}
                                            </td>
                                        </tr>
                                    {% else %}
                                        <tr>
                                            <td colspan="3">SIN REGISTROS</td>
                                        </tr>
                                    {% endfor %}
                                    </tbody>
                                </table>
                            </div>
                        </div><!-- FIN row -->
                    </div><!-- FIN card-body -->
                </div><!-- FIN card -->
            </div><!-- FIN col-lg-6 -->


        </div><!-- FIN row -->

        <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-building mr-1"></i>
                        TRAMITES DIRECTAS
                        <a href="{{ path('cartera_vencida_tramites_planteles_exportar',{'tipoReporte' : 2}) }}"
                           class="btn btn-primary btn-sm" target="_blank">
                            DESCARGAR CUADRO GENERAL
                            <i class="fa fa-download fw"></i>
                        </a>
                    </div>
                    <div class="card-body">
                        <div class="row small">
                            <div class="col-lg-12 table-responsive">
                                <table class="table table-bordered table-condensed table-hover small">
                                    <thead class="thead-light">
                                    <tr class="text-center">
                                        <th class="text-center" style="vertical-align: middle;">N.C.</th>
                                        <th class="text-center" style="vertical-align: middle;white-space: nowrap;">
                                            NOMBRE DEL PLANTEL
                                        </th>
                                        <th class="text-center" style="vertical-align: middle;white-space: nowrap;">
                                            TOTAL DE TRÁMITES
                                        </th>
                                        {% for e in estatus %}
                                            <th class="text-center"
                                                style="vertical-align: middle;white-space: nowrap;background-color: #0A650C;color: white;">
                                                {{ e }}
                                            </th>
                                            <th style="vertical-align: middle;">TOTAL</th>
                                            <th style="vertical-align: middle;">ABONADO</th>
                                            <th style="vertical-align: middle;">DEBE</th>
                                        {% endfor %}
                                        <th class="text-center" style="vertical-align: middle;">
                                            VALIDACIÓN
                                        </th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {% for key, d in directa %}
                                        <tr id="{{ key }}" class="filaPlantel"
                                            onclick="cambiarColorFila(this.id);">
                                            <td style="vertical-align: middle;">{{ loop.index }}</td>
                                            <td style="vertical-align: middle;white-space: nowrap;">
                                                <div class="row">
                                                    <div class="col-lg-8">
                                                        {{ d['nomenclatura'] }}
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <a href="{{ path('cartera_vencida_tramites_por_planteles_exportar',{'tipoReporte' : 2,'p' : d['idePla']}) }}"
                                                           class="btn btn-primary btn-xs" target="_blank">
                                                            <i class="fa fa-download fw"></i>
                                                        </a>
                                                    </div>
                                                </div>
                                            </td>
                                            <td class="text-center" style="vertical-align: middle;">
                                                {{ d['total'] }}
                                            </td>
                                            {% set sumaEstatus = 0 %}
                                            {% for k, dd in d['estatus'] %}
                                                <td class="text-center"
                                                    style="vertical-align: middle;background-color: lightblue;">
                                                    {% if dd['total'] > 0 %}
                                                        <b style="color: darkred;">{{ dd['total'] }}</b>
                                                    {% else %}
                                                        {{ dd['total'] }}
                                                    {% endif %}
                                                </td>
                                                <td class="text-right" style="vertical-align: middle;">
                                                    ${{ dd['pagos']['total'] | number_format(2,'.',',') }}
                                                </td>
                                                <td class="text-right" style="vertical-align: middle;">
                                                    ${{ dd['pagos']['abonado'] | number_format(2,'.',',') }}
                                                </td>
                                                <td class="text-right" style="vertical-align: middle;">
                                                    {% if dd['pagos']['debe'] > 0 %}
                                                        <b style="color: red;">${{ dd['pagos']['debe'] | number_format(2,'.',',') }}</b>
                                                    {% else %}
                                                        ${{ dd['pagos']['debe'] | number_format(2,'.',',') }}
                                                    {% endif %}
                                                </td>
                                                {% set sumaEstatus = sumaEstatus + dd['total'] %}
                                            {% endfor %}
                                            <td class="text-center" style="vertical-align: middle;">
                                                {% if sumaEstatus == d['total'] %}
                                                    <b style="color: darkgreen;">{{ sumaEstatus }}</b>
                                                {% else %}
                                                    <b style="color: red;">{{ sumaEstatus }}</b>
                                                {% endif %}
                                            </td>

                                        </tr>
                                    {% else %}
                                        <tr>
                                            <td colspan="3">SIN REGISTROS</td>
                                        </tr>
                                    {% endfor %}
                                    </tbody>
                                </table>
                            </div>
                        </div><!-- FIN row -->
                    </div><!-- FIN card-body -->
                </div><!-- FIN card -->
            </div><!-- FIN col-lg-6 -->

        </div><!-- FIN row -->

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

    <!-- Modal -->
    <div class="modal fade" id="ventanaModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
         aria-labelledby="ventanaModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-xl">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="ventanaModalLabel">

                    </h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"
                            onclick="actualizarDatos();"></button>
                </div>
                <div class="modal-body">
                    <div class="row" id="cont_det_esp">

                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"
                            onclick="actualizarDatos();">Cerrar
                    </button>
                    <button type="button" class="btn btn-primary">Guardar Cambios</button>
                </div>
            </div>
        </div>
    </div>
{% endblock %}