{% if params.typePopup == 'ok' %}
	<div class="modal-body clearfix display_table">
			<span class="icone-modal information"></span>
		
		<div class="display_cell">
			{{ params.alerte | raw   }}
			{{ params.info | raw   }}
		</div>
	</div>
{% else %}
	{% if params.alerte is iterable %}
		<div class="modal_erreur">
			{% for erreur in params.alerte %}
				{{ erreur| raw }}
			{% endfor %}
		</div>
	{% elseif params.alerte != '' %}
		<div class="modal_erreur">
			{{ params.alerte | raw }}
		</div>
	{% endif %}
	{% if params.avertissement != '' %}
		<div class="modal_attention">
			{{ params.avertissement | raw }}
		</div>
	{% endif %}
    {% if messageInformatif %}
        <div style="font-style: italic;">
            {{ messageInformatif | raw }}
        </div>
    {% endif %}
{% endif %}

{% if params.alerte != '' or params.info != '' %}
	<div class="modal-footer">
		{% if params.pathURL %}
			<a class="button secondaire" id="btn_close" href="{{ params.pathURL }}">{{ 'Fermer' | trad }}</a>
		{% else %}
			<button type="button" id="btn_close" class="button secondaire" data-dismiss="modal" onclick="desactivePopup();">{{ 'Fermer' | trad }}</button>
		{% endif %}
	</div>
{% else %}
	<div class="modal-footer">
		<button type="button" id="btn_close" class="button secondaire" data-dismiss="modal" onclick="desactivePopup();">{{ 'Annuler' | trad }}</button>
		{% if pathURL == '' and (statut != 'B' and statut != 'E') %}
			<button type="button" id="btn_close" class="button principal" data-dismiss="modal" onclick="$('#submitForce').val(1);$('#{{ params.action }}').click();">{{ 'Continuer' | trad }}</button>
		{% elseif pathURL != '' and (statut != 'B' and statut != 'E') %}
			<button type="button" class="button principal" onclick="AjaxGestionDesEvalExec('{{ pathURL }}', '{{ entity }}', '{{ div }}', '{{ form }}');">{{ 'Confirmer' | trad}}</button>
		{% endif %}
	</div>
{% endif %}</div>
{% if application == 'Mobility' %}
	<style>
		.modal-dialog{
			width: auto !important;
			min-width: none !important;
		}
		.modal-content .modal_small{
			width: auto !important;
			min-width: none !important;
			margin: auto !important;
		}
	</style>
{% endif %}



<script>
	$("#modal-title").html('{{ params.titrePopup ? (params.titrePopup|e('js')|raw) : ('Validation'|trad)}}');

	{% if (params.alerte is iterable or params.alerte != '') and statut != 'O'  %}
		$( document ).ready(function() {
			$('.modal-header').addClass('popup_error');
		});
	{% elseif statut == 'O' %}
		$( document ).ready(function() {
			$('.modal-header').addClass('popup_informative');
		});
	{% else %}
		$( document ).ready(function() {
			$('.modal-header').addClass('popup_alert');
		});
	{% endif %}

	{% if not params.info %}
		{% if params.typePopup == 'ok' and contexteDetail != true %}
			refrechDivGestionEval('{{ path('Evaluation.Campaign.index') }}', 'divRefresh', 'toto',  '{{post | raw }}' );
		{% elseif params.typePopup == 'ok' and contexteDetail == true %}
			refrechDivGestionEval('{{ path('Evaluation.Campaign.detail', {'id':id}) }}', 'campaign', 'toto',  '{{post | raw }}' );
		{% endif %}
	{% endif %}

	function AjaxGestionDesEvalExec(path, entity, div, form)
	{
		activeLoader();
		$.ajax({
			dataType : 'html',
			url: path,
			data : { 'entity' : entity ,'div' : div ,'form' : form, 'page' : '{{page}}', 'post' : {{post |raw }}  },
			type: "POST",
			success: function(result){
				desactiveLoader();
				if(div=='page')
				{
					window.location.reload();
				}
				else if(div=='redirect')
				{
					try{
						var data = jQuery.parseJSON(result);
					}catch(error){
						data = {};
					}
					
					if(data.path)
					{
						redirectJSWithPost(data.path, data.post);
					}
				}
				else
				{
					try{
						var data = jQuery.parseJSON(result);
					}catch(error){
						data = {};
					}
	
					if(data.path && data.pathOnlyRedirect != true)
					{
						refrechDivGestionEval(data.path, div, form);
					}
					else
					{
						refrechDivGestionEval(window.location.pathname, div, form);
					}
				}
					
			},
			error: function (data){
				{% if contexteDetail != true %}
					desactiveLoader();
					$("#modal-content").addClass("modal_small");
					$("#modal-body").html(data.responseText);
					activePopup();
				{% endif %}
			}
		});
	}

	
function refrechDivGestionEval(path, id, form, menu, paramJson)
{
	activeLoader();
	if(form == 'undefined' || form == null)
	{
		data = '';
	}
	else if(paramJson != null || paramJson != 'undefined' && form == 'undefined' || form == null)
	{
		data = paramJson;
	}	
	else if(form)
	{
		data = $('#'+form).serialize();
	}
	else
	{
		data = '';
	}
	$.ajax({
			url: path,
			type: 'POST',
			dataType: 'html',
			data : {{post | raw }},
			success: function (htmlData) 
			{
			
				refreshFonction(id, htmlData, menu);
	
				desactiveLoader();
				return true;
			}
	});	
	
	return false;

}
</script>