{% extends "SsoBackendBundle:token:base.html.twig" %}
{# % form_theme filterForm ':Forms:bootstrap.layout.html.twig' % #}
{% block title %}{{ parent() }} - Index{% endblock %}

{% block body %}
    <br/><br/>
    <a class="btn btn-success btn-xs" href="{{ path('_admin_backend_servicetoken_index') }}">Back to main
        overview</a></td>

    <br/><br/>

    {% if assignableTokenCount > 0 %}
        {{ form_start(assignForm) }}
        {{ form_label(assignForm.token) }} <br/>
        {{ form_widget(assignForm.token) }} {{ form_widget(assignForm.submit) }}
        {{ form_end(assignForm) }}
        <br/><br/>
    {% else %}
        <div class="panel panel-default">
            <div class="panel-heading">All available tokens have been assigned to this Service Group Name</div>
        </div>
    {% endif %}

    <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>
    <table class="table table-striped table-bordered table-condensed">
        <thead>
        <tr>
            <th {% if pagination.isSorted('a.ServiceToken') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'Service Token', 'a.ServiceToken') }}</th>
            <th {% if pagination.isSorted('a.ServiceToken2Ip') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'Service Token Ip', 'a.ServiceToken2Ip') }}</th>
            <th {% if pagination.isSorted('a.AllowedCallsPerDay') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'Allowed Calls Per Day', 'a.AllowedCallsPerDay') }}</th>
            <th {% if pagination.isSorted('a.ValidUntil') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'Valid Until', 'a.ValidUntil') }}</th>
            <th {% if pagination.isSorted('a.Blocked') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'Blocked', 'a.Blocked') }}</th>
            <th {% if pagination.isSorted('a.BlockedReason') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'Blocked Reason', 'a.BlockedReason') }}</th>
            <th {% if pagination.isSorted('a.Description') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'Description', 'a.Description') }}</th>
            <th>&nbsp;</th>
        </tr>
        </thead>
        <tbody>
        {% for entity in pagination %}
            <tr>
                <td>{{ entity.ServiceToken|slice(0,50) }}....</td>
                <td>{{ entity.ServiceToken2Ip }}</td>
                <td>{{ entity.AllowedCallsPerDay }}</td>
                <td>{{ entity.ValidUntil|date('Y-m-d') }}</td>
                <td>{{ entity.Blocked }}</td>
                <td>{{ entity.BlockedReason }}</td>
                <td>{{ entity.Description }}</td>
                <td><a class="btn btn-danger btn-xs"
                       href="{{ path('_admin_backend_servicetoken_delete_token', {'ServiceToken': entity.ServiceToken, 'ServiceNameId': serviceName.ServiceNameId}) }}">Remove</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 %}
