{% extends "formunculous/base.html" %}

{% load i18n %}
{% block js %}{{ block.super }}
{% if history %}
<script type="text/javascript" src="{{ MEDIA_URL }}formunculous/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}formunculous/js/history.js"></script>
<script type="text/javascript">
  var historyURL = '{% url formunculous-apply-history %}'
</script>
{% endif %}
{% endblock %}

{% block css %}{{ block.super }}
<link href="{{ MEDIA_URL }}formunculous/css/formunculous.css" rel="stylesheet" type="text/css" />
{% endblock %}

{% block title %}{{ ad.name}} - {% trans "Completed Form" %}{% endblock %}
{% block content_title %}{{ ad.name}} {% trans "Completed Form" %}{% endblock %}
{% block content %}
<p>
  {% blocktrans with ad.name as appname %}
   Thank you for completing <i>{{ appname }}</i>.
  {% endblocktrans %}
</p>
<p>
  {% blocktrans %}
    It was submitted
  {% endblocktrans %}
      {{ app.submission_date|timesince }} {% trans "ago on" %} {{ app.submission_date|date:"D d M Y" }}
      {% trans "at" %} {{ app.submission_date|time:"g:i A" }}.
   {% blocktrans with ad.owner as email %}
</p>
<p>
      If there any problems, or
      some of the information is incorrect, please contact 
      <a href="mailto:{{ email }}">{{ email }}</a> to make any corrections.
   {% endblocktrans %}
</p>
{% if not ad.email_only %}
<p>
  {% blocktrans %}
    Below is the information that you submitted:
  {% endblocktrans %}
</p>

{% if ad.authentication %}
  {% if ad.authentication_multi_submit %}
  {# Offer link to start an additional form #}
    <div style="float:right;margin-top: 1em;">
	  <p>
		<a href="{% url formunculous-apply ad.slug %}?new=1" class="formunculous_newapplink">
		  {% trans "Start an additional form" %}
		</a>
	  </p>
	</div>
  {% endif %}
{% endif %}

{% if history %}
<div class="formunculous_tab_bar">
  <ul>
	<li class="here" id="formunculous-current">
	  <a href="#" class="formunculous_currentlink">{% trans "Current" %}</a>
	</li>
	<li id="formunculous-history">
	  <a href="#" class="formunculous_historylink">{% trans "History" %}</a>
	</li>
  </ul>
</div>


<div class="formunculous_history_bar">
  <div class="formunculous_history_list">
	<p>View previously completed {{ ad.name }} forms:</p>
	<ul>
	  {% for item in history %}
	  <li>
		<a href="#" onclick="getHistory({{ item.id }},this);">{{ item.submission_date|date:"D d M Y" }} {{ item.submission_date|time:"g:i A" }}</a>
	  </li>
	  {% endfor %}
	</ul>
  </div>
  <div id="formunculous-history-app">
	
  </div>
</div>
{% endif %}

<div class="formunculous_container">
  <div class="fr" style="margin-right: 2em;">
	<a href="javascript:window.print()" class="formunculous_printlink">{% trans "Print" %}</a>
  </div>
  <ul class="formunculous_form_info">
	{% for field in fields %}
	   <li>
	      <span class="formunculous_field_label">{{ field.label }}:</span>
		  <span class="formunculous_field_data">
			{% if field.data.url %}
			<a target="_blank" href="{{ field.data.url }}">
			{% endif %}
			{{ field.data }}
			{% if field.data.url %}
			</a>
			{% endif %}
		  </span>
	   </li>
    {% endfor %}
  </ul>
  {% if sub_apps %}
  {% for sub_app_group in sub_apps %}
    <h3 class="formunculous_sub_ad_title">{{ sub_app_group.sub_ad.name }}</h3>
	{% for sub_app in sub_app_group.sub_apps %}
	  <ul class="formunculous_form_info formunculous_sub_form_info">
		{% for field in sub_app.fields %}
		  <li>
			<span class="formunculous_field_label">{{ field.label }}:</span>
			<span class="formunculous_field_data">
			  {% if field.data.url %}
			  <a target="_blank" href="{{ field.data.url }}">
				{% endif %}
				{{ field.data }}
				{% if field.data.url %}
			  </a>
			  {% endif %}
			</span>
		  </li>
		{% endfor %}
	  </ul>
	{% endfor %}
  {% endfor %}
  {% endif %}
</div>

{% endif %}
{% endblock %}
