
<button class="button btn secondaire pointer btn_right" type="button" onClick="$('.sous_onglet > li >  a:first').trigger('click');">{{ 'Retour' | trad }}</button>

<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="6%">
                {% if pathAjoutAdr %}
                    <a class="ajouter_blanc_v2  white-tooltip"  onClick="ajoutLigneAdresses('{{ pathAjoutAdr }}', '{{ TYPE_ADRESSE }}')" style="float: right;">
                        <span class="infos_tooltip left">
                            {{ 'Ajouter une adresse' |trad }}
                        </span>
                    </a>
                {% endif %}
            </th>
        </tr>
    </thead>
    
    {% for ligne in listeAdresses %}
        {% set index = loop.index %}
        {% include '@GlobalApplication/ModifDaCde/Adresses/detailAdresse.twig' %}
    {% endfor %}
</table>

<script>
    {% if idTrigger %}
        $('.sous_onglet > li >  a').click(function(){

        	if($(this).attr('class')===undefined)
        	{
        		$('#{{ idClose }}').hide();
        		$('#{{ iDivAdd }}').html('');
        	}
        });

        $('#{{ idClose }}').click(function(){
    		$('#{{ iDivAdd }}').html('');
        });
        
    {% endif %}
    {% if dynamique %}
    	function ajoutLigneAdresses(path, type, codeAdresse)
    	{
    		if(codeAdresse===undefined)
    			codeAdresse = '';
    		
            $.ajax({
              	dataType : 'html',
            	url: path,
            	data: {'CODE' : '{{ CODE }}','idClose' : '{{ idClose }}', 'MODIF_COD_ADR' : codeAdresse},
            	type: "POST",
            	success: function(result){
                	$('#{{idTriggerCreation}}').show();
                	$('#{{idTriggerCreation}}').find('a').html('{{titre_creation_Onglet}}');
                	$('#{{idTriggerCreation}}').find('a').trigger('click');
            		$('#{{iDivAdd}}').html(addFonctionAjax(result));
                	desactiveLoader();
            	}
            });
        }

        function suppressionAdresses(type, MODIF_COD_ADR)
        {
            $.ajax({
              	dataType : 'html',
            	url: "{{ path('GlobalApplication.Adresses.suppressionAdresses', {TYPE_ADRESSE : TYPE_ADRESSE}) }}",
            	data: {'CODE' : '{{ CODE }}', 'MODIF_COD_ADR' : MODIF_COD_ADR,'idClose' : '{{ idClose }}'},
            	type: "POST",
            	success: function(result){
            		$('#adresse'+MODIF_COD_ADR).remove();
                	desactiveLoader();
            	}
            });
        }
    {% endif %}
</script>