{% extends "docbow/base_user.html" %}
{% load crispy_forms_tags %}
{% load i18n %}
{% load docbow %}
{% load humanize %}
{% load url from future %}

{% block title %}
{% include "docbow/message_title.html" %}
{% endblock %}

{% block extra_scripts %}
{{ form.media }}
{% endblock %}

{% block main-column %}
<h3>{% include "docbow/message_title.html" %}</h3>

<div id="download-buttons">
{% for kind, files in attached_files %}
  <span>{{ kind.name }}</span>
  {% for file in files %}
    <h4 class="download-button">
      <a title="{{file.name}}" href="{{file.pk}}/{{file.name}}">
        {% trans "Download" %}
        <span class="file-size">({{file.content.size|frfilesizeformat}})</span>
        <div class="filename">{{file.name|escape|ellipsizedfilename:50|safe}}</div>
      </a>
    </h4>
  {% endfor %}
{% endfor %}
</div>

<h4 id="to-header">{% trans "To" %}:</h4>
<div id="to">
	{% for to in document.human_to %}
	<span>{{to}}</span>
	{% endfor %}
</div>
<h4 id="comment-header">{% trans "Comment" %}:</h4>
<p id="comment">{{ document.comment }}</p>
{% if view_name == 'inbox' %}
<div class="form">
  <form action="{% url 'send-file-selector' %}" class="uniForm">
    <input type="hidden" name="reply_to" value="{{ mailbox.pk }}"/>
    <div class="buttonHolder">
      <input type="submit" class="submit submitButton" value="{% trans "Reply" %}"/>
    </div>
  </form>
</div>
{% endif %}
{% if form %}
{% if document.document_forwarded_to.all %}
<h4 id="forwarded-header">{% trans "Forwarded to" %}</h4>
<div id="forwarded">
	<ul>
		{% for document_forwarded in document.document_forwarded_to.all %}
		{% with document_forwarded=document_forwarded.to_document %}
		<li>{{document_forwarded.recipients}}
    {% with date=document_forwarded.date|date:"SHORT_DATE_FORMAT" sender=document_forwarded.sender|username time=document_forwarded.date|time:"H:i" %}
      {% if document_forwarded.automatic %}
        {% blocktrans %}on {{date}} at {{time}} automatically{% endblocktrans %}
      {% else %}
        {% blocktrans %}on {{date}} at {{time}} by {{sender}}{% endblocktrans %}
      {% endif %}
    {% endwith %}
    </li>

		{% endwith %}
		{% endfor %}
	</ul>
</div>
{% endif %}
<div class="forward-form">
{% with form.helper as helper %}
<h3>Transférer le document à&nbsp;:</h3>
<div class="form">
	{% crispy form helper %}
</div>
{% endwith %}
</div>
{% endif %}
{% endblock %}
