{# @var travel_program \AppBundle\Entity\TravelProgram #}
{% extends get_base_template() %}

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

{% block body %}

    <section class="clearfix">
        <div class="content-copy">

            <h1>{{ travel_program.title|default(page.pagetitle)|default(page.title) }}</h1>

            {#
                ********* SLIDER *********
            #}

            {% if travel_program.lowestPrice > 0 %}
                <div class="price-over-slider">
                    <div class="cprice">ab {{ travel_program.lowestPrice|number_format }} € p.P.</div>
                </div>
            {% endif %}

            <div class="pull-right btn-over-slider">
                <button type="button"
                        class="btn btn-primary btn-lg border-radius st-slider-booking-btn"
                        onclick=
                >
                    Jetzt Buchen
                </button>
            </div>

            <div class="pull-right btn-over-slider btn-over-slider-bottom">
                <a href="{{ page.slug }}/pdf" title="Reisebeschreibung als PDF herunterladen" class="btn btn-primary btn-lg border-radius st-slider-booking-btn st-slider-booking-btn-bottom" >
                    PDF herunterladen
                </a>
            </div>
            <section class="section fullscreen background padding-0 margin-bottom-20">
                <div id="myCarousel" class="carousel slide">
                    <!-- Indicators -->
                    <ol class="carousel-indicators">
                        <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
                        <li data-target="#myCarousel" data-slide-to="1"></li>
                        <li data-target="#myCarousel" data-slide-to="2"></li>
                    </ol>
                    <!-- Wrapper for Slides -->
                    <div class="carousel-inner">
                        {% for travel_program_image in travel_program.images %}
                            {# @var image \AppBundle\Entity\TravelProgramImage #}
                            <div class="item{% if loop.first %} active{% endif %}">
                                <!-- Set the first background image using inline CSS below. -->
                                {# TODO #}
                                <div class="fill" style="background-image:url('https://www.sterntours.de/uploads/travel_program/{{ travel_program_image.fileNameWithExtension }}');"></div>
                            </div>
                        {% endfor %}
                    </div>

                    <!-- Controls -->
                    <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
                        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                        <span class="sr-only">Previous</span>
                    </a>
                    <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
                        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                        <span class="sr-only">Next</span>
                    </a>

                </div>
            </section><!-- end section -->

            {#
                ********* TAB BAR *********
            #}

            {% block travel_program_tab_bar %}
                <div class="scroller-nav-tabs scroller-left-nav-tabs"><i class="glyphicon glyphicon-chevron-left"></i></div>
                <div class="scroller-nav-tabs scroller-right-nav-tabs"><i class="glyphicon glyphicon-chevron-right"></i></div>
                <div class="wrapper-nav-tabs">
                    <ul class="nav nav-tabs nav-justified list-nav-tabs">
                        <li class="active">
                            <a href="#travel-description-content-tab" aria-controls="travel-description-content-tab" role="tab" data-toggle="tab">
                                Reiseablauf
                            </a>
                        </li>
                        {% if travel_program.included is not empty or
                            travel_program.excluded is not empty or
                            travel_program.classDescription is not empty
                        %}
                            <li>
                                <a href="#travel-service-content-tab" aria-controls="travel-service-content-tab" role="tab" data-toggle="tab">
                                    Leistungen
                                </a>
                            </li>
                        {% endif %}
                        {% if travel_program.travelDates is not empty %}
                            <li>
                                <a href="#travel-dates-content-tab" aria-controls="travel-dates-content-tab" role="tab" data-toggle="tab">
                                    Termine <i class="fa fa-star"></i> Preise
                                </a>
                            </li>
                        {% endif %}
                        {% if travel_program.hasMap %}
                            <li>
                                <a href="#travel-map-content-tab" aria-controls="travel-map-content-tab" role="tab" data-toggle="tab">
                                    Karte
                                </a>
                            </li>
                        {% endif %}
                        <li>
                            <a href="#travel-info-content-tab" aria-controls="travel-info-content-tab" role="tab" data-toggle="tab">
                                Landinfos
                            </a>
                        </li>
                        {#<li><a href="#content_tab_07" aria-controls="content_tab_07" role="tab" data-toggle="tab">Team vor Ort</a></li>#}
                    </ul>
                </div>
            {% endblock travel_program_tab_bar %}

            <div class="tab-content">

                {#
                    ********* REISEABLAUF *********
                #}

                <div role="tabpanel" class="tab-pane active" id="travel-description-content-tab">
                    {{ travel_program.htmlDescription|raw|keywords }}

                    {% if travel_program.advices is not empty %}
                        <h3>Hinweise</h3>
                        <ul>
                            {% for travel_program_advice in travel_program.advices|trim|split('\n') %}
                                <li>{{ travel_program_advice|raw }}</li>
                            {% endfor %}
                        </ul>
                    {% endif %}

                </div> <!-- END tabpanel -->

                {#
                    ********* LEISTUNGEN *********
                #}

                <div role="tabpanel" class="tab-pane" id="travel-service-content-tab">

                    <h2>Eingeschlossene Leistungen</h2>
                    <ul>
                        {% 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>

                    {% if travel_program.classDescription is not empty %}
                        {{ travel_program.classDescription|replace({'*': '<img src="/bundles/app/images/star-mini.png" >'})|raw }}
                    {% endif %}

                    {% if travel_program.excluded is not empty %}
                        <h2>Nicht eingeschlossene / zubuchbare Leistungen</h2>
                        <ul>
                            {% for travel_program_service in travel_program.excluded|replace({'*': '<img src="/bundles/app/images/star-mini.png" >'})|split('\n') %}
                                <li>{{ travel_program_service|raw }}</li>
                            {% endfor %}
                        </ul>
                    {% endif %}

                </div>  <!-- END tabpanel -->

                {#
                    ********* TERMINE UND PREISE *********
                #}

                <div role="tabpanel" class="tab-pane" id="travel-dates-content-tab">

                    <h2>{{ travel_program.subtitle }}</h2>

                    <div class="table-responsive" id="no-more-tables">

                        {% if travel_program.travelDates is not empty %}
                            {% set has_three_bed_room = (travel_program.travelDates|first).prices[5] is defined %}

                            <table class="table">
                                <thead>
                                    <tr>
                                        <th>Nr.</th>
                                        <th>Beginn</th>
                                        <th>Ende</th>
                                        {% if has_three_bed_room %}<th>Preis p.P im Dreibettzimmer</th>{% endif %}
                                        <th>Preis p.P im Doppelzimmer</th>
                                        <th>Preis p.P im Einzelzimmer</th>
                                        <th>Abflugorte / Zuschläge</th>
                                        <th>Status</th>
                                        <th>Buchungsformular</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {% for travel_date in travel_program.travelDates if travel_date.status > 0 %}
                                        {# @var travel_date \AppBundle\Entity\TravelDate #}
                                        <tr>
                                            <td data-title="Nr."><strong class="small">{{ travel_date.name }}</strong></td>
                                            <td data-title="Beginn">{{ travel_date.start|date }}</td>
                                            <td data-title="Ende">{{ travel_date.end|date }}</td>
                                            {% if has_three_bed_room %}
                                                <td data-title="Preis p.P. im Dreibettzimmer">
                                                    {% if travel_date.prices[5] is defined %}
                                                        {% if travel_date.prices[5].effectiveDiscountPrice %}
                                                            <i class="icons-percent"></i>
                                                        {% endif %}
                                                        <span class="block">
                                                            <span class="{% if travel_date.prices[5].effectiveDiscountPrice %}old_price{% endif %}">
                                                                ab {{ travel_date.prices[5].effectivePrice|number_format }} €
                                                            </span>
                                                            {% if travel_date.prices[5].effectiveDiscountPrice %}
                                                                <span class="new_price">
                                                                    ab {{ travel_date.prices[5].effectiveDiscountPrice|number_format }} €
                                                                </span>
                                                            {% endif %}
                                                        </span>
                                                    {% endif %}
                                                </td>
                                            {% endif %}
                                            <td data-title="Preis p.P im Doppelzimmer">
                                                {% if travel_date.prices[3].effectiveDiscountPrice %}
                                                    <i class="icons-percent"></i>
                                                {% endif %}
                                                <span class="block">
                                                    <span class="{% if travel_date.prices[3].effectiveDiscountPrice %}old_price{% endif %}">
                                                        ab {{ travel_date.prices[3].effectivePrice|number_format }} €
                                                    </span>
                                                    {% if travel_date.prices[3].effectiveDiscountPrice %}
                                                        <span class="new_price">
                                                            ab {{ travel_date.prices[3].effectiveDiscountPrice|number_format }} €
                                                        </span>
                                                    {% endif %}
                                                </span>
                                            </td>
                                            <td data-title="Preis p.P im Einzelzimmer">
                                                {% if travel_date.prices[1].effectiveDiscountPrice %}
                                                    <i class="icons-percent"></i>
                                                {% endif %}
                                                <span class="block">
                                                    <span class="{% if travel_date.prices[1].effectiveDiscountPrice %}old_price{% endif %}">
                                                        ab {{ travel_date.prices[1].effectivePrice|number_format }} €
                                                    </span>
                                                    {% if travel_date.prices[1].effectiveDiscountPrice %}
                                                        <span class="new_price">
                                                            ab {{ travel_date.prices[1].effectiveDiscountPrice|number_format }} €
                                                        </span>
                                                    {% endif %}
                                                </span>
                                            </td>
                                            <td data-title="Abflugorte / Zuschläge">
                                                <a href="#" class="color-brand" data-toggle="modal" data-target="#st-departures-modal-{{ loop.index0 }}">
                                                    Flughäfen
                                                </a>

                                                {% include 'default/components/departuresModal.html.twig' with {
                                                    'departures': travel_date.departures,
                                                    'id': loop.index0
                                                } %}
                                            </td>
                                            <td data-title="Verfügbarkeit">
                                                <img src="/images/icons/available-{{ travel_date.effectiveStatus }}.png"
                                                     alt="Verfügbarkeit">
                                            </td>
                                            <td data-title="">
                                                <a href="{{ page.urlPath ~ '/buchen?nr=' ~ travel_date.name }}"
                                                   class="btn btn-primary"
                                                   rel="nofollow"
                                                >
                                                    Weiter
                                                </a>
                                            </td>
                                        </tr>
                                    {% endfor %}
                                </tbody>
                            </table>
                        {% else %}
                            Momentan sind für dieses Programm keine Termine verfügbar.
                        {% endif %}
                    </div>

                </div>  <!-- END tabpanel -->

                {#
                    ********* LANDKARTE *********
                #}

                {% if travel_program.hasMap %}
                    <div role="tabpanel" class="tab-pane" id="travel-map-content-tab">

                        {% if travel_program.mapHtml is not empty %}
                            {{ travel_program.mapHtml|raw|stripslashes }}
                        {% else %}
                                <img src="/uploads/maps/ {{ travel_program.mapImage ~ travel_program.mapImageExt }}" width="100%"
                                     alt="Karte zum Reiseablauf" class="img-responsive"
                                 >
                        {% endif %}

                    </div>  <!-- END tabpanel -->
                {% endif %}

                {#
                    ********* LANDINFOS *********
                #}

                <div role="tabpanel" class="tab-pane" id="travel-info-content-tab">

                    {% for country in travel_program.countries %}

                        <h2>{{ country.name }}</h2>
                        {{ country.htmlInformation|raw }}

                    {% endfor %}

                </div>  <!-- END tabpanel -->

            </div>

            {{ block('travel_program_tab_bar') }}
        </div>
    </section><!-- end section -->
{% endblock body %}