
{% extends 'admin.html.twig' %}

{% block body %}

    <h2 class="my-4 text-primary">
        Caracteristicas actuales 
        <a class="btn btn-primary btn-sm" href="{{ path('caracteristica_registrar') }}">
            <i class="fas fa-plus-circle"></i>&nbsp;Agregar
        </a>
    </h2>

    <div class="row">
        <div class="col-md-12">

            <div class="table-responsive">
                <table class="table table-striped table-bordered">
                    <thead class="thead-dark">
                        <tr>
                            <th scope="col">Nombre</th>
                            <th class="text-center" scope="col">Estatus</th>
                            <th class="text-center" scope="col">Opciones</th>
                        </tr>
                    </thead>

                    <tbody>

                        {% if caracteristicas %}
                            {% for caracteristica in caracteristicas %}
                                <tr class="caracteristica-{{ caracteristica.id }}">
                                    <td class="caracteristica-{{ caracteristica.id }}">{{ caracteristica.nombre }}</td>

                                    <td class="text-center caracteristica-estatus">

    {% if caracteristica.estatus == constant('ESTATUS_ACTIVO', caracteristica) %}
        <i class="text-success fas fa-check-circle fa-lg"></i> <span class="estatus-nombre">Activo<span>
    {% else %}
        <i class="text-danger fas fa-ban fa-lg"></i> <span class="estatus-nombre">Inactivo<span>
    {% endif %}

                                    </td>

<td class="text-center">
    <a href="{{ path('caracteristica_editar', {id : caracteristica.id}) }}" title="Modificar">
        <i class="fas fa-edit fa-lg text-dark"></i>
    </a>

    <a 
    data-url="{{ path('caracteristica_activar', {id : caracteristica.id}) }}" 
    data-id="{{ caracteristica.id }}" 
    data-estatus="{{ caracteristica.estatus }}" 
    data-nombre="{{ caracteristica.nombre }}" 
    data-target="#modal-activar-caracteristica" 
    data-toggle="modal" 
    class="not-decoration text-dark"
    title="Cambiar Estatus">
        <i class="fas fa-exchange-alt fa-lg"></i>
    </a>
</td>
                                </tr>
                            {% endfor %}
                        {% else %}
                            <tr>
                                <th colspan="3" class="text-center">No existen Caracteristicas creadas</th>
                            </tr>
                        {% endif %}

                    </tbody>
                </table>
            </div>

        </div>
    </div>


    <div class="modal fade" id="modal-activar-caracteristica" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
            <div class="modal-header bg-warning">
                <h5 class="modal-title text-dark">¿Esta seguro?</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <span>¿esta seguro que desea <strong><span id="caracteristica-estatus-activar"></span></strong> la caracteristica (<strong><span id="caracteristica-nombre-activar"></span></strong>)?</span> 
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cerrar</button>
                <button id="btn-activar-caracteristica" data-id="" data-url="" type="button" class="btn btn-primary">Actualizar</button>
            </div>
            </div>
        </div>
    </div>



{% endblock %}

    {% block javascripts %}

        <script src={{ asset('build/js/caracteristica-listado.js') }}></script>

    {% endblock %}