{% extends 'base.html.twig' %}

{% block pagewrapper %}
    <form>
    <h1 class="page-title">Configuration Générale</h1>

    Attention, selon la configuration du portail, certains paramètres sont forcés au niveau du serveur et donc certains réglages peuvent être inopérants dans cette interface.
    <br><br>
    <div class="card">
        <div class="card-header">
            <i class="fa fa-table fa-fw"></i> Liste des Configurations
        </div>

        <div class="card-body">
            <div class="dataTable_wrapper">
                <table class="table table-striped table-bordered table-hover" id="dataTables" style="width:100%">
                    <thead>
                    <tr>
                        <th width="90px">Action</th>
                        <th width="70px">Ordre</th>
                        <th width="200px">Clé</th>
                        <th>Description</th>
                        <th>Valeur</th>
                    </tr>
                    </thead>

                    {% for config in configs %}
                        {% if (config.required) and (config.value=="" ) %}
                            <tr class="danger">
                        {% else %}
                            <tr>
                        {% endif %}
                            <td>
                                <a style="cursor:pointer" onClick="showInfo('info-{{ config.id }}');" data-bs-toggle="modal" data-bs-target="#modalinfo" title='Information'><i id="info-{{ config.id }}" class="fa fa-info-circle" data="{{ config.help }}"></i></a>
                                {% if config.changeable %}
                                    <a href={{ path('app_core_config_commun_update', {'id': config.id}) }} title='Modifier'><i class="fa fa-file fa-fw"></i></a>
                                    {% if not config.required %}
                                        <a href={{ path('app_core_config_commun_delete', {'id': config.id}) }} title='Supprimer'><i class="fa fa-trash fa-fw"></i></a>
                                    {% endif %}
                                {% endif %}
                            </td>
                            <td>{{ config.order }}</td>
                            <td>{{ config.id }}</td>
                            <td>{{ config.help|raw }}</td>
                            <td>
                                {% if config.type == "boolean" %}
                                    {% if config.value == "0" %}
                                        non
                                    {% else %}
                                        oui
                                    {% endif %}
                                {% elseif config.type == "logo" %}
                                    <img src="{{ asset(config.value) }}"" height="90px">    
                                {% elseif config.type == "header" %}
                                    <img src="{{ asset(config.value) }}"" width="100%">       

                                {% else %}
                                    {{ config.value }}
                                {% endif %}
                            </td>
                        </tr>
                    {% endfor %}
                </table>
            </div>
        </div>
    </div>
    </form>
{% endblock %}

{% block localjavascript %}
    function showInfo(id) {
        $("#modalinfo #modalinfotext").html($("#"+id).attr("data").replace(/\n/g, "<br />"));
    }


    $(document).ready(function() {
        $('#dataTables').DataTable({
            responsive: true,
            order: [[ 1, "asc" ]]
        });
    });
{% endblock %}
