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

{% trans_default_domain 'form' %}

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

    {# Search form #}
    <form action="{{ path('operationpee_category_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 colspan="3">{{ 'word.actions'|trans({}, 'word') }}</th>
            </tr>
        </thead>
        <tbody>
        {% for category in categories %}
            <tr class="delete-element-container">
                <td class="center">
                    {% if category.logoPath is not null %}
                        <a href="{{ path('operationpee_category_edit', {id:category.id}) }}">
                            {{ file_get_contents(vich_uploader_asset(category, 'logoFile')) }}
                        </a>
                    {% endif %}
                </td>
                <td>
                    <a href="{{ path('operationpee_category_edit', {id:category.id}) }}">
                        {{ category.name }}
                    </a>
                </td>
                <td class="action">
                    <a
                        class="edit"
                        href="{{ path('operationpee_category_edit', {id:category.id}) }}"
                        title="{{ 'action.edit.label'|trans({}, 'action') }} : {{ category.name }}"
                    >
                        <span>{{ 'action.edit.label'|trans({}, 'action') }}</span>
                    </a>
                </td>
                <td class="action">
                        <input
                            {% if category.isactive %} checked="checked"{% endif %}
                            class="input-active"
                            data-type="OperationPEECategory"
                            data-url="{{ path('element_actif')}}"
                            type="checkbox"
                            value="{{ category.id }}"
                        />
                        <span class="checkbox"></span>
                    </td>
                <td class="action">
                    {% if category.isDeletable() %}
                        <a
                            class="delete-element "
                            href="{{ path('operationpee_category_delete', {id:category.id}) }}"
                            title="{{ 'action.delete.label'|trans({}, 'action') }} : {{ category.name }}"
                        >
                            <span>{{ 'action.delete.label'|trans({}, 'action') }}</span>
                        </a>
                    {% else %}
                        <button
                            class="delete-element"
                            disabled
                            title= "{{ 'notice.operationPee.category.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 %}
