{% 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">

                    <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>


                    <style>
                        .table > tbody > tr > td.normal {
                            background-color: #deebde;
                            padding: 6px;

                        }
                        .table > tbody > tr > td.calendar-day-non {
                            background-color: #fff;
                        }
                        .table > tbody > tr > td.calendar-day-past {
                            background-color: rgba(242, 242, 242, 0.5);
                        }
                        .table > tbody > tr > td.calendar-light {
                            opacity: 0.5;
                        }
                        .table > tbody > tr > td.calendar-day-disabled-half {
                            /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#f0bcbc+49,f2f2f2+50,f0bcbc+51 */
                            background: #f0bcbc; /* Old browsers */
                            background: -moz-linear-gradient(-35deg, #f0bcbc 49%, #f2f2f2 50%, #f0bcbc 51%); /* FF3.6-15 */
                            background: -webkit-linear-gradient(-35deg, #f0bcbc 49%,#f2f2f2 50%,#f0bcbc 51%); /* Chrome10-25,Safari5.1-6 */
                            background: linear-gradient(145deg, #f0bcbc 49%,#f2f2f2 50%,#f0bcbc 51%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
                            filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f0bcbc', endColorstr='#f0bcbc',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
                        }
                        .table > tbody > tr > td.calendar-day-disabled-half-booked {
                            /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#f0bcbc+49,f2f2f2+50,f0bcbc+51 */
                            background: #f0bcbc; /* Old browsers */
                            background: -moz-linear-gradient(-35deg, #f0bcbc 49%, #f2f2f2 50%, #C5DCC6 51%); /* FF3.6-15 */
                            background: -webkit-linear-gradient(-35deg, #f0bcbc 49%,#f2f2f2 50%,#C5DCC6 51%); /* Chrome10-25,Safari5.1-6 */
                            background: linear-gradient(145deg, #f0bcbc 49%,#f2f2f2 50%,#C5DCC6 51%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
                            filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f0bcbc', endColorstr='#C5DCC6',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
                        }
                        .table > tbody > tr > td.calendar-day-disabled-half-booked.active {
                            /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#f0bcbc+49,f2f2f2+50,f0bcbc+51 */
                            background: #f0bcbc; /* Old browsers */
                            background: -moz-linear-gradient(-35deg, #f0bcbc 49%, #f2f2f2 50%, #b7ceb8 51%); /* FF3.6-15 */
                            background: -webkit-linear-gradient(-35deg, #f0bcbc 49%,#f2f2f2 50%,#b7ceb8 51%); /* Chrome10-25,Safari5.1-6 */
                            background: linear-gradient(145deg, #f0bcbc 49%,#f2f2f2 50%,#b7ceb8 51%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
                            filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f0bcbc', endColorstr='#b7ceb8',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
                        }
                        .table > tbody > tr > .calendar-day-reservation-begin {
                            background-color: #f0bcbc;
                            background: -moz-linear-gradient(to bottom right, #deebde 0%, #deebde 49%, #f0bcbc 50%, #f0bcbc 100%);
                            background: -webkit-gradient(linear, left top, right bottom, color-stop(0%, #deebde), color-stop(49%, #deebde), color-stop(50%, #f0bcbc), color-stop(100%, #f0bcbc));
                            background: -webkit-linear-gradient(to bottom right, #deebde 0%, #deebde 49%, #f0bcbc 50%, #f0bcbc 100%);
                            background: -o-linear-gradient(to bottom right, #deebde 0%, #deebde 49%, #f0bcbc 50%, #f0bcbc 100%);
                            background: -ms-linear-gradient(to bottom right, #deebde 0%, #deebde 49%, #f0bcbc 50%, #f0bcbc 100%);
                            background: linear-gradient(to bottom right, #deebde 0%, #deebde 49%, #f0bcbc 50%, #f0bcbc 100%);
                        }
                        .table > tbody > tr > .calendar-day-reservation-end {
                            background-color: #f2f2f2;
                            background: -moz-linear-gradient(to bottom right, #f0bcbc 0%, #f0bcbc 49%, #deebde 50%, #deebde 100%);
                            background: -webkit-gradient(linear, left top, right bottom, color-stop(0%, #f0bcbc), color-stop(49%, #f0bcbc), color-stop(50%, #deebde), color-stop(100%, #deebde));
                            background: -webkit-linear-gradient(to bottom right, #f0bcbc 0%, #f0bcbc 49%, #deebde 50%, #deebde 100%);
                            background: -o-linear-gradient(to bottom right, #f0bcbc 0%, #f0bcbc 49%, #deebde 50%, #deebde 100%);
                            background: -ms-linear-gradient(to bottom right, #f0bcbc 0%, #f0bcbc 49%, #deebde 50%, #deebde 100%);
                            background: linear-gradient(to bottom right, #f0bcbc 0%, #f0bcbc 49%, #deebde 50%, #deebde 100%);
                        }

                        .table > tbody > tr > td.active {
                            background-color: rgba(88, 155, 92, 0.35);
                            padding: 6px;

                        }
                        .table > tbody > tr > td.active:hover {
                            background-color: #648859;
                        }

                        .table > tbody > tr > td a.link {
                            color: #5a5a5a;
                            font-weight: 700;
                            width: 100%;
                            display: block;
                            height: 100%;
                           // padding: 6px;
                            text-decoration: underline;
                        }

                        .table > tbody > tr > td:hover a.link {
                            color: #fff;
                            font-weight: 700;
                            width: 100%;
                            display: block;
                            height: 100%;
                        }
                        .table > tbody > tr > td a.link {
                            font-weight: 700;
                            width: 100%;
                            display: block;
                            height: 100%;
                          //  padding: 6px;
                        }



                    </style>


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

                    <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 %}
                                {% if lodgingPrice.season is not empty %}

                                    <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>
                                {% endif %}

                            {% 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>
                    <hr>

                    <br><br>

                    {{ 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>
                    #}


                    <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>
                    <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>



                </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 %}