{% load i18n %}
{% load lfs_tags %}
<table class="lfs-manage-table">
    <tr>
        <th colspan="4">
            {% trans 'General' %}
        </th>
    </tr>
    <tr>
        <td width="25%"
            class="label">
            {% trans 'Order number' %}:
        </td>
        <td width="25%">
            {{ current_order.number|default_if_none:"-" }}
        </td>
        <td width="25%"
            class="label">
            {% trans 'Date' %}:
        </td>
        <td width="25%">
            {{ current_order.created|date:_("DATETIME_FORMAT") }}
        </td>
    </tr>
    <tr>
        <td class="label">
            {% trans 'E-mail' %}:
        </td>
        <td>
            <a href="mailto:{{ current_order.customer_email }}">
                {{ current_order.customer_email }}
            </a>
        </td>
        <td class="label">
            {% trans 'State' %}:
        </td>
        <td>
            {{ current_order.get_state_display }} {% if current_order.state_modified %}({{ current_order.state_modified|date:_("DATETIME_FORMAT") }}){% endif %}
        </td>
    </tr>
    <tr>
        <td class="label">
            {% trans 'Phone' %}:
        </td>
        <td>
            {{ current_order.shipping_phone }}
        </td>
        <td class="label">
            {% trans 'Total' %}:
        </td>
        <td>
            {{ current_order.price|currency:request }}
        </td>
    </tr>

</table>
<table class="lfs-manage-table">
    <tr>
        <th width="25%">
            {% trans 'Shipping address' %}
        </th>
        <th width="25%">
            {% trans 'Invoice address' %}
        </th>
        <th width="25%">
            {% trans 'Shipping method' %}
        </th>
        <th width="25%">
            {% trans 'Payment method' %}
        </th>
    </tr>
    <tr>
        <td class="top">
            <div>
                {{ current_order.shipping_firstname }} {{ current_order.shipping_lastname }}
            </div>
            {% if current_order.shipping_company_name %}
                <div>
                    {{ current_order.shipping_company_name }}
                </div>
            {% endif %}
                <div>
                {{ current_order.shipping_line1 }}
            </div>
            {% if current_order.shipping_line2 %}
                <div>
                    {{ current_order.shipping_line2 }}
                </div>
            {% endif %}
            <div>
                {{ current_order.shipping_code }} {{ current_order.shipping_city }}
            </div>
            <div>
                {{ current_order.shipping_state }}
            </div>
            <div>
                {{ current_order.shipping_country }}
            </div>
            <div>
                {{ current_order.shipping_phone }}
            </div>
        </td>
        <td class="top">
            <div>
                {{ current_order.invoice_firstname }} {{ current_order.invoice_lastname }}
            </div>
            {% if current_order.invoice_company_name %}
                <div>
                    {{ current_order.invoice_company_name }}
                </div>
            {% endif %}
                <div>
                {{ current_order.invoice_line1 }}
            </div>
            {% if current_order.invoice_line2 %}
                <div>
                    {{ current_order.invoice_line2 }}
                </div>
            {% endif %}
            <div>
                {{ current_order.invoice_code }} {{ current_order.invoice_city }}
            </div>
            <div>
                {{ current_order.invoice_state }}
            </div>
            <div>
                {{ current_order.invoice_country }}
            </div>
            <div>
                {{ current_order.invoice_phone }}
            </div>
        </td>
        <td class="top">
            {{ current_order.shipping_method }}
        </td>
        <td class="top">
            {{ current_order.payment_method.name }}
            {% ifequal current_order.payment_method.id 1 %}
                <div>
                    {{ current_order.account_number }}
                </div>
                <div>
                    {{ current_order.bank_identification_code }}
                </div>
                <div>
                    {{ current_order.bank_name }}
                </div>
                <div>
                    {{ current_order.depositor }}
                </div>
            {% endifequal %}
        </td>
    </tr>
</table>

<table class="lfs-manage-table">
    <tr>
        <th width="200px">
            {% trans 'SKU' %}
        </th>
        <th>
            {% trans 'Name' %}
        </th>
        <th width="80px"
            class="number">
            {% trans 'Amount' %}
        </th>
        <th width="150px"
            class="number">
            {% trans 'Price' %}
        </th>
        <th width="150px"
            class="number">
            {% trans 'Included VAT' %}
        </th>
        <th width="150px"
            class="number">
            {% trans 'Total' %}
        </th>
    </tr>
    {% for item in current_order.items.all %}
        <tr>
            <td>
                {{ item.product_sku }}
            </td>
            <td>
                {% if item.product %}
                    <a href="{% url lfs_manage_product item.product.id %}">
                        {{ item.product_name }}
                    </a>
                {% else %}
                    {{ item.product_name }}
                {% endif %}
                {% for property in item.product.get_displayed_properties %}
                    <div>
                        {{ property.title }} : {{ property.value }} {{ property.unit|safe }}
                    </div>
                {% endfor %}

                {% for property in item.product.get_variant_properties %}
                    <div>
                        {{ property.title }}: {{ property.value }} {{ property.unit|safe }}
                    </div>
                {% endfor %}

                {% if item.product.is_configurable_product %}
                    {% for property in item.get_properties %}
                        <div>
                            {{ property.title }} : {{ property.value }} {{ property.unit|safe }}
                            {% if property.display_price %}
                                ({{ property.price|currency:request }})
                            {% endif %}
                        </div>
                    {% endfor %}
                {% endif %}
            </td>

            <td class="number">
               {{ item.amount }} {{ item.product.unit }}
                {% if item.product.active_packing_unit %}
                    <span class="packing-unit">
                        ({{ item|packages }} {{ item.product.packing_unit_unit }})
                    </span>
                {% endif %}

            </td>
            <td class="number">
               {{ item.product_price_gross|currency:request }}{% if item.product.price_unit %} / {{ item.product.price_unit }}{% endif %}
            </td>
            <td class="number">
               ({{ item.product_tax|currency:request }})
            </td>
            <td class="number">
               {{ item.price_gross|currency:request }}
            </td>
        </tr>
    {% endfor %}
    {% if current_order.voucher_number %}
        <tr>
            <td></td>
            <td>
                {% trans 'Voucher' %} ({{ current_order.voucher_number }})
            </td>
            <td class="number">
                1
            </td>
            <td class="number">
                - {{ current_order.voucher_price|currency:request }}
            </td>
            <td></td>
            <td class="number">
                - {{ current_order.voucher_price|currency:request }}
            </td>
        </tr>
    {% endif %}
    <tr>
        <td></td>
        <td>
            {% trans 'Shipping' %} ({{ current_order.shipping_method }})
        </td>
        <td class="number">
            1
        </td>
        <td class="number">
            {{ current_order.shipping_price|currency:request }}
        </td>
        <td></td>
        <td class="number">
            {{ current_order.shipping_price|currency:request }}
        </td>
    </tr>
    <tr>
        <td></td>
        <td>
            {% trans 'Payment' %} ({{ current_order.payment_method }})
        </td>
        <td class="number">
            1
        </td>
        <td class="number">
            {{ current_order.payment_price|currency:request }}
        </td>
        <td></td>
        <td class="number">
            {{ current_order.payment_price|currency:request }}
        </td>
    </tr>
    <tr class="total">
        <td colspan="6"
            class="number total">
            {{ current_order.price|currency:request }}
        </td>
    </tr>
    <tr>
        <td colspan="6"
            class="number tax">
            <span class="total-label">{% trans 'Inclusive VAT' %}:</span>
            {{ current_order.tax|currency:request }}
        </td>
    </tr>
</table>
{% if current_order.message %}
    <table class="lfs-manage-table">
        <tr>
            <th colspan="5">
                {% trans 'Message from the customer' %}
            </th>
        </tr>
        <tr>
            <td colspan="5">
                {{ current_order.message }}
            </td>
        </tr>
    </table>
{% endif %}
{% if current_order.paypalordertransaction_set.all %}
<table class="lfs-manage-table">
        <tr>
            <th colspan="5">
                {% trans 'Paypal Transaction ID' %}
            </th>
        </tr>
        {% for ppt in current_order.paypalordertransaction_set.all %}
        {% for ipn in ppt.ipn.all %}
        <tr>
            <td colspan="5">
                {{ ipn.txn_id }}
            </td>
        </tr>
        {% endfor %}
        {% endfor %}
    </table>

{% endif %}
