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

{% block body %}
    <center>
        <div id="genetableau">
            <div>
                <form method="POST" id='question_list' name='question_list'>
                    <input type="hidden" name="label" value="{{ post.label }}" />
                    <input type="hidden" name="theme" value="{{ post.theme }}" />
                    
                    <table class="table" id="tableau">
                        <thead class="thead-dark">
                            <tr>
                                <th>{{ triTable('LIB_QUEST',  infoPagination.filter.tri_LIB_QUEST, 'Libellé' | trad, 'genetableau', path, 'question_list') }}</th>
                                <th>{{ triTable('LIB_THEME',  infoPagination.filter.tri_LIB_THEME, 'Thème' | trad, 'genetableau', path, 'question_list') }}</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <th>{{ filterTable('LIB_QUEST', infoPagination.filter.filter_LIB_QUEST, '', 'genetableau', path, 'question_list') }}</th>
                                <th>{{ filterTable('LIB_THEME', infoPagination.filter.filter_LIB_THEME, '', 'genetableau', path, 'question_list') }}</th>
                            </tr>
                            {% for question in entity %}
                                <tr onclick='updateInput("{{ post.divCode }}","{{ question.ID_CAMP }}","{{ question.LIB_QUEST|e('js')|raw }}", "{{ question.LIB_THEME|e('js')|raw }}", "{{ question.ID_THEME }}", "{{ question.ID_QUEST }}");desactivePopup();'>
                                    <td id ="{{ question.ID_THEME ~ '_' ~ question.ID_QUEST }}">{{ question.LIB_QUEST  }}</td>
                                    <td>{{ question.LIB_THEME  }}</td>
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </form>
            {{ paginations(path, infoPagination.nombreDePage, infoPagination.page, infoPagination.post, 'genetableau') }}
            </div>
        </div>
    </center>
    <script>
        function updateInput(codeInput, campId, label, theme, themeId, questionId) {
            $('#' + codeInput.replace('input', 'text')).val(label + ' (' + theme + ')').blur();
            $('#' + codeInput).val(campId + '~~' + themeId + '~~' + questionId).blur();
            activeLoader();
            $.ajax({
                dataType : 'html',
                url: '{{ path('Evaluation.Question.generateDependencyOptions',{mode: mode, id: id}) }}',
                data: {'themeId': themeId, 'questionId': questionId},
                type: "POST",
                success: function(result){
                    $('#dependency_options').removeAttr('style');
                    $('#dependency_options').html(result);
                    desactiveLoader();
                }
            });
        }
    </script>
{% endblock %}