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

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

    <link rel="stylesheet" type="text/css" href="{{asset('bootstrap-select/dist/css/bootstrap-select.css')}}"/>
{% endblock %}

{% block javascripts %}
    <script src="{{asset('js/misJs/otrosIngresos.js')}}"></script>
    <script src="{{asset('js/chosen/chosen.jquery.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('bootstrap-select/dist/js/bootstrap-select.js')}}"></script>
{% endblock %}

{% block content %}
    <div class="container-fluid">
        {#<h1 class="mt-4">Registro de Pagos</h1>#}
        <ol class="breadcrumb mb-2">
            <li class="breadcrumb-item"><a href="{{ path('cm_homepage') }}">Tablero</a></li>
            <li class="breadcrumb-item active">Registro de pagos</li>
        </ol>

        <div class="row">
            <div class="col-lg-6 col-xs-12">
                <div class="card border-secondary mb-1">
                    <div class="card-header bg-secondary border-secondary text-white">
                        <i class="fas fa-search mr-1"></i>
                        BUSCAR ALUMNO POR MATRICULA O POR NOMBRE
                    </div>
                    <div class="card-body" style="background-color: #e9ecef;">
                        <div class="row">
                            <div class="col-lg-12">
                                <form class="row small" action="{{path('vista_pago')}}" method="POST">
                                    <div class="col-sm-9">
                                        <label class="control-label" for="cveCtl" style="font-size: small;">CLAVE:</label>
                                        <input type="text" class="form-control form-control-sm text-center" id="cveCtl" name="cveCtl" placeholder="CVE CTL" autofocus="true">
                                    </div>
                                    <div class="col-sm-3 text-center">
                                        <label class="control-label">*</label>
                                        <button type="submit" class="btn btn-sm btn-primary btn-block">BUSCAR</button>
                                    </div>
                                </form>
                            </div><!-- FIN col-lg-12 -->
                            <div class="col-lg-12">
                                <form class="row small" action="{{path('vista_pago')}}" method="POST">
                                    <div class="col-lg-9">
                                        <label class="control-label">NOMBRE: </label>
                                        <select class="form-control form-control-sm selectpicker" data-live-search="true" id="cveCtl" name="cveCtl">
                                            <option value="">Selecciona</option>
                                            {% if alumnos is defined %}
                                                {% set nivel = "" %}
                                                {% for a in alumnos %}
                                                    {% if a.tipoAlumno == 3 %}
                                                        {% set nivel = "Lic." %}
                                                    {% elseif a.tipoAlumno == 4 %}
                                                        {% set nivel = "Matria." %}
                                                    {% elseif a.tipoAlumno == 5 %}
                                                        {% set nivel = "Doc." %}
                                                    {% elseif a.tipoAlumno == 8 %}
                                                        {% set nivel = "T.D." %}
                                                    {% else %}
                                                        {% set nivel = "" %}
                                                    {% endif %}
                                                    <option value="{{a.cveCtl}}">{{a.apePat}} {{a.apeMat}} {{a.nomAlu}} : {{nivel}}</option>
                                                {% endfor %}
                                            {% endif %}
                                        </select>
                                    </div>
                                    <div class="col-lg-3 text-center">
                                        <label class="control-label">*</label>
                                        <button type="submit" class="btn btn-sm btn-primary btn-block">BUSCAR</button>
                                    </div>
                                </form>
                            </div><!-- FIN col-lg-12 -->


                        </div><!-- FIN row -->
                    </div><!-- FIN card-body -->
                </div><!-- FIN card -->
            </div>
            <div class="col-lg-6 col-xs-12">
                <div class="card border-danger mb-1">
                    <div class="card-header bg-danger border-danger text-white">
                        <i class="fas fa-calendar-alt mr-1"></i>
                        CONSULTAR PAGOS POR FECHAS
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-lg-6 col-xs-12">
                                <label class="control-label" for="fA">Fecha Inicial</label>
                                <input type="date" id="fA" name="fA" value="{{"now" | date('Y-m-d') }}" class="form-control form-control-sm">
                            </div>
                            <div class="col-lg-6 col-xs-12">
                                <label class="control-label" for="fB">Fecha Final</label>
                                <input type="date" id="fB" name="fB" class="form-control form-control-sm">
                            </div>
                            <div class="col-lg-12 text-right" style="padding-top: 5px;">
                                <a class="btn btn-sm btn-info" id="buscarPorFecha"><i class="fa fa-search fw"></i> BUSCAR</a>
                                <a class="btn btn-sm btn-primary" id="buscarPorFechaExportar"><i class="fa fa-download fw"></i> EXPORTAR</a>
                            </div>
                        </div><!-- FIN row -->
                    </div><!-- FIN card-body -->
                </div><!-- FIN card -->
            </div>

            <div class="col-lg-6 col-xs-12">
                <div class="card border-info mb-1">
                    <div class="card-header bg-info border-info text-white">
                        <i class="fas fa-search mr-1"></i>
                        HISTORIAL DE PAGOS DE MATRICULACIÓN
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-lg-12 table-responsive">
                                <table class="table table-condensed table-bordered table-hover small">
                                    <thead class="thead-light">
                                        <tr>
                                            <th class="text-center">#</th>
                                            <th class="text-center">RECIBO</th>
                                            <th class="text-center">PLANTEL</th>
                                            <th class="text-center">CANTIDAD</th>
                                            <th class="text-center">*</th>
                                            <th class="text-center">ENFERMERÍA</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        {% set total = 0 %}
                                        {% set enfermeria = 0 %}

                                        {% for i in ingresosMat %}
                                            <tr>
                                                <td class="text-right">{{loop.index}}</td>
                                                <td class="text-center">{{i.numRecibo}}</td>
                                                <td class="text-left">
                                                    {{i.cvePla.nomenclatura}}
                                                </td>
                                                <td class="text-right">
                                                    $ {{i.total | number_format(2,".",",") }}
                                                </td>
                                                <td>
                                                    {% if i.tipPag == 0 %}
                                                        BOUCHER
                                                    {% elseif i.tipPag == 1 %}
                                                        <b>EFECTIVO</b>
                                                    {% elseif i.tipPag == 2 %}
                                                        TRANSFERENCIA
                                                    {% elseif i.tipPag == 3 %}
                                                        TERMINAL
                                                    {% elseif i.tipPag == 4 %}
                                                        --- XD ---
                                                    {% endif %}
                                                </td>
                                                <td class="text-center" style="vertical-align: middle;">
                                                    {% if i.enfermeria == 1 %}
                                                        <b style="color: green;">SI</b>
                                                        {% set enfermeria = enfermeria + i.total %}
                                                    {% else %}
                                                        NO
                                                    {% endif %}
                                                </td>
                                                {% set total = total + i.total %}
                                            </tr>
                                        {% endfor %}
                                    </tbody>
                                    <tfoot>
                                        <tr style="background-color: #e9ecef;font-weight: bold;">
                                            <td colspan="3" class="text-right">TOTAL</td>
                                            <td class="text-right">$ {{total | number_format(2,".",",") }}</td>
                                            <td></td>
                                            <td class="text-right">
                                                $ {{enfermeria | number_format(2,".",",") }}
                                            </td>
                                        </tr>
                                    </tfoot>
                                </table>
                            </div>


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

            </div>
            <div class="col-lg-6 col-xs-12">
                <div class="card border-success mb-1">
                    <div class="card-header bg-success border-success text-white">
                        <i class="fas fa-calendar-alt mr-1"></i>
                        HISTORIAL DE PAGOS
                    </div>
                    <div class="card-body">
                        <div class="row">

                            <div class="col-lg-12 table-responsive">
                                <table class="table table-condensed table-bordered table-hover small">
                                    <thead class="thead-light">
                                        <tr>
                                            <th>#</th>
                                            <th>CVE CTL</th>
                                            <th>REFERENCIA</th>
                                            <th class="text-center">MONTO</th>
                                            <th class="text-center">RECARGOS</th>
                                            <th class="text-center">TOTAL</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        {% set total = 0 %}
                                        {% if ingresos is defined %}
                                            {% for i in ingresos %}
                                                {% if i.tipPag == 1 %}
                                                    <tr class="text-right" style="background-color: lightblue;">
                                                    {% else %}
                                                    <tr class="text-right">
                                                    {% endif %}
                                                    <td>{{loop.index}}</td>
                                                    <td>{{i.cveAlu.cveCtl}}</td>
                                                    <td>{{i.referencia}}</td>
                                                    <td class="text-right">$ {{i.monto | number_format(2,".",",") }}</td>
                                                    <td class="text-right">$ {{i.recargos | number_format(2,".",",") }}</td>
                                                    <td class="text-right">$ {{i.total | number_format(2,".",",") }}</td>
                                                    {% if i.tipPag == 1 %}
                                                        {% set total = total + i.total %}
                                                    {% endif %}
                                                </tr>
                                            {% endfor %}
                                        {% endif %}                        
                                    </tbody>
                                    <tfoot>
                                        <tr>
                                            <td colspan="5" class="text-right">TOTAL</td>
                                            <td class="text-right">$ {{total | number_format(2,".",",") }}</td>
                                        </tr>
                                    </tfoot>
                                </table>
                            </div>

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




            </div>

        </div><!-- fin row -->

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


{% endblock %}