{#
 * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
 * 
 * This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
#}
{% extends "@ChillPerson/Person/layout.html.twig"  %}

{% set activeRouteKey = 'report_select_type' %}

{% block title %}{{ 'Report list' |trans }}{% endblock title %}

{% block content %}
    
    <h1>{{ 'Report list'|trans }}</h1>
    
    {% if reports|length == 0 %}
        <p>
            <span class="chill-no-data-statement">{{ "No report registered for this person."|trans }}</span>
        </p>
    {% else %}
    <table class="" style="width:100%">
        <thead>
            <tr>
                <th class="chill-red">{{ 'Date' | trans }}</th>
                <th class="chill-green">{{ 'Report type' | trans }}</th>
                <th class="chill-orange">{{ 'Circle' | trans }}</th>
                <th>&nbsp;</th>
            </tr>
        </thead>
        <tbody>
        {% for report in reports %}
            <tr>
                <td>{% if report.date %}{{ report.date|format_date('long') }}{% endif %}</td>
                <td>{{ report.cFGroup.getName|localize_translatable_string  }}</td>
                <td>{{ report.scope.name|localize_translatable_string }}</td>
                <td>
                    <ul class="record_actions">
                        {% if is_granted('CHILL_REPORT_SEE', report) %}
                        <li>
                            <a href="{{ path('report_view', { 'person_id': report.person.id, 'report_id': report.id }) }}" class="btn btn-view"></a>
                        </li>
                        {% endif %}
                        {% if is_granted('CHILL_REPORT_UPDATE', report) %}
                            <li>
                        <a href="{{ path('report_edit', { 'person_id': report.person.id, 'report_id': report.id }) }}" class="btn btn-update"></a>
                            </li>
                        {% endif %}
                    </ul>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
        
    {% if reports|length < paginator.getTotalItems %}
        {{ chill_pagination(paginator) }}
    {% endif %}
        
    {% endif %}
        
    <ul class="record_actions">
        <li>
            <a href="{{ path('report_select_type', { 'person_id' : person.id } ) }}" class="btn btn-new">
                {{ 'Create a new report'|trans }}
            </a>
        </li>
    </ul>
    
{% endblock %}
