
<script>

function sendForm()
{
	activeLoader();
	$.ajax({
    	url : '{{ path('Facture.popup.modifierDateEcheance', {'numFact' : numFact }) }}',
        type: 'POST',
	  	dataType : 'JSON',
        data: $("#form_modif_echeance").serialize(),
        success: function (data) {
        	if(data.statut=='O'){
        		reloadGestionFacture('{{ path('Facture.GestionFacture.index') }}');
        	}
        	else{
        		desactiveLoader();
        		$("#modal-body").html(data.content);
        		$('#confirmationSendForm').val('true');
        	}
        }
    });
}

$("#input_DTAE_ECH").change(function() {
	$('#message_erreur_popup').html('');
	$('#confirmationSendForm').val('false');
});

</script>
<div class="modal-body">
	<div id="message_erreur_popup" class="error displayNone clearfix" >{{ message | raw }}</div>
    <form method="post" name="form_modif_echeance" id="form_modif_echeance" class="box-form">
        <div class="row">
        	<input id='confirmationSendForm' name='confirmationSendForm' type='hidden' value="false">
            {{ inputDate('Nouvelle date d\'échéance :' | trad, 'DTAE_ECH', (DTAE_ECH ?? date | dateTrad) , '' , path('Ajax.validator.date'), '{}') }}
        </div>
        <div class="modal-footer">
        	<button type="button" class="button secondaire" data-dismiss="modal" onClick="desactivePopup();">{{ 'Annuler' | trad }}</button>
        	<button type="button" class="button principal" onclick="sendForm()" >{{ 'Enregistrer' | trad }}</button>
        </div>                        
    </form>
</div>

<script type="text/javascript" src="{{ baseUrl('js/parametre.js') }}"></script>
<script>
$(function() {
	 $( ".datepicker" ).datepicker({
		showOn: "button",
		buttonImage: "{{ baseUrl('IconeV2/Global/deadline-change.svg') }}",
		buttonImageOnly: true,
/* 		minDate: "-3M",
		maxDate: "+1M", */
		showAnim: "fade",
		dateFormat: "{{ 'dd/mm/yy' | paramDateFormat }}"
		
	});

	/* TODO */ 
	  
	  {{ tradDatePickers() }}
	  $.datepicker.setDefaults($.datepicker.regional['fr']);

});
</script>	