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

{% block body %}
    <center>
        <div id="genetableau">
            <div>
                {% set formName = 'formulaireListeArticlesNotOnSite' %}
                <form method="POST" id="{{ formName }}">
                    <input type="hidden" name="divCode" value="{{ post.divCode }}"/>
                    <input type="hidden" name="divLibelle" value="{{ post.divLibelle }}"/>
                    <input type="hidden" name="not_on_site" value="{{ post.not_on_site }}"/>
                    <input type="hidden" name="refArtFabInput" value="{{ post.refArtFabInput }}"/>

                    <div class="colonne">
                        <div class="row">
                            {{ inputSwitch(
                                'Uniquement les valides ?' | trad,
                                'valide',
                                post.valide,
                                (post.valide_obligatoire == 1 ? 'disabled' : '')
                            ~ 'onChange="ajaxRechercheTableau(\'' ~ path(pathPopup) ~ '\', \'genetableau\', \'' ~ formName ~ '\')"'
                            ) }}
                        </div>
                    </div>
                    <table class="table" id="tableau">
                        <thead class="thead-dark">
                        <tr>
                            <th>{{ triTable('CODE_ART',  post.tri_CODE_ART, 'Code' | trad, 'genetableau', path(pathPopup), formName) }}</th>
                            <th>{{ triTable('DESIGN',  post.tri_DESIGN, 'Libellé' | trad, 'genetableau', path(pathPopup), formName) }}</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <th>{{ filterTable('egal_STO#point#CODE_ART', post['filter_egal_STO#point#CODE_ART'], '', 'genetableau', path(pathPopup), formName) }}</th>
                            <th>{{ filterTable('egal_STO#point#DESIGN', post['filter_egal_STO#point#DESIGN'], '', 'genetableau', path(pathPopup), formName) }}</th>
                        </tr>
                        {% for article in listeArticles %}
                            <tr onclick="{{ attrJs('changeCodeLibelle', [ post.divCode, article.CODE_ART, post.divLibelle, article.DESIGN ~ ' (' ~ article.CODE_ART ~ ')']) }}; changeRefartfab('{{ article.REFARTFAB }}', '{{ post.refArtFabInput }}'); desactivePopup()">
                                <td>{{ article.CODE_ART | convert_encoding('UTF-8', 'ISO-8859-1') }}</td>
                                <td>{{ article.DESIGN | convert_encoding('UTF-8', 'ISO-8859-1') }}</td>
                            </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                </form>
                {{ paginations(path(pathPopup),infoPagination.nombreDePage, infoPagination.page, infoPagination.post, 'modal-body') }}
            </div>
        </div>
    </center>
    <script type="application/javascript">
        function changeRefartfab (value, inputId) {
            $('#' + CSS.escape(inputId)).val(value);
        }
    </script>
    {# </div> #}
{% endblock %}
