{% extends '@CadolesCore/base.html.twig' %}

{% block pagewrapper %}
    {% set color = app.session.get('color') %}

    <h1>
        Gestion des Signataires de Chartes
    </h1>

    <div class="row">
        <div class="col-md-12">
            <p>
                <a href="{{ path('cadoles_portal_config_notice_users_deleteall',{id:notice.id }) }}" class="btn btn-danger">Supprimer toutes les signatures</a>
                <a class="btn btn-default" href={{ path('cadoles_portal_config_notice') }}>Annuler</a>
            </p>

            <div id="list" class="panel-group">
                <div class="dataTable_wrapper">
                    <table class="table table-striped table-bordered table-hover" id="dataTables" style="width:100%">
                        <thead>
                            <tr>
                            <th width="100px" class="no-sort">Action</th>
                            <th width="70px" class="no-sort">Avatar</th>
                            <th>Login</th>
                            <th>Nom</th>
                            <th>Prénom</th>
                            </tr>
                        </thead>

                        {% for user in notice.users %}
                            {% set colorbody = "background-color: #" ~ color['main'] %}
                                <tr>
                                    <td>
                                        <a href="{{ path('cadoles_portal_config_notice_users_delete',{id:notice.id,userid:user.id}) }}" data-method='delete' title='Supprimer'><i class='fa fa-trash fa-fw fa-2x'></i></a>
                                    </td>
                                    <td><img src="/{{ alias }}/uploads/avatar/{{ user.avatar }}" class="avatar" style="margin:auto;display:block;"></td>
                                    <td>{{ user.username }}</td>
                                    <td>{{ user.lastname }}</td>
                                    <td>{{ user.firstname }}</td>
                                </tr>
                            <div
                        {% endfor %}

                    </table>
                </div>

            </div>
        </div>
    </div>
{% endblock %}

{% block localjavascript %}
    $(document).ready(function() {
        table = $('#dataTables').DataTable({
            columnDefs: [ { "targets": 'no-sort', "orderable": false } ],
            responsive: true,
            iDisplayLength: 100,
            order: [[ 2, "asc" ]],
            drawCallback: function(settings) {
                $("a[data-method='delete']").click(function(){
                    if( !confirm('Êtes-vous sûr de vouloir supprimer ce calendrier ?')) {
                        return false;
                    }        
                });               
            }              
        });

    });
{% endblock %}


