{% extends '@ajax-layout/layout.twig' %}

{% block body %}
	
    <div id="importFournisseur" class="padding15">     
        <form method="POST" id='formulaireGeneral' enctype="multipart/form-data" class="box-form clearfix" >
        	<div id="message_info" class="zoneError" style="margin-bottom:15px;"></div>
        	<input type="hidden" value='' name='importSend'>
        	<div class="single">
					{{ inputAdvance('FILE', {'name' : 'accord'} ) }}
            </div>
            <hr>
    		<button class="button principal button_right" type='button' onClick="ajoutAccord('{{ path('Consultation.AjoutFournisseur.popupCreateEditAccord', {idAO:idAO, idFrs:idFrs, typeFG:typeFG, mode:mode}) }}');"> {% if mode =='create' %}{{ 'Ajouter' | trad }}{% else %}{{ 'Modifier' | trad }}{% endif %}</button>
            <button class="button secondaire button_right" type="button" onClick="desactivePopup();">{{ 'Fermer' | trad }}</button>  
        </form>
    </div>
    
    <script>
        function ajoutAccord(path)
        {
			jForm.append("importSend", $('[name="importSend"]').val());

        	activeLoader();
            $.ajax({
            	url : path ,
            	data : jForm,
                type: 'POST',
                contentType: false,
                cache: false,
                processData: false,
                mimeType: "multipart/form-data",
                success: function (data) {            
                	var data = jQuery.parseJSON(data);
                	if(data.statut == 'O') {
        				refrechDiv(window.location.pathname, 'refreshFrs');
        				desactivePopup();
                	}else{
                		$('#message_info').html(data.message);
                	}
                }
            });
        };
        
        $("#modal-title").html('{{ 'Accord de confidentialité pour le fournisseur :' | trad }} {{ convertLibelleGlobal('FOURNISS', '', idFrs, true) |e('js')|raw }}');
    </script>
{% endblock %}
