{% extends "new_request.html" %}

{% load editor %}
{% load crispy_forms_tags %}
{% load url from future %}

{% block extra_scripts %}
{{ block.super }}
{% endblock %}

{% block content %}
<div class="row-fluid">
	<div class="span12">


<form action="" method="post" enctype="multipart/form-data" class="well bootstrap form-horizontal">

	<h1>Demande de reprographie</h1>
	<h2>Étape finale&nbsp;: {{ wizard.form.display_name }}</h2>

    {% editablecontent "_request_edit_validation_header" %}
    {% endeditablecontent %}

{% if messages %}
	{% for message in messages %}
	<p{% if message.tags %} class="alert alert-{{ message.tags }}"{% endif %}>{{ message }}</p>
	{% endfor %}
{% endif %}

	{% for step, form, pprint_data, missings in all_forms %}
	{% if not forloop.last %}{# don't process last step == validation #}
	<h3><a href="../{{ step }}?correction">Étape {{ forloop.counter }}. {{ form.display_name }}</a></h3>
		<ul>
		{% for d,v in pprint_data %}
            {% if v %}
            <li>{% if d %}{{ d }}: {% endif %}{{ v }}</li>
            {% endif %}
        {% endfor %}
		</ul>
        {% if missings %}
        <p class="alert alert-error">Champs manquants: {{ missings|join:", " }}</p>
        {% endif %}
		</li>
	{% endif %}
	{% endfor %}

    {% editablecontent "_request_edit_validation_footer" %}
    {% endeditablecontent %}

{{ wizard.management_form }}
{% crispy wizard.form %}

<div class="form-actions">
	{% if wizard.steps.prev %}
	<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}" class="btn pull-left"> <i class="icon-backward"></i> Retour</button>
	{% endif %}
    <div class="pull-right">
    {% for workflow in workflows %}
    <a class="btn{% if workflow.warn %} btn-danger{% endif%}{% if workflow.default %} btn-success{% endif %}" href="{% url 'request_action' pk=object.pk workflow_pk=workflow.pk %}">{{ workflow.name }}</a>
    {% endfor %}
    </div>
</div>

</form>

</div>
</div>

{% endblock %}
