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

{% block body %}
    <div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h2>Do you really want to delete this token?</h2>
                </div>
                <div class="modal-body">
                    <p>You are about to delete one token, this procedure is irreversible.</p>
                    <p>Do you want to proceed?</p>
                    <p>We hope that you know what you do!</a>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                    <a href="#" class="btn btn-danger danger">Delete</a>
                </div>
            </div>
        </div>
    </div>
    <h2>Token List</h2>
    <div class="row">
        <div class="col-md-12 col-ld-12">
            <a class="btn btn-primary dropdown-toggle" data-toggle="collapse" data-target="#filters">
                show filter
                <span class="caret"></span>
            </a>
        </div>
        <div class="col-md-12 col-ld-12">
            <div id="filters" class="collapse">
                <form class="well" method="get" action="">
                    {{ form_rest(form) }}
                    <p>
                        <button class="btn btn-primary" type="submit" name="filter_action"
                                value="filter">{% trans %}btn.filter{% endtrans %}</button>
                        <button id="reset" class="btn btn-danger" type="submit" name="filter_action"
                                value="reset">{% trans %}btn.reset{% endtrans %}</button>
                    </p>
                </form>
            </div>
        </div>
    </div>
    <hr/>
    <div class="row">
        <div class="col-md-12 col-ld-12">
            <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">
                <tr>
                    <th {% if pagination.isSorted('a.ServiceToken') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'ServiceToken', 'a.ServiceToken') }}</th>
                    <th>ServiceToken2Ip</th>
                    <th>AllowedCallsPerDay</th>
                    <th>ValidUntil</th>
                    <th>Blocked</th>
                    <th>Description</th>
                    <th>Action</th>
                </tr>
                {% for token in pagination %}
                    <tr>
                        <td><a class="tt" data-toggle="tooltip" data-placement="top" title="{{ token.ServiceToken }}"
                               href="#"><span class="cutstring">{{ token.ServiceToken }}</span></a></td>
                        <td>{{ token.ServiceToken2Ip }}</td>
                        <td>{{ token.AllowedCallsPerDay }}</td>
                        <td>{{ token.ValidUntil|date('Y-m-d') }}</td>
                        <td>{{ token.Blocked }}</td>
                        <td>{{ token.Description }}</td>
                        <td>
                            <a class="btn btn-default btn-xs"
                               href="{{ path('_admin_backend_token_edit', {'tokenId': token.ServiceToken}) }}">edit</a>
                            <a class="btn btn-success btn-xs"
                               href="{{ path('_admin_backend_token_show', {'tokenId': token.ServiceToken}) }}">show</a>
                            <a class="btn btn-danger btn-xs" data-toggle="modal" data-target="#confirm-delete"
                               data-href="{{ path('_admin_backend_token_delete', {'tokenId': token.ServiceToken}) }}"
                               href="#">delete</a>
                        </td>
                    </tr>
                {% endfor %}
            </table>
        </div>

        <div class="col-md-12 col-ld-12">
            <div class="navigation">
                {{ knp_pagination_render(pagination) }}
            </div>
        </div>

    </div>
    <script>
        $(function () {
            $(".tt").tooltip();
        });
        $('#confirm-delete').on('show.bs.modal', function (e) {
            $(this).find('.danger').attr('href', $(e.relatedTarget).data('href'));
        });

    </script>
    <a class="btn btn-default" href="{{ path('_admin_backend_token_create') }}" title="add token">add
        token</a>{% endblock %}
