{% extends "layout.html" %}

{% set nav_active = 'acceso' %}
{% block content %}

{% if respuesta.success != "" %}
<div class="alert alert-success alert-dismissible" role="alert">
    {{respuesta.success}}
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">&times;</span>
    </button>
</div>
{% endif %}
{% if respuesta.error != "" %}
<div class="alert alert-danger alert-dismissible" role="alert">
    {{respuesta.error}}
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">&times;</span>
    </button>
</div>
{% endif %}

<div class="box">
    <div class="box-header with-border">
        <h3 class="box-title">Privilegios de acceso</h3>
        <div class="box-tools pull-right">
            <button class="btn btn-box-tool" data-widget="collapse">
                <i class="fa fa-minus"></i>
            </button>

            <button class="btn btn-box-tool" data-widget="remove">
                <i class="fa fa-times"></i>
            </button>
        </div>
    </div>
    <div class="box-body">
        <div class="row">
            <div class="col-md-12">

                <div class="row" style="margin-top: 20px;">
                    {% for nivel in niveles %}
                    <div class="col-md-4">
                        <p class="text-center bg-verdelight" style="margin: 0;">{{nivel.nombre}}</p>
                        <div class="table-responsive">
                            <table class="table table-bordered table-condensed table-striped">
                                {% for privilegiopermitido in privilegiospermitidos %}
                                <tr>
                                    <td>{{privilegiopermitido.nombre}}</td>
                                    <td>
                                        {% if nivel.getPirivilegios(privilegiopermitido.id) %}
                                        <a href="delete_privilegio.php?nivel={{nivel.id}}&privilegio={{privilegiopermitido.id}}" class="btn btn-sm btn-light text-verdedark">Permitido</buttom>    
                                        {% else %}
                                        <a href="agregar_privilegio.php?nivel={{nivel.id}}&privilegio={{privilegiopermitido.id}}" class="btn btn-sm text-warning">Denegado</buttom>
                                        {% endif %}
                                    </td>
                                </tr>
                                {% endfor %}
                            </table>
                        </div>
                    </div>
                    {% endfor %}
                </div>

            </div>
        </div>
    </div>
</div>

{% endblock %}