{% load i18n %}
<html>
<body>
  <h1>{% translate "My shop" %}</h1>
  <p>
    {% translate "Invoice no." %} {{ order.id }}<br>
    <span class="secondary">
      {{ order.created|date:"M d, Y" }}
    </span>
  </p>
  <h3>{% translate "Bill to" %}</h3>
  <p>
    {{ order.first_name }} {{ order.last_name }}<br>
    {{ order.email }}<br>
    {{ order.address }}<br>
    {{ order.postal_code }}, {{ order.city }}
  </p>
  <h3>{% translate "Items bought" %}</h3>
  <table>
    <thead>
      <tr>
        <th>{% translate "Product" %}</th>
        <th>{% translate "Price" %}</th>
        <th>{% translate "Quantity" %}</th>
        <th>{% translate "Cost" %}</th>
      </tr>
    </thead>
    <tbody>
      {% for item in order.items.all %}
        <tr class="row{% cycle "1" "2" %}">
          <td>{{ item.product.name }}</td>
          <td class="num">${{ item.price }}</td>
          <td class="num">{{ item.quantity }}</td>
          <td class="num">${{ item.get_cost }}</td>
        </tr>
      {% endfor %}

      {% if order.coupon %}
        <tr class="subtotal">
          <td colspan="3">{% translate "Subtotal" %}</td>
          <td class="num">
            ${{ order.get_total_cost_before_discount|floatformat:2 }}
          </td>
        </tr>
        <tr>
          <td colspan="3">
            {% blocktranslate with code=order.coupon.code discount=order.discount %}
              "{{ code }}" ({{ discount }}% off)
            {% endblocktranslate %}
          </td>
          <td class="num neg">
            - ${{ order.get_discount|floatformat:2 }}
          </td>
        </tr>
      {% endif %}

      <tr class="total">
        <td colspan="3">{% translate "Total" %}</td>
        <td class="num">${{ order.get_total_cost|floatformat:2 }}</td>
      </tr>
    </tbody>
  </table>

  <span class="{% if order.paid %}paid{% else %}pending{% endif %}">
    {% if order.paid %}{% translate "Paid" %}{% else %}{% translate "Pending payment" %}{% endif %}
  </span>
</body>
</html>
