{% extends 'base.html.twig' %}
{% form_theme form 'default/form/theme.html.twig' %}

{% block meta_robots %}
    <meta name="robots" content="noindex,nofollow" />
    {% if app.debug %}<!-- meta-robots wurde durch das Twig-Seitentemplate festgelegt -->{% endif %}
{% endblock %}
{% block canonical_tag %}{% if app.debug %}<!-- Die canonical URL wird für diese Seite bewusst nicht definiert, da sie vom Suchindex ausgeschlossen wurde (Siehe meta robots) -->{% endif %}{% endblock %}

{% block stylesheets %}
    {{ parent() }}
    {% stylesheets 'bundles/app/css/booking.css' filter='cssrewrite' %}
        <link rel="stylesheet" href="{{ asset_url }}"/>
    {% endstylesheets %}
{% endblock %}

{% block javascripts %}
    {{ parent() }}
    {% javascripts '@AppBundle/Resources/public/js/booking.js' %}
        <script src="{{ asset_url }}"></script>
    {% endjavascripts %}
{% endblock %}

{% block body %}
    <section class="clearfix">

        <div class="content-copy">

            <h1>Buchungsformular</h1>

            <div class="pull-right">
                <a href="{{ page.urlPath }}" class="btn btn-primary btn-sm"><< zurück zu Termine und Preise</a>
            </div>
            <div class="clearfix"></div>

            <h2 style="margin-top:10px">{{ travel_program.title }}</h2>


            <div id="booking_form" class="booking_form">

                <form class="st-booking-form" method="post" data-toggle="validator">

                    {{ form_errors(form) }}

                      {{ form_errors(form.email) }}

                    <div id="message"></div>

                    <div class="form-box">
                        <div class="table-responsive" id="no-more-tables_first">
                            <table class="table first-table">
                                <tbody>
                                <tr>
                                    <td>Reiseprogramm</td>
                                    <td>
                                        {{ travel_program.title }}
                                        {#<br class="visible-xs"><a href="#" data-toggle="modal" data-target="#myModal">(Reisebeschreibung aufrufen)</a>#}
                                    </td>
                                </tr>
                                <tr>
                                    <td>Kategorie</td>
                                    <td>Standard {# #TODO #}</td>
                                </tr>
                                <tr>
                                    <td>Reisezeitraum</td>
                                    <td>{{ travel_date.start|date }} - {{ travel_date.end|date }} ({{ travel_date.name }})</td>
                                </tr>
                                <tr>
                                    <td>{{ form_label(form.departure, 'Abflugort') }}</td>
                                    <td>
                                        <div class="form-group" style="margin-bottom: 0px;">
                                            {{ form_widget(form.departure) }}
                                            {{ form_errors(form.departure) }}
                                            <div class="help-block with-errors"></div>
                                        </div>
                                    </td>
                                </tr>
                                {# TODO folgendes evtl noch weiter verallgemeinern #}
                                {% set priceTypeIds = [] %}
                                {% for price in travel_date.prices %}
                                    {% set priceTypeIds = priceTypeIds|merge([price.priceTypeId]) %}
                                {% endfor %}

                                {% if "1" in priceTypeIds %}
                                <tr>
                                {% else %}
                                <tr style="display:none">
                                {% endif %}
                                    <td>{{ form_label(form.singleRoomCount, 'Einzelzimmer') }}</td>
                                    <td>
                                        {{ form_widget(form.singleRoomCount) }}
                                        {{ form_errors(form.singleRoomCount) }}
                                    </td>
                                </tr>
                                {% if "3" in priceTypeIds %}
                                <tr>
                                {% else %}
                                <tr style="display:none">
                                {% endif %}
                                    <td>{{ form_label(form.doubleRoomCount, 'Doppelzimmer') }}</td>
                                    <td>
                                        {{ form_widget(form.doubleRoomCount) }}
                                        {{ form_errors(form.doubleRoomCount) }}
                                    </td>
                                </tr>

                                {% if "5" in priceTypeIds %}
                                <tr>
                                {% else %}
                                <tr style="display:none">
                                {% endif %}
                                    <td>{{ form_label(form.tripleRoomCount, 'Dreibettzimmer') }}</td>
                                    <td>
                                        {{ form_widget(form.tripleRoomCount) }}
                                        {{ form_errors(form.tripleRoomCount) }}
                                    </td>
                                </tr>
                        
                                <tr>
                                    <td>Zubuchbare Leistungen</td>
                                    <td>
                                        {% if form.comfort is defined %}
                                            <div class="checkbox">
                                                {{ form_widget(form.comfort) }}
                                                <label for="{{ form.comfort.vars.id }}">
                                                    Komfort-Kategorie (4 Sterne)
                                                    (<a href="#" data-toggle="modal" data-target="#st-comfort-booking-option-modal">Details</a>)
                                                </label>
                                                {% embed "default/components/embed/modal.html.twig" with {
                                                    'title': 'Komfort-Kategorie (4 Sterne)',
                                                    'id': 'comfort-booking-option'
                                                } %}
                                                    {% block body %}
                                                        <h4>Aufpreise für Kategorie</h4>
                                                        <ul>
                                                            {% for price in travel_date.prices %}
                                                                {# @var price \AppBundle\Entity\TravelPeriodPrice #}
                                                                <li>
                                                                    p.P. {{ price.effectiveComfortPrice|number_format(2) }} €
                                                                    {{ price_type_by_id[price.priceType.id].name }}
                                                                </li>
                                                            {% endfor %}
                                                        </ul>
                                                    {% endblock %}
                                                {% endembed %}
                                            </div>
                                        {% endif %}

                                        {% if form.travelOptions is defined %}
                                            {% for travelOptionForm in form.travelOptions %}
                                                {% include 'default/components/booking/travelOption.html.twig' with {
                                                    'travelOptionForm': travelOptionForm,
                                                    'travelOption': form.travelOptions.vars.choices[travelOptionForm.vars.value].data
                                                } %}
                                            {% endfor %}
                                        {% endif %}
                                    </td>
                                </tr>
                                <tr style="display:none">
                                    <td>Reiseversicherung</td>
                                    <td>
                                        <div class="radio">
                                            <input id="st-no-insurance-opt" type="radio" value=""
                                                   name="{{ form.insurance.vars.full_name }}"
                                                   {% if form.insurance.vars.value == '' %}checked{% endif %}
                                            >
                                            <label for="st-no-insurance-opt">keine Reiseversicherung</label>
                                        </div>

                                        {% for insuranceForm in form.insurance %}
                                            {% include 'default/components/booking/insurance.html.twig' with {
                                                'form': insuranceForm,
                                                'insurance': form.insurance.vars.choices[insuranceForm.vars.value].data
                                            } %}
                                        {% endfor %}

                                        {{ form_errors(form.insurance) }}
                                    </td>
                                </tr> 

                                <tr>
                                    <td>Reiseversicherung</td>
                                    <td>
                                     <p style="white-space: normal;">
                                        <br>
                                        STERN TOURS GmbH empfiehlt generell den Abschluss einer Reise-Rücktrittskosten-Versicherung und einer Auslands-Reisekrankenversicherung mit Rücktransport. Im Anschluss der Buchung senden wir Ihnen diesbezüglich Informationen zu.
                                    </p>
                                    </td>
                                </tr>


                                </tbody>
                            </table>
                        </div>

                        <div class="col-xs-12">
                            <div class="panel">
                                <div class="panel-body">
                                    <h3>Ihr gewähltes Angebot</h3>
                                    <div class="st-booking-summary">
                                        {% include 'default/components/booking/summary.html.twig' with {
                                            'summary': summary,
                                            'total_price': total_price
                                        } %}
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>

                    <div class="form-box">
                        <div class="">
                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <h5>Reiseleistungen</h5>
                            </div>

                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <div class="accordion-toggle-2">
                                    <div class="panel-group" id="accordion">
                                        <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapse1" aria-expanded="true">
                                            <h3><span>Reiseleistungen einblenden</span><i class="indicator pull-right icon-plus"></i></h3>
                                        </a>
                                        <div id="collapse1" class="panel-collapse collapse" aria-expanded="true" style="">
                                            <div class="panel-body">
                                                <h3>Eingeschlossene Leistungen</h3>
                                                <ul class="c1">
                                                    {% for travel_program_service in travel_program.included|replace({'*': '<img src="/bundles/app/images/star-mini.png" >'})|split('\n') %}
                                                        <li>{{ travel_program_service|raw }}</li>
                                                    {% endfor %}
                                                </ul>
                                                <h3>Nicht eingeschlossene / zubuchbare Leistungen</h3>
                                                <ul class="c1">
                                                    {% for travel_program_service in travel_program.excluded|split('\n') %}
                                                        <li>{{ travel_program_service|raw }}</li>
                                                    {% endfor %}
                                                </ul>
                                                <h3>Hinweise</h3>
                                                <ul class="c1">
                                                    {% for travel_program_service in travel_program.advices|split('\n') %}
                                                        <li>{{ travel_program_service|raw }}</li>
                                                    {% endfor %}
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div><!-- accordion -->
                        </div>
                    </div>
                    <div class="form-box">
                        <div class="">
                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <h5>Reiseanmelder</h5>
                            </div>

                            <div class="form-group col-md-12 col-sm-12 col-xs-12">
                                {{ form_field_pho(form.salutation, 'Anrede', {'label_attr': {class: 'sr-only'}}) }}
                            </div>

                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <div class="form-group">
                                     <div class="required">
                                        {{ form_field_pho(form.firstName, 'Vorname') }}
                                     </div>
                                      <div class="help-block with-errors"></div>
                                 </div>
                            </div>

                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <div class="form-group">
                                 <div class="required">
                                    {{ form_field_pho(form.lastName, 'Nachname') }}
                                 </div>
                                      <div class="help-block with-errors"></div>
                                 </div>
                            </div>

                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <div class="form-group">
                                 <div class="required">
                                    {{ form_field_pho(form.streetAddress, 'Straße, Hausnummer') }}
                                 </div>
                                      <div class="help-block with-errors"></div>
                                 </div>
                            </div>

                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <div class="form-group">
                                 <div class="required">
                                    {{ form_field_pho(form.zipCode, 'PLZ') }}
                                 </div>
                                      <div class="help-block with-errors"></div>
                                 </div>
                            </div>

                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <div class="form-group">
                                 <div class="required">
                                    {{ form_field_pho(form.city, 'Ort') }}
                                 </div>
                                      <div class="help-block with-errors"></div>
                                 </div>
                            </div>

                            <div class="form-group col-md-12 col-sm-12 col-xs-12">
                                {{ form_field_pho(form.nation, 'Land') }}
                            </div>

                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <div class="form-group">
                                 <div class="required">
                                    {{ form_field_pho(form.phone, 'Telefon tagsüber') }}
                                 </div>
                                      <div class="help-block with-errors"></div>
                                 </div>
                            </div>

                            <div class="col-md-6 col-sm-6 col-xs-12">
                                {{ form_field_pho(form.fax, 'Fax (optional)') }}
                            </div>

                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <div class="form-group">
                                 <div class="required">
                                    {{ form_field_pho(form.email, 'E-Mail-Adresse') }}
                                 </div>
                                      <div class="help-block with-errors"></div>
                                 </div>
                            </div>

                        </div>
                    </div><!-- end form-box -->

                    <div class="form-box">
                        <div class="">
                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <h5>Reiseteilnehmer</h5>
                                <p>Bitte geben Sie Ihre Vornamen und Nachnamen in die beiden Felder "Vornamen" und "Nachnamen" ein, wie diese im maschinenlesbaren Teil in Ihrem Reisepass eingetragen sind.</p>
                            </div>
                            <div class="col-md-12 col-sm-12 col-xs-12">

                                <div class="table-responsive" id="no-more-tables">
                                    <table class="table">
                                        <thead>
                                            <tr>
                                                <th>Zimmertyp</th>
                                                <th>Geschlecht</th>
                                                <th>Vorname</th>
                                                <th>Nachname</th>
                                                <th>Geburtsdatum</th>
                                            </tr>
                                        </thead>
                                        <tbody class="st-travelers">
                                            {% set currentIndex = 0 %}
                                            {% for room in form.rooms %}
                                                {% for traveler in room.travelers %}
                                                    {#{{ dump(room.vars.value.roomType) }}#}
                                                    {% set currentIndex = currentIndex + 1 %}
                                                    <tr class="st-traveler st-traveler-{{ currentIndex }}"
                                                        data-st-traveler-index="{{ currentIndex }}"
                                                        data-room-index="{{ loop.parent.loop.index }}"
                                                        data-room-type="{{ room.vars.value.type }}"
                                                        style="display: none;"
                                                    >
                                                        <td>
                                                            <button class="btn btn-primary btn-sm border-radius st-traveller-index"
                                                                    type="button"
                                                            >
                                                                {% set roomType = " " %}
                                                                {% if loop.parent.loop.index is not null %}
                                                                    {% if room.vars.value.type == "1" %}
                                                                        {% set roomType = "Einzelzimmer" %}
                                                                    {% elseif room.vars.value.type == "2" %}
                                                                        {% set roomType = "Doppelzimmer" %}
                                                                    {% elseif room.vars.value.type == "3" %}
                                                                        {% set roomType = "Dreibettzimmer" %}
                                                                    {% endif %}
                                                                {% endif %}
                                                                {{ roomType }}
                                                            </button>
                                                        </td>
                                                        <td>
                                                            {{ form_field_pho(traveler.sex, 'Geschlecht', {
                                                                required: false
                                                            }) }}
                                                        </td>
                                                        <td>
                                                            <div class="form-group" style="margin-bottom: 15px;">
                                                                <div class="required">
                                                                {{ form_field_pho(traveler.firstName, 'Vorname') }}
                                                                </div>
                                                            </div>
                                                        </td>
                                                        <td>
                                                           <div class="form-group" style="margin-bottom: 15px;">
                                                                <div class="required">
                                                                {{ form_field_pho(traveler.lastName, 'Nachname') }}
                                                                </div>
                                                            </div>
                                                        </td>
                                                        <td>
                                                            <div class="form-group" style="margin-bottom: 15px;">
                                                                <div class="required">
                                                                {{ form_field_pho(traveler.birthDate, 'Geburtsdatum') }}
                                                                </div>
                                                            </div>
                                                        </td>
                                                    </tr>

                                                {% endfor %}
                                            {% endfor %}
                                        </tbody>
                                    </table>
                                </div>

                            </div>
                        </div>
                    </div><!-- end form-box -->

                    <div class="form-box">
                        <div class="">
                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <h5>Mitteilungen / Sonstiges (optional)</h5>
                            </div>
                            <div class="col-md-12 col-sm-12 col-xs-12">
                                {{ form_field(form.notes, 'Mitteilungen / Sonstiges (optional)', {
                                    'label_attr': {'class': 'sr-only'},
                                    'attr': {'rows': '6'}
                                }) }}
                            </div>
                        </div>
                    </div><!-- end form-box -->

                   {# 
                    <div class="form-box">
                        <div class="">
                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <h5>Einreisebestimmungen</h5>
                                {% for country in travel_program.countries %}
                                 <h2>{{ country.name }}</h2>
                                    {{ country.entryRequirements|raw }}
                                {% endfor %}
                                <div class="form-group">
                                    <div class="checkbox">
                                        {{ form_widget(form.acceptEntryRequirements) }}
                                        <label for="{{ form.acceptEntryRequirements.vars.id }}">
                                            Bitte bestätigen Sie, dass die das gesetzliche Formblatt zur Kenntnis genommen haben.
                                        </label>
                                        {{ form_errors(form.acceptEntryRequirements) }}
                                         <div class="help-block with-errors"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>


                      <div class="form-box">
                        <div class="">
                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <h5>Reiseveranstalter</h5>
                                <p>{{ travel_program.organizer.name|raw }}</p>
                                <h5>Insolvensversicherer</h5>
                                <p>{{ travel_program.organizer.insolvency|raw }}</p>
                                <h5>gesetzliche Rechte</h5>
                                <p>{{ travel_program.organizer.legalRights|raw }}</p>
                                
                                 <div class="form-group">
                                     <div class="checkbox">
                                        {{ form_widget(form.acceptLegalRights) }}
                                        <label for="{{ form.acceptLegalRights.vars.id }}">
                                            Bitte bestätigen Sie, dass die das gesetzliche Formblatt zur Kenntnis genommen haben.
                                        </label>
                                        {{ form_errors(form.acceptLegalRights) }}
                                         <div class="help-block with-errors"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div> #}


                    <div class="form-box">
                        <div class="">
                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <h5>Zahlung</h5>
                                <p>Die gewünschte Zahlungsart (Rechnung, Überweisung, Sofortüberweisung, Kreditkarten,
                                    Barzahlung) stimmen wir mit Ihnen im Anschluss an Ihre Buchung ab.
                                </p>
                            </div>
                        </div>
                    </div>

                    <!-- end form-box -->

                    <div class="form-box">
                        <div class="">
                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <h5>Allgemeine Geschäftsbedingungen und Datenschutzerlärung</h5>
                                <div class="form-group">
                                <div class="checkbox">
                                    {{ form_widget(form.acceptTerms) }}
                                    <label for="{{ form.acceptTerms.vars.id }}">
                                        Ich habe alle Daten und Angaben auf Richtigkeit überprüft. Ich habe die
                                        <a href="/uploads/{{ travel_program.organizer.fileName }}" target="_blank">
                                            Allgemeinen Geschäftsbedingungen des Reiseveranstalters
                                        </a> {{ travel_program.organizer.name }}
                                        {% if travel_program.isMediated %}
                                            sowie die
                                            <a href="/uploads/{{ mediator_terms_filename }}" target="_blank">
                                                Allgemeinen Geschäftsbedingungen des Reisevermittlers
                                            </a>
                                        {% endif %}
                                        gelesen und akzeptiert. Zugleich erkenne ich diese für alle Reiseteilnehmer an.
                                    </label>
                                    {{ form_errors(form.acceptTerms) }}
                                     <div class="help-block with-errors"></div>
                                </div>
                                </div>

                                <div class="form-group">
                                <div class="checkbox">
                                    {{ form_widget(form.acceptPrivacy) }}
                                    <label for="{{ form.acceptPrivacy.vars.id }}">
                                       Hiermit willige ich in die im Rahmen der 
                                       <a href="/datenschutz" target="_blank">
                                            Datenschutzerklärung
                                        </a> genannte Datenverarbeitung ein.
                                    </label>
                                    {{ form_errors(form.acceptPrivacy) }}
                                     <div class="help-block with-errors"></div>
                                </div>
                                </div>

                            </div>
                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <button type="submit" value="SEND" id="submit"
                                        class="aligncenter btn btn-primary btn-lg border-radius"
                                >
                                    kostenpflichtig<br class="visible-xs"> buchen
                                </button>
                            </div>
                        </div>
                    </div><!-- end form-box -->

                  

                    {{ form_rest(form) }}
                </form>

            </div><!-- end contact-form -->

        </div>

    </section>
{% endblock body %}