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

{% block localstyle %}
    #page-wrapper {
        padding: 0px;
        min-height:0px !important;
    }
{% endblock %}

{% block pagewrapper %}
{{ form_start(form) }}
    {{ form_widget(form.submit) }} <a class="btn btn-secondary" onClick="closeModal()">Annuler</a>

    <br><br>

    {% 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 %}

    {{ form_row(form.destinataire) }}
    <div class='alert alert-info' style='font-size: 80%;padding: 5px;margin-top: -10px;'>
        Séparer les adresses mails par des ;
    </div>    

    {{ form_row(form.subject) }}
    {{ form_row(form.message) }}

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

{% block localjavascript %}
    $(document).ready(function() {
        {% if closed %}
            closeModal();
        {% else %}
            $("#mail_subject").val("{{ subject }}");
            CKEDITOR.instances["mail_message"].setData("{{ message | raw }}");

            $("#mail_destinataire").focus();
        {% endif %}
    });

    function closeModal() {
        window.parent.$("#mymodal").modal('hide');;
    }

{% endblock %}