{#

This file is part of the Sonata package.

(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.

#}

{# DEPRECATED #}
{# This file is kept here for backward compatibility - Rather use SonataAdminBundle:Button:create_button.html.twig #}

{% extends 'SonataAdminBundle:Button:create_button.html.twig' %}                                                                                      {#

This file is part of the Sonata package.

(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.

#}

{% extends base_template %}

{% block title %}{{ 'title_search_results'|trans({'%query%': query}, 'SonataAdminBundle') }}{% endblock%}
{% block breadcrumb %}{% endblock %}
{% block content %}
    <!--
    <div class="row">
        <form action="{{ url('sonata_admin_search') }}" method="GET"  class="form-search">
            <div class="input-append">
                <input type="text" name="q" value="{{ query }}" class="input-large search-query">
                <button type="submit" class="btn">Search</button>
            </div>
        </form>
    </div>
    -->

    <h1>{{ 'title_search_results'|trans({'%query%': query}, 'SonataAdminBundle') }}</h1>

    {% if query is defined and query is not sameas(false) %}
        {% set count = 0 %}
        <div class="row">

            {% for group in groups %}
                {% set display = (group.roles is empty or is_granted('ROLE_SUPER_ADMIN') ) %}
                {% for role in group.roles if not display %}
                    {% set display = is_granted(role)%}
                {% endfor %}

                {% if display %}
                    {% for admin in group.items %}
                        {% if count % 3 == 0 %}
                            </div><div class="row">
                        {% endif %}

                        {% set count = count + 1 %}
                        {% if admin.hasroute('create') and admin.isGranted('CREATE') or admin.hasroute('list') and admin.isGranted('LIST') %}
                            {{ sonata_block_render({
                                'type': 'sonata.admin.block.search_result'
                            }, {
                                'query': query,
                                'admin_code': admin.code,
                                'page': 0,
                                'per_page': 10
                            }) }}
                        {% endif %}
                    {% endfor %}
                {% endif %}
            {% endfor %}
        </div>
    {% endif %}

{% endblock %}
