{% extends 'layout.twig' %}

{% block body %}
    <div class="contenu clearfix" id="import_multiple_reporting">
        <h1>{{ 'Short Lists Fournisseur' | trad }}</h1>
        {{ ariane() }}

        {{ flash.display|raw }}

        {{ arianeSub() }}

        <div id="transformCsvToXml" class="padding15">
            <form method="POST" id='formulaireGeneral' enctype="multipart/form-data" class="box-form clearfix" >
                <input type="hidden" value='' name='importSend'>
                <div class="single">
                    {{ inputAdvance('FILE', {'name' : 'shortListFournisseur', 'format' : 'excel'} ) }}
                </div>
                <br>
                <center><h4 style="font-weight:lighter!important;">{{ libelleForm | raw }}</h4></center>
                {% include '@GlobalApplication/Component/_tableImportFormat.twig' with {
                    listCol: [
                        {
                            label: 'Code fournisseur' | trad,
                            mandatory: true,
                            format: 'A',
                            formatMask: 12,
                        },
                        {
                            label: 'Code Short List' | trad,
                            mandatory: true,
                            format: 'N',
                        },
                        {
                            label: 'Statut' | trad,
                            mandatory: true,
                            format: 'M',
                            formatMask: '(C : Création ; D : Suppression)',
                        },
                    ],
                } only %}
                <button class="button principal button_right" type='button' onclick="importShortListFournisseur('{{ path('Fournisseur.GestionShortList.ajaxImportFournisseurShortList') }}')">{{ 'Importer' | trad }}</button>
            </form>
        </div>
    </div>

    <script>
        function importShortListFournisseur(path)
        {
            jForm.append("importSend", $('[name="importSend"]').val());

            activeLoader();
            $.ajax({
                url: path,
                data: jForm,
                type: 'POST',
                contentType: false,
                cache: false,
                mimeType: "multipart/form-data",
                processData: false,
                success: function (response) {
                    desactiveLoader();
                    $("#modal-content").addClass("modal_small");
                    $("#modal-body").html(response);
                    activePopup();
                },
                error: function(data) {
                    data = jQuery.parseJSON(data.responseText);
                    if (data.postGestion) {
                        redirectJSWithPost(data.path, data.postGestion);
                    } else {
                        window.location.href = data.path;
                    }
                },
            });
        }
    </script>

{% endblock %}