{% extends "admin/change_form.html" %}
{% load i18n admin_modify adminmedia %}

{% block content %}<div id="content-main">
{% block object-tools %}
{% if change %}{% if not is_popup %}
  <ul class="object-tools"><li><a href="history/" class="historylink">{% trans "History" %}</a></li>
  {% if has_absolute_url %}<li><a href="../../../r/{{ content_type_id }}/{{ object_id }}/" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif%}
  </ul>
{% endif %}{% endif %}
{% endblock %}
<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.module_name }}_form">{% block form_top %}{% endblock %}
{% csrf_token %}
<div>
{% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %}
{% if save_on_top %}{% submit_row %}{% endif %}
{% if errors %}
    <p class="errornote">
    {% blocktrans count errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
    </p>
    <ul class="errorlist">{% for error in adminform.form.non_field_errors %}<li>{{ error }}</li>{% endfor %}</ul>
{% endif %}

{% block after_field_sets %}
<fieldset class="module aligned">
  <h2><div class="description">{% trans 'Online order' %}#<strong>{{ original.id }}<strong></div></h2>
    <table>
    <th>№</th>
    <th>{% trans 'Item name' %}</th>
    <th>{% trans 'Quantity' %}</th>
    <th>{% trans 'Price' %}</th>
    <th>{% trans 'Total' %}</th>
    {% for item in original.items.all %}
      <tr>
      <td>{{ forloop.counter }}</td>
      <td>{{ item.content_object }}</td>
      <td style="text-align:center">{{ item.quantity }}</td>
      <td>{{ item.get_price }}</td>
      <td>{{ item.get_sum }}</td>
      <tr>
    {% endfor %}
    </table>
      <div class="form-row">
      <h3>{% trans 'Order price' %}: {{ original.summary }}<br/> {% trans 'Items quantity' %}: {{ original.goods }}</h3>
      </div>
      {% if original.user %}
	      <div class="form-row">
	        <div>{% trans 'User id' %}: {{ original.user.id }}</div>
	        <a href='../?q={{ original.user.username }}'>{% trans 'Shopping history' %}</a>
	      </div>
      {% endif %}
</fieldset>
{% endblock %}

{% for fieldset in adminform %}
  {% include "admin/includes/fieldset.html" %}
{% endfor %}

{% for inline_admin_formset in inline_admin_formsets %}
    {% include inline_admin_formset.opts.template %}
{% endfor %}

{% block after_related_objects %}{% endblock %}

{% submit_row %}

{% if adminform and add %}
   <script type="text/javascript">document.getElementById("{{ adminform.first_field.auto_id }}").focus();</script>
{% endif %}

{# JavaScript for prepopulated fields #}
{% prepopulated_fields_js %}

</div>
</form></div>
{% endblock %}

