{% extends "SsoBackendBundle:PasswordPolicy:base.html.twig" %}
{% block title %}{{ parent() }} - Index{% endblock %}

{% block body %}
    <br /><br />

    <div style="font-size: 20px;margin-bottom: 20px;" class="pull-right">
        <span class="label label-success label-as-badge">count: {{ pagination.getTotalItemCount }}</span>
    </div>
    <a href="{{ path('_admin_backend_passwordpolicy_add') }}" class="btn btn-success btn-s">Add new policy</a><br><br>
    <table class="table table-striped table-bordered table-condensed">
        <thead>
        <tr>
            <th width="230px" {% if pagination.isSorted('a.policyId') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'Policy ID', 'a.policyId') }}</th>
            <th {% if pagination.isSorted('a.regEx') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'RegEx', 'a.regEx') }}</th>
            <th {% if pagination.isSorted('a.validityDuration') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'Validity (days)', 'a.validityDuration') }}</th>
            <th {% if pagination.isSorted('a.historySize') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'History', 'a.historySize') }}</th>
            <th {% if pagination.isSorted('a.editDistance') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'Edit Distance', 'a.editDistance') }}</th>
            <th {% if pagination.isSorted('a.changeDelay') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'Change Delay (minutes)', 'a.changeDelay') }}</th>
            <th {% if pagination.isSorted('a.isDefault') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'Default', 'a.isDefault') }}</th>
            <th {% if pagination.isSorted('a.title') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'Title', 'a.title') }}</th>
            <th width="150px">&nbsp;</th>
        </tr>
        </thead>
        <tbody>
        {% for entity in pagination %}
            <tr>
                <td style="font-size: x-small;">{{ entity.policyId }}</td>
                <td>{{ entity.regEx }}</td>
                <td>{{ entity.validityDuration }}</td>
                <td>{{ entity.historySize }}</td>
                <td>{{ entity.editDistance }}</td>
                <td>{{ entity.changeDelay }}</td>
                <td>{% if entity.isDefault == '1' %}<span class="label label-success label-xs">DEFAULT</span>{% endif %}</td>
                <td>{{ entity.title }}</td>
                <td>
                    <a href="{{ path('_admin_backend_passwordpolicy_show', {'policyId': entity.policyId}) }}" class="btn btn-info btn-xs">Show</a>
                    <a href="{{ path('_admin_backend_passwordpolicy_edit', {'policyId': entity.policyId}) }}" class="btn btn-info btn-xs">Edit</a>
                    <a href="{{ path('_admin_backend_passwordpolicy_delete', {'policyId': entity.policyId}) }}" class="btn btn-danger btn-xs">Delete</a>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
    <div class="navigation">
        {{ knp_pagination_render(pagination) }}
    </div>

    <style>
        th.sorted > a.desc:before {
            content: "\2191";
            padding-right: 3px;
            margin-top: -5px;
            font-size: 18px;
            color: #000;
            text-decoration: none;
            font-weight: bold;
        }

        th.sorted > a.asc:before {
            content: "\2193";
            padding-right: 3px;
            margin-top: -5px;
            font-size: 18px;
            color: #000;
            text-decoration: none;
            font-weight: bold;
        }
    </style>
{% endblock %}
