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

{% block body %}

    <form method="post" name="form_actionImpu" id="form_actionImpu">
    
        <div class="single">
        
            <div class="row">
                {{ inputAdvance('TEXT', {
                    'name' : 'LIB',
                    'titre' : 'Libellé' | trad,
                    'option':'readOnly',
                    'value' : infoLigne.DES_ART,
                }) }}
            </div>

            {% if action == 'split' %}
                <div class="row">
                    {{ inputAdvance('TEXT', {
                        'name' : 'QTE',
                        'titre' : 'Quantité maximale' | trad,
                        'option':'readOnly',
                        'value' : qteByUnite(infoLigne.qte, infoLigne.COD_UNIT),
                    }) }}
                </div>
            {% endif %}

            <div class="row">
                {{ inputAdvance('TEXT', {
                    'name' : 'QTE',
                    'titre' :  (action == 'split'? 'Nouvelle quantité'|trad:'Nombre de duplications' | trad),
                    'value' : (action == 'split'? qteByUnite(0, infoLigne.COD_UNIT):0),
                }) }}
            </div>
        
        </div>

        <div id="message_erreur_popup" class="error displayNone clearfix" ></div>

        <div class="modal-footer">
            <button type="button" class="button secondaire" data-dismiss="modal" onclick="desactivePopup();desactiveLoader();">
                {{ 'Fermer'|trad }}
            </button>
            <button type="button" class="button principal" onClick="actionPopup('{{ path('Panier.TabBlocFrs.ajaxActionImpu', {action:action, idLigne:idLigne}) }}')">{{ 'Confirmer'|trad }}</button>
        </div>
    
    </form>

    <script>
    
        function actionPopup(path)
        {
            $.ajax({
                dataType : 'html',
                url: path,
                data: $('#form_actionImpu').serialize(),
                type: "POST",
                success: function(result){    				
                    refrechDiv('{{ path('Panier.Panier.index') }}', 'blocFrs__{{ idBlocfrs }}');

                    document.querySelector('#ongletimputation{{idBlocfrs}} a').click();
                    desactiveLoader();
                    desactivePopup();
                },
                error: function (data){
                    desactiveLoader();
                    $('#message_erreur_popup').html(data.responseText);
                }
            });
        }

    </script>

{% endblock %}