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

{% block pagewrapper %}
{{ form_start(form) }}
    <h1 class="page-title">Modification Configuration Générale = {{config.id}}</h1>

    <p>
        {{ form_widget(form.submit) }}  <a class="btn btn-secondary" href={{ path('app_core_config_commun') }}>Annuler</a>
    </p>

    {% if app.session.flashbag.has('error') %}
        <div class='alert alert-danger' style='margin: 5px 0px'>
            <strong>Erreur</strong><br>
            {% for flashMessage in app.session.flashbag.get('error') %}
                {{ flashMessage }}<br>
            {% endfor %}
        </div>
    {% endif %}

    {% if app.session.flashbag.has('notice') %}
        <div class='alert alert-info' style='margin: 5px 0px'>
            <strong>Information</strong><br>
            {% for flashMessage in app.session.flashbag.get('notice') %}
                {{ flashMessage }}<br>
            {% endfor %}
        </div>
    {% endif %}

    <div class="card">
        <div class="card-header">
            <i class="fa fa-pencil-alt fa-fw"></i> Informations
        </div>

        <div class="card-body">
            {{ form_row(form.id) }}

            {% if type=="logo" %}
                <div style="width:90px; margin:10px auto;">
                <img id="config_value_img" src="{{ asset(config.value) }}" style="width:90px;height:auto;margin:auto;display:block;margin-bottom:5px;">
                {{ form_widget(form.value) }}
                <a class="btn btn-info" style="width:90px" data-bs-toggle="modal" data-bs-target="#mymodal" onClick="ModalLoad('mymodal','Téléchargez votre Logo','{{ path('app_core_config_logo') }}');" title='Ajouter un Logo'>Modifier</a>
                </div>

            {% elseif type=="header" %}
                <div style="margin:10px auto;">
                <img id="config_value_img" src="{{ asset(config.value) }}" style="width:100%;margin:auto;display:block;">
                {{ form_widget(form.value) }}
                <a class="btn btn-info" style="width:100%" data-bs-toggle="modal" data-bs-target="#mymodal" onClick="ModalLoad('mymodal','Téléchargez votre Bannière','{{ path('app_core_config_header') }}');" title='Ajouter un Header'>Modifier</a>
                </div>

            {% else %}
                {{ form_row(form.value) }}
            {% endif %}

            {{ form_widget(form.help) }}
        </div>
    </div>

{{ form_end(form) }}
{% endblock %}

{% block localjavascript %}
    $('#mymodal').on('hidden.bs.modal', function () {
        var imgSrc = $("#config_value_img").attr('src');
        $("#config_value_img").attr('src',imgSrc);
    }); 


{% endblock %}
