{% extends "SsoBackendBundle:token:base.html.twig" %}

{% block title %}
    Sso Types
{% 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 all types with all corresponding objects and attribute groups?</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!</p>
                </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>Type Overview</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>
            <a class="btn btn-danger pull-right" data-toggle="modal" data-target="#confirm-delete" id="deleteAll"
               data-href="{{ path('_admin_backend_webservice_type_delete_all') }} " href="#">
                !!! delete all types and corresponding objects/attribute groups !!!
            </a>
        </div>
        <div class="col-md-12 col-ld-12">
            <div id="filters" class="collapse">
                <form class="well" method="get" action="">
                    {{ form_widget(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 table-striped table-bordered table-condensed">
                <thead>
                <tr>
                    <th>Id</th>
                    <th {% if pagination.isSorted('a.order') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'Order', 'a.order') }}</th>
                    <th {% if pagination.isSorted('a.name') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'Name', 'a.name') }}</th>
                    <th>LoweName</th>
                    <th>Actions</th>
                </tr>
                </thead>
                <tbody>
                {% for entity in pagination %}
                    <tr>
                        <td>{{ entity.id }}</td>
                        <td>{{ entity.typeOrder }}</td>
                        <td>{{ entity.name }}</td>
                        <td>{{ entity.lowerName }}</td>
                        <td>
                            <a class="btn btn-primary btn-mini"
                               href="{{ path('_admin_backend_webservice_type_show', { 'typeId': entity.id }) }}">
                                show
                            </a>&nbsp;
                            <a class="btn btn-danger"
                               href="{{ path('_admin_backend_webservice_type_edit', { 'typeId': entity.id }) }}">
                                edit
                            </a>
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>

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

        <div class="col-md-6 col-ld-6">
            <a class="btn btn-success likepaginator" href="{{ path('_admin_backend_webservice_type_new') }}">
                New Type
            </a>
        </div>

    </div>

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

{% endblock %}