{% extends 'dismissal/debug/base.html' %}

{% block title %}Права на увольнения{% endblock title %}
{% block header %}Права на увольнения{% endblock header %}

{% block form %}
    <form class="form-horizontal">
        {{ form.non_field_errors }}
        {% for field in form %}
            <div class="control-group{% if field.errors %} error{% endif %}">
                <label class="control-label" for="{{ field.id }}">{% if field.field.required %}<b>{% endif %}{{ field.label }}{% if field.field.required %}</b>{% endif %}</label>
                <div class="controls">
                    {{ field }}
                    <p class="help-inline">{{ field.errors|join:", " }}</p>
                </div>

            </div>
        {% endfor %}
        <input type="submit" class="btn btn-primary" value="Проверить права"/>
    </form>
{% endblock form %}

{% block results %}

    <div>
        {% if who and for_whom %}
            <h2>Права <b>{{ who_genitive }}</b> по отношению к <b>{{ for_whom_dative }}</b></h2>

            <table class="table">
                <tr>
                    <th>Существует процедура увольнения с обходным {{ for_whom_genitive }}</th>
                    <td>{% if exists_dismissal_procedure_for %}
                        <span class="label label-success">да</span>
                    {% else %}
                        <span class="label label-important">нет</span>
                    {% endif %}</td>
                </tr>
                <tr>
                    <th>{{ who }} может видеть ссылку на анкете {{ for_whom_genitive }}</th>
                    <td>{% if can_see_dismissal_link %}
                        <span class="label label-success">да</span>
                    {% else %}
                        <span class="label label-important">нет</span>
                    {% endif %}</td>
                </tr>
                {% if not exists_dismissal_procedure_for %}
                <tr>
                    <th>
                        {{ who }} может уволить с прямо анкеты {{ for_whom_genitive }}
                        <p>can_dismiss_from_anketa</p>
                    </th>
                    <td>{% if can_dismiss_from_anketa %}
                        <span class="label label-success">да</span>
                    {% else %}
                        <span class="label label-important">нет</span>
                    {% endif %}</td>
                </tr>
                {% else %}
                <tr>
                    <th>
                        {{ who }} может создать увольнение {{ for_whom_genitive }}
                        <p>can_create_dismissal</p>
                    </th>
                    <td>{% if can_create_dismissal %}
                        <span class="label label-success">да</span>
                    {% else %}
                        <span class="label label-important">нет</span>
                    {% endif %}</td>
                </tr>

                <tr>
                    <th>
                        {{ who }} может уволить {{ for_whom_genitive }} из обходного
                        <p>can_dismiss_from_chit</p>
                    </th>
                    <td>{% if can_dismiss_from_chit %}
                        <span class="label label-success">да</span>
                    {% else %}
                        <span class="label label-important">нет</span>
                    {% endif %}</td>
                </tr>
                <tr>
                    <th>
                        {{ who }} видит комментарий для HR для заявки {{ for_whom_genitive }}
                        <p>can_see_hr_note</p>
                    </th>
                    <td>{% if can_see_hr_note %}
                        <span class="label label-success">да</span>
                    {% else %}
                        <span class="label label-important">нет</span>
                    {% endif %}</td>
                </tr>
                {% endif %}

            </table>

            <h3>Пермишны пользователя {{ who }}</h3>
            <ul>
                {% for perm in who.user.get_all_permissions %}
                    <li>{{ perm }}</li>
                {% endfor %}
            </ul>

        {% endif %}
    </div>
{% endblock results %}
