{% extends "cms/home.html" %}
{% load danceschool_tags crispy_forms_tags cms_tags i18n %}

{% block title %}{% trans "Complete Your Registration" %}{% endblock %}

{% block content %}

{# Display any warning or error messages associated with the previous form submission #}
<div id="message-alerts">
{% for message in messages %}
    <div class="alert {% if message.level == DEFAULT_MESSAGE_LEVELS.ERROR %}alert-danger{% elif message.level == DEFAULT_MESSAGE_LEVELS.WARNING %}alert-warning{% else %}alert-info{% endif %}">{{ message }}</div>
{% endfor %}
</div>

<div class="regsummary">
	{% block summary %}

	    <h2>
	    	{% blocktrans with name=registration.firstName %}
	    	Hi {{ name }}!
	    	{% endblocktrans %}
	    </h2>
	    
	    <p>{% trans "You are about to register for the following" %}:</p>

	    <table class="table classregsummary">
		    <tr>
		        <th>{% trans "Class/Event Name" %}</th>
		        <th>{% trans "Date(s)" %}</th>
		        <th>{% trans "Time" %}</th>
		        <th>{% trans "Role" %}</th>
		        <th>{% trans "Price" %}</th>
		    </tr>

		    {% for item in registration.temporaryeventregistration_set.all %}
		    <tr>
		        <td>{% if item.dropIn %}{% trans "DROP IN" %}: {% endif %}{{ item.event.name }}</td>
		        <td>
		        {% if item.event.eventoccurrence_set.count == 4 and not item.event.series.special %}
		        	{% blocktrans with weekday=item.event.startTime|date:"l" month=item.event.month|readable_month startTime=item.event.startTime|date:"F jS" %}
		        	{{ weekday }}s in {{ month }}, starting {{ startTime }}
		        	{% endblocktrans %}
		        {% else %}
		        	{% for occ in item.event.eventoccurrence_set.all reversed %}
		        		{{ occ.startTime|date:"D. F jS" }}{% if not forloop.last %}, {% endif %}
		        	{% endfor %}
		        {% endif %}
		        </td>
		        <td>{{ item.event.startTime|date:"P" }}</td>
		        <td>{{ item.role.name|default:"N/A" }}</td>
				<td>{{ currencySymbol }}{{ item.price|floatformat:"-2" }}</td>
		    </tr>
		    {% endfor %}
	    </table>

		{% if addonItems %}
		<p>
			{% for addon in addonItems %}
				<strong>{% trans "Free Add-On" %}:</strong>&nbsp;{{ addon.name }}
			{% endfor %}
		</p>
		{% endif %}

		<p>
			{% if total_discount_amount > 0 %}
				{% for code in discount_codes %}
					<strong>{% trans "Discount Code Applied" %}:</strong> {{ code.0 }}, {{ currencySymbol }}{{ code.2|floatformat:"-2" }}<br />
				{% endfor %}
				{% if discount_codes %}<br />{% endif %}

				{% if voucher_names %}
					<strong>{% trans "Vouchers Applied" %}:</strong> {{ voucher_names|join:", " }}<br /><br />
				{% endif %}

				<strong>{% trans "Total Discounts Applied" %}:</strong> {{ currencySymbol }}{{ total_discount_amount|floatformat:"-2" }} <br /><br />
			{% endif %}

			{# Add taxes if they are not included in the published price #}
			{% if taxes %}
				<strong>{% trans "Subtotal" %}:</strong> {{ currencySymbol }}{{ subtotal|floatformat:"-2" }}<br>			
				<strong>{% trans "Taxes" %}:</strong> {{ currencySymbol }}{{ taxes|floatformat:"-2" }}<br>
			{% endif %}

	        <div style="font-size: 1.2em;"><strong><em>{% trans "Total" %}:</em></strong> {{ currencySymbol }}{{ netPrice|floatformat:"-2" }}</div>
	    </p>

	{% endblock %}

	{% block payment_info %}

	    <p>
	     {% if is_free %}
	        {% trans "Thanks! You're all set." %}
	     {% else %}
		     {% trans "In order to complete your registration you must click on the button below to make a payment." %}</p>

		     {% if payAtDoor %}
		        <form action="" method="post">
		            {% crispy form %}
		        </form>
		     {% endif %}

		 	{% if payAtDoor %}
		 		<div class="card mt-4">
	 				<h6 class="card-header">{% trans "Immediate Payment" %}</h6>
		 			<div class="card-body">
		 	{% endif %}

		 	{% static_placeholder "registration_payment_placeholder" %}

		 	{% if payAtDoor %}
		 			</div>
	 			</div>
		 	{% endif %} 
	    {% endif %}

	{% endblock %}

	{% block disclaimer %}
		{% static_placeholder "registration_summary_disclaimer" %}
	{% endblock %}

</div>
{% endblock %}
