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

{% block body %}
<div class="modal-body clearfix display_table">
	<span class="icone-modal interrogation"></span>
    <div class="display_cell">
    	{{ message|raw  }}
  	</div>

</div>
<div class="modal-footer">

    {% if refresh %}
    	<button type="button" class="button secondaire" data-dismiss="modal" onClick="desactivePopup();desactiveLoader();">{{ 'Fermer'|trad }}</button>
    {% else %}
    	<button type="button" class="button secondaire" data-dismiss="modal" onClick="desactivePopup();desactiveLoader();">{{ 'Fermer'|trad }}</button>
    {% endif %}

    {% if path %}
    	<a class="button principal" onClick="ModifTypeReponse('{{type_reponse}}', '{{id_question}}');desactivePopup();activeLoader();">{{ 'Confirmer'|trad }}</a>
    {% endif %}

</div>

<script>
    function ModifTypeReponse(type_reponse, id_question)
    {
        path = ''; 

        switch(type_reponse)
        {
            case 'O':
                path = "{{ path('Evaluation.BibliothequeDeQuestions.OuvertAjaxModifierQuestion')}}";
                break; 
            case 'T': 
                path = "{{ path('Evaluation.BibliothequeDeQuestions.TableauDeReponseAjaxModifierQuestion')}}";
                break;
            case 'N':
                path = "{{ path('Evaluation.BibliothequeDeQuestions.NumeriqueAjaxModifierQuestion')}}";
                break;
            case 'C': 
                path = "{{ path('Evaluation.BibliothequeDeQuestions.CalculeAjaxModifierQuestion')}}";
                break;
            case 'L': 
                path = "{{ path('Evaluation.BibliothequeDeQuestions.LogiqueAjaxModifierQuestion')}}";
                break; 
        }
        $.ajax({
            url : path,
            type: 'POST',
            dataType : 'HTML',
            data: {'choix' : 'O', 'id' : id_question , 'typeReponse' : type_reponse},
            success: function (htmlData) 
            {
                //var result = $('<tr />').append(content).find('#commande'+id+'Modif').html();
                //$('#commande'+id+'Modif').html(result);
                var resultModif = $('<tr />').append(htmlData).find('#commande'+id_question+'detailModif').html();
                $('#commande'+id_question+'detailModif').html(resultModif);
                $('#modifTypeRep' + id_question).val(1); 
                desactiveLoader();
               //refrechDiv(path, 'historique-accord-cadre', '{{ form_refresh }}');
            }
        });
    }

</script>

{% endblock %}