{% extends "ClarolineCoreBundle:Administration:layout.html.twig" %}

{% block title %}{{ parent() ~ ' - ' ~ 'roles_management' | trans({}, 'platform') | striptags | raw }}{% endblock %}

{% block breadcrumb %}
    {{
        macros.breadcrumbs([
            {
                'icon': 'fa fa-cog',
                'name': 'administration'|trans({}, 'platform'),
                'href': path('claro_admin_index')
            },
            {
                'name': 'roles_management'|trans({}, 'platform'),
                'href': path('claro_admin_roles_index')
            },
            {
                'name': 'manage_tools'|trans({}, 'platform'),
                'href': ''
            }
        ])
    }}
{% endblock %}

{% block section_content %}
    <div class="panel-heading">
        {{ 'manage_tools'|trans({}, 'platform') }}
    </div>
    <div class="panel-body">
        <form role="form">
            <div class="table-responsive">
                <table id="user-table" class="table table-striped table-bordered table-condensed">
                    <thead>
                        <tr>
                            <th>{{ 'name'|trans({}, 'platform') }}</th>
                            {% for role in roles %}
                                <th>{{ role.getTranslationKey()|trans({}, 'platform') }}</th>
                            {% endfor %}
                        </tr>
                    </thead>
                        <tbody>
                        {% for tool in tools %}
                            <tr id="{{ tool.getId() }}" class="row-user">
                                <td>{{ tool.getName()|trans({}, 'tools') }}</td>
                                {% for role in roles %}
                                    <td>
                                        <input type="checkbox"
                                               class="chk-role"
                                               data-role-id="{{ role.getId() }}"
                                               data-tool-id="{{ tool.getId() }}"
                                               {% for linkedrole in tool.getRoles %}
                                                   {%  if linkedrole.getId() == role.getId() %}
                                                       checked
                                                   {% endif %}
                                               {% endfor %}
                                        />
                                    </td>
                                {% endfor %}
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </form>
    </div>
{% endblock %}

{% block javascripts %}
    {{ parent() }}
    <script src='{{ asset('bundles/clarolinecore/js/administration/admin_tools_roles.js') }}' type="text/javascript"></script>
{% endblock %}
