{% extends 'Admin/layout.html.twig' %}

{% trans_default_domain 'form' %}

{% block body %}
    {{ knp_menu_render('actions_partners') }}

    {# Search form #}
    <form action="{{ path('partner_index') }}" class="search-admin" method="get">
        <fieldset>
            <div class="search-fields">
                <p>
                    <label for="form_search_name">{{ 'form.name.label'|transchoice(1, []) }}</label>
                    <input id="form_search_name" name="name" type="search" value="{{ app.request.query.get('name', '') }}"/>
                </p>
            </div>
        </fieldset>
        <p>
            <input class="btn" type="submit" value="{{ 'action.search'|trans({}, 'action') }}"/>
        </p>
    </form>

    <table class="tableBo">
        <thead>
            <tr>
                <th>{{ 'form.logo.label'|trans }}</th>
                <th>{{ 'form.name.label'|trans }}</th>
                <th>{{ 'form.description.label'|trans }}</th>
                <th>{{ 'form.website.label'|trans }}</th>
                <th colspan="2">{{ 'word.actions'|trans({}, 'word') }}</th>
            </tr>
        </thead>
        <tbody>
        {% for partner in partners %}
            <tr class="delete-element-container">
                <td class="center">
                    {% if partner.logoPath is not null %}
                        <a href="{{ path('partner_edit', {id:partner.id}) }}">
                            <img alt="" src="{{ vich_uploader_asset(partner, 'logoFile')|imagine_filter('30H') }}"/>
                        </a>
                    {% endif %}
                </td>
                <td><a href="{{ path('partner_edit', {id:partner.id}) }}">{{ partner.name }}</a></td>
                <td>{{ partner.description|truncate(100, '…') }}</td>
                <td>
                    <a
                        href="{{ partner.website }}" target="_blank"
                        title="{{ 'action.goto.website'|trans({}, 'action') }}"
                    >
                        {{ partner.website }}
                    </a>
                </td>
                <td class="action">
                    <a
                        class="edit"
                        href="{{ path('partner_edit', {id:partner.id}) }}"
                        title="{{ 'action.edit.label'|trans({}, 'action') }} : {{ partner.name }}"
                    >
                        <span>{{ 'action.edit.label'|trans({}, 'action') }}</span>
                    </a>
                </td>
                <td class="action">
                    {% if partner.isDeletable() %}
                        <a
                            class="delete-element "
                            href="{{ path('partner_delete', {id:partner.id}) }}"
                            title="{{ 'action.delete.label'|trans({}, 'action') }} : {{ partner.name }}"
                        >
                            <span>{{ 'action.delete.label'|trans({}, 'action') }}</span>
                        </a>
                    {% else %}
                        <button
                            class="delete-element"
                            disabled
                            title= "{{ 'notice.partner.removed.failure'|trans({}, 'notice') }}"
                        >
                            <span>{{ 'action.delete.label'|trans({}, 'action') }}</span>
                        </button>
                    {% endif %}
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>

    {{ include('Admin/Paginator/pagination.html.twig', {pages:nb_pages}) }}
{% endblock %}
