<%inherit file="shopping_cart_flow.html" />
<%!
from django.utils.translation import ugettext as _
from django.utils.translation import ungettext
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="wrapper confirm-enrollment shopping-cart print">
    <div class="gray-bg">
      <div class="message-left">
        <% courses_url = reverse('courses') %>
        % if receipt_has_donation_item:
          <b>${_("Thank you for your purchase!")}</b>
          % for inst in instructions:
            ${inst}
          % endfor
        % elif order_type == 'personal':
           ## in case of multiple courses in single self purchase scenario,
           ## we will show the button View Dashboard
          <% dashboard_url = reverse('dashboard') %>
          <a href="${dashboard_url}" class="blue pull-right">${_("View Dashboard")} <i class="icon-caret-right"></i></a>
          <span class="mt-7">
            ${_(u"You have successfully been enrolled for {course_names}. "
                u"The following receipt has been emailed to {receipient_emails}").format(
                  course_names=u"<b>{course_names}</b>".format(
                    course_names=appended_course_names
                  ),
                  receipient_emails=u"<strong>{receipient_emails}</strong>".format(
                    receipient_emails=appended_recipient_emails
                  ),
            )}
          </span>
        % elif order_type == 'business':
          ${ungettext(
            "You have successfully purchased <b>{number} course registration code</b> for {course_names}.",
            "You have successfully purchased <b>{number} course registration codes</b> for {course_names}.",
            total_registration_codes
          ).format(
            number=total_registration_codes,
            course_names=u"<b>{course_names}</b>".format(
              course_names=appended_course_names
            )
          )}
          ${_("The following receipt has been emailed to {receipient_emails}").format(
            receipient_emails=u"<strong>{receipient_emails}</strong>".format(
              receipient_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>
        <th>${_("Status")}</th>
        </thead>
        <tbody>
        % for reg_code_info in reg_code_info_list:
          <tr>
            <td>${reg_code_info['course_name']}</td>
            <td>${reg_code_info['code']}</td>
            % if reg_code_info['is_redeemed']:
            <td>${reg_code_info['redemption_url']}</td>
            % else:
            <td><a href="${reg_code_info['redemption_url']}" data-base-url="${site_name}">${reg_code_info['redemption_url']}</a></td>
            % endif
            <td>
              % if reg_code_info['is_redeemed']:
                <span class="red"></M>${_("Used")}</span>
              % else:
                <span class="green"></M>${_("Available")}</span>
              % endif
            </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:
                      ${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:
                      ${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:
                      ${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:
                      ${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">  ${currency_symbol}${"{0:0.2f}".format(item.list_price)}</span>
                    </div>
                    <div class="price green">${_('Discount Applied:')} <span>   ${currency_symbol}${"{0:0.2f}".format(item.unit_cost)} </span></div>
                  % else:
                    <div class="price">${_('Price per student:')} <span>  ${currency_symbol}${"{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">   ${currency_symbol}${"{0:0.2f}".format(item.list_price)}</span>
                    </div>
                    <div class="price green">${_('Discount Applied:')} <span><del>  ${currency_symbol}${"{0:0.2f}".format(item.unit_cost)}
                    </del></span></div>
                  % else:
                    <div class="price">${_('Price per student:')} <span><del>  ${currency_symbol}${"{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> ${currency_symbol}${"{0:0.2f}".format(order.total_cost)}  ${currency.upper()}</b></span>
      </div>
    </div>
  </section>
</div>
</%block>
