{% extends 'layout.twig' %}
{% block body %}
    <div class="contenu clearfix"  id="compare_offers">
        <h1>
            {{ 'Consultations' | trad }}
        </h1>
        {{ ariane() }}
        <h2 id="divMenu" style="position:relative;">
            {{ 'Consultation' | trad }} : {{ consultation.NO_AO }} - {{ consultation.OBJET_AO }} {{ 'créée le' | trad }} {{ consultation.DTE_AO | dateTrad }} {% if AOEventCreat.NOM %} {{ 'par' | trad }} {{ AOEventCreat.NOM }} {% endif %}
            {{ arianeAnnuler('Retour' | trad) }}
        </h2>
        <div class="tab-content">
            <form method="post" name="formChoixFrs" id="formChoixFrs" class="clearfix padding15">   
                <div id="table-scroll" class="table-scroll">
                    <div class="table-wrap">
                        <table id="choixFrs" class="table table-V2 table-hover main-table" style="margin-bottom:0px;">
                            <thead>
                                <th class="auto_width" style="min-width:150px;"></th>
                                    {% for frs in listeFrs %}
                                        <th class="align-center auto_width" style="min-width:150px;">
                                            {% if frs.TYPE_FG == 'G' %}
                                                {{ frs.RS_GRP }} ({{ frs.CODE_FOU }})
                                            {% else %}
                                                {{ frs.RS }} ({{ frs.CODE_FOU }})
                                            {% endif %}
                                        </th>
                                    {% endfor %}
                            </thead>
                            <tbody>
                            </tbody>
                            <tfoot>
                                {% for theme in supplierByQuestionsByThemes %}
                                    <tr class="questionnaire_supplier_{{ idAO }}detail detail_ligne">
                                        <td class="auto_width fixed-side fixed-bottom noBorderTop borderRight borderBottom" 
                                            style="min-width:150px;font-weight:bold;">
                                            {{ theme.LIB_THEME }}
                                        </td> 
                                        <td class="ligne_split fixed-side fixed-bottom borderRight noBorderTop"></td>
                                    </tr>
                                    {% if theme.questionsList %}
                                        {% for question in theme.questionsList %}
                                            <tr class="questionnaire_supplier_{{ idAO }}detail detail_ligne">
                                                <td class="auto_width fixed-side fixed-bottom noBorderTop borderRight borderBottom" 
                                                    style="min-width:150px;">
                                                    {{ question.LIB_QUEST }}
                                                </td> 
                                                {% for supplier in question.suppliers %}
                                                    <td class="auto_width align-right borderRight borderBottom" style="text-align:center;min-width:150px;">
                                                        {% if supplier.TERMINE | boolSql %}
                                                            {% if question.TYPE_REP == 'L' %}
                                                                {{ supplier.REPONSE | boolTrad }}
                                                            {% elseif question.TYPE_REP == 'N' %}
                                                                {{ supplier.REPONSE | prix }}  
                                                            {% else %}
                                                                {{ supplier.REPONSE }}
                                                            {% endif %}
                                                            {{ ' (' ~ supplier.NOTE ~ '/10)' }}
                                                            {% if supplier.COMMENTAIRE != '' %}
                                                                <a class="commentaire white-tooltip">
                                                                    <span class="infos_tooltip left">
                                                                        {{ shortLibelle(supplier.COMMENTAIRE, 250) }}
                                                                    </span>
                                                                </a>
                                                            {% endif %}
                                                        {% else %}
                                                            {{ 'Sans réponse' | trad ~ ' (0/10)' }}
                                                        {% endif %}
                                                    </td>          
                                                {% endfor %}   
                                            </tr>
                                        {% endfor %}
                                    {% endif %}
                                {% endfor %}
                                {# Questionnaire fournisseur #}
                                {# {% for contributor in averageContributorGradesByContributors %}
                                    <tr id="questionnaire_supplier_{{ idAO }}">
                                        <td 
                                            class="toggleSlide auto_width fixed-side fixed-bottom noBorderTop borderRight borderBottom" 
                                            style="min-width:150px;"
                                            onclick="eventGetData(this)"
                                            data-id = "{{ idAO }}"
                                        >
                                            {{ contributor.NOM ~ ' (' ~ contributor.CONTRIB ~ ')' }}
                                        </td>
                                        {% for frs in contributor.suppliers %}
                                            <td class="auto_width fixed-side align-right borderRight borderBottom" style="min-width:150px;">
                                                {{ frs.AVERAGE_GRADE | prix ~ '/10' }}
                                            </td>
                                        {% endfor %}
                                    </tr>                                    
                                {% endfor %}
                                <tr id="questionnaire_contributor_{{ idAO }}">
                                    <td 
                                        class="auto_width fixed-side fixed-bottom noBorderTop borderRight borderBottom" 
                                        style="min-width:150px;"
                                    >
                                        {{ 'Note globale' | trad }}
                                    </td>
                                    {% for frs in listeFrs %}
                                        <td class="auto_width fixed-side align-right borderRight borderBottom" style="min-width:150px;">
                                            {{ frs.NOTE_CONTRIB | prix  ~ '/10' }}
                                        </td>
                                    {% endfor %}
                                </tr> #}
                            </tfoot>
                        </table>
                    </div>
                </div>
            </form>
            <script type="text/javascript" src="{{ baseUrl('ext/tableHeadFixer/js/tableHeadFixer.js')~'?cache='~getSession('cache')  }}"></script>
            <script>
                $('#input_visibilitePanel').change(function(){
                    showHidePanel();
                });
                
                function showHidePanel()
                {
                    if ($('#input_visibilitePanel').val() == '') {
                        $('.selected, .unselected').show();
                    } else if($('#input_visibilitePanel').val() == '1') {
                        $('.selected').show();
                        $('.unselected').hide();
                    } else if($('#input_visibilitePanel').val() == '2') {
                        $('.selected').hide();
                        $('.unselected').show();
                    } 
                }

                function eventGetData(object)
                {
                    let id = $(object).attr("data-id");
                    if ($(".questionnaire_supplier_" + id + 'detail').length) {
                        $(".questionnaire_supplier_" + id + 'detail').remove();
                    } else {
                        $.ajax({
                            url : '{{ path('Consultation.ChoixFournisseur.ajaxDetailSupplierQuestionnaire', { idAO: idAO }) }}',
                            type : 'POST',
                            dataType : 'html',
                            success : function(html){
                                $("#questionnaire_supplier_" + id).after(html);
                                $(object).attr("data-etat", 'open');
                            }
                        }); 
                    }
                }
            </script>                    
        </div>
    </div>		
{% endblock %}