{% load i18n %}

<h3>
  {% trans "Order ID:" %} {{ order.id }}
</h3>

<p>
  {% trans "Order Status" %}: {{ order.get_status_display }}
</p>

<table class="order-address" border="1">
  <tr>
    <td style="vertical-align:top;">
      <strong>{% trans "Shipping Address" %}</strong><br>
      {% if order.shipping_name %}{{ order.shipping_name }}<br>{% endif %}
      {% if order.shipping_address %}{{ order.shipping_address }}<br>{% endif %}
      {% if order.shipping_address2 %}{{ order.shipping_address2 }}<br>{% endif %}
      {% if order.shipping_zip_code %}{{ order.shipping_zip_code }}<br>{% endif %}
      {% if order.shipping_state %}{{ order.shipping_state }}<br>{% endif %}
      {% if order.shipping_country %}{{ order.shipping_country }}<br>{% endif %}
    </td>
    <td style="vertical-align:top;">
      <strong>{% trans "Billing Address" %}</strong><br>
      {% if order.billing_name %}{{ order.billing_name }}<br>{% endif %}
      {% if order.billing_address %}{{ order.billing_address }}<br>{% endif %}
      {% if order.billing_address2 %}{{ order.billing_address2 }}<br>{% endif %}
      {% if order.billing_zip_code %}{{ order.billing_zip_code }}<br>{% endif %}
      {% if order.billing_state %}{{ order.billing_state }}<br>{% endif %}
      {% if order.billing_country %}{{ order.billing_country }}<br>{% endif %}
    </td>
  </tr>
</table>

<table border="1" class="order">
  <thead>
    <tr>
    <th>{% trans "Product name" %}</th>
    <th>{% trans "Unit price" %}</th>
    <th>{% trans "Quantity" %}</th>
    <th>&nbsp;</th>
    </tr>
  </thead>

  <tbody>
    {% for item in order.items.all %}
      <tr>
        <td>{{item.product_name}}</td>
        <td>{{ item.unit_price }}</td>
        <td>{{item.quantity}}</td>
        <td>{{item.line_subtotal }}</td>
      </tr>
      {% for item_extra in item.extraorderitempricefield_set.all %}
        <tr>
          <td colspan="2">&nbsp;</td>
          <td>{{ item_extra.label }}</td>
          <td>{{ item_extra.value }}</td>
        </tr>
      {% endfor %}
      <tr><td colspan="2">&nbsp;</td><td>{% trans "Line Total" %}:</td><td>{{item.line_total }}</td></tr>
    {% endfor %}
  </tbody>

  <tfoot>
    <tr><td colspan="2">&nbsp;</td><td>{% trans "Order Subtotal" %}</td><td>{{order.order_subtotal }}</td></tr>
    {% for extra_price_field in order.extraorderpricefield_set.all %}
      <tr>
        <td colspan="2">&nbsp;</td>
        <td>{{ extra_price_field.label }}</td>
        <td>{{ extra_price_field.value }}</td>
      </tr>
    {% endfor %}
    <tr><td colspan="2">&nbsp;</td><td><b>{% trans "Order Total" %}</b></td><td><b>{{order.order_total}}</b></td></tr>
  </tfoot>
</table>

{% for extra_info in order.extra_info.all  %}
  <p>{{ extra_info.text }}</p>
{% endfor %}

