<%inherit file="shopping_cart_flow.html" />
<%! from django.utils.translation import ugettext as _ %>
<%! from django.core.urlresolvers import reverse %>
<%!
from courseware.courses import course_image_url, get_course_about_section, get_course_by_id
%>

<%block name="billing_details_highlight">
% if order_type == 'business':
  <li>${_('Billing Details')}</li>
%endif
</%block>

<%block name="confirmation_highlight">class="active"</%block>

<%block name="custom_content">
<div class="container">
  <section class="notification">
    <h2>${_("Thank you for your Purchase!")}</h2>
    % if (len(shoppingcart_items) == 1 and order_type == 'personal') or receipt_has_donation_item:
      % for inst in instructions:
        <p>${inst}</p>
      % endfor
    % endif
  </section>
  <section class="wrapper confirm-enrollment shopping-cart print">
    <div class="gray-bg">
      <div class="message-left">
        <% courses_url = reverse('courses') %>
        % if order_type == 'personal':
           ## in case of multiple courses in single self purchase scenario,
           ## we will show the button View Dashboard
          % if len(shoppingcart_items) > 1 :
            <% dashboard_url = reverse('dashboard') %>
            <a href="${dashboard_url}" class="blue pull-right">${_("View Dashboard")} <i class="icon-caret-right"></i></a>
          % elif shoppingcart_items and shoppingcart_items[0][1]:
            <% course = shoppingcart_items[0][1] %>
            <% course_info_url = reverse('info', kwargs={'course_id': course.id.to_deprecated_string()}) %>
            <a href="${course_info_url}" class="blue pull-right">${_("View Course")} <i class="icon-caret-right"></i></a>
          %endif
          ${_("You have successfully been enrolled for <b>{appended_course_names}</b>. The following receipt has been emailed to"
          " <strong>{appended_recipient_emails}</strong>").format(appended_course_names=appended_course_names, appended_recipient_emails=appended_recipient_emails)}
        % elif order_type == 'business':
          % if total_registration_codes > 1 :
            <% code_plural_form = 'codes' %>
          % else:
            <% code_plural_form = 'code' %>
          % endif
          ${_("You have successfully purchased <b>{total_registration_codes} course registration codes</b> "
          "for <b>{appended_course_names}. </b>"
           "The following receipt has been emailed to <strong>{appended_recipient_emails}</strong>"
           ).format(total_registration_codes=total_registration_codes, appended_course_names=appended_course_names, appended_recipient_emails=appended_recipient_emails)}
        % endif

      </div>
    </div>
    % if order_type == 'business':
      <h3 class="text-center">${_("Please send each professional one of these unique registration codes to enroll into the course. The confirmation/receipt email you will receive has an example email template with directions for the individuals enrolling.")}.</h3>
      <table class="course-receipt">
        <thead>
        <th>${_("Course Name")}</th>
        <th>${_("Enrollment Code")}</th>
        <th>${_("Enrollment Link")}</th>
        </thead>
        <tbody>
        % for registration_code in registration_codes:
          <% course = get_course_by_id(registration_code.course_id, depth=0) %>
          <tr>
            <td>${_("{course_name}").format(course_name=course.display_name)}</td>
            <td>${registration_code.code}</td>

            <% redemption_url = reverse('register_code_redemption', args = [registration_code.code] ) %>
            <% enrollment_url = '{redemption_url}'.format(redemption_url=redemption_url) %>
            <td><a href="${redemption_url}">${enrollment_url}</a></td>
          </tr>
        % endfor
        </tbody>
      </table>
    %endif
    <div class="bordered-bar">
      <h2>${_('Invoice')} #${order.id}<span>${_('Date of purchase')}: ${order_purchase_date} </span><span
          class="pull-right"><a href="" onclick="window.print();" class="blue-link"><i class="icon-print"></i> ${_('Print Receipt')}</a></span>
      </h2>
    </div>
    % if order.total_cost > 0:
      <div class="pattern">
        <h2> ${_("Billed To Details")}: </h2>

        <div class="col-two no-border">
          % if order_type == 'business':
            <div class="row">
              <div class="row-inside">
                <p>
                  <b>${_('Company Name')}:</b>
                  <label>
                    % if order.company_name:
                      ${_("{company_name}").format(company_name=order.company_name)}
                    % else:
                      N/A
                    % endif
                  </label>
                </p>
              </div>
              <div class="row-inside">
                <p>
                  <b>${_('Purchase Order Number')}:</b>
                  <label>
                    % if order.customer_reference_number:
                      ${_("{customer_reference_number}").format(customer_reference_number=order.customer_reference_number)}
                    % else:
                      N/A
                    % endif
                  </label>
                </p>
              </div>
              <div class="row-inside">
                <p>
                  <b>${_('Company Contact Name')}:</b>
                  <label>
                    % if order.company_contact_name:
                      ${_("{company_contact_name}").format(company_contact_name=order.company_contact_name)}
                    % else:
                      N/A
                    % endif
                  </label>
                </p>
              </div>
              <div class="row-inside">
                <p>
                  <b>${_('Company Contact Email')}:</b>
                  <label>
                    % if order.company_contact_email:
                      ${ order.company_contact_email }
                    % else:
                      N/A
                    % endif
                  </label>
                </p>
              </div>
              <div class="row-inside">
                <p>
                  <b>${_('Recipient Name')}:</b>
                  <label>
                    % if order.recipient_name:
                      ${_("{recipient_name}").format(recipient_name=order.recipient_name)}
                    % else:
                      N/A
                    % endif
                  </label>
                </p>
              </div>
              <div class="row-inside">
                <p>
                  <b>${_('Recipient Email')}:</b>
                  <label>
                    % if order.recipient_email:
                      ${order.recipient_email}
                    % else:
                      N/A
                    % endif
                  </label>
                </p>
              </div>
            </div>
        %endif
          <div class="row">
            <div class="row-inside">
              <p>
                <b>${_('Card Type')}:</b>
                <label>
                  % if order.bill_to_cardtype:
                    ${order.bill_to_cardtype}
                  % else:
                    N/A
                  % endif
                </label>
              </p>
            </div>
            <div class="row-inside">
              <p>
                <b>${_('Credit Card Number')}:</b>
                <label>
                  % if order.bill_to_ccnum:
                    ${order.bill_to_ccnum}
                  % else:
                    N/A
                  % endif
                </label>
              </p>
            </div>
            <div class="row-inside">
              <p>
                <b>${_('Name')}:</b>
                <label>
                  % if order.bill_to_first or order.bill_to_last:
                    ${order.bill_to_first} ${order.bill_to_last}
                  % else:
                    N/A
                  % endif
                </label>
              </p>
            </div>
            <div class="row-inside">
              <p>
                <b>${_('Address 1')}:</b>
                <label>
                  % if order.bill_to_street1:
                    ${order.bill_to_street1}
                  % else:
                    N/A
                  % endif
                </label>
              </p>
            </div>
            <div class="row-inside">
              <p>
                <b>${_('Address 2')}:</b>
                <label>
                  % if order.bill_to_street2:
                    ${order.bill_to_street2}
                  % else:
                    N/A
                  % endif
                </label>
              </p>
            </div>
            <div class="row-inside">
              <p>
                <b>${_('City')}:</b>
                <label>
                  % if order.bill_to_city:
                    ${order.bill_to_city}
                  % else:
                    N/A
                  % endif
                </label>
              </p>
            </div>
            <div class="row-inside">
              <p>
                <b>${_('State')}:</b>
                <label>
                  % if order.bill_to_state:
                    ${order.bill_to_state}
                  % else:
                    N/A
                  % endif
                </label>
              </p>
            </div>
            <div class="row-inside">
              <p>
                <b>${_('Country')}:</b>
                <label>
                  % if order.bill_to_country:
                    ${order.bill_to_country.upper()}
                  % else:
                    N/A
                  % endif
                </label>
              </p>
            </div>
          </div>
        </div>
      </div>
    % endif
    <hr class="border"/>
    % for item, course in shoppingcart_items:
      % if loop.index > 0 :
        <hr>
      %endif
      <div class="user-data">
        <div class="clearfix">
          <div class="image">
            <img style="width: 100%; height: 100%;" src="${course_image_url(course)}"
                 alt="${course.display_number_with_default | h} ${get_course_about_section(course, 'title')} Image"/>
          </div>
          <div class="data-input">
            <h3>${_("Registration for")}:
              <span class="pull-right">
                <%
                    course_start_time = course.start_datetime_text()
                    course_end_time = course.end_datetime_text()
                %>
                % if course_start_time or course_end_time:
                  ${_("Course Dates")}:
                %endif
              </span>
            </h3>

            <h1>${_(" {course_name} ").format(course_name=course.display_name)}
              <span class="pull-right">
                % if course_start_time:
                  ${course_start_time}
                %endif
                -
                % if course_end_time:
                  ${course_end_time}
                %endif
              </span>
            </h1>
            <hr/>
            <div class="three-col">
              % if item.status == "purchased":
                <div class="col-1">
                  % if item.list_price != None:
                    <div class="price">${_('Price per student:')} <span class="line-through">  $${"{0:0.2f}".format(item.list_price)}</span>
                    </div>
                    <div class="price green">${_('Discount Applied:')} <span>  $${"{0:0.2f}".format(item.unit_cost)} </span></div>
                  % else:
                    <div class="price">${_('Price per student:')} <span>  $${"{0:0.2f}".format(item.unit_cost)}</span></div>
                  % endif
                </div>
                <div class="col-2">
                  <div class="numbers-row">
                    <label>${_("Students")}:</label>
                    <div class="counter no-border text-dark-grey">
                      ${item.qty}
                    </div>
                  </div>
                </div>
              % elif item.status == "refunded":
                <div class="col-1">
                  % if item.list_price != None:
                    <div class="price">${_('Price per student:')} <span class="line-through">  $${"{0:0.2f}".format(item.list_price)}</span>
                    </div>
                    <div class="price green">${_('Discount Applied:')} <span><del> $${"{0:0.2f}".format(item.unit_cost)}
                    </del></span></div>
                  % else:
                    <div class="price">${_('Price per student:')} <span><del> $${"{0:0.2f}".format(item.unit_cost)}</del></span>
                    </div>
                  % endif
                </div>
                <div class="col-2">
                  <div class="numbers-row">
                    <label>${_("Students")}:</label>
                    <div class="counter no-border">
                      <del>${item.qty}</del>
                    </div>
                  </div>
                </div>
              %endif
            </div>
          </div>
        </div>
      </div>
    % endfor
    <div class="discount">
      <div class="code-text">
        % if any_refunds:
          <span>
          ## Translators: Please keep the "<del>" and "</del>" tags around your translation of the word "this" in your translation.
            ${_("Note: items with strikethough like <del>this</del> have been refunded.")}
          </span>
        % endif
        <span class="pull-right">${_("Total")}: <b>$${"{0:0.2f}".format(order.total_cost)} USD</b></span>
      </div>
    </div>
  </section>
</div>
</%block>
