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

{% block body %}
    <section class="clearfix">
        <div class="content-copy">
            <h1>{{ lodging.name }} bearbeiten</h1>

            <form class="st-booking-form" method="post">

                {{ form_errors(form) }}

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

                <div class="form-box">

                    {{ form_row(form.name, {'label': 'Name'}) }}
                    {{ form_row(form.group, {'label': 'Gruppe'}) }}
                    {{ form_row(form.type, {'label': 'Typ'}) }}
                    {{ form_row(form.description, {'label': 'Beschreibung'}) }}
                    {{ form_row(form.equipment, {'label': 'Ausstattung'}) }}
                    {{ form_row(form.adress1, {'label': 'Adresse 1'}) }}
                    {{ form_row(form.adress2, {'label': 'Adresse 2'}) }}
                    {{ form_row(form.zipCode, {'label': 'PLZ'}) }}
                    {{ form_row(form.city, {'label': 'Ort'}) }}
                    {{ form_row(form.maximumPersons, {'label': 'Maximale Personenanzahl'}) }}
                    {{ form_row(form.deposit, {'label': 'Kaution'}) }}

                    {#
                    <div class="checkbox">
                        {{ form_widget(form.calendarVisible) }}
                        <label for="{{ form.calendarVisible.vars.id }}">
                            Kalender sichtbar
                        </label>
                        {{ form_errors(form.calendarVisible) }}
                    </div>
                    #}

                    <br><br>

                    <h3>Bilder</h3>
                    {% if lodging.images is not empty %}
                    <table class="table">
                        <thead>
                        <tr>
                            <th>Bild</th>
                            <th>Pos</th>
                            <th>Name</th>
                            <th>Beschreibung</th>
                            <th></th>
                        </tr>
                        </thead>
                        <tbody>
                            {% for image in lodging.images %}
                                <tr>
                                    <td><img src="{{ asset('uploads/images/' ~ image.file) }}" alt="{{ image.description }}" style="width:228px;height:75px;" ></td>
                                    <td>{{ image.pos }}</td>
                                    <td>{{ image.fileName }}</td>
                                    <td>{{ image.description }}</td>
                                    <td>
                                        <a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/images/' ~ image.id }}"
                                           class="btn btn-primary"
                                        >
                                            Bearbeiten
                                        </a>
                                        <a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/images/' ~ image.id ~ '/delete' }}"
                                           class="btn btn-primary"
                                        >
                                            Löschen
                                        </a>
                                    </td>
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                    {% else %}
                        <h4>Keine Bilder vorhanden</h4>
                    {% endif %}

                    <a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/images/new' }}" class="btn btn-primary">
                        Hinzufügen
                    </a>
                    <a href="/admin/fewo/lodgings/{{ lodging.id }}/images/multi-upload" class="btn btn-primary">
                        Mehrere Bilder hochladen
                    </a>

                    <br><br>

                    <h3>Saisons (Preise)</h3>

                    {% if lodging.prices is not empty %}
                    <table class="table">
                        <thead>
                        <tr>
                            <th>Name</th>
                            <th>Von</th>
                            <th>Bis</th>
                            <th>Mindestbelegung</th>
                            <th>Preis pro Nacht</th>
                            <th>Service-Gebühr</th>
                            <th></th>
                        </tr>
                        </thead>
                        <tbody>
                            {% for lodgingPrice in lodging.prices %}
                                <tr>
                                    <td>{{ lodgingPrice.season.name }}</td>
                                    <td>{{ lodgingPrice.season.fromDate|date('d.m.y') }}</td>
                                    <td>{{ lodgingPrice.season.toDate|date('d.m.y') }}</td>
                                    <td>{{ lodgingPrice.season.minimumStay }}</td>
                                    <td>{{ lodgingPrice.perNight }}</td>
                                    <td>{{ lodgingPrice.flatPrice }}</td>
                                    <td>
                                        <a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/prices/' ~ lodgingPrice.id }}"
                                           class="btn btn-primary"
                                           rel="nofollow"
                                        >
                                            Bearbeiten
                                        </a>
                                        <a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/prices/' ~ lodgingPrice.id ~ '/delete' }}"
                                           class="btn btn-primary"
                                           rel="nofollow"
                                        >
                                            Löschen
                                        </a>
                                    </td>
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                    {% else %}
                        <h4>Keine Saisons vorhanden</h4>
                    {% endif %}

                    <a href="/admin/fewo/lodgings/{{ lodging.id }}/prices/new"
                       class="btn btn-primary"
                       rel="nofollow"
                    >
                        Hinzufügen
                    </a>

                    <br><br>

                    <h3>Reservierungen</h3>

                    {% if lodging.reservations is not empty %}
                        <table class="table">
                            <thead>

                            <tr>
                                <th>Von</th>
                                <th>Bis</th>
                                <th>Status</th>
                                <th>Typ</th>
                                <th></th>
                            </tr>

                            </thead>
                            <tbody>

                            {% for lodgingReservation in lodging.reservations %}
                                <tr>
                                    <td>{{ lodgingReservation.fromDate|date('d.m.y') }}</td>
                                    <td>{{ lodgingReservation.toDate|date('d.m.y') }}</td>
                                    <td>
                                        {% if lodgingReservation.status == 0 %}
                                            belegt
                                        {% elseif lodgingReservation.status == 1 %}
                                            nicht verfügbar
                                        {% endif %}
                                    </td>
                                    <td>
                                        {% if lodgingReservation.type == 0 %}
                                            Buchung
                                        {% elseif lodgingReservation.type == 1 %}
                                            händisch
                                        {% endif %}
                                    </td>
                                    <td>
                                        <a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/reservations/' ~ lodgingReservation.id }}"
                                           class="btn btn-primary"
                                           rel="nofollow"
                                        >
                                            Bearbeiten
                                        </a>
                                        <a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/reservations/' ~ lodgingReservation.id ~ '/delete' }}"
                                           class="btn btn-primary"
                                           rel="nofollow"
                                        >
                                            Löschen
                                        </a>
                                    </td>
                                </tr>
                            {% endfor %}

                            </tbody>
                        </table>
                    {% else %}
                        <h4>Keine Reservierungen vorhanden</h4>
                    {% endif %}

                    {% if lodging.prices is not empty %}
                        <a href="/admin/fewo/lodgings/{{ lodging.id }}/reservations/new"
                           class="btn btn-primary"
                           rel="nofollow"
                        >
                            Hinzufügen
                        </a>
                    {% else %}
                        <h4>Mindestens eine Saison pflegen.</h4>
                    {% endif %}

                    <br><br>

                    <h1>Verfügbarkeit</h1>

                    {% include 'default/admin/lodgingsEditCalendar.html.twig' %}

                    <br>

                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <button type="submit" value="SEND" id="submit"
                                class="btn btn-primary btn-lg border-radius"
                        >
                            Speichern
                        </button>
                    </div>
                </div><!-- end form-box -->
                {{ form_rest(form) }}
            </form>
            <a href="/admin/fewo/lodgings"
               class="btn btn-primary"
               rel="nofollow"
            >
                Zurück
            </a>
        </div>
    </section><!-- end section -->
{% endblock body %}