<table class="table table-hover tableForm" id="tableAdresse">
    <thead class="thead-dark">
        <tr>
            <th>{{ 'Code' | trad }}</th>
            <th>{{ 'Libellé' | trad }}</th>
            <th>{{ 'Adresse' | trad }}</th>
            <th width="18%">{{ 'Pays' | trad }}</th>
            <th>{{ 'CP' | trad }}</th>
            <th>{{ 'Ville' | trad }}</th>
            <th width="60px">
                {% if droit.HA_FRS_ADR %}
                    <a class="ajouter_blanc_v2  white-tooltip"  onClick="ajoutAdresse('{{ infoFrs.CODE }}');" style="float: right;">
                        <span class="infos_tooltip left">
                            {{ 'Ajouter une adresse' |trad }}
                        </span>
                    </a>
                {% endif %}
            </th>
        </tr>
    </thead>
    
    {% for ligne in listeAdresses %}
        {% include '@rechercheArticles/Fournisseur/_ligneAdresse.twig' %}
    {% endfor %}
</table>

<script>
    function ajoutAdresse(codeFou, edit)
    {
        $.ajax({
          	dataType : 'html',
        	url: "{{ path('GlobalApplication.Adresses.ajaxAjoutLigneAdresses', {TYPE_ADRESSE: 'FOU', contexte: 'panier'}) }}",
        	data: {'FOU' : codeFou, 'CODE' : codeFou,'idClose' : 'ongletAdr', 'MODIF_COD_ADR' : edit},
        	type: "POST",
        	success: function(result){
            	$('#onglet_DivModulableCreation').show();
            	$('#onglet_DivModulableCreation').find('a').html('Création adresse');
            	$('#onglet_DivModulableCreation').find('a').trigger('click');
        		$('#DivModulableCreation').html(addFonctionAjax(result));
            	desactiveLoader();
        	}
        });
    }

        document.addEventListener('click',(event) => {
            var target = event.target;
            if (!(target instanceof HTMLElement) ) {
                return;
            }

            if (!target.hasAttribute('data-changeAdr') ){
                return;
            } 

            $('#input_ADRESSE').val($(target).data('adresse'));
            $('#input_VILLE1').val($(target).data('ville'));
            $('#input_CPOSTAL').val($(target).data('cpostal'));
            $('#input_CODPAYS').val($(target).data('codepays'));

        });

</script>