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

{% block body %}
    <div>
        <center>
            <div id="genetableau">
                {% set formName = 'sdrEntes' %}
                <form method="POST" name="{{ formName }}" id='{{ formName }}'>
                    <input type="hidden" name="divCode" value="{{ post.divCode }}" />
                    <input type="hidden" name="divLibelle" value="{{ post.divLibelle }}" />
                    <input type="hidden" name="siteInputName" value="{{ post.siteInputName }}" />
                    <table class="table" id="tableau">
                        <thead class="thead-dark">
                        <tr>
                            <th>{{ triTable('NO_PR',  infoPagination.filter.tri_NO_PR, 'N°PR' | trad, 'genetableau', path('Ajax.liste.propositionsReappro'), formName) }}</th>
                            <th>{{ triTable('MAG',  infoPagination.filter.tri_MAG, 'Magasinier' | trad, 'genetableau', path('Ajax.liste.propositionsReappro'), formName) }}</th>
                            <th>{{ triTable('SITE',  infoPagination.filter.tri_SITE, 'SiteStock' | trad, 'genetableau', path('Ajax.liste.propositionsReappro'), formName) }}</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <th>{{ filterTable('egal_NO_PR', infoPagination.filter.filter_egal_NO_PR, '', 'genetableau', path('Ajax.liste.propositionsReappro'), formName) }}</th>
                            <th>{{ filterTable('MAG', infoPagination.filter.filter_MAG, '', 'genetableau', path('Ajax.liste.propositionsReappro'), formName) }}</th>
                            <th>{{ filterTable('SITE', infoPagination.filter.filter_SITE, '','genetableau', path('Ajax.liste.propositionsReappro'),formName) }}</th>
                        </tr>
                        {% for propositionReappro in liste %}
                            <tr onclick='changeCodeLibelle("{{ post.divCode }}","{{ propositionReappro.NO_PR }}", "{{ post.divLibelle }}", "{{ propositionReappro.NO_PR }}"); changeSiteStock("{{ post.siteInputName }}", "{{ propositionReappro.SITE }}", "{{ propositionReappro.LIBELLE }}"); desactivePopup()'>
                                <td>{{ propositionReappro.NO_PR }}</td>
                                <td>{{ propositionReappro.MAG }}</td>
                                <td>{{ propositionReappro.SITE }}</td>
                            </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                </form>
                {{ paginations(path('Ajax.liste.propositionsReappro'),infoPagination.nombreDePage, infoPagination.page, infoPagination.post, 'modal-body') }}
            </div>
        </center>
    </div>
    <script type="application/javascript">
        function changeSiteStock (siteInputName, siteStock, libelle) {
            const facadeInput = $('#text_' + siteInputName);

            $('#input_' + siteInputName).val(siteStock);
            facadeInput.val(libelle + ' (' + siteStock + ')');
            facadeInput.prop('disabled', true);
        }
    </script>
{% endblock %}