{% extends 'layout.twig' %}

{% block body %}


    <div class="contenu" id="liste">
    
        <h1>
            {{ 'Accords-cadres' | trad }} :            
        </h1>

        {{ ariane() }}

        <h3 class="clearfix">
            {{ 'RFA de l\'accord-cadre' | trad }} - {{ acd.LIBELLE }} {% if acd.AVENANT %} - {{ acd.AVENANT }}{% endif %} ({{ acd.CODE_ACD }})
            
            {% if droit.HA_ACD_CM or droit.HA_ACD_ADM %}
                <a href="{{ path('Contrat.RFA.createEdit', {type:type, idacc:idacc}) }}" class="button principal" style="margin-right:0px">{{ 'Nouvelle RFA' | trad }}</a>
            {% endif %}
            <form class="d-inline"
                action="{{ path('Ajax.Outil.appelAsync') }}"
                onsubmit="return ajaxSubmit(event, new FormData(document.getElementById('form_rfa')))"
                data-onsuccess="successPopupExport"
            >
                <input type="hidden" name="exportPathAction" 
                    value="{{ path('Contrat.RFA.export', {idacc: idacc}) }}"
                />
                <button class="button secondaire " type="submit">
                    {{- 'Exporter' | trad -}}
                </button>
            </form>
        </h3>

        <div class="content clearfix" style="margin-top:10xp";>

            <form method="post" name="form_rfa" id="form_rfa">
                <table class="table table-hover">
                    <thead class="thead-dark">
                        <tr>
                            <th scope="col">{{ triTable('LIBELLE',  post.tri_LIBELLE, 'Libellé' | trad, '', '', 'form_rfa') }}</th>
                            <th scope="col">{{ triTable('DTE_DEBUT',  post.tri_DTE_DEBUT, 'Date début' | trad, '', '', 'form_rfa') }}</th>
                            <th scope="col">{{ triTable('DTE_FIN',  post.tri_DTE_FIN, 'Date fin' | trad, '', '', 'form_rfa') }}</th>
                            <th scope="col">{{ triTable('TACITE_RECOND',  post.tri_TACITE_RECOND, 'Tacite reconduction' | trad, '', '', 'form_rfa') }}</th>
                            <th scope="col">{{ triTable('TYPE_RFA',  post.tri_TYPE_RFA, 'Type RFA' | trad, '', '', 'form_rfa') }}</th>
                            <th scope="col">{{ triTable('BASE_CALCUL',  post.tri_BASE_CALCUL, 'Base de calcul' | trad, '', '', 'form_rfa') }}</th>
                            <th scope="col">{{ triTable('VALEUR_RFA',  post.tri_VALEUR_RFA, 'Valeur' | trad, '', '', 'form_rfa') }}</th>
                            <th scope="col">{{ triTable('SOLDE',  post.tri_SOLDE, 'Soldée ?' | trad, '', '', 'form_rfa') }}</th>
                            <th scope="col" width="100px">{{ 'Actions' | trad }}</th>
                        </tr>
                    </thead>

                    <tbody>
                        <tr class="recherche">
                            <td>{{ filterTable('LIBELLE', post.filter_LIBELLE, '', '', '', 'form_rfa', '', '') }}</td>
                            <td>{{ filterTable('date_DTE_DEBUT', post.filter_date_DTE_DEBUT, '', '', '','form_rfa', 'datepicker','Date début' | trad) }}</td>
                            <td>{{ filterTable('date_DTE_FIN', post.filter_date_DTE_FIN, '', '', '','form_rfa', 'datepicker','Date fin' | trad) }}</td>
                            <td>{{ filterSelect('TACITE_RECOND', post.filter_TACITE_RECOND, ouiNon, 'form_rfa', '','', '', '', '') }}</td>
                            <td>{{ filterSelect('TYPE_RFA', post.filter_TYPE_RFA, typeRFA, 'form_rfa', '','', '', '', '') }}</td>
                            <td>{{ filterSelect('BASE_CALCUL', post.filter_BASE_CALCUL, baseCalcul, 'form_rfa', '','', '', '', '') }}</td>
                            <td>{{ filterTable('VALEUR_RFA', post.filter_VALEUR_RFA, '', '', '', 'form_rfa', '', '') }}</td>
                            <td>{{ filterSelect('SOLDE', post.filter_SOLDE, ouiNon, 'form_rfa', '','', '', '', '') }}</td>
                            <td></td>
                        </tr>
                        {% for rfa in listeRFA %}
                            <tr id="index{{loop.index}}">
                                <td class="loupe">{{rfa.LIBELLE}}</td>
                                <td>{{rfa.DTE_DEBUT | dateTrad }}</td>
                                <td>{{rfa.DTE_FIN | dateTrad }}</td>
                                <td>{{rfa.TACITE_RECOND | boolTrad}}</td>
                                <td>{{typeRFA[rfa.TYPE_RFA]}}</td>
                                <td>{{baseCalcul[rfa.BASE_CALCUL]}}</td>
                                <td class="montant">{{rfa.VALEUR_RFA | tva }} {% if rfa.TYPE_RFA == 'M'%}{{devise}}{% else %}%{% endif %}</td>
                                <td>{{rfa.SOLDE| boolTrad}}</td>
                                <td>
                                    {{ menuContextuel('index' ~ loop.index, false, rfa.menuContextuel) }}
                                </td>
                            </tr>
                            <tr id="index{{loop.index}}detail" class="detail_ligne hide_detail">
                                <td colspan="10">
                                    <div class="informations">
                                        <p>
                                            <span class="champs_label">{{ 'Commentaire :' | trad }}</span>
                                            <span class="resultat">{{ rfa.COMMENTAIRE | nl2br }}</span>
                                        </p>
                                    </div>
                                </td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>

                {{ paginations(path('Contrat.RFA.liste', {idacc:idacc,type:type}),infoPagination.nombreDePage, infoPagination.page, infoPagination.post, '') }}

            </form>
        </div>

    </div>

{% endblock %}