<form id="validation">
    <table class="table table-hover" id="table_prix">
        <thead class="thead-dark">
            <tr>
                <th scope="col" width='100px'>{{ 'Tranche' | trad }}</th>
                <th scope="col">{{ 'Qte tranche' | trad }}</th>
                <th scope="col">{{ 'Taux remise' | trad }}</th>
                <th scope="col">{{ 'Prix net' | trad }}</th>
                <th scope="col" width="100px">
                    <a class="ajouter_blanc_v2  white-tooltip" onClick="addLigne('{{ path('Catalogue.ControleVersion.ajaxPrixDegressif') }}')" style="float: right;">
                        <span class="infos_tooltip left">
                            {{ 'Ajouter un prix degressif' |trad }}
                        </span>
                    </a>
                </th>
            </tr>
        </thead>
        <tbody>
            {% for prix in listeQte %}
                {% include '@catalogue/Controle/PrixDegressif/_prixDegressif.twig' with {
                    rand : random(),
                } %}
            {% endfor %}
        </tbody>
    </table>

    <class id="Msgerror" class="error"></class>
    <hr>
    <button class="button principal button_right" type='button' onClick="validateLigne('{{ path('Catalogue.parametrageFormat.ajaxImportTransco') }}');">{{ 'Enregistrer' | trad }}</button>
</form>
<script>
    function addLigne(path) {
        $.ajax({
            url: path,
            type: 'POST',
            dataType : 'html',
            data: {},
            success: function(data){
                $('#table_prix > tbody').append(data);
            }
        });
    }

    function validateLigne()
    {
        activeLoader();
        $.ajax({
            url: '{{ path('Catalogue.ControleVersion.validatePrixDegressif', {idLigne:IdLigne}) }}',
            type: "POST",
            data: $('#validation').serialize(),
            success: function (data) {     
                desactiveLoader();
            },
            error: function (data){
                var data = jQuery.parseJSON(data.responseText);
                $('#Msgerror').html(data.msgError);
                desactiveLoader();
            }
        });
    }
</script>