{% extends 'layout.twig' %}

{% block body %}

    <div class="contenu clearfix"  id="Consultation_choixFrs">
        <h1>
            {{ 'Consultations' | trad }}
        </h1>
        {{ ariane() }}
        <h2 id="divMenu" style="position:relative;">
            {{ 'Consultation' | trad }} : {{ consultation.NO_AO }} - {{ consultation.OBJET_AO }} {{ 'créé le' | trad }} {{ consultation.DTE_AO | dateTrad }} {% if AOEventCreat.NOM %} {{ 'par' | trad }} {{ AOEventCreat.NOM }} {% endif %}
            {# <button type="button" class="button principal" onClick="ajaxPopupV2('{{ path('Consultation.ChoixFournisseur.validateChoixFrs', {idAO:idAO}) }}', 'formChoixFrs');">{{ 'Sélection finale' | trad }}</button> #}
            {% if canChooseFour %}
                <button type="button" class="button principal" 
                    onClick="ajaxPopup('{{ path('Consultation.ChoixFournisseur.popupEmailAutoChoixFournisseur', {idAO:idAO}) }}');"
                >{{ 'Sélection finale' | trad }}</button>
            {% endif %}
            {{ arianeAnnuler('Retour' | trad) }}
        </h2>
        <div class="tab-content">
            <form method="post" name="formChoixFrs" id="formChoixFrs" class="clearfix padding15">   
                <div class="clearfix" style="display:flex;align-items:end;margin-bottom:10px;">
                    {{ inputAdvance('SELECT',{
                        'name' : 'visibilitePanel',
                        'listeValue' : {'':  'Tout' | trad , '1': 'Panel' | trad , '2': 'Hors panel' | trad},
                        'addCss' : "width: 100px;float: left;",
                    }) }}
                    <div class="listeButton" style="margin-left: auto;">
                        <a class="eye_V2 showFrs pointer white-tooltip mx-tiny" onClick="$('.frsSansReponse').hide();$('.showFrs').hide();$('.hideFrs').show();showHidePanel();" >
                            <span class="infos_tooltip top-left">
                                {{ 'Exclure du tableau les fournisseurs n\'ayant pas répondu' | trad }}
                            </span>
                        </a>
                        <a class="eye-slash_V2 hideFrs pointer white-tooltip mx-tiny" style="display:none;" onClick="$('.frsSansReponse').show();$('.hideFrs').hide();$('.showFrs').show();showHidePanel();" >
                            <span class="infos_tooltip top-left">
                                {{ 'Inclure du tableau les fournisseurs n\'ayant pas répondu' | trad }}
                            </span>
                        </a>
                        <a onclick="ajaxPopup('{{ path('Consultation.Consultation.popupBlocNote', {idAO:idAO}) }}', '{{ 'Bloc-note' | trad }}', '', '')" 
                            class="bloc_note_V2 white-tooltip mx-tiny"
                        >
                            <span class="infos_tooltip top-left">
                                {{ 'Bloc-note de la consultation' | trad }}
                            </span>
                        </a>
                        <a onclick="resetChoix('{{ path('Consultation.ChoixFournisseur.ajaxResetChoix', {idAO:idAO}) }}', '{{ 'Bloc-note' | trad }}', '', '')" 
                            class="undo_V2 white-tooltip mx-tiny"
                        >
                            <span class="infos_tooltip top-left">
                                {{ 'Réinitialiser le choix fournisseur' | trad }}
                            </span>
                        </a>
                        <a class="pieces_jointes white-tooltip mx-tiny"
                            href="{{ path('GlobalApplication.CreationDocRattaches.ajoutDocAtt', {id: idFordoc, NO_DA: 'AO_ENTET', typeAccCadre:'JUSTIF'}) }}">
                            <span class="infos_tooltip left">
                                {{ 'Ajouter un document' | trad }}
                            </span>
                        </a>
                        <a class="download_v2 white-tooltip mx-tiny"
                            onClick="exportCSV2('{{ path('Consultation.ChoixFournisseur.export', {idAO:idAO, type:'RFQ'}) }}', '', '{{ path('Ajax.Erreur.popupInformation') }}', '{{ path('Ajax.Outil.appelAsync') }}');">
                            <span class="infos_tooltip left">
                                {{ 'Exporter les données' | trad }}
                            </span>
                        </a>
                        {# <a class="download_v2 white-tooltip" style="float:right;margin-left:5px!important;" 
                            onClick="exportCSV('{{ path('Consultation.ChoixFournisseur.export', {idAO:idAO, type:'RFQ'}) }}', 'filtre_acc');"
                            href="{{ path('Consultation.ChoixFournisseur.export', {idAO:idAO, type:'RFQ'}) }}" target="_blank">
                            <span class="infos_tooltip left">
                                {{ 'Exporter les données' | trad }}
                            </span>
                        </a> #}
                    </div>
                </div>   		
                <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 class="thead-dark">
                                <tr>
                                    {% if canChooseFour %}
                                    <th scope="col" class="fixed-side"><input type="checkbox" name="allLigne" id="allLigne" onclick="checkout('checkbox', 'allLigne');selectAll();" class="form-control checkbox" checked /></th>
                                    {% endif %}
                                    <th scope="col" class="fixed-side">{{ 'Réf. article' | trad }}</th>
                                    <th scope="col" class="fixed-side">{{ 'Désignation' | trad }}</th>
                                    <th scope="col" class="fixed-side">{{ 'Désign. compl.' | trad }}</th>
                                    <th scope="col" class="fixed-side align-right">{{'Quantité' | trad }}</th>
                                    <th scope="col" class="fixed-side">{{'Unité' | trad }}</th>
                                    <th scope="col" class="fixed-side align-right">{{'Prix réf' | trad }}</th>
                                    <th scope="col" class="fixed-side align-right borderRight">{{'Budget' | trad }}</th>
                                    <th width="20px" class="entete_split fixed-side"></th>
                                    {% set countFrs = 0 %}
                                    {% for frs in listeFrs %}
                                        {% set countFrs = countFrs + 1 %}
                                        <th scope="col" class="align-center colonneFrs {% if frs.C_V %}rowSelectionnable{% else%}frsSansReponse{% endif %}" 
                                            data-frs="{{ frs.CODE_FOU }}" data-ligne="" data-typeFG="{{ frs.TYPE_FG }}" data-CV="{{ frs.C_V }}" style="min-width: 150px;"> 
                                            {% if frs.TYPE_FG == 'F' %} {{ frs.RS }} {% else %} {{ frs.RS_GRP }} {% endif %}
                                        </th>
                                    {% endfor %}
                                </tr>
                            </thead>
                            <tbody>
                            {% set sous_total = 0 %}
                            {% set subTotalGroup = 1 %}
                            {% set subTotalList = '' %}
                            {% set sous_total_frs = {} %}
                            {% for ligne in ligneConsultation %}
                                {% if ligne.TITRE_AVANT_LIGNE != '' %}
                                    <tr>
                                        <td colspan="8" class="borderRight">
                                            <h4 style="margin-left:15px;">
                                                {{ ligne.TITRE_AVANT_LIGNE }}
                                            </h4>
                                        </td>
                                        <td class="ligne_split fixed-side borderRight noBorderTop"></td>
                                        <td colspan="{{ countFrs }}"></td>
                                    </tr>									
                                {% endif %}
                                {% set sous_total = sous_total + (ligne.QTE * ligne.PRIX_REF) %}
                                <tr id="ligne{{ ligne.NO_PO }}" class="ligneConsultation selected">
                                    {# Bloc ligne de besoin #}
                                    {% if canChooseFour %}
                                    <td class="fixed-side ">
                                        <input data-idligne="{{ ligne.NO_PO }}" type="checkbox" name="ligneSelected{{ ligne.NO_PO }}" id="ligneSelected{{ ligne.NO_PO }}" class="form-control checkbox checkboxLigne" checked/>
                                    </td>
                                    {% endif %}
                                    <td class="fixed-side" style="">{{ ligne.CODE_ART }}</td>
                                    <td class="fixed-side td-tooltips">{{ shortLibelle(ligne.DES, 30, 'top-right', true) }}</td>
                                    <td class="fixed-side td-tooltips">{{ shortLibelle(ligne.DES_COMP, 30, 'top-right', true) }}</td>
                                    <td class="fixed-side montant">{{ ligne.QTE | prix }}</td>
                                    <td class="fixed-side devise">{{ ligne.UNITE }}</td>
                                    <td class="fixed-side montant">{{ ligne.PRIX_REF | prixUnitaire }}</td>
                                    <td class="fixed-side montant borderRight">{{ ligne.BUDGET | prix }}</td>
                                    <td class="ligne_split fixed-side borderRight noBorderTop"></td>
                                    
                                    {# Bloc Réponse fournisseur #}
                                    {% for frs in listeFrs %}
                                        {% set myIndex = frs.CODE_FOU ~ frs.TYPE_FG %}									
                                        <td class="ligne_{{ ligne.NO_PO }} frs{{ frs.CODE_FOU }}  borderRight 
                                                {% if arrayCompare[ligne.NO_PO]['CODE_FOU'] == frs.CODE_FOU %} bestPriceFrs {% endif %}
                                                {% if arrayRepFrs[frs.CODE_FOU][ligne.NO_PO]['PU'] %}rowSelectionnable{% else %}frsSansReponse{% endif %} 
                                                {% if arraySelected[ligne.NO_PO]['CODE_FOU'] == frs.CODE_FOU %}selectedRow{% endif %}"
                                                data-frs="{{ frs.CODE_FOU }}" data-ligne="{{ ligne.NO_PO }}" data-typeFG="{{ frs.TYPE_FG }}" data-CV="{{ arrayRepFrs[frs.CODE_FOU][ligne.NO_PO]['C_V'] }}">
                                            <div class="divPxFrs">
                                                <input type="checkbox" class="checkboxCellule ligneCheckBox{{ ligne.NO_PO }} frsCheckbox{{ frs.CODE_FOU }}" style="display:none;" name="frsSelect{{ spliter() }}{{ ligne.NO_PO }}{{ spliter() }}{{ frs.CODE_FOU }}{{ spliter() }}{{ frs.TYPE_FG }}{{ spliter() }}{{ arrayRepFrs[frs.CODE_FOU][ligne.NO_PO]['C_V'] }}" {% if arraySelected[ligne.NO_PO]['CODE_FOU'] == frs.CODE_FOU %}checked{% endif %}/>	
                                                
                                                {% if arrayRepFrs[frs.CODE_FOU][ligne.NO_PO]['COUNT_REPSL'] %}
                                                    <span class="split_V2 white-tooltip" style="float:left;cursor:pointer;margin-right:10px;" onClick="showDetails('{{ path('Consultation.ChoixFournisseur.popupShowDetails', {idAO:idAO, idLigne:ligne.NO_PO ,idRep:frs.DTE_REP ,typeFG:frs.TYPE_FG, idFrs:frs.CODE_FOU, CV:frs.C_V}) }}');">
                                                        <span class="infos_tooltip left ">
                                                            {{ 'Réponse fournisseur en plusieurs lignes. Cliquez pour afficher le détail.' | trad }}
                                                        </span>
                                                    </span>
                                                {% endif %}
                                                
                                                {% if arrayRepFrs[frs.CODE_FOU][ligne.NO_PO]['QTE'] != ligne.QTE and arrayRepFrs[frs.CODE_FOU][ligne.NO_PO]['QTE'] %}	
                                                    <span class="white-tooltip quantiteAno">
                                                        <span class="infos_tooltip left ">
                                                            {{ 'Les quantités de la consultation et de la réponse sont différentes' | trad }} ({{ ligne.QTE }}/{{ arrayRepFrs[frs.CODE_FOU][ligne.NO_PO]['QTE'] }}).
                                                        </span>
                                                        {{ arrayRepFrs[frs.CODE_FOU][ligne.NO_PO]['QTE'] }}
                                                    </span>
                                                {% endif %}

                                                {% if arrayRepFrs[frs.CODE_FOU][ligne.NO_PO]['TOTAL_REPSL'] %}
                                                    <span class="montant">{{ arrayRepFrs[frs.CODE_FOU][ligne.NO_PO]['TOTAL_REPSL'] | prixUnitaire }}</span>
                                                    {% set oldMontant = sous_total_frs[myIndex] %}
                                                    {% set sous_total_frs = sous_total_frs|merge({ (myIndex) : oldMontant + (arrayRepFrs[frs.CODE_FOU][ligne.NO_PO]['QTE'] * arrayRepFrs[frs.CODE_FOU][ligne.NO_PO]['TOTAL_REPSL']) } ) %}
                                                {% elseif arrayRepFrs[frs.CODE_FOU][ligne.NO_PO]['PU']  %}
                                                    <span class="montant">{{ arrayRepFrs[frs.CODE_FOU][ligne.NO_PO]['PU'] | prixUnitaire }}</span>
                                                    {% set oldMontant = sous_total_frs[myIndex] %}
                                                    {% set sous_total_frs = sous_total_frs|merge({ (myIndex) : oldMontant + (arrayRepFrs[frs.CODE_FOU][ligne.NO_PO]['QTE'] * arrayRepFrs[frs.CODE_FOU][ligne.NO_PO]['PU'])} ) %}
                                                {% endif %}
                                            </div>
                                        </td>
                                    {% endfor %}
                                </tr>
                                {% if ligne.TITREST != '' %}
                                    <tr>
                                        <td colspan="8" class="borderRight" style="text-align:right;">
                                            <h5>
                                                <span>{{ ligne.TITREST }}</span> : <span id="subTotal{{ subTotalGroup }}" class="{{ subTotalList }}">{{ sous_total|prix }}</span>{{ ' ' ~ devise }}
                                            </h5>
                                        </td>
                                        <td class="ligne_split fixed-side borderRight noBorderTop"></td>
                                        {% for frs in listeFrs %}
                                            {% set myIndex = frs.CODE_FOU ~ frs.TYPE_FG %}
                                            <td colspan="1" class="borderRight" style="text-align:right; font-style: italic">
                                                <h5 style="font-weight: normal">
                                                    <span id="subTotal{{ subTotalGroup }}" class="{{ subTotalList }}">{{ sous_total_frs[myIndex] | prix }}</span>{{ ' ' ~ devise }}
                                                </h5>
                                            </td>
                                        {% endfor %}
                                    </tr>
                                {% set sous_total = 0 %}
                                {% set sous_total_frs = {} %}
                                {% set subTotalGroup = subTotalGroup + 1 %}
                                {% set subTotalList = '' %}
                                {% endif %}
                            {% endfor %}
                            </tbody>
                            <tfoot>
                                {# Ligne de sépération #}
                                <tr>
                                    <td class="fixed-side fixed-bottom noBorderLeft"></td>
                                    <td class="fixed-side fixed-bottom"></td>
                                    <td class="fixed-side fixed-bottom"></td>
                                    <td class="fixed-side fixed-bottom"></td>
                                    <td class="fixed-side fixed-bottom"></td>
                                    <td class="fixed-side fixed-bottom"></td>
                                    <td class="fixed-side fixed-bottom"></td>
                                    <td class="fixed-side fixed-bottom"></td>
                                    <td class="fixed-side fixed-bottom noBorderTop"></td>
                                    <td class="fixed-side fixed-bottom noBorderRight" colspan="999"></td>
                                </tr>
                                {# Ligne des notes questionnaire
                                {% if questionnaire %}
                                    <tr id="questionnaire">
                                        <td class="montant fixed-side fixed-bottom"></td>
                                        <td class="montant fixed-side fixed-bottom"></td>
                                        <td class="montant fixed-side fixed-bottom"></td>
                                        <td class="montant fixed-side fixed-bottom"></td>
                                        <td class="montant fixed-side fixed-bottom"></td>
                                        <td class="montant fixed-side fixed-bottom"></td>
                                        <td class="fixed-side fixed-bottom borderRight" colspan="2">{{ 'Note au questionnaire' | trad }}</td>
                                        <td class="ligne_split fixed-side fixed-bottom noBorderTop borderRight "></td>
                                        {% for frs in listeFrs %}
                                            <td class="toggleSlide code montant borderRight fixed-bottom {% if frs.C_V %}{% else%}frsSansReponse{% endif %}" onclick="toggleSlide('{{ path('Consultation.GestionConsultation.ajaxDetailEntete', {idAO : Consultation.NO_AO}) }}' , 'questionnaire{{ loop.index }}detail');">
                                            {{ frs.NOTE | prix }}
                                            </td>	
                                        {% endfor %}
                                    <tr>
                                    <tr id="Consultation{{ loop.index }}detail" class="detail_ligne hide_detail"></tr>
                                {% endif %} #}
                                {# Total ligne séléctionnées #}
                                <tr>
                                    <td class="fixed-side fixed-bottom"></td>
                                    <td class="fixed-side fixed-bottom"></td>
                                    <td class="fixed-side fixed-bottom"></td>
                                    <td class="fixed-side fixed-bottom"></td>
                                    <td class="fixed-side fixed-bottom"></td>
                                    <td class="fixed-side fixed-bottom"></td>
                                    
                                    <td class="fixed-side fixed-bottom borderRight" colspan="2">
                                    {{- strBuild(
                                        'Total des articles sélectionnés (en @1@)' | trad,
                                        [
                                            devise
                                        ]
                                    ) -}}    
                                    </td>
                                    <td class="ligne_split fixed-side fixed-bottom borderRight noBorderTop"></td>
                                    {% for frs in listeFrs %}
                                        <td class="montant borderRight fixed-bottom selection{{ frs.CODE_FOU }} {% if questionnaire %}noBorderTop{% endif %} {% if frs.C_V %}{% else%}frsSansReponse{% endif %}" style="{% if totalSelected[frs.CODE_FOU] %}background-color: #e7eaea;{% endif %}">{{ totalSelected[frs.CODE_FOU] | prix }}</td>
                                    {% endfor %}
                                </tr>
                                {# Total ligne fournisseur #}
                                <tr>
                                    <td class="fixed-side fixed-bottom borderBottom noBorderTop"></td>
                                    <td class="fixed-side fixed-bottom borderBottom noBorderTop"></td>
                                    <td class="fixed-side fixed-bottom borderBottom noBorderTop"></td>
                                    <td class="fixed-side fixed-bottom borderBottom noBorderTop"></td>
                                    <td class="fixed-side fixed-bottom borderBottom noBorderTop"></td>
                                    <td class="fixed-side fixed-bottom borderBottom noBorderTop"></td>
                                    <td class="fixed-side fixed-bottom noBorderTop borderRight borderBottom" colspan="2">
                                        {{- strBuild(
                                            'Total des articles (en @1@)' | trad,
                                            [
                                                devise
                                            ]
                                        ) -}}
                                    </td>
                                    <td class="ligne_split fixed-side fixed-bottom borderRight noBorderTop"></td>
                                    {% for frs in listeFrs %}
                                        <td class="montant borderRight fixed-bottom noBorderTop borderBottom {% if frs.C_V %}{% else%}frsSansReponse{% endif %}">
                                            <a href="{{ path('Consultation.GestionConsultation.ajaxImpression', {idAO:idAO, tousFournisseur:'U', typeFG:frs.TYPE_FG, codeFrs:frs.CODE_FOU}) }}" target="_blank" class="pdf white-tooltip" style="float:left;">    
                                            <span class="infos_tooltip top-left">
                                                    {{ 'Détails des réponses' | trad }}
                                                </span>
                                            </a> 
                                            {% if frs.docAbsent %}
                                                <span class="incidents white-tooltip" style="float:left;">
                                                    <span class="infos_tooltip top-left ">
                                                        {{ 'Des documents attendus obligatoires sont absents.' | trad }}
                                                    </span>
                                                </span>
                                            {% endif %}
                                            {% if frs.repDepasse %}
                                                <span class="incidents white-tooltip" style="float:left;">
                                                    <span class="infos_tooltip top-left ">
                                                        {{ 'La date limite de l\'offre est dépassée.' | trad }}
                                                    </span>
                                                </span>
                                            {% endif %}
                                            {{ totalFrs[frs.CODE_FOU] | prix }}
                                        </td>
                                    {% endfor %}

                                </tr>
                                {# Documents de la réponse #}
                                <tr>
                                    <td style="font-weight: bold;" colspan="7" 
                                        class="fixed-side fixed-bottom borderBottom noBorderTop"></td>
                                    <td style="font-weight: bold;"
                                        class="fixed-side fixed-bottom borderBottom noBorderTop">
                                    {# </td> #}
                                    {# <td class="fixed-side fixed-bottom noBorderTop borderRight borderBottom" colspan="2"> #}
                                        {{ 'Documents de la réponse' | trad }}
                                    </td>
                                    <td class="ligne_split fixed-side fixed-bottom borderRight noBorderTop"></td>
                                    {% for frs in listeFrs %}
                                        <td class="borderBottom borderRight">
                                            <ul>
                                                {% for PJ in frs.docs %}
                                                    <li><a 
                                                    href="{{ path('Consultation.SaisieReponsesPJ.downloadFichier', {typeDoc:PJ.TYPE_DOC, typeFG:PJ.TYPE_FG, idAO:idAO, idFrs:PJ.CODE_FOU, idRep:PJ.DTE_REP, CV:PJ.C_V, ordre:PJ.NUM_ORDRE}) }}" target="_blank">{{ PJ.TITRE }}</a></li>
                                                {% endfor %}
                                            </ul>
                                        </td>
                                    {% endfor %}
                                </tr>
                                {# Note finale #}
                                <tr id="questionnaire_supplier_{{ idAO }}">
                                    <td style="font-weight: bold;" colspan="7" 
                                        class="fixed-side fixed-bottom borderBottom noBorderTop"></td>
                                    <td style="font-weight: bold;"
                                        class="fixed-side fixed-bottom borderBottom noBorderTop">
                                    {# <td class="toggleSlide auto_width fixed-side fixed-bottom noBorderTop borderRight borderBottom" 
                                        style="min-width:150px;" colspan="2"
                                        onclick="eventGetData(this)"
                                        data-id = "{{ idAO }}"
                                    > #}
                                    <a class="white-tooltip" target="_blank" style="color:white;"
                                        href="{{ path('Consultation.ChoixFournisseur.viewSuppliersAnswers', {idAO:idAO}) }}">
                                        {{ 'Questionnaire fournisseur' | trad }}
                                        <span class="infos_tooltip top-left">
                                            {{ 'Voir le détail du questionnaire' | trad }}
                                        </span>
                                    </a>
                                    </td>
                                    <td class="ligne_split fixed-side fixed-bottom borderRight noBorderTop"></td>
                                    {% for frs in listeFrs %}
                                        <td class="auto_width align-right borderRight borderBottom" style="min-width:150px;">
                                            {{ frs.NOTE_SUPPLIER | prix }}
                                        </td>
                                    {% endfor %}
                                </tr>
                                {# Questionnaire contributeur #}
                                <tr id="questionnaire_contributor_{{ idAO }}">
                                    <td style="font-weight: bold;" colspan="7" 
                                        class="fixed-side fixed-bottom borderBottom noBorderTop"></td>
                                    <td style="font-weight: bold;"
                                        class="fixed-side fixed-bottom borderBottom noBorderTop">
                                    {# <td class="toggleSlide auto_width fixed-side fixed-bottom noBorderTop borderRight borderBottom" 
                                        style="min-width:150px;" colspan="2"
                                        onclick="showContributors(this)"
                                        data-id = "{{ idAO }}"
                                    > #}
                                        <a class="white-tooltip" target="_blank" style="color:white;"
                                            href="{{ path('Consultation.ChoixFournisseur.viewContributorsAnswers', {idAO:idAO}) }}">
                                            {{ 'Questionnaire contributeur' | trad }}
                                            <span class="infos_tooltip top-left">
                                                {{ 'Voir le détail du questionnaire' | trad }}
                                            </span>
                                        </a>
                                    </td>
                                    <td class="ligne_split fixed-side fixed-bottom borderRight noBorderTop"></td>
                                    {% for frs in listeFrs %}
                                        <td class="auto_width align-right borderRight borderBottom" style="min-width:150px;">
                                            {{ frs.NOTE_CONTRIB | prix }}
                                        </td>
                                    {% endfor %}
                                </tr>

                                {# Note finale #}
                                <tr id="average_grade_{{ idAO }}">
                                    <td style="background-color: rgb(124, 124, 124);" class="fixed-side fixed-bottom borderBottom noBorderTop"></td>
                                    <td style="font-weight: bold;" colspan="7" 
                                        class="fixed-side fixed-bottom borderBottom noBorderTop">
                                    {# <td class="auto_width fixed-side fixed-bottom noBorderTop borderRight borderBottom" 
                                        style="min-width:150px;" colspan="2"
                                    > #}
                                        {{ 'Note finale' | trad }}
                                    </td>
                                    <td class="ligne_split fixed-side fixed-bottom borderRight noBorderTop"></td>
                                    {% for frs in listeFrs %}
                                        <td class="auto_width align-right borderRight borderBottom" style="min-width:150px;">
                                            {{ frs.NOTE | prix }}
                                        </td>
                                    {% endfor %}
                                </tr>
                            </tfoot>
                        </table>
                    </div>
                    <div class="clearfix" style="display:flex;margin-top:10px;">
                        <div style="display:flex;width:200px">
                            <span style="display:block;height:20px;width:30px;background-color: #e7eaea;border:1px solid #ddd"></span>
                            <span style="font-style: italic;">: {{ 'Valeurs sélectionnées' | trad }}</span> 
                        </div>
                        <div style="display:flex;width:200px">
                            <span style="display:block;height:20px;width:50px;color: #42bd42; font-weight: bold;background-color: white;">
                                10.00
                            </span>
                            <span style="font-style: italic;">: {{ 'Prix le plus bas' | trad }}</span>
                        </div>
                    </div>
                    <input type="hidden" name="MailFrsRetenus" id="MailFrsRetenus" value="false" />
                    <input type="hidden" name="MailFrsNonRetenus" id="MailFrsNonRetenus" value="false" />
                </form> 
                <script type="text/javascript" src="{{ baseUrl('ext/tableHeadFixer/js/tableHeadFixer.js')~'?cache='~getSession('cache')  }}"></script>
                <script>
                    $(document).ready(function() {
                        $("#choixFrs").tableHeadFixer(
                            {'z-index' : 0, "head" : false, "left" : 9, "foot": {% if questionnaire %}4{% else %}3{% endif %}}
                        ); 
                    });
                    
                    function showDetails(path)
                    {
                        event.stopPropagation();
                        ajaxPopup(path, '{{ 'Détail poste consultation N°' | trad }}{{ idAO }}', '','','','modal_small');
                    }
                    
                    function resetChoix(path)
                    {
                        activeLoader();
                        $.ajax({
                            dataType : 'html',
                            url: path,
                            type: "POST",
                            success: function(result){
                                refrechDiv(window.location.pathname, 'table-scroll');
                            }
                        });
                    }
                    
                    function selectAll()
                    {
                        if($('#allLigne').is(':checked')) {
                            $('.ligneConsultation').removeClass('unselected').addClass('selected');
                        } else {
                            $('.ligneConsultation').addClass('unselected').removeClass('selected');
                        }
                        showHidePanel();
                    };

                    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',
                                data : {'type': '{{consultation.RFI_Q}}'},
                                success : function(html){
                                    $("#questionnaire_supplier_" + id).after(html);
                                    $(object).attr("data-etat", 'open');
                                }
                            }); 
                        }
                    }

                    function showContributors(object)
                    {
                        let id = $(object).attr("data-id");
                        if ($(".questionnaire_contributor_" + id + 'detail').length) {
                            $(".questionnaire_contributor_" + id + 'detail').remove();
                        } else {
                            $.ajax({
                                url : '{{ path('Consultation.ChoixFournisseur.ajaxDetailsContributors', {idAO: idAO}) }}',
                                type : 'POST',
                                dataType : 'html',
                                data : {'type': '{{consultation.RFI_Q}}'},
                                success : function(html){
                                    $("#questionnaire_contributor_" + id).after(html);
                                    $(object).attr("data-etat", 'open');
                                }
                            }); 
                        }
                    }
                    
                    $('.checkboxLigne').change(function(){
                        if($(this).is(':checked')) {
                            $('#ligne'+$(this).data('idligne')).removeClass('unselected').addClass('selected');
                        } else {
                            $('#ligne'+$(this).data('idligne')).removeClass('selected').addClass('unselected');
                        }
                        showHidePanel();
                    });
                    
                    $('#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();
                        } 
                    }
                
                    $('.rowSelectionnable').click(function(){
                    
                        if($(this).hasClass('selectedRow')) {
                            return true;
                        }
                    
                        if( $(this).data('ligne') == '') {
                            $('#choixFrs tbody tr td').removeClass('selectedRow');
                            $('.frs'+$(this).data('frs')).addClass('selectedRow');
                            
                            $('.checkboxCellule').removeAttr('checked');
                            $('.frsCheckbox'+$(this).data('frs')).attr('checked','checked');
                        } else {
                            $('.ligne_'+$(this).data('ligne')).removeClass('selectedRow');
                            $(this).addClass('selectedRow');
                            
                            $('.ligneCheckBox'+$(this).data('ligne')).removeAttr('checked');
                            var checkbox = $(this).children('.divPxFrs').children('input[type="checkbox"]');
                            checkbox.attr('checked','checked');
                        }
                    
                        activeLoader();
                        $.ajax({
                            dataType : 'html',
                            url: '{{ path('Consultation.ChoixFournisseur.ajaxUpdateSelection', {idAO:idAO}) }}',
                            data: {'NO_PO' : $(this).data('ligne'), 'CODE_FOU' : $(this).data('frs'), 'TYPE_FG' : $(this).data('typefg'), 'RET_CV' : $(this).data('cv')},
                            type: "POST",
                            success: function(result){
                                var data = jQuery.parseJSON(result);
                                $.each(data[0], function( index, value ) {
                                    $('.selection'+index).html(formatNombre(value, ' '));
                                    
                                    if(value) {
                                        $('.selection'+index).attr('style', 'background-color: #e7eaea;');
                                    } else {
                                        $('.selection'+index).attr('style', 'background-color:none;');
                                    }
                                    
                                });

                                $("#choixFrs").tableHeadFixer({'z-index' : 0, "head" : false, "left" : 9, "foot": {% if questionnaire %}4{% else %}3{% endif %}}); 
                                desactiveLoader();
                            }
                        });
                    });
                </script>                    
            </div>
        </div>		
    </div>	
{% endblock %}