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

{% block pagewrapper %}
{{ form_start(form) }}
    <h1 class="page-title">
    {% if mode=="update" %}
    Modification Tâche
    {% elseif mode=="submit" %}
    Création Tâche
    {% endif %}
    </h1>

    <p>
        {{ form_widget(form.submit) }}
        {% if mode=="update" %}
        <a class="btn btn-secondary" href='{{ path('app_portal_'~access~'_projecttask_view',{'id':entity.id}) }}'>Annuler</a>
        {% elseif mode=="submit" %}
            {% set projectid=0 %}
            {%if entity.project.id is defined %}
                {% set projectid=entity.project.id %}
            {%endif%}
        
            {% if pageid is empty %}
                <a class="btn btn-secondary" href='{{ path('app_portal_'~access~'_project_view',{'id':projectid})}}'>Annuler</a>
            {% else %}
                <a class="btn btn-secondary" href="{{path('app_core_home',{id:pageid})}}" target="_top">Annuler</a>
            {% endif %}
        {% endif %}

        {% if mode=="update" %}
        <a href={{ path('app_portal_'~access~'_projecttask_delete',{'id':entity.id}) }}
            class="btn btn-danger float-end"
            data-method="delete" data-csrf="_token:{{ 'csrf' }}"
            data-confirm="Êtes-vous sûr de vouloir supprimer cette tâche ?">
            Supprimer
        </a>
        {% endif %}
    </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="row">
        <div class="col-md-8">
            <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.name) }}
                    {{ form_row(form.project) }}
                    {{ form_row(form.user) }}
                    {{ form_row(form.priority) }}

                </div>
            </div>
        </div>

        <div class="col-md-4">
            <div class="card">
                <div class="card-header"><i class="fa fa-pencil-alt fa-fw"></i> Détails</div>
                <div class="card-body"> 
                    {{ form_row(form.percentage) }}
                    {{ form_row(form.end) }}
                    {{ form_row(form.projecttasktag) }}
                    {{ form_row(form.projecttaskstatus) }}
                </div>
            </div>
        </div>

        <div class="col-md-12">
            <div class="card">
                <div class="card-header"><i class="fa fa-pencil-alt fa-fw"></i> Editeur</div>
                <div class="card-body"> 
                    {{ form_widget(form.description) }}
                </div>
            </div>
        </div>

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

