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

{% block body %}
<form method="post"
    class="bg_form padding_form border_form form-default"
{% if incident != null %}

	action="{{ path('GlobalApplication.Incidents.cloturerLitige', {incidId: incident.IDUNIQUE}) }}"

{% else %}
	action="{{ path('GlobalApplication.Incidents.cloturerLitigeFactureOld', {numFact}) }}"
{% endif %}


    onsubmit="return ajaxSubmit(event);"
    data-onsuccess="processClosure"
>
    <div class="error" data-form-error></div>
    
    {{ inputAdvance('SELECT', {
        titre: 'Type de litige' | trad,
        name: 'typeLitige',
        value: incident.CODE,
        listeValue: choixIncident,
        obligatoire: true,
        option: 'disabled'
    }) }}
    
    {{ inputAdvance('textArea', {
        titre: 'Commentaire' | trad,
        name: 'comment',
        pathValidator: path('Ajax.validator.isStringAvecEspace'),
        paramsValidator: {sizeMin: 1, sizeMax: 3000},
        obligatoire: true,
    }) }}
        
    <div class="modal-footer">
        <button type="button" class="button secondaire" data-dismiss="modal" 
            onclick="desactivePopup();"
        >{{ 'Annuler' | trad }}</button>
        <button type="submit" class="button principal">{{ 'Confirmer' | trad }}</button>
    </div>
</form>
<script>
    window.action.processClosure = function () {
        if ($('#refreshTable').length){
            desactivePopup();
            const formID = document.getElementById('filtre_facture') ? 'filtre_facture' : 'filtre_sigFac';
            refrechDiv(window.location.pathname, 'refreshTable', formID);
        } else {
            document.location.href="{{ path('Facture.GestionFacture.index') }}";
        }
    }
</script>
{% endblock %}