{% extends "customer/emails/base.html" %}
{% load currency_filters i18n %}

{% block tbody %}
<tr>
    <td class="content-block">
        <p xmlns="http://www.w3.org/1999/html">{% trans 'Hello' %} {{ user.get_full_name }},</p>
        <p>{% blocktrans with order_number=order.number %}We are pleased to confirm your order {{ order_number }} has been received and will be processed shortly.{% endblocktrans %}</p>
    </td>
</tr>

<tr>
    <td class="content-block">
        <table class="order">
            <tbody><tr>
                <th>{% trans 'Your order contains:' %}</th>
            </tr>
            <tr>
                <td>
                    <table class="order-items" cellpadding="0" cellspacing="0">
                        <tbody>
                            {% for line in order.lines.all %}
                                <tr>
                                    <td><p>{{ line.title }} &times; {{ line.quantity }}</p>{% if line.attributes.exists %}<ul>
                                        {% for option in line.attributes.all %}
                                            <li><small>{{ option.option.name }}: {{ option.display_value }}<small></li>
                                        {% endfor %}</ul>{% endif %}</td>
                                    <td class="alignright">{{ line.line_price_before_discounts_incl_tax|currency:order.currency }}</td>
                                </tr>
                            {% endfor %}
                            {% if order.basket_discounts.exists %}
                                {% if order.lines.count > 1 %}
                                <tr class="subtotal">
                                    <td class="alignright">{% trans "Basket total (before discounts)" %}</td>
                                    <td>{{ order.basket_total_before_discounts_incl_tax|currency:order.currency }}</td>
                                </tr>
                                {% endif %}
                                {% for discount in order.basket_discounts %}
                                    <tr class="discount">
                                        <td class="alignright">{% trans "Discount" %} <i>{{ discount.offer }}:</i></td>
                                        <td{% if order.lines.count <= 1 %} class="alignright"{% endif %}>{{ discount.amount.copy_negate|currency:order.currency }}</td>
                                    </tr>
                                {% endfor %}
                            {% endif %}
                            <tr>
                                <td class="alignright">{% trans 'Basket total:' %}</td>
                                <td class="alignright">{{ order.basket_total_incl_tax|currency:order.currency }}</td>
                            </tr>
                            {% if order.has_shipping_discounts %}
                                <tr class="subtotal">
                                    <td class="alignright">{{ order.shipping_method }}</td>
                                    <td>{{ order.shipping_before_discounts_incl_tax|currency:order.currency }}</td>
                                </tr>
                                {% for discount in order.shipping_discounts %}
                                    <tr class="discount">
                                        <td class="alignright">{% trans "Discount" %} <i>{{ discount.offer }}:</i></td>
                                        <td>{{ discount.amount.copy_negate|currency:order.currency }}</td>
                                    </tr>
                                {% endfor %}
                                <tr>
                                    <td class="alignright">{% trans "Shipping charge (after discounts)" %}</td>
                                    <td class="alignright">{{ order.shipping_incl_tax|currency:order.currency }}</td>
                                </tr>
                            {% else %}
                            <tr>
                                <td class="alignright">{% trans 'Shipping:' %}</td>
                                <td class="alignright">{{ order.shipping_incl_tax|currency:order.currency }}</td>
                            </tr>
                            {% endif %}
                            
                            {% if order.surcharges.exists %}
                                {% for charge in order.surcharges.all %}
                                    <tr>
                                        <td class="alignright">{{charge.name}}:</td>
                                        <td class="alignright">{{ charge.incl_tax|currency:order.currency }}</td>
                                    </tr>
                                {% endfor %}
                            {% endif %}
                            <tr class="total">
                                <td class="alignright" width="80%">{% trans 'Order Total:' %}</td>
                                <td class="alignright total">{{ order.total_incl_tax|currency:order.currency }}</td>
                            </tr>
                            <tr class="no-border">
                                <td class="alignright">{% trans 'Total tax' %}</td>
                                <td class="alignright">{{ order.total_tax|currency:order.currency }}</td>
                            </tr>
                            <tr>
                                <td class="alignright">{% trans "Total excl. tax" %}</td>
                                <td class="alignright">{{ order.total_excl_tax|currency:order.currency }}</td>
                            </tr>
                        </tbody>
                    </table>
                </td>
            </tr>
        </tbody></table>
    </td>
</tr>

<tr>
    <td>
    <table class="order">
        <thead>
            <tr>
                <th scope="col">{% trans 'Shipping address' %}</th>
                <th scope="col"  class="alignright">{% trans 'Billing address' %}</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
                    <p>{% for field in order.shipping_address.ordered_active_address_fields %}  {{ field }}<br/>
                    {% endfor %}</p>
                </td>
                {% if order.billing_address %}
                <td class="alignright">
                    <p>{% for field in order.billing_address.ordered_active_address_fields %}  {{ field }}<br/>
                    {% endfor %}</p>
                </td>
                {% else %}
                <td class="alignright">
                    <p>{% for field in order.shipping_address.ordered_active_address_fields %}  {{ field }}<br/>
                    {% endfor %}</p>
                </td>
                {% endif %}
            </tr>
        </tbody>
</table>
</td>
</tr>
{% if status_url %}
    <tr>
        <td class="content-block">
            {% blocktrans %}You can view the status of this order by clicking <a href="{{ status_url }}" title="order status">here</a>{% endblocktrans %}
        </td>
    </tr>
{% endif %}

{% endblock %}
