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

{% block body %}

<script>

$("#send").click(function(e) {

    var myForm = $("#creation_avenant").serializeArray();
    ACD_COMMENT = $('#input_MOTIFAVENANT').val(); 
    myForm.push({name : 'MOTIFAVENANT', value : ACD_COMMENT});
                
    if(ACD_COMMENT != '')
    {
        
        //activeLoader();
        //refrechDiv('{{ path('Contrat.accord-cadre.popupCreationAvenant', {'type' : 'accordCadre', 'idacc' : idacc } ) }}', 'contenteTable', '', '', myForm);
        desactivePopup();
        activeLoader();
        $.ajax({
            url : '{{ path('Contrat.accord-cadre.popupCreationAvenant', {'type' : 'accordCadre', 'idacc' : idacc } ) }}',
            type: 'POST',
            dataType : 'JSON',
            data: {'MOTIFAVENANT' : ACD_COMMENT},
            success: function (data) 
            {
                if(data.statut[0]=='O')
                {
                    desactiveLoader(); 
                    redirectJSWithPost(data.path, data.post);
                }
                else
                {
                    desactiveLoader();
                    $('#message_erreur_popup').show().html(data.erreur);
                }
            }
            

        });
    }
});



</script>

<div class="modal-body clearfix">
    <form class="form clearfix" name = "creation_avenant">
        <p style ="color: #FF0000;" id ="message_erreur_popup">{{erreur}}</p>
        <div class="row">
            <label>{{'Veuillez indiquer le motif de l\'avenant' | trad }} :</label>
            {{ inputTextarea('', 'MOTIFAVENANT', '', path('Ajax.validator.isStringAvecEspace'), "{'sizeMin' : '1','nomChamp' : 'input_MOTIFAVENANT'}") }}
            <!-- <textarea class="form-control" name="MOTIFAVENANT" id ="MOTIFAVENANT"></textarea> -->
        </div>
    </form>
    <div class="modal-footer">
            
        <button type ="button" id="send" class="button principal button_right" >{{'Enregistrer' | trad }}</button>
        <button onclick ="desactivePopup()" class="button secondaire button_right" data-dismiss="modal">{{'Annuler' | trad}}</button>
        
    </div>
</div


{% endblock %}