{% extends layout ? layout : 'layout.mail.twig' %}

{% block title %}Neue Buchung auf lernwerk.de{% endblock %}

{% block body %}
{#<span class="preheader">This is preheader text. Some clients will show this text as a preview.</span>#}
<table class="main">

  <!-- START MAIN CONTENT AREA -->
  <tr>
	<td class="wrapper">
	  <table border="0" cellpadding="0" cellspacing="0">
		<tr>
		  <td>
			Zusammenfassung der Buchung:
		  </td>
		</tr><tr>
			<td>
				<h2>Kursdaten</h2>
				{% for course in model.courses|slice(0, 1) -%}
					{%- if course.veranstaltungsreihe is not empty -%}
						<p>Veranstaltung: {{ course.veranstaltungsreihe.title }}</p>
					{%- endif -%}
				{%- endfor %}

				{% for course in model.courses %}
					<p>Kurs: {{ course.title }}</p>
					<p>Six-Id: {{ course.id }}</p>
					<p>Buchung-Nr.: {{ order.id }}</p>

					{%- set info = course -%}
					{%- if course.veranstaltungsreihe is not empty -%}
						{%- set info = course.veranstaltungsreihe -%}
					{%- endif -%}

					{% if info.link_standort.title is not empty -%}
						<p>Standort: {{ info.link_standort.title }}</p>
					{%- endif %}

					<p>Termin: {{ info.text_termin }}{% if info.text_termin_opt is not empty %} {{ info.text_termin_opt }}{% endif %}</p>

					{% if ( 1 * info.period_start|date('Y') ) > 2000 -%}
						<p>Zeitraum: {{ info.period_start | date('d.m.Y') }}{% if ( 1 * info.period_end|date('Y') ) > 2000 %} - {{ info.period_end | date('d.m.Y') }}{% endif %}</p>
					{%- endif %}

					{% if info.text_period is not empty -%}
						<p>{{ info.text_period }}</p>
					{%- endif %}

					{% if course.bemerkungen is not empty -%}
						{{ course.bemerkungen | raw }}
					{%- endif %}

					{%- if model.order.options is not empty -%}
						<p>Gebuchte Optionen:<br />
							{%- for option_id in model.order.options -%}
								{% set addBreak = true %}
								{% if loop.last == true %}
									{% set addBreak = false %}
								{% endif %}

								{{ course.link_kursvorlage.rel_kurs_optionen[option_id].title }}{% if addBreak == true %}<br />{% endif %}

								{%- if course.link_kursvorlage.link_kurs_optionen is not empty -%}
									{% for id,optionGroup in course.link_kursvorlage.link_kurs_optionen %}
										{% if optionGroup.link_kurs_options_felder is not empty %}
											{% if optionGroup.link_kurs_options_felder[option_id] is not empty %}
												{{- optionGroup.link_kurs_options_felder[option_id].title -}}{% if addBreak == true %}<br />{% endif %}
											{% endif %}
										{% endif %}
									{% endfor %}
								{%- endif -%}
							{%- endfor -%}
						</p>
					{%- endif -%}
				{% endfor %}
			</td>
		</tr>
		{%- if model.coupon_string is not empty -%}
			<tr>
				<td>
					<h2>Coupon Codes</h2>
					<p>{{ model.coupon_string|replace({', ': '<br />'})|raw }}</p>
				</td>
			</tr>
		{%- endif -%}
		<tr>
			<td>
				<h2>Preis &amp; Rabattcode</h2>
				{% set hasMonthly = false %}
				{% set hasCode = false %}
				{% for preis in model.order.preis %}
					{% if preis.preis_intervall is same as('monatlich') %}
						{% set hasMonthly = true %}
					{% endif %}
				{% endfor %}
				{% if model.order.preis_rabatt is not empty %}
					{% set hasCode = true %}
				{% endif %}

				{% for preis in model.order.preis %}
					{% if hasCode %}
						{% if preis.preis_intervall is same as('monatlich') %}
							{# mit gutschein code, monatlich #}
							{% set rabatPreisMonatlich = (preis.preis * 0.01) - model.order.preis_rabatt %}
							<p class="order-price-label"><span class="price">{{ rabatPreisMonatlich|number_format(0, ',', '.') }} € in den ersten 10 Monaten, {{ (preis.preis * 0.01)|number_format(0, ',', '.') }} € für Folgemonate</span></p>
							<p class="order-price-discount" style="font-style: italic;">{{ 'Sie erhalten jweils %value% € Rabatt auf die ersten 10 Monatsbeiträge.'|replace({'%value%':model.order.preis_rabatt}) }}</p>
							{% set hasCode = false %}
						{% elseif preis.preis_intervall is same as('einmalig') and not hasMonthly %}
							{# mit gutschein code, einmalig, ohne monatlich #}
							{% set rabatPreisEinmalig = (preis.preis * 0.01) - model.order.preis_rabatt %}
							<p class="order-price-label"><span class="price">{{ rabatPreisEinmalig|number_format(0, ',', '.') }} € statt <span style="text-decoration: line-through;">{{ (preis.preis * 0.01)|number_format(0, ',', '.') }} €</span></span> {{ preis.preis_intervall }}</p>
							<p class="order-price-discount" style="font-style: italic;">{{ 'Sie erhalten einmalig %value% € Rabatt auf ihre Bestellung.'|replace({'%value%':model.order.preis_rabatt}) }}</p>
							{% set hasCode = false %}
						{% else %}
							{# mit gutschein code, einmalig, mit monatlich #}
							<p class="order-price-label"><span class="price">{{ (preis.preis * 0.01)|number_format(0, ',', '.') }} €</span> {{ preis.preis_intervall }}</p>
						{% endif %}
					{% else %}
						{# ohne gutschein code, einmalig oder monatlich #}
						<p class="order-price-label"><span class="price">{{ (preis.preis * 0.01)|number_format(0, ',', '.') }} €</span> {{ preis.preis_intervall }}</p>
					{% endif %}
				{% endfor %}
				{% if model.order.preis_rabatt is not empty and model.order.rcode is not empty %}
					<p class="order-price-discount">Eingesetzter Gutscheincode: {{ model.order.rcode }}</p>
				{% endif %}
			</td>
		</tr><tr>
			<td>
				<h2>Teilnehmer / Schüler</h2>
				<p>Vorname: {{ model.participator.vorname | raw }}</p>
				<p>Nachname: {{ model.participator.name | raw }}</p>
				<p>Geburtstag: {{ model.participator.geburtsdatum | date('d.m.Y') }}</p>
				<p>Klasse: {{ model.participator.klasse }}</p>
				<p>Schule: {{ model.participator.schule | raw }}</p>
				<p>Schulart: {{ model.participator.schulart }}</p>
				<p>Six-Id: {{ model.participator.id }}</p>
			</td>
		</tr><tr>
			<td>
				<h2>Angemeldet durch</h2>
				<p>Anrede: {{ model.user.anrede }}</p>
				<p>Vorname: {{ model.user.vorname | raw }}</p>
				<p>Nachname: {{ model.user.name | raw }}</p>
				<p>Telefon: {{ model.user.telefon }}</p>
				<p>Mobil: {{ model.user.mobil }}</p>
				<p>E-Mail: {{ model.user.user_email }}</p>
				<p>Straße &amp; Nr.: {{ model.user.strasse | raw }}</p>
				<p>Postleitzahl: {{ model.user.plz }}</p>
				<p>Ort: {{ model.user.ort | raw }}</p>
				<p>Six-Id: {{ model.user.id }}</p>
				<p>Bisherige Buchungen: {{ model.user.orders }}</p>
			</td>
		</tr><tr>
			<td>
				<h2>Einzugsermächtigung</h2>
				<p>Konto Besitzer: {{ model.payment.kontoinhaber | raw }}</p>
				<!--<p>IBAN: {{ model.payment.iban }}</p>-->
				<p>IBAN (gekürzt): {{ model.payment.iban_last }}</p>
				{% if model.order.payment == 'new' -%}
				<p>Konto wurde neu angelegt.</p>
				{%- endif %}
			</td>
		</tr><tr>
			<td>
				<h2>Weitere Angaben</h2>
				<p>Bemerkungen: {{ model.order.bemerkungen }}</p>
			</td>
		</tr>
	  </table>
	</td>
  </tr>

<!-- END MAIN CONTENT AREA -->
</table>
{% endblock %}
