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

{% block title %}{{ 'profil_edition'|trans({}, 'platform') }}{% endblock %}

{% block content %}
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">{{ 'profil_edition'|trans({}, 'platform') }}</h3>
        </div>
        {% set actionForm = editYourself ? path('claro_user_profile_edit') : path('claro_user_profile_edit', {'user': user.getId()}) %}
        {% set cancelUrl  = editYourself ? path('claro_profile_view') : path('claro_admin_user_list') %}
        <form role="form" class="form-horizontal" action="{{ actionForm }}" method="post" {{ form_enctype(form) }} id="profile_form">
            <div class="panel-body">
                {% for role in unavailableRoles %}
                    <div class="alert alert-warning"> {{ 'role_limit_reached'|trans({'%translationKey%': role.getTranslationKey()|trans({}, 'platform')}, 'platform') }}</div>
                {% endfor %}
                {{ form_widget(form) }}
            </div>
            <div class="panel-footer">
                <button type="submit" class="btn btn-primary">{{ 'edit'|trans({}, 'platform') }}</button>
                <a href="{{ cancelUrl }}" class="btn btn-default" role="button">{{ 'cancel' | trans({}, 'platform') }}</a>
            </div>
        </form>
    </div>
{% endblock %}
{% block javascripts %}
    {{ parent() }}
    <script>
        //disable unavailable checkboxes
        {% for role in unavailableRoles %}
            $('#profile_form_platformRoles_' + {{ role.getId() }}).attr('disabled', true);
        {% endfor %}
    </script>
{% endblock %}
