{% extends 'edx/base.html' %}
{% load core_extras %}
{% load currency_filters %}
{% load i18n %}
{% load offer_tags %}
{% load staticfiles %}

{% block title %}
  {% blocktrans with order_number=order.number %}
    Receipt for {{ order_number }}
  {% endblocktrans %}
{% endblock title %}

{% block javascript %}
  <script src="{% static 'js/pages/receipt_page.js' %}"></script>
{% endblock javascript %}

{% block navbar %}
  {% include 'edx/partials/_student_navbar.html' %}
{% endblock navbar %}

{% block content %}
  <div id="receipt-container"
       class="receipt container content-container"
       data-currency="{{ order.currency }}"
       data-fire-tracking-events="{{ fire_tracking_events|yesno:"true,false" }}"
       data-order-id="{{ order.number }}"
       data-total-amount="{{ order.total_incl_tax }}">
      <h2 class="thank-you">{% trans "Thank you for your order!" %}</h2>

      <div class="list-info">
        <div class="info-item payment-info row">
          <div class="copy col-md-8">
            <div class="confirm-message">
              {% captureas link_start %}
                <a href="mailto:{{ order.user.email }}">
              {% endcaptureas %}
              {% blocktrans with email=order.user.email link_end="</a>" %}
                Your order is complete. If you need a receipt, you can print this page.
                You will also receive a confirmation message with this information at
                {{ link_start }}{{ email }}{{ link_end }}.
              {% endblocktrans %}
            </div>

            {% if order.billing_address %}
              <address class="billing-address">
                {% for field in order.billing_address.active_address_fields %}
                  {{ field }}<br/>
                {% endfor %}
              </address>
            {% endif %}
          </div>

          <div class="order-headers order-summary col-md-4">
            <dl>
              <dt>{% trans "Order Number:" %}</dt>
              <dd>{{ order.number }}</dd>
              {% if payment_method %}
                <dt>{% trans "Payment Method:" %}</dt>
                <dd>{{ payment_method }}</dd>
              {% endif %}
              <dt>{% trans "Order Date:" %}</dt>
              <dd>{{ order.date_placed|date:"E d, Y" }}</dd>
            </dl>
          </div>
        </div>

        <h2>{% trans "Order Information" %}</h2>
        <div class="table">
          <dl class="order-lines">
            <div class="header">
              <dt aria-hidden="true">{% trans "Quantity" %}</dt>
              <dt aria-hidden="true">{% trans "Description" %}</dt>
              <dt aria-hidden="true">{% trans "Item Price" %}</dt>
            </div>
            {% for line in order.lines.all %}
              <div class="order-line-data">
                <dt class="quantity sr">{% trans "Quantity:" %}</dt>
                <dd class="quantity">{{ line.quantity }}</dd>
                <dt class="course-description sr">{% trans "Description:" %}</dt>
                <dd class="course-description">
                  <span>{{ line.description }}</span>
                  <p>{{ line.product.course.id|course_organization }}</p>
                </dd>
                <dt class="line-price sr">{% trans "Item Price:" %}</dt>
                <dd class="line-price price">{{ line.line_price_before_discounts_incl_tax|currency:order.currency }}</dd>
              </div>
            {% endfor %}
          </dl>
          <div class="order-total">
            <div class="description">{% trans "Subtotal:" %}</div>
            <div class="price">{{ order.total_before_discounts_incl_tax|currency:order.currency }}</div>
          </div>

          {% if order.total_discount_incl_tax %}
            {% for voucher in order.basket.vouchers.all %}
              <div class="order-total">
                <div class="description">
                  <span>{% trans "Coupon applied:" %}</span>
                  <p>
                    {% blocktrans with voucher_code=voucher.code voucher_discount_amount=voucher.benefit|benefit_discount %}
                      {{ voucher_code }} {{ voucher_discount_amount }} off
                    {% endblocktrans %}
                  </p>
                </div>
                <div class="price">
                  -{{ order.total_discount_incl_tax|currency:order.currency }}
                </div>
              </div>
            {% endfor %}
          {% endif %}

          <div class="order-total">
            <div class="description">{% trans "Total:" %}</div>
            <div class="price">{{ order.total_incl_tax|currency:order.currency }}</div>
          </div>
        </div>

        {% if display_credit_messaging %}
          {% captureas link_start %}
            <a href="{{ lms_dashboard_url }}">
          {% endcaptureas %}

          <div class="nav-wizard row">
            <p class="header">{% trans "Get Your Course Credit" %}</p>
            <p class="message">
              {% blocktrans with link_end="</a>" %}
                To receive academic credit for this course, you must apply for credit at the organization that offers the credit.
                You can find a link to the organization’s website on your {{ link_start }}dashboard{{ link_end }}, next to the course name.
              {% endblocktrans %}
            </p>
          </div>
        {% endif %}
      </div>

      {% if verified_course_id and not user_verified %}
        <div class="nav-wizard row">
            {% include 'oscar/checkout/_verification_data.html' with course_id=verified_course_id %}
        </div>
      {% else %}
        <div id="dashboard-link">
          <a class="dashboard-link nav-link" href="{{ lms_dashboard_url }}">
            {% trans "Go to Dashboard" %}
          </a>
        </div>
      {% endif %}
    </div>
  </div>
{% endblock content %}
