diff --git a/trunk/app/Resources/views/admin.html.twig b/trunk/app/Resources/views/admin.html.twig new file mode 100644 index 00000000..6768b1a7 --- /dev/null +++ b/trunk/app/Resources/views/admin.html.twig @@ -0,0 +1,128 @@ + +{% if app.debug -%} + +{%- endif %} + + + + + + + + + {% block page_title %} + FeWo-Adminbereich + {% endblock page_title %} + + + + + + + + + {% block stylesheets %} + {% stylesheets + 'bundles/app/css/bootstrap-3.3.7.css' + filter='cssrewrite' + %} + + {% endstylesheets %} + {% stylesheets + 'bundles/app/css/custom.css' + filter='cssrewrite' + %} + + {% endstylesheets %} + {# TODO Move to custom.css #} + {% endblock stylesheets %} + + + + + + +
+
+ +
+ + +
+
+
+
+ + +
+ +
+ {% block body %} +
+
+

Sterntours - Adminbereich

+
+
+ {% endblock %} +
+ +
+ + +
+
+
+
+ + {#{% include 'default/components/footer.html.twig' %}#} + +
+ + +{#{% embed 'default/components/embed/modal.html.twig' with {id: 'default'} %}{% endembed %}#} + +{#TODO ausmisten und im gleichen zuge das CSS für den Datepicker einfügen#} +{% block javascripts %} + + {% javascripts + '@AppBundle/Resources/public/js/jquery-3.1.1.js' + '@AppBundle/Resources/public/js/jquery-ui-1.12.1.js' + '@AppBundle/Resources/public/js/bootstrap-3.3.7.js' + '@AppBundle/Resources/public/js/jquery.prettyPhoto-3.1.6.js' + '@AppBundle/Resources/public/js/parallax.js' + '@AppBundle/Resources/public/js/owl.carousel-2.2.0.js' + '@AppBundle/Resources/public/js/bootstrap-select-1.12.0.js' + '@AppBundle/Resources/public/js/custom.js' + %} + + {% endjavascripts %} +{% endblock javascripts %} + + + diff --git a/trunk/app/Resources/views/default/admin/imagesNew.html.twig b/trunk/app/Resources/views/default/admin/imagesNew.html.twig new file mode 100644 index 00000000..c526a013 --- /dev/null +++ b/trunk/app/Resources/views/default/admin/imagesNew.html.twig @@ -0,0 +1,38 @@ +{% extends 'admin.html.twig' %} +{% form_theme form 'default/form/theme.html.twig' %} + +{% block body %} +
+
+

Neues Bild für "{{ lodging.name }}" anlegen

+ +
+ + {{ form_errors(form) }} + +
+ +
+ {{ form_row(form.file, {label: 'Bild'}) }} + {{ form_row(form.fileName, {label: 'Name'}) }} + {{ form_row(form.description, {label: 'Beschreibung'}) }} + +
+ +
+
+ {{ form_rest(form) }} +
+ + Zurück + +
+
+{% endblock body %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/admin/lodgings.html.twig b/trunk/app/Resources/views/default/admin/lodgings.html.twig new file mode 100644 index 00000000..ccbd0660 --- /dev/null +++ b/trunk/app/Resources/views/default/admin/lodgings.html.twig @@ -0,0 +1,63 @@ +{% extends 'admin.html.twig' %} + + +{% block body %} +
+
+

Objekte

+ +
+ + + + + + + + + + + + {% if lodgings is not empty %} + {% for lodging in lodgings %} + + + + + + + {% endfor %} + {% else %} +

Keine Objekte verfügbar

+ {% endif %} + + + + + + +
IDNameTypObjekt
{{ lodging.id }}{{ lodging.name }}{{ lodging.type }} + + Bearbeiten + + + Löschen + +
+ + Hinzufügen + +
+
+
+
+{% endblock body %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/admin/lodgingsEdit.html.twig b/trunk/app/Resources/views/default/admin/lodgingsEdit.html.twig new file mode 100644 index 00000000..a405f4c4 --- /dev/null +++ b/trunk/app/Resources/views/default/admin/lodgingsEdit.html.twig @@ -0,0 +1,231 @@ +{% extends 'admin.html.twig' %} +{% form_theme form 'default/form/theme.html.twig' %} + +{% block body %} +
+
+

{{ lodging.name }} bearbeiten

+ +
+ + {{ form_errors(form) }} + +
+ +
+ + {{ form_row(form.name, {'label': 'Name'}) }} + {{ 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'}) }} + {{ form_row(form.onlyWeekday, {'label': 'Exklusiver Wochentag'}) }} + +
+ {{ form_widget(form.calendarVisible) }} + + {{ form_errors(form.calendarVisible) }} +
+ +

+ +

Bilder

+ {% if lodging.images is not empty %} + + + + + + + + + + + {% for image in lodging.images %} + + + + + + + {% endfor %} + +
BildNameBeschreibung
{{ image.description }}{{ image.fileName }}{{ image.description }} + + Löschen + +
+ {% else %} +

Keine Bilder vorhanden

+ {% endif %} + + + Hinzufügen + + +

+ +

Saisons (Preise)

+ + {% if lodging.prices is not empty %} + + + + + + + + + + + + + + {% for lodgingPrice in lodging.prices %} + + + + + + + + + + {% endfor %} + +
NameVonBisMindestbelegungPreis pro NachtPauschalpreis
{{ lodgingPrice.season.name }}{{ lodgingPrice.season.fromDate|date('d-m-y') }}{{ lodgingPrice.season.toDate|date('d-m-y') }}{{ lodgingPrice.season.minimumStay }}{{ lodgingPrice.perNight }}{{ lodgingPrice.flatPrice }} + + Bearbeiten + + + Löschen + +
+ {% else %} +

Keine Saisons vorhanden

+ {% endif %} + + + Hinzufügen + + +

+ +

Reservierungen

+ + {% if lodging.reservations is not empty %} + + + + + + + + + + + + + + + {% for lodgingReservation in lodging.reservations %} + + + + + + + + {% endfor %} + + +
VonBisStatusTyp
{{ lodgingReservation.fromDate|date('d-m-y') }}{{ lodgingReservation.toDate|date('d-m-y') }} + {% if lodgingReservation.status == 0 %} + belegt + {% elseif lodgingReservation.status == 1 %} + nicht verfügbar + {% endif %} + + {% if lodgingReservation.type == 0 %} + Buchung + {% elseif lodgingReservation.type == 1 %} + händisch + {% endif %} + + + Bearbeiten + + + Löschen + +
+ {% else %} +

Keine Reservierungen vorhanden

+ {% endif %} + + {% if lodging.prices is not empty %} + + Hinzufügen + + {% else %} +

Mindestens eine Saison pflegen.

+ {% endif %} + +

+ +

Verfügbarkeit

+ + {% include 'default/admin/lodgingsEditCalendar.html.twig' %} + +
+ +
+ +
+
+ {{ form_rest(form) }} +
+ + Zurück + +
+
+{% endblock body %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/admin/lodgingsEditCalendar.html.twig b/trunk/app/Resources/views/default/admin/lodgingsEditCalendar.html.twig new file mode 100644 index 00000000..481ccf55 --- /dev/null +++ b/trunk/app/Resources/views/default/admin/lodgingsEditCalendar.html.twig @@ -0,0 +1,100 @@ + + {% for month in calendar %} + + + + + + + + + + + + + + + + + {% for weekIndex in 0..5 %} + + {% for dayIndex in 0..6 %} + {% set day = month['data'][(weekIndex * 7) + dayIndex]|split(',') %} + {% if day|length > 1 %} + {% if day[1] == 'reservable' %} + + {% else %} + {% if day|length > 3%} + + {% elseif day|length > 2 and day[2] == 'from' %} + + {% elseif day|length > 2 and day[2] == 'to' %} + + {% else %} + + {% endif %} + {% endif %} + {% else %} + + {% endif %} + {% endfor %} + + {% endfor %} + + {% endfor %} +
+ {{ month['monthName'] }} {{ month['year'] }} +
MoDiMiDoFrSaSo
+ + {{ day[0] }} + + + + {{ day[0] }} + + + + {{ day[0] }} + + + + {{ day[0] }} + + + + {{ day[0] }} + + + {% if day[0] == 0 %} + - + {% else %} + {{ day[0] }} + {% endif %} +
diff --git a/trunk/app/Resources/views/default/admin/lodgingsNew.html.twig b/trunk/app/Resources/views/default/admin/lodgingsNew.html.twig new file mode 100644 index 00000000..e8add428 --- /dev/null +++ b/trunk/app/Resources/views/default/admin/lodgingsNew.html.twig @@ -0,0 +1,56 @@ +{% extends 'admin.html.twig' %} +{% form_theme form 'default/form/theme.html.twig' %} + +{% block body %} +
+
+

Neues Objekt anlegen

+ +
+ + {{ form_errors(form) }} + +
+ +
+ + {{ form_row(form.name, {label: 'Name'}) }} + {{ 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'}) }} + {{ form_row(form.onlyWeekday, {label: 'Exklusiver Wochentag'}) }} + + +
+ {{ form_widget(form.calendarVisible) }} + + {{ form_errors(form.calendarVisible) }} +
+ +
+ +
+
+ {{ form_rest(form) }} +
+ + Zurück + +
+
+{% endblock body %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/admin/loginAdmin.html.twig b/trunk/app/Resources/views/default/admin/loginAdmin.html.twig new file mode 100644 index 00000000..0197ee74 --- /dev/null +++ b/trunk/app/Resources/views/default/admin/loginAdmin.html.twig @@ -0,0 +1,37 @@ +{% extends 'admin.html.twig' %} + +{% block body %} +
+
+

Login Adminbereich

+ + {% if error %} +
{{ error.messageKey|trans(error.messageData, 'security') }}
+ {% endif %} + +
+ + {#{{ form_errors(form) }}#} + +
+ + + + + + + {#TODO hier evtl hidden input#} + +

+
+ +
+
+
+
+
+{% endblock body %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/admin/pricesEdit.html.twig b/trunk/app/Resources/views/default/admin/pricesEdit.html.twig new file mode 100644 index 00000000..c219abc6 --- /dev/null +++ b/trunk/app/Resources/views/default/admin/pricesEdit.html.twig @@ -0,0 +1,37 @@ +{% extends 'admin.html.twig' %} +{% form_theme form 'default/form/theme.html.twig' %} + +{% block body %} +
+
+

Saison von {{ lodging.name }} bearbeiten

+ +
+ + {{ form_errors(form) }} + +
+ +
+ {{ form_row(form.season, {label: 'Saison'}) }} + {{ form_row(form.perNight, {label: 'Preis pro Nacht'}) }} + {{ form_row(form.flatPrice, {label: 'Pauschalpreis'}) }} +
+ +
+
+ {{ form_rest(form) }} +
+ + Zurück + +
+
+{% endblock body %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/admin/pricesNew.html.twig b/trunk/app/Resources/views/default/admin/pricesNew.html.twig new file mode 100644 index 00000000..af43d6bf --- /dev/null +++ b/trunk/app/Resources/views/default/admin/pricesNew.html.twig @@ -0,0 +1,37 @@ +{% extends 'admin.html.twig' %} +{% form_theme form 'default/form/theme.html.twig' %} + +{% block body %} +
+
+

Saison zu {{ lodging.name }} hinzufügen

+ +
+ + {{ form_errors(form) }} + +
+ +
+ {{ form_row(form.season, {label: 'Saison'}) }} + {{ form_row(form.perNight, {label: 'Preis pro Nacht'}) }} + {{ form_row(form.flatPrice, {label: 'Pauschalpreis'}) }} +
+ +
+
+ {{ form_rest(form) }} +
+ + Zurück + +
+
+{% endblock body %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/admin/reservationsEdit.html.twig b/trunk/app/Resources/views/default/admin/reservationsEdit.html.twig new file mode 100644 index 00000000..15d405d3 --- /dev/null +++ b/trunk/app/Resources/views/default/admin/reservationsEdit.html.twig @@ -0,0 +1,73 @@ +{% extends 'admin.html.twig' %} +{% form_theme form 'default/form/theme.html.twig' %} + +{% block body %} +
+
+

Reservierung bearbeiten für {{ lodging.name }}

+ +

Mögliche Saisons

+ + + + + + + + + + + + + {% for lodgingPrice in lodging.prices %} + + + + + + + + {% endfor %} + +
NameVonBisPreis pro NachtPauschalpreis
{{ lodgingPrice.season.name }}{{ lodgingPrice.season.fromDate|date('d-m-y') }}{{ lodgingPrice.season.toDate|date('d-m-y') }}{{ lodgingPrice.perNight }}{{ lodgingPrice.flatPrice }}
+ +

Reservierung

+ +
+ + {{ form_errors(form) }} + +
+ +
+ {{ form_row(form.lodging, {label: 'Objekt'}) }} + {{ form_row(form.fromDate , {label: 'Von'}) }} + {{ form_row(form.toDate, {label: 'Bis'}) }} + {{ form_row(form.status, {label: 'Status'}) }} + {{ form_row(form.type, {label: 'Typ'}) }} + +
+ +
+
+ {{ form_rest(form) }} +
+ + Zurück + + + Löschen + +
+
+{% endblock body %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/admin/reservationsNew.html.twig b/trunk/app/Resources/views/default/admin/reservationsNew.html.twig new file mode 100644 index 00000000..4a68df96 --- /dev/null +++ b/trunk/app/Resources/views/default/admin/reservationsNew.html.twig @@ -0,0 +1,67 @@ +{% extends 'admin.html.twig' %} +{% form_theme form 'default/form/theme.html.twig' %} + +{% block body %} +
+
+

Neue Reservierung anlegen für {{ lodging.name }}

+ +

Mögliche Saisons

+ + + + + + + + + + + + + {% for lodgingPrice in lodging.prices %} + + + + + + + + {% endfor %} + +
NameVonBisPreis pro NachtPauschalpreis
{{ lodgingPrice.season.name }}{{ lodgingPrice.season.fromDate|date('d-m-y') }}{{ lodgingPrice.season.toDate|date('d-m-y') }}{{ lodgingPrice.perNight }}{{ lodgingPrice.flatPrice }}
+ +

Reservierung

+ +
+ + {{ form_errors(form) }} + +
+ +
+ {{ form_row(form.lodging, {label: 'Objekt'}) }} + {{ form_row(form.fromDate , {label: 'Von'}) }} + {{ form_row(form.toDate, {label: 'Bis'}) }} + {{ form_row(form.status, {label: 'Status'}) }} + {{ form_row(form.type, {label: 'Typ'}) }} + +
+ +
+
+ {{ form_rest(form) }} +
+ + Zurück + +
+
+{% endblock body %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/admin/seasons.html.twig b/trunk/app/Resources/views/default/admin/seasons.html.twig new file mode 100644 index 00000000..71cdf0f0 --- /dev/null +++ b/trunk/app/Resources/views/default/admin/seasons.html.twig @@ -0,0 +1,64 @@ +{% extends 'admin.html.twig' %} + + +{% block body %} +
+
+

Saisons

+ +
+ + + + + + + + + + + + {% if seasons is not empty %} + {% for season in seasons %} + + + + + + + + {% endfor %} + {% else %} +

Keine Saisons verfügbar

+ {% endif %} + + + + + +
NameVonBis
{{ season.name }}{{ season.fromDate|date('d-m-y') }}{{ season.toDate|date('d-m-y') }} + + Bearbeiten + + + + Löschen + +
+ + Hinzufügen + +
+
+
+
+{% endblock body %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/admin/seasonsEdit.html.twig b/trunk/app/Resources/views/default/admin/seasonsEdit.html.twig new file mode 100644 index 00000000..902185f0 --- /dev/null +++ b/trunk/app/Resources/views/default/admin/seasonsEdit.html.twig @@ -0,0 +1,42 @@ +{% extends 'admin.html.twig' %} +{% form_theme form 'default/form/theme.html.twig' %} + +{% block body %} +
+
+

Saison {{ season.name }} bearbeiten

+ +
+ + {{ form_errors(form) }} + +
+ +
+ {{ form_row(form.name, {label: 'Name'}) }} + {{ form_row(form.fromDate, {label: 'Von'}) }} + {{ form_row(form.toDate, {label: 'Bis'}) }} + {{ form_row(form.minimumStay, {label: 'Mindestbelegung in Tagen'}) }} + {{ form_row(form.description, {label: 'Beschreibung'}) }} + + + +
+ +
+
+ {{ form_rest(form) }} +
+ + Zurück + +
+
+{% endblock body %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/admin/seasonsNew.html.twig b/trunk/app/Resources/views/default/admin/seasonsNew.html.twig new file mode 100644 index 00000000..deb6ac98 --- /dev/null +++ b/trunk/app/Resources/views/default/admin/seasonsNew.html.twig @@ -0,0 +1,42 @@ +{% extends 'admin.html.twig' %} +{% form_theme form 'default/form/theme.html.twig' %} + +{% block body %} +
+
+

Neue Saison anlegen

+ +
+ + {{ form_errors(form) }} + +
+ +
+ {{ form_row(form.name, {label: 'Name'}) }} + {{ form_row(form.fromDate, {label: 'Von'}) }} + {{ form_row(form.toDate, {label: 'Bis'}) }} + {{ form_row(form.minimumStay, {label: 'Mindestbelegung in Tagen'}) }} + {{ form_row(form.description, {label: 'Beschreibung'}) }} + + + +
+ +
+
+ {{ form_rest(form) }} +
+ + Zurück + +
+
+{% endblock body %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/components/booking/fewoSummary.html.twig b/trunk/app/Resources/views/default/components/booking/fewoSummary.html.twig new file mode 100644 index 00000000..39a33115 --- /dev/null +++ b/trunk/app/Resources/views/default/components/booking/fewoSummary.html.twig @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + +
+ + {{ fewo_lodging.deposit|number_format(2) }} € + + Kaution +
+ + {{ fewo_price.flatPrice|number_format(2) }} € + + Pauschalpreis +
+ + {{ total_price_per_night|number_format(2) }} € + + ({{ fewo_booking_request.numberDays }} x {{ fewo_price.perNight|number_format(2) }} €) +
+ = {{ total_price|number_format(2) }} € + Gesamtpreis der Reise
diff --git a/trunk/app/Resources/views/default/components/pageBoxImage.html.twig b/trunk/app/Resources/views/default/components/pageBoxImage.html.twig index 5ff6ab0c..1e86a1d1 100644 --- a/trunk/app/Resources/views/default/components/pageBoxImage.html.twig +++ b/trunk/app/Resources/views/default/components/pageBoxImage.html.twig @@ -4,6 +4,9 @@ {% elseif page.travelProgram is not empty and page.travelProgram.previewImage is not empty %} {% set image_url = '/uploads/travel_program/' ~ page.travelProgram.previewImage.fileNameWithExtension %} {% set image_alt = page.title %} +{% elseif page.fewoLodging is not empty and page.fewoLodging.images[0] is not empty %} + {% set image_url = asset('uploads/images/' ~ page.fewoLodging.images[0].file) %} + {% set image_alt = page.title %} {% else %} {% set image_url = '/bundles/app/images/no-picture.png' %} {% set image_alt = 'Kein Vorschaubild vorhanden' %} diff --git a/trunk/app/Resources/views/default/email/components/fewoBookingSummary.txt.twig b/trunk/app/Resources/views/default/email/components/fewoBookingSummary.txt.twig new file mode 100644 index 00000000..e3dccad7 --- /dev/null +++ b/trunk/app/Resources/views/default/email/components/fewoBookingSummary.txt.twig @@ -0,0 +1,34 @@ +{# @var fewo_booking_request \AppBundle\Entity\FewoBookingRequest #} +{# @var fewo_lodging \AppBundle\Entity\FewoLodging #} +{# @var fewo_price \AppBundle\Entity\FewoPrice #} +===================================================================================== +Reisedaten: +===================================================================================== +Ferienwohnung: {{ fewo_lodging.name }} +Saison: {{ fewo_price.season.name }} +Reisezeitraum: {{ fewo_booking_request.fromDate|date }} - {{ fewo_booking_request.toDate|date }} + +Gesamtpreis: {{ fewo_booking_request.totalPrice|number_format(2) }} € + +===================================================================================== +Reiseanmelder{% if fewo_booking_request.salutation == 2 %}in{% endif %} + +===================================================================================== +Vorname: {{ fewo_booking_request.firstName }} +Nachname: {{ fewo_booking_request.lastName }} +Adresse: {{ fewo_booking_request.streetAddress }} +PLZ: {{ fewo_booking_request.zipCode }} +Ort: {{ fewo_booking_request.city }} +Telefonnummer: {{ fewo_booking_request.phone }} +Fax: {{ fewo_booking_request.fax ?? 'keine Angabe' }} +E-Mail: {{ fewo_booking_request.email ?? 'keine Angabe' }} + +===================================================================================== +Reiseteilnehmer: {{ fewo_booking_request.travelerCount }} +===================================================================================== +===================================================================================== +Mitteilungen / Sonstiges: +===================================================================================== +{{ fewo_booking_request.notes ?? '-' }} + + diff --git a/trunk/app/Resources/views/default/email/fewoBookingConfirmationEmail.txt.twig b/trunk/app/Resources/views/default/email/fewoBookingConfirmationEmail.txt.twig new file mode 100644 index 00000000..3002d7aa --- /dev/null +++ b/trunk/app/Resources/views/default/email/fewoBookingConfirmationEmail.txt.twig @@ -0,0 +1,11 @@ +{# @var fewo_booking_request \AppBundle\Entity\FewoBookingRequest #} +Sehr geehrte{{ fewo_booking_request.salutation == 1 ? 'r Herr' : ' Frau' }} {{ fewo_booking_request.lastName }}, + +vielen Dank für Ihren Buchungsauftrag. Dieser wird schnellstmöglich bearbeitet und stellt noch keine{# +#} Buchungsbestätigung dar. Bitte prüfen Sie noch einmal Ihre Angaben und kontaktieren Sie uns bitte, wenn ein Fehler{# +#} enthalten ist. + +{% include 'default/email/components/fewoBookingSummary.txt.twig' %} + +{% include 'default/email/components/signature.txt.twig' %} + diff --git a/trunk/app/Resources/views/default/email/fewoBookingServiceEmail.txt.twig b/trunk/app/Resources/views/default/email/fewoBookingServiceEmail.txt.twig new file mode 100644 index 00000000..597dacdf --- /dev/null +++ b/trunk/app/Resources/views/default/email/fewoBookingServiceEmail.txt.twig @@ -0,0 +1,7 @@ +FOLGENDE REISE WURDE GEBUCHT: + +URL: {{ lodging_url }} + +CRM: {{ crm_url }} + +{% include 'default/email/components/fewoBookingSummary.txt.twig' %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/pages/cms/calendarLodgingProgram.html.twig b/trunk/app/Resources/views/default/pages/cms/calendarLodgingProgram.html.twig new file mode 100644 index 00000000..ae36ddfc --- /dev/null +++ b/trunk/app/Resources/views/default/pages/cms/calendarLodgingProgram.html.twig @@ -0,0 +1,84 @@ +{% for monthIndex in 0..11 %} + {% if monthIndex is even %} + + {% else %} +
+ {% endif %} + + + + + + + + + + + + + + + + {% for weekIndex in 0..5 %} + + {% for dayIndex in 0..6 %} + {% set day = calendar[monthIndex]['data'][(weekIndex * 7) + dayIndex]|split(',') %} + {% if day|length > 1 %} + {% if day[1] == 'reservable' %} + + {% else %} + {% if day|length > 3%} + + {% elseif day|length > 2 and day[2] == 'from' %} + + {% elseif day|length > 2 and day[2] == 'to' %} + {% set nextDay = calendar[monthIndex]['data'][(weekIndex * 7) + (dayIndex + 1)]|split(',') %} + + {% else %} + + {% endif %} + {% endif %} + + {% else %} + + {% if day[0] == 0 %} + + {% else %} + + {% endif %} + + {% endif %} + {% endfor %} + + {% endfor %} + +
+ {{ calendar[monthIndex]['monthName'] }} {{ calendar[monthIndex]['year'] }} +
MoDiMiDoFrSaSo
+ + {{ day[0] }} + + + {{ day[0] }} + + {{ day[0] }} + + + {{ day[0] }} + + + {{ day[0] }} + + - + + {{ day[0] }} +
+{% endfor %} diff --git a/trunk/app/Resources/views/default/pages/cms/fewoTravelProgram.html.twig b/trunk/app/Resources/views/default/pages/cms/fewoTravelProgram.html.twig new file mode 100644 index 00000000..d60addfa --- /dev/null +++ b/trunk/app/Resources/views/default/pages/cms/fewoTravelProgram.html.twig @@ -0,0 +1,221 @@ +{#{% extends 'admin.html.twig' %}#} +{# @var fewo_lodging \AppBundle\Entity\FewoLodging #} +{% extends get_base_template() %} + +{% block javascripts %} + {{ parent() }} + {% javascripts '@AppBundle/Resources/public/js/travelProgram.js' %} + + {% endjavascripts %} +{% endblock %} + +{% block body %} + +
+
+ +

{{ fewo_lodging.name }}

+ + {# + ********* SLIDER ********* + #} + +
+ +
+ + {# + ********* TAB BAR ********* + #} + + {% block travel_lodging_program_tab_bar %} +
+
+ + {% endblock travel_lodging_program_tab_bar %} + +
+ + {# + ********* BESCHREIBUNG ********* + #} + +
+ {#TODO alles wirklich hier? wo bilder?#} + +

Allgemeines

+ +
+ + + + + + + + + + + + + + + + + + + + + +
TypAdressePLZOrtMax. PersonenanzahlKaution
+ {{ fewo_lodging.type }} + + {{ fewo_lodging.adress1 }} + {% if fewo_lodging.adress2 is not empty %} + {{ fewo_lodging.adress2 }} + {% endif %} + + {{ fewo_lodging.zipCode }} + + {% if fewo_lodging.city is not empty %} + {{ fewo_lodging.city }} + {% endif %} + + {% if fewo_lodging.maximumPersons is not empty %} + {{ fewo_lodging.maximumPersons }} + {% endif %} + + {% if fewo_lodging.deposit is not empty %} + {{ fewo_lodging.deposit|number_format(2, ',', '.') }} € + {% endif %} +
+
+ {% if fewo_lodging.description is not empty %} +
+
+ {{ fewo_lodging.description|raw }} +
+ {% endif %} + +
+ + {# + ********* AUSSTATTUNG ********* + #} + +
+
+ {{ fewo_lodging.equipment|raw }} +
+
+ + {# + ********* TERMINE UND PREISE ********* + #} + +
+

Saisons

+
+ + {% if fewo_lodging.prices is not empty %} + + + + + + + + + + + + + {% for price in fewo_lodging.prices %} + + + + + + + + + {% endfor %} + +
NameBeginnEndePreis p.P. pro NachtPauschalpreisKaution
+ + {{ price.season.name }} + + + {{ price.season.fromDate|date }} + + {{ price.season.toDate|date }} + + {{ price.perNight|number_format(2, ',', '.') }} € + + {{ price.flatPrice|number_format(2, ',', '.') }} € + + {% if fewo_lodging.deposit is not empty %} + {{ fewo_lodging.deposit|number_format(2, ',', '.') }} € + {% endif %} +
+

Buchung

+ {% include 'default/pages/cms/calendarLodgingProgram.html.twig' %} + {% else %} + Momentan sind für dieses Programm keine Termine verfügbar. + {% endif %} +
+ +
+
+ + {{ block('travel_lodging_program_tab_bar') }} +
+
+{% endblock body %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/pages/fewoBooking.html.twig b/trunk/app/Resources/views/default/pages/fewoBooking.html.twig new file mode 100644 index 00000000..cb0e2e24 --- /dev/null +++ b/trunk/app/Resources/views/default/pages/fewoBooking.html.twig @@ -0,0 +1,192 @@ +{% extends 'base.html.twig' %} +{% form_theme form 'default/form/theme.html.twig' %} + +{% block stylesheets %} + {{ parent() }} + {% stylesheets 'bundles/app/css/booking.css' filter='cssrewrite' %} + + {% endstylesheets %} +{% endblock %} + +{% block javascripts %} + {{ parent() }} + {% javascripts '@AppBundle/Resources/public/js/fewoBooking.js' %} + + {% endjavascripts %} +{% endblock %} + +{% block body %} +
+ +
+ +

Buchungsformular FeWo

+ + {# + +
+ #} + +

{{ lodging.name }}

+ + +
+ +
+ + {{ form_errors(form) }} + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Ferienwohnung + {{ lodging.name }} +
Saison + {{ fewo_price.season.name }} +
Reisebeginn{{ fromDate|date }}
{{ form_label(form.toDate, 'Reiseende') }} + {{ form_widget(form.toDate) }} + {{ form_errors(form.toDate) }} +
{{ form_label(form.travelerCount, 'Reiseteilnehmer') }} + {{ form_widget(form.travelerCount) }} + {{ form_errors(form.travelerCount) }} +
+
+ +
+
+
+

Ihr gewähltes Angebot

+
+ {% include 'default/components/booking/fewoSummary.html.twig' with { + 'fewo_booking_request' : fewo_booking_request, + 'fewo_lodging' : fewo_lodging, + 'fewo_price' : fewo_price, + 'total_price' : total_price, + 'total_price_per_night' : total_price_per_night, + } %} +
+
+
+
+ +
+
+
+
+
Reiseanmelder
+
+ +
+ {{ form_field_pho(form.salutation, 'Anrede', {'label_attr': {class: 'sr-only'}}) }} +
+ +
+ {{ form_field_pho(form.firstName, 'Vorname') }} +
+ +
+ {{ form_field_pho(form.lastName, 'Nachname') }} +
+ +
+ {{ form_field_pho(form.streetAddress, 'Straße, Hausnummer') }} +
+ +
+ {{ form_field_pho(form.zipCode, 'PLZ') }} +
+ +
+ {{ form_field_pho(form.city, 'Ort') }} +
+ +
+ {{ form_field_pho(form.phone, 'Telefon tagsüber') }} +
+ +
+ {{ form_field_pho(form.fax, 'Fax (optional)') }} +
+ +
+ {{ form_field_pho(form.email, 'E-Mail-Adresse') }} +
+ +
+
+ +
+
+
+
Mitteilungen / Sonstiges (optional)
+
+
+ {{ form_field(form.notes, 'Mitteilungen / Sonstiges (optional)', { + 'label_attr': {'class': 'sr-only'}, + 'attr': {'rows': '6'} + }) }} +
+
+
+ + +
+
+ {# +
+
Allgemeine Geschäftsbedingungen
+
+ {{ form_widget(form.acceptTerms) }} + + {{ form_errors(form.acceptTerms) }} +
+
+ #} +
+ +
+
+
+ + + {{ form_rest(form) }} +
+ +
+ +
+ +
+{% endblock body %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/pages/fewoBookingConfirmation.html.twig b/trunk/app/Resources/views/default/pages/fewoBookingConfirmation.html.twig new file mode 100644 index 00000000..608328de --- /dev/null +++ b/trunk/app/Resources/views/default/pages/fewoBookingConfirmation.html.twig @@ -0,0 +1,150 @@ +{% extends 'base.html.twig' %} + +{% block canonical_tag %}{% endblock %} + +{% block body %} + +
+ +
+ +

Vielen Dank für Ihren Buchungsauftrag!

+ + +
+ +

{{ page.fewoLodging.name }} {{ fewo_price.season.name }}

+ + +
+ +
+ + +
+ +
+
+ + + + + + + + + + + +
Ferienwohnung + {{ page.fewoLodging.name }} +
Reisezeitraum{{ fewo_booking_request.fromDate|date }} - {{ fewo_booking_request.toDate|date }}
+
+ + {#TODO#} +
+
+
+

Ihr gewähltes Angebot

+
+ {% include 'default/components/booking/fewoSummary.html.twig' with { + 'fewo_booking_request' : fewo_booking_request, + 'fewo_lodging' : fewo_lodging, + 'fewo_price' : fewo_price, + 'total_price' : total_price, + 'total_price_per_night' : total_price_per_night, + } %} +
+
+
+
+ +
+
+
+
+
Reiseanmelder
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Anrede + {% if fewo_booking_request.salutation == 1 %} + Herr + {% elseif fewo_booking_request.salutation == 2 %} + Frau + {% endif %} +
Vorname{{ fewo_booking_request.firstName }}
Nachname{{ fewo_booking_request.lastName }}
Straße, Hausnummer{{ fewo_booking_request.streetAddress }}
PLZ{{ fewo_booking_request.zipCode }}
Ort{{ fewo_booking_request.city }}
Telefon tagsüber{{ fewo_booking_request.phone }}
Fax (optional){{ fewo_booking_request.fax }}
E-Mail-Adresse{{ fewo_booking_request.email }}
+ Anzahl Reiseteilnehmer + {{ fewo_booking_request.travelerCount }}
+
+
+
+ +
+
+
+
Mitteilungen / Sonstiges (optional)
+
+
+

{{ fewo_booking_request.notes }}

+
+
+
+ + +
+ + + +
+ +
+ +{% endblock %} \ No newline at end of file diff --git a/trunk/app/config/routing.yml b/trunk/app/config/routing.yml index b7192783..7aec1605 100644 --- a/trunk/app/config/routing.yml +++ b/trunk/app/config/routing.yml @@ -5,4 +5,7 @@ route1: path: /{req} defaults: { _controller: 'AppBundle:Default:default' } requirements: - req: ".+" \ No newline at end of file + req: ".+" + +logout: + path: /logout \ No newline at end of file diff --git a/trunk/app/config/security.yml b/trunk/app/config/security.yml index 8072372c..2da0c116 100644 --- a/trunk/app/config/security.yml +++ b/trunk/app/config/security.yml @@ -1,24 +1,32 @@ # To get started with security, check out the documentation: # http://symfony.com/doc/current/book/security.html security: - - # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers - providers: - in_memory: - memory: ~ - - firewalls: - # disables authentication for assets and the profiler, adapt it according to your needs - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - - main: - anonymous: ~ - # activate different ways to authenticate - - # http_basic: ~ - # http://symfony.com/doc/current/book/security.html#a-configuring-how-your-users-will-authenticate - - # form_login: ~ - # http://symfony.com/doc/current/cookbook/security/form_login_setup.html + # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers + providers: + in_memory: + memory: + users: + bstar: + password: $2y$13$./cas5fxa2yto6Q2or0TZ.zwwisoFWWP6MgrCQbO7ljUtynaCalAi + roles: 'ROLE_ADMIN' + encoders: + Symfony\Component\Security\Core\User\User: #plaintext + algorithm: bcrypt + cost: 13 + firewalls: + dev: + pattern: ^/(_(profiler|wdt)|css|images|js)/ + security: false + main: + anonymous: ~ + form_login: + login_path: login + check_path: login + default_target_path: after_login + always_use_default_target_path: true + logout: + path: /logout + target: / + access_control: + - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: ^/admin, roles: ROLE_ADMIN } \ No newline at end of file diff --git a/trunk/app/config/services.yml b/trunk/app/config/services.yml index 7c0ff2de..c5b5adfb 100644 --- a/trunk/app/config/services.yml +++ b/trunk/app/config/services.yml @@ -36,6 +36,11 @@ services: arguments: - '@monolog.logger' + app.fewo_booking_exporter: + class: AppBundle\Export\FewoBookingSternToursCrmExporter + arguments: + - '@monolog.logger' + app.contact_exporter: class: AppBundle\Export\ContactSternToursCrmExporter arguments: @@ -50,4 +55,22 @@ services: class: AppBundle\Pdf arguments: - '%kernel.root_dir%' - - '@assetic.asset_manager' \ No newline at end of file + - '@assetic.asset_manager' + + app.image_uploader: + class: AppBundle\Service\FileManager + arguments: + - '%image_upload_directory%' + + app.image_upload_listener: + class: AppBundle\Listener\DoctrineFileListener + autowire: true + tags: + - { name: doctrine.event_listener, event: prePersist } + - { name: doctrine.event_listener, event: preUpdate } + - { name: doctrine.event_listener, event: preRemove } + + app.lodging_calendar_util: + class: AppBundle\Util\LodgingCalendarUtil + arguments: + - '@doctrine.orm.entity_manager' \ No newline at end of file diff --git a/trunk/src/AppBundle/Controller/AdminController.php b/trunk/src/AppBundle/Controller/AdminController.php new file mode 100644 index 00000000..f815740a --- /dev/null +++ b/trunk/src/AppBundle/Controller/AdminController.php @@ -0,0 +1,830 @@ +getDoctrine()->getManager(); + } + + /** + * @Route("/login", name="login") + */ + public function adminAction(Request $request) + { + $authUtils = $this->get('security.authentication_utils'); + $error = $authUtils->getLastAuthenticationError(); + $lastUsername = $authUtils->getLastUsername(); + + return $this->render('default/admin/loginAdmin.html.twig', [ + 'last_username' => $lastUsername, + 'error' => $error, + ]); + + } + + /** + * @Route("/admin/fewo") + */ + public function adminFewoAction() + { + return $this->render('admin.html.twig', [ + + ]); + } + + /** + * @Route("/admin/fewo/lodgings", name="after_login") + */ + public function adminFewoLodgingsAction(Request $request) + { + $fewoLodgingRepo = $this->getEntityManager()->getRepository('AppBundle:FewoLodging'); + + $lodgings = $fewoLodgingRepo->findAll(); + + return $this->render('default/admin/lodgings.html.twig', [ + 'lodgings' => $lodgings, + ]); + } + + /** + * @Route("/admin/fewo/lodgings/new") + */ + public function adminFewoNewLodgingAction(Request $request) + { + $lodging = null; + + if ($request->getMethod() != 'POST') + { + $lodging = new FewoLodging(); + } + + $form = $this->createForm(FewoLodgingType::class, $lodging, [ + + ]); + + // todo if(form == null)... + + if ($request->getMethod() == 'POST') + { + $form->handleRequest($request); + $lodging = $form->getData(); + } + + + if ($request->getMethod() == 'POST' && $form->isValid()) + { + $em = $this->getEntityManager(); + $em->persist($lodging); + $em->flush(); + + return $this->redirect('/admin/fewo/lodgings'); + } + return $this->render('default/admin/lodgingsNew.html.twig', [ + 'form' => $form->createView(), + ]); + } + + private function getSeasons(FewoLodging $lodging) + { + $seasons = []; + $lodgingPrices = $lodging->getPrices(); + foreach($lodgingPrices as $price) + { + $seasons[] = $price->getSeason(); + } + + return $seasons; + } + + private function setChoosableSeasons(FewoLodging $lodging) + { + $em = $this->getEntityManager(); + $fewoSeasonRepo = $em->getRepository('AppBundle:FewoSeason'); + $allSeasons = $fewoSeasonRepo->findAll(); + $lodgingSeasons = []; + $lodgingSeasons = $this->getSeasons($lodging); + $seasons = null; + + for($i = 0; $i < count($allSeasons); $i++) + { + if(!in_array($allSeasons[$i], $lodgingSeasons)) + { + $seasons[] = $allSeasons[$i]; + } + } + + $lodging->setChoosableSeasons($seasons); + } + + /** + * @Route("/admin/fewo/lodgings/{lodgingId}", requirements={"lodgingId": "\d+"}) + */ + public function adminFewoEditLodgingAction(Request $request, $lodgingId) + { + $em = $this->getEntityManager(); + $fewoLodgingRepo = $em->getRepository('AppBundle:FewoLodging'); + + $lodging = null; + + $calendarUtil = $this->container->get('app.lodging_calendar_util'); + + $lodging = $fewoLodgingRepo->find($lodgingId); + $reservations = $calendarUtil->getReservations($lodging); + + + + $paddedCalendar = $calendarUtil->getCalendarWithPadding(); + $calendar = $calendarUtil->getCalendar(); + $calendar = $calendarUtil->markCalendarDaysWithReservations($lodging, $calendar); + $calendar = $calendarUtil->mergeWithPaddedCalendar($calendar, $paddedCalendar); + + $form = $this->createForm(FewoLodgingType::class, $lodging, [ + //options + ]); + + if($request->getMethod() == 'POST') + { + $form->handleRequest($request); + } + + + if ($request->getMethod() == 'POST' && $form->isValid()) + { + $em->flush(); + + return $this->redirect('/admin/fewo/lodgings'); + } + + + return $this->render('default/admin/lodgingsEdit.html.twig', [ + 'form' => $form->createView(), + 'lodging' => $lodging, + 'calendar'=> $calendar, + 'reservations' => $reservations + ]); + } + + /** + * @Route("/admin/fewo/lodgings/{lodgingId}/delete", requirements={"lodgingId": "\d+"}) + */ + public function adminFewoDeleteLodgingAction(Request $request, $lodgingId) + { + $em = $this->getEntityManager(); + $fewoLodgingRepo = $em->getRepository('AppBundle:FewoLodging'); + + $lodging = $fewoLodgingRepo->find($lodgingId); + + if($lodging != null) + { + $em->remove($lodging); + $em->flush(); + } + + return $this->redirect('/admin/fewo/lodgings'); + } + + /** + * @Route("/admin/fewo/lodgings/{lodgingId}/program", requirements={"lodgingId": "\d+"}) + */ + public function adminFewoLodgingProgramAction(Request $request, $lodgingId) + { + $fewoLodgingRepo = $this->getEntityManager()->getRepository('AppBundle:FewoLodging'); + + $lodging = $fewoLodgingRepo->find($lodgingId); + + $calendarUtil = $this->container->get('app.lodging_calendar_util'); + + $reservations = $calendarUtil->getReservations($lodging); + + $paddedCalendar = $calendarUtil->getCalendarWithPadding(); + $calendar = $calendarUtil->getCalendar(); + $calendar = $calendarUtil->markCalendarDaysWithReservations($lodging, $calendar); + $calendar = $calendarUtil->mergeWithPaddedCalendar($calendar, $paddedCalendar); + + + return $this->render('default/pages/cms/fewoTravelProgram.html.twig', [ + 'fewo_lodging' => $lodging, + 'calendar' => $calendar + ]); + } + + /** + * @ Route("/admin/fewo/lodgings/{lodgingId}/prices/{priceId}/reservations/new/{fromDate}/booking", requirements={"lodgingId": "\d+", "priceId": "\d+", "fromDate": "\w+"}) + */ + public function adminFewoBookingAction(Request $request, $lodgingId, $priceId, $fromDate) + { + $em = $this->getEntityManager(); + $fewoLodgingRepo = $em->getRepository('AppBundle:FewoLodging'); + $fewoPriceRepo = $em->getRepository('AppBundle:FewoPrice'); + + $lodging = $fewoLodgingRepo->find($lodgingId); + $price = $fewoPriceRepo->find($priceId); + + /** @var FewoSeason $season */ + $season = $price->getSeason(); + $minimumStay = $season->getMinimumStay(); + $fromDate = $this->convertDate($fromDate); + $toDate = ''; + + $maxPersons = $lodging->getMaximumPersons(); + + $fewoBookingRequest = new FewoBookingRequest(); + $reservation = new FewoReservation(); + + if ($request->getMethod() != 'POST') + { + $dateAppendix = " + ".($minimumStay - 1)." day"; + if($minimumStay > 1) + { + $dateAppendix= $dateAppendix."s"; + } + + $toDate = date('d.m.Y', strtotime($fromDate.$dateAppendix)); + $fewoBookingRequest->setFromDate($fromDate); + $fewoBookingRequest->setToDate($toDate); + } + + $form = $this->createForm(FewoBookingRequestType::class, $fewoBookingRequest, [ + 'lodging' => $lodging, + 'maxPersons' => $maxPersons, + 'toDate' => $toDate + ]); + + if ($request->getMethod() == 'POST') + { + $form->handleRequest($request); + $fewoBookingRequest = $form->getData(); + $fromDateTime = new \DateTime($fromDate); + $fewoBookingRequest->setFromDate($fromDateTime); + $fewoBookingRequest->setLodging($lodging); + } + + + if ($request->getMethod() == 'POST' && $form->isValid()) + { + $reservation->setFromDate($fewoBookingRequest->getFromDate()); + $reservation->setToDate($fewoBookingRequest->getToDate()); + $reservation->setStatus(0); // 0 = belegt; 1 = nicht verfügbar + $reservation->setType(0); // 0 = Buchung; 1 = Händisch + + $reservation->setLodging($lodging); + $em->persist($reservation); + $em->flush(); + + + $crmBookingUrl = $this->get('app.fewo_booking_exporter')->process($fewoBookingRequest, $lodging, $price);//, $travelDate, $bookingPriceInfo); + $crmBookingUrl = preg_replace('/\\/api/', '', $crmBookingUrl) .'/edit'; + + $this->get('mailer')->send(\Swift_Message::newInstance() + ->setSubject('Ihr FeWo-Buchungsauftrag bei STERN TOURS') + ->setFrom('stern@stern-tours.de', 'STERN TOURS') + ->setTo($fewoBookingRequest->getEmail()) + ->setBody( + $this->renderView('default/email/fewoBookingConfirmationEmail.txt.twig', [ + 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR, + 'fewo_booking_request' => $fewoBookingRequest, + //'booking_price_info' => $bookingPriceInfo, + //'travel_date' => $travelDate, + //'breadcrumb_entries' => $breadcrumbEntries, + ]), + 'text/plain', 'utf-8' + ) + ); + + $this->get('mailer')->send(\Swift_Message::newInstance() + ->setSubject('FEWO-BUCHUNG: '. $lodging->getName())//$travelProgram->getTitle() .'('. $travelDate->getName() .')') //TODO !!! allein hierfür braucht man mehr infos in $fewoBookingRequest + ->setFrom('stern@stern-tours.de', 'STERN TOURS') + ->setTo('stern@stern-tours.de') + ->setBody( + $this->renderView('default/email/fewoBookingServiceEmail.txt.twig', [ + 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR, + 'crm_url' => $crmBookingUrl, + //'travel_program_url' => Util::getBaseUrl() . $travelProgramPage->getUrlPath(), + 'fewo_booking_request' => $fewoBookingRequest, + //'booking_price_info' => $bookingPriceInfo, + //'travel_date' => $travelDate, + //'breadcrumb_entries' => $breadcrumbEntries, + ]), + 'text/plain', 'utf-8' + ) + ); + + + return $this->redirect('/admin/fewo/lodgings/'.$lodgingId.'/program'); + } + + // ------------------------------------------------------------------------------------------- + + + return $this->render('default/admin/fewoBooking.html.twig', [ + 'form' => $form->createView(), + 'lodging' => $lodging, + 'fromDate' => $fromDate, + 'toDate' => $toDate + ]); + + } + + /** + * @Route("/admin/fewo/lodgings/{lodgingId}/prices/new", requirements={"lodgingId": "\d+"}) + */ + public function adminFewoNewPriceAction(Request $request, $lodgingId) + { + $em = $this->getEntityManager(); + $fewoLodgingRepo = $em->getRepository('AppBundle:FewoLodging'); + $lodging = $fewoLodgingRepo->find($lodgingId); + + $price = null; + if ($request->getMethod() != 'POST') + { + $price = new FewoPrice(); + } + + $this->setChoosableSeasons($lodging); + $form = $this->createForm(FewoPriceType::class, $price, [ + 'lodging' => $lodging + ]); + + if ($request->getMethod() == 'POST') + { + $form->handleRequest($request); + $price = $form->getData(); + } + + + if ($request->getMethod() == 'POST' && $form->isValid()) + { + + if($price == null) + { + return $this->redirect('/admin/fewo/lodgings/'.$lodgingId); + } + + $price->setLodging($lodging); + $em->persist($price); + $em->flush(); + + + return $this->redirect('/admin/fewo/lodgings/'.$lodgingId); + } + + return $this->render('default/admin/pricesNew.html.twig', [ + 'form' => $form->createView(), + 'lodging' => $lodging, + ]); + } + + /** + * @Route("/admin/fewo/lodgings/{lodgingId}/prices/{priceId}", requirements={"lodgingId": "\d+", "priceId": "\d+"}) + */ + public function adminFewoEditPriceAction(Request $request, $lodgingId, $priceId) + { + $em = $this->getEntityManager(); + $fewoLodgingRepo = $em->getRepository('AppBundle:FewoLodging'); + $fewoPriceRepo = $em->getRepository('AppBundle:FewoPrice'); + $lodging = $fewoLodgingRepo->find($lodgingId); + $price = $fewoPriceRepo->find($priceId); + + $choosableSeason[] = $price->getSeason(); + $lodging->setChoosableSeasons($choosableSeason); + + $form = $this->createForm(FewoPriceType::class, $price, [ + 'lodging' => $lodging + ]); + + if ($request->getMethod() == 'POST') + { + $form->handleRequest($request); + } + + + if ($request->getMethod() == 'POST' && $form->isValid()) + { + + if($price == null) + { + return $this->redirect('/admin/fewo/lodgings/'.$lodgingId); + } + $em->flush(); + + + return $this->redirect('/admin/fewo/lodgings/'.$lodgingId); + } + + return $this->render('default/admin/pricesEdit.html.twig', [ + 'form' => $form->createView(), + 'lodging' => $lodging, + ]); + } + + /** + * @Route("/admin/fewo/lodgings/{lodgingId}/prices/{priceId}/delete", requirements={"lodgingId": "\d+", "priceId": "\d+"}) + */ + public function adminFewoDeletePriceAction(Request $request, $lodgingId, $priceId) + { + $em = $this->getEntityManager(); + $fewoPriceRepo = $em->getRepository('AppBundle:FewoPrice'); + $fewoLodgingRepo = $em->getRepository('AppBundle:FewoLodging'); + $lodging = $fewoLodgingRepo->find($lodgingId); + + $price = $fewoPriceRepo->find($priceId); + + if($price != null) + { + $em->remove($price); + $em->flush(); + } + + return $this->redirect('/admin/fewo/lodgings/'.$lodgingId); + } + + + /** + * @Route("/admin/fewo/lodgings/{lodgingId}/reservations/new", requirements={"lodgingId": "\d+"}) + */ + public function adminFewoNewReservationAction(Request $request, $lodgingId) + { + $em = $this->getEntityManager(); + $fewoLodgingRepo = $em->getRepository('AppBundle:FewoLodging'); + $lodging = $fewoLodgingRepo->find($lodgingId); + + $reservation = null; + if ($request->getMethod() != 'POST') + { + $reservation = new FewoReservation(); + } + + $form = $this->createForm(FewoReservationType::class, $reservation, [ + 'lodging' => $lodging + ]); + + if ($request->getMethod() == 'POST') + { + $form->handleRequest($request); + $reservation = $form->getData(); + } + + + if ($request->getMethod() == 'POST' && $form->isValid()) + { + + if($reservation == null) + { + return $this->redirect('/admin/fewo/lodgings/'.$lodgingId); + } + + $reservation->setLodging($lodging); + $em->persist($reservation); + + $em->flush(); + + + return $this->redirect('/admin/fewo/lodgings/'.$lodgingId); + } + + return $this->render('default/admin/reservationsNew.html.twig', [ + 'form' => $form->createView(), + 'lodging' => $lodging, + ]); + + } + + private function addDaysToDate($date, $days) + { + $result = date('dd-mm-yyyy', strtotime($date." + ".$days." days")); + return $result; + } + + private function convertDate($date) + { + $result = substr($date, 0, 2).'.'.substr($date, 2, 2).'.'.substr($date, 4, 4); + return $result; + } + + + /** + * @Route("/admin/fewo/lodgings/{lodgingId}/reservations/new/{fromDate}", requirements={"lodgingId": "\d+", "fromDate": "\w+"}) + */ + public function adminFewoNewReservationWithStartingDayAction(Request $request, $lodgingId, $fromDate) + { + //todo price -> season + //todo season.minimumStay + $em = $this->getEntityManager(); + $fewoLodgingRepo = $em->getRepository('AppBundle:FewoLodging'); + $lodging = $fewoLodgingRepo->find($lodgingId); + + $fromDate = $this->convertDate($fromDate); + + $reservation = null; + if ($request->getMethod() != 'POST') + { + $reservation = new FewoReservation(); + } + + $form = $this->createForm(FewoReservationType::class, $reservation, [ + 'lodging' => $lodging, + 'fromDate' => $fromDate + ]); + + if ($request->getMethod() == 'POST') + { + $form->handleRequest($request); + $reservation = $form->getData(); + } + + + if ($request->getMethod() == 'POST' && $form->isValid()) + { + + if($reservation == null) + { + return $this->redirect('/admin/fewo/lodgings/'.$lodgingId); + } + + $reservation->setLodging($lodging); + $em->persist($reservation); + $em->flush(); + + + return $this->redirect('/admin/fewo/lodgings/'.$lodgingId); + } + + return $this->render('default/admin/reservationsNew.html.twig', [ + 'form' => $form->createView(), + 'lodging' => $lodging, + ]); + + } + + + /** + * @Route("/admin/fewo/lodgings/{lodgingId}/reservations/{reservationId}", requirements={"lodgingId": "\d+", "reservationId": "\d+"}) + */ + public function adminFewoEditReservationAction(Request $request, $lodgingId, $reservationId) + { + $em = $this->getEntityManager(); + $fewoLodgingRepo = $em->getRepository('AppBundle:FewoLodging'); + $fewoReservationRepo = $em->getRepository('AppBundle:FewoReservation'); + $lodging = $fewoLodgingRepo->find($lodgingId); + $reservation = $fewoReservationRepo->find($reservationId); + $fromDate = $reservation->getFromDate()->format('d.m.Y'); + + $form = $this->createForm(FewoReservationType::class, $reservation, [ + 'lodging' => $lodging, + 'fromDate' => $fromDate, + ]); + + if ($request->getMethod() == 'POST') + { + $form->handleRequest($request); + } + + + if ($request->getMethod() == 'POST' && $form->isValid()) + { + $em->flush(); + + return $this->redirect('/admin/fewo/lodgings/'.$lodgingId); + } + + return $this->render('default/admin/reservationsEdit.html.twig', [ + 'form' => $form->createView(), + 'lodging' => $lodging, + 'reservationId' => $reservationId + ]); + + } + + /** + * @Route("/admin/fewo/lodgings/{lodgingId}/reservations/{reservationId}/delete", requirements={"lodgingId": "\d+", "reservationId": "\d+"}) + */ + public function adminFewoDeleteReservationAction(Request $request, $lodgingId, $reservationId) + { + $em = $this->getEntityManager(); + $fewoLodgingRepo = $em->getRepository('AppBundle:FewoLodging'); + $fewoReservationRepo = $em->getRepository('AppBundle:FewoReservation'); + + $lodging = $fewoLodgingRepo->find($lodgingId); + $reservation = $fewoReservationRepo->find($reservationId); + + if($reservation != null) + { + $em->remove($reservation); + $em->flush(); + } + + return $this->redirect('/admin/fewo/lodgings/'.$lodgingId); + + } + + + /** + * @Route("/admin/fewo/seasons") + */ + public function adminFewoSeasonsAction(Request $request) + { + $fewoSeasonRepo = $this->getEntityManager()->getRepository('AppBundle:FewoSeason'); + + $seasons = $fewoSeasonRepo->findAll(); + + return $this->render('default/admin/seasons.html.twig', [ + 'seasons' => $seasons, + ]); + + } + + /** + * @Route("/admin/fewo/seasons/new") + */ + public function adminFewoNewSeasonAction(Request $request) + { + $em = $this->getEntityManager(); + $season = null; + + if ($request->getMethod() != 'POST') + { + $season = new FewoSeason(); + } + + $form = $this->createForm(FewoSeasonType::class, $season, [ + + ]); + + if ($request->getMethod() == 'POST') + { + $form->handleRequest($request); + $season = $form->getData(); + } + + + if ($request->getMethod() == 'POST' && $form->isValid()) + { + if($season == null) + { + return $this->redirect('/admin/fewo/seasons'); + } + + $em->persist($season); + $em->flush(); + + return $this->redirect('/admin/fewo/seasons'); + } + return $this->render('default/admin/seasonsNew.html.twig', [ + 'form' => $form->createView(), + 'season' => $season, + ]); + + } + + /** + * @Route("/admin/fewo/seasons/{seasonId}", requirements={"seasonId": "\d+"}) + */ + public function adminFewoEditSeasonAction(Request $request, $seasonId) + { + $em = $this->getEntityManager(); + $fewoSeasonsRepo = $em->getRepository('AppBundle:FewoSeason'); + + $season = null; + $season = $fewoSeasonsRepo->find($seasonId); + + $form = $this->createForm(FewoSeasonType::class, $season, [ + //options + ]); + + if($request->getMethod() == 'POST') + { + $form->handleRequest($request); + } + + + if ($request->getMethod() == 'POST' && $form->isValid()) + { + $em->flush(); + + return $this->redirect('/admin/fewo/seasons'); + } + return $this->render('default/admin/seasonsEdit.html.twig', [ + 'form' => $form->createView(), + 'season' => $season, + ]); + } + + /** + * @Route("/admin/fewo/seasons/{seasonId}/delete", requirements={"seasonId": "\d+"}) + */ + public function adminFewoDeleteSeasonAction(Request $request, $seasonId) + { + $em = $this->getEntityManager(); + $fewoSeasonRepo = $em->getRepository('AppBundle:FewoSeason'); + + $season = $fewoSeasonRepo->find($seasonId); + + if($season != null) + { + $em->remove($season); + $em->flush(); + } + + return $this->redirect('/admin/fewo/seasons'); + } + + /** + * @Route("/admin/fewo/lodgings/{lodgingId}/images/new", requirements={"lodgingId": "\d+"}) + */ + public function adminFewoNewImageAction(Request $request, $lodgingId) + { + $em = $this->getEntityManager(); + $fewoLodgingRepo = $em->getRepository('AppBundle:FewoLodging'); + + $lodging = $fewoLodgingRepo->find($lodgingId); + + $image = null; + if ($request->getMethod() != 'POST') + { + $image = new FewoLodgingImage(); + } + + $form = $this->createForm(FewoLodgingImageType::class, $image, [ + + ]); + + if ($request->getMethod() == 'POST') + { + $form->handleRequest($request); + $image = $form->getData(); + } + + + if ($request->getMethod() == 'POST' && $form->isValid()) + { + + if($lodging == null) + { + return $this->redirect('/admin/fewo/lodgings'); + } + + $image->setLodging($lodging); + $em->persist($image); + $em->flush(); + + return $this->redirect('/admin/fewo/lodgings/'.$lodgingId); + } + + return $this->render('default/admin/imagesNew.html.twig', [ + 'form' => $form->createView(), + 'lodging' => $lodging, + ]); + } + + /** + * @Route("/admin/fewo/lodgings/{lodgingId}/images/{imageId}/delete", requirements={"lodgingId": "\d+", "imageId": "\d+"}) + */ + public function adminFewoDeleteImageAction(Request $request, $lodgingId, $imageId) + { + $em = $this->getEntityManager(); + $fewoLodgingImageRepo = $em->getRepository('AppBundle:FewoLodgingImage'); + + $image = $fewoLodgingImageRepo->find($imageId); + + if($image != null) + { + $em->remove($image); + $em->flush(); + } + + return $this->redirect('/admin/fewo/lodgings/'.$lodgingId); + } +} \ No newline at end of file diff --git a/trunk/src/AppBundle/Controller/CmsController.php b/trunk/src/AppBundle/Controller/CmsController.php index 99d80029..e850a9f6 100644 --- a/trunk/src/AppBundle/Controller/CmsController.php +++ b/trunk/src/AppBundle/Controller/CmsController.php @@ -123,6 +123,29 @@ class CmsController extends Controller ]); } + public function fewoLodgingAction(Page $page) + { + //$calendarUtil = new Util\LodgingCalendarUtil(); + $calendarUtil = $this->container->get('app.lodging_calendar_util'); + //$fewoLodgingRepo = $this->getEntityManager()->getRepository('AppBundle:FewoLodging'); + $lodging = $page->getFewoLodging(); + + $paddedCalendar = $calendarUtil->getCalendarWithPadding(); + $calendar = $calendarUtil->getCalendar(); + $calendar = $calendarUtil->markCalendarDaysWithReservations($lodging, $calendar); + $calendar = $calendarUtil->mergeWithPaddedCalendar($calendar, $paddedCalendar); + + + return $this->render('default/pages/cms/fewoTravelProgram.html.twig', [ + 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR, + 'page' => $page, + 'fewo_lodging' => $lodging, + //'lodging' => $lodging, //so wurde es im AdminController aufgerufen + 'calendar' => $calendar + + ]); + } + public function pdfAction(Page $page) { $travelProgram = $page->getTravelProgram(); diff --git a/trunk/src/AppBundle/Controller/FewoBookingController.php b/trunk/src/AppBundle/Controller/FewoBookingController.php new file mode 100644 index 00000000..b660fdae --- /dev/null +++ b/trunk/src/AppBundle/Controller/FewoBookingController.php @@ -0,0 +1,251 @@ +getDoctrine()->getManager(); + } + + /** + * The routing for this action is entirely controlled by KernelControllerListener! + * + * @param Page $fewoTravelProgramPage + * @param Request $request + * @param $action + * + * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response + * @throws \Exception + */ + public function indexAction(Page $fewoTravelProgramPage, $action, Request $request) + { + + //$calendarUtils = new Util\LodgingCalendarUtil(); + $calendarUtil = $this->container->get('app.lodging_calendar_util'); + $em = $this->getEntityManager(); + //$fewoLodgingRepo = $em->getRepository('AppBundle:FewoLodging'); + $fewoPriceRepo = $em->getRepository('AppBundle:FewoPrice'); + + if (!$request->query->has('pnr') || !$request->query->has('fd')) + { + return $this->redirect($fewoTravelProgramPage->getUrlPath()); + } + + $priceId = $request->query->get('pnr'); + $fromDate = $request->query->get('fd'); + + $lodging = $fewoTravelProgramPage->getFewoLodging(); + /** @var FewoPrice $price */ + $price = $fewoPriceRepo->find($priceId); + + /** @var FewoSeason $season */ + $season = $price->getSeason(); + $minimumStay = $season->getMinimumStay(); + + $fromDate = $calendarUtil->convertDate($fromDate); + $fromDateTime = new \DateTime($fromDate); + $toDate = ''; + + $maxPersons = $lodging->getMaximumPersons(); + + + $fewoBookingRequest = new FewoBookingRequest(); + $reservation = new FewoReservation(); + + $fewoBookingRequest->setFromDate($fromDateTime); + //$fewoBookingRequest->setToDate($toDate); + $fewoBookingRequest->setNumberDays($minimumStay); + $fewoBookingRequest->setLodging($lodging); + $fewoBookingRequest->setPrice($price); + + + if ($request->getMethod() != 'POST') + { + $dateAppendix = " + ".($minimumStay - 1)." day"; + if($minimumStay > 1) + { + $dateAppendix= $dateAppendix."s"; + } + + $toDate = date('d.m.Y', strtotime($fromDate.$dateAppendix)); + $fewoBookingRequest->setFromDate($fromDate); + $fewoBookingRequest->setToDate($toDate); + $fewoBookingRequest->setNumberDays($minimumStay); + $fewoBookingRequest->setLodging($lodging); + $fewoBookingRequest->setPrice($price); + } + + $form = $this->createForm(FewoBookingRequestType::class, $fewoBookingRequest, [ + 'lodging' => $lodging, + 'maxPersons' => $maxPersons, + 'toDate' => $toDate + ]); + + if ($request->getMethod() == 'POST') + { + $form->handleRequest($request); + + /** @var FewoBookingRequest $fewoBookingRequest */ + $fewoBookingRequest = $form->getData(); + $fewoBookingRequest->setFromDate($fromDateTime); + + $finalFromDate = $fewoBookingRequest->getFromDate(); + $finalToDate = $fewoBookingRequest->getToDate(); + + $timeDiff = date_diff($finalFromDate, $finalToDate); + + $numberDays = $timeDiff->days + 1; + + $fewoBookingRequest->setNumberDays($numberDays); + $fewoBookingRequest->setLodging($lodging); + $fewoBookingRequest->setPrice($price); + } + + $totalPrice = $this->calculatePrice($fewoBookingRequest, $lodging, $price); + $perDayTotalPrice = $this->calculatePerDayTotalPrice($fewoBookingRequest, $price); + $fewoBookingRequest->setTotalPrice($totalPrice); + + if($action == '/fewo-buchen') + { + + if ($request->getMethod() == 'POST' && $form->isValid()) + { + $reservation->setFromDate($fewoBookingRequest->getFromDate()); + $reservation->setToDate($fewoBookingRequest->getToDate()); + $reservation->setStatus(0); // 0 = belegt; 1 = nicht verfügbar + $reservation->setType(0); // 0 = Buchung; 1 = Händisch + + $reservation->setLodging($lodging); + $em->persist($reservation); + $em->flush(); + + $crmBookingUrl = $this->get('app.fewo_booking_exporter')->process($fewoBookingRequest, $lodging, $price);//, $travelDate, $bookingPriceInfo); + $crmBookingUrl = preg_replace('/\\/api/', '', $crmBookingUrl) . '/edit'; + + $this->get('mailer')->send(\Swift_Message::newInstance() + ->setSubject('Ihr FeWo-Buchungsauftrag bei STERN TOURS') + ->setFrom('stern@stern-tours.de', 'STERN TOURS') + ->setTo($fewoBookingRequest->getEmail()) + ->setBody( + $this->renderView('default/email/fewoBookingConfirmationEmail.txt.twig', [ + 'base_dir' => realpath($this->getParameter('kernel.root_dir') . '/..') . DIRECTORY_SEPARATOR, + 'fewo_booking_request' => $fewoBookingRequest, + 'fewo_lodging' => $lodging, + 'fewo_price' => $price, + //'booking_price_info' => $bookingPriceInfo, + //'travel_date' => $travelDate, + //'breadcrumb_entries' => $breadcrumbEntries, + ]), + 'text/plain', 'utf-8' + ) + ); + + + $this->get('mailer')->send(\Swift_Message::newInstance() + ->setSubject('FEWO-BUCHUNG: ' . $lodging->getName()) + ->setFrom('stern@stern-tours.de', 'STERN TOURS') + ->setTo('stern@stern-tours.de') + ->setBody( + $this->renderView('default/email/fewoBookingServiceEmail.txt.twig', [ + 'base_dir' => realpath($this->getParameter('kernel.root_dir') . '/..') . DIRECTORY_SEPARATOR, + 'crm_url' => $crmBookingUrl, + 'lodging_url' => Util::getBaseUrl() . $fewoTravelProgramPage->getUrlPath(), + 'fewo_booking_request' => $fewoBookingRequest, + 'fewo_lodging' => $lodging, + 'fewo_price' => $price, + //'booking_price_info' => $bookingPriceInfo, + //'travel_date' => $travelDate, + //'breadcrumb_entries' => $breadcrumbEntries, + ]), + 'text/plain', 'utf-8' + ) + ); + + + return $this->render('default/pages/fewoBookingConfirmation.html.twig', [ + 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR, + 'page' => $fewoTravelProgramPage, + 'fewo_booking_request' => $fewoBookingRequest, + 'fewo_lodging' => $lodging, + 'fewo_price' => $price, + 'total_price' => $totalPrice, + 'total_price_per_night' => $perDayTotalPrice, + ]); + } + + return $this->render('default/pages/fewoBooking.html.twig', [ + 'form' => $form->createView(), + 'fewo_booking_request' => $fewoBookingRequest, + 'lodging' => $lodging, + 'fromDate' => $fromDate, + 'toDate' => $toDate, + 'fewo_lodging' => $lodging, + 'fewo_price' => $price, + 'total_price' => $totalPrice, + 'total_price_per_night' => $perDayTotalPrice, + + ]); + + } + elseif($action == '/fewo-berechne-gesamtpreis') + { + return $this->render('default/components/booking/fewoSummary.html.twig', [ + 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR, + 'fewo_booking_request' => $fewoBookingRequest, + 'fewo_lodging' => $lodging, + 'fewo_price' => $price, + 'total_price' => $totalPrice, + 'total_price_per_night' => $perDayTotalPrice, + ]); + + } + throw new \Exception('Unknow FewoBookingController action: '. $action); + } + + public function calculatePrice(FewoBookingRequest $fewoBookingRequest, FewoLodging $fewoLodging, FewoPrice $fewoPrice) + { + $result = $fewoLodging->getDeposit(); + $result = $result + $fewoPrice->getFlatPrice(); + + for($i = 0; $i < $fewoBookingRequest->getNumberDays(); $i++) + { + $result = $result + $fewoPrice->getPerNight(); + } + + return $result; + } + + public function calculatePerDayTotalPrice(FewoBookingRequest $fewoBookingRequest, FewoPrice $fewoPrice) + { + $result = 0; + for($i = 0; $i < $fewoBookingRequest->getNumberDays(); $i++) + { + $result = $result + $fewoPrice->getPerNight(); + } + return $result; + } +} \ No newline at end of file diff --git a/trunk/src/AppBundle/Entity/FewoBookingRequest.php b/trunk/src/AppBundle/Entity/FewoBookingRequest.php new file mode 100644 index 00000000..0ebc3c78 --- /dev/null +++ b/trunk/src/AppBundle/Entity/FewoBookingRequest.php @@ -0,0 +1,428 @@ + + * @date 12/16/2016 + */ + +namespace AppBundle\Entity; + +use Symfony\Component\Validator\Constraints as Assert; +use AppBundle\Validator\Constraints as AppBundleAssert; +use Symfony\Component\Validator\Context\ExecutionContextInterface; + +//TODO im folgenden fehlt noch die Validierung +/** + * Class BookingRequest + * @package AppBundle\Entity + * @AppBundleAssert\FewoBookingRequest + */ +class FewoBookingRequest +{ + // Used in SternToursCrmBookingExports, expected to be equivalent to sex (as defined in Traveler) + const MR = 1; + const MRS = 2; + + /** + * @Assert\DateTime() + */ + private $fromDate; + + /** + * @Assert\DateTime() + */ + private $toDate; + + private $numberDays; + + private $totalPrice; + + private $salutation; + + /** + * @Assert\NotBlank() + */ + private $firstName; + + /** + * @Assert\NotBlank() + */ + private $lastName; + + /** + * @Assert\NotBlank() + */ + private $streetAddress; + + /** + * @Assert\NotBlank() + */ + private $zipCode; + + /** + * @Assert\NotBlank() + */ + private $city; + + private $nation; + + /** + * @Assert\NotBlank() + */ + private $phone; + + private $fax; + + /** + * @Assert\NotBlank() + */ + private $email; + + private $notes; + + private $travelerCount; + + private $acceptTerms = false; + + private $lodging; + + private $season; + + private $price; + + /** + * BookingRequest constructor. + */ + public function __construct() + { + + } + + /** + * @return mixed + */ + public function getFromDate() + { + return $this->fromDate; + } + + /** + * @param mixed $fromDate + */ + public function setFromDate($fromDate) + { + $this->fromDate = $fromDate; + } + + /** + * @return mixed + */ + public function getToDate() + { + return $this->toDate; + } + + /** + * @param mixed $toDate + */ + public function setToDate($toDate) + { + $this->toDate = $toDate; + } + + /** + * @return mixed + */ + public function getSalutation() + { + return $this->salutation; + } + + /** + * @param mixed $salutation + */ + public function setSalutation($salutation) + { + $this->salutation = $salutation; + } + + /** + * @return mixed + */ + public function getFirstName() + { + return $this->firstName; + } + + /** + * @param mixed $firstName + */ + public function setFirstName($firstName) + { + $this->firstName = $firstName; + } + + /** + * @return mixed + */ + public function getLastName() + { + return $this->lastName; + } + + /** + * @param mixed $lastName + */ + public function setLastName($lastName) + { + $this->lastName = $lastName; + } + + /** + * @return mixed + */ + public function getStreetAddress() + { + return $this->streetAddress; + } + + /** + * @param mixed $streetAddress + */ + public function setStreetAddress($streetAddress) + { + $this->streetAddress = $streetAddress; + } + + /** + * @return mixed + */ + public function getZipCode() + { + return $this->zipCode; + } + + /** + * @param mixed $zipCode + */ + public function setZipCode($zipCode) + { + $this->zipCode = $zipCode; + } + + /** + * @return mixed + */ + public function getCity() + { + return $this->city; + } + + /** + * @param mixed $city + */ + public function setCity($city) + { + $this->city = $city; + } + + /** + * @return mixed + */ + public function getNation() + { + return $this->nation; + } + + /** + * @param mixed $nation + */ + public function setNation($nation) + { + $this->nation = $nation; + } + + /** + * @return mixed + */ + public function getPhone() + { + return $this->phone; + } + + /** + * @param mixed $phone + */ + public function setPhone($phone) + { + $this->phone = $phone; + } + + /** + * @return mixed + */ + public function getFax() + { + return $this->fax; + } + + /** + * @param mixed $fax + */ + public function setFax($fax) + { + $this->fax = $fax; + } + + /** + * @return mixed + */ + public function getEmail() + { + return $this->email; + } + + /** + * @param mixed $email + */ + public function setEmail($email) + { + $this->email = $email; + } + + /** + * @return mixed + */ + public function getNotes() + { + return $this->notes; + } + + /** + * @param mixed $notes + */ + public function setNotes($notes) + { + $this->notes = $notes; + } + + /** + * @return mixed + */ + public function getTravelerCount() + { + return $this->travelerCount; + } + + /** + * @param mixed $travelerCount + */ + public function setTravelerCount($travelerCount) + { + $this->travelerCount = $travelerCount; + } + + /** + * @return mixed + */ + public function getAcceptTerms() + { + return $this->acceptTerms; + } + + /** + * @param mixed $acceptTerms + */ + public function setAcceptTerms($acceptTerms) + { + $this->acceptTerms = $acceptTerms; + } + + /** + * @return mixed + */ + public function getNumberDays() + { + return $this->numberDays; + } + + /** + * @param mixed $numberDays + */ + public function setNumberDays($numberDays) + { + $this->numberDays = $numberDays; + } + + /** + * @return mixed + */ + public function getTotalPrice() + { + return $this->totalPrice; + } + + /** + * @param mixed $totalPrice + */ + public function setTotalPrice($totalPrice) + { + $this->totalPrice = $totalPrice; + } + + /** + * @return FewoLodging + */ + public function getLodging() + { + return $this->lodging; + } + + /** + * @param FewoLodging $lodging + */ + public function setLodging($lodging) + { + $this->lodging = $lodging; + } + + /** + * @return FewoSeason + */ + public function getSeason() + { + return $this->season; + } + + /** + * @param FewoSeason $season + */ + public function setSeason($season) + { + $this->season = $season; + } + + /** + * @return FewoPrice + */ + public function getPrice() + { + return $this->price; + } + + /** + * @param FewoPrice $price + */ + public function setPrice($price) + { + $this->price = $price; + } + + /** + * @Assert\Callback + */ + public function validate(ExecutionContextInterface $context, $payload) + { + //$context-> + } + +} \ No newline at end of file diff --git a/trunk/src/AppBundle/Entity/FewoLodging.php b/trunk/src/AppBundle/Entity/FewoLodging.php new file mode 100644 index 00000000..6ecc0f24 --- /dev/null +++ b/trunk/src/AppBundle/Entity/FewoLodging.php @@ -0,0 +1,619 @@ +choosableSeasons; + } + + public function setChoosableSeasons($choosableSeasons) + { + $this->choosableSeasons = $choosableSeasons; + } + + public function getSeasons() + { + $prices = $this->getPrices(); + $seasons = null; + for($i = 0; $i < count($prices); $i++) + { + $seasons[] = $prices->get($i)->getSeason(); + } + return $seasons; + } + + /** + * Constructor + */ + public function __construct() + { + $this->prices = new \Doctrine\Common\Collections\ArrayCollection(); + $this->images = new \Doctrine\Common\Collections\ArrayCollection(); + $this->reservations = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set name + * + * @param string $name + * + * @return FewoLodging + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set description + * + * @param string $description + * + * @return FewoLodging + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set equipment + * + * @param string $equipment + * + * @return FewoLodging + */ + public function setEquipment($equipment) + { + $this->equipment = $equipment; + + return $this; + } + + /** + * Get equipment + * + * @return string + */ + public function getEquipment() + { + return $this->equipment; + } + + /** + * Set adress1 + * + * @param string $adress1 + * + * @return FewoLodging + */ + public function setAdress1($adress1) + { + $this->adress1 = $adress1; + + return $this; + } + + /** + * Get adress1 + * + * @return string + */ + public function getAdress1() + { + return $this->adress1; + } + + /** + * Set adress2 + * + * @param string $adress2 + * + * @return FewoLodging + */ + public function setAdress2($adress2) + { + $this->adress2 = $adress2; + + return $this; + } + + /** + * Get adress2 + * + * @return string + */ + public function getAdress2() + { + return $this->adress2; + } + + /** + * Set zipCode + * + * @param string $zipCode + * + * @return FewoLodging + */ + public function setZipCode($zipCode) + { + $this->zipCode = $zipCode; + + return $this; + } + + /** + * Get zipCode + * + * @return string + */ + public function getZipCode() + { + return $this->zipCode; + } + + /** + * Set city + * + * @param string $city + * + * @return FewoLodging + */ + public function setCity($city) + { + $this->city = $city; + + return $this; + } + + /** + * Get city + * + * @return string + */ + public function getCity() + { + return $this->city; + } + + /** + * Set maximumPersons + * + * @param integer $maximumPersons + * + * @return FewoLodging + */ + public function setMaximumPersons($maximumPersons) + { + $this->maximumPersons = $maximumPersons; + + return $this; + } + + /** + * Get maximumPersons + * + * @return integer + */ + public function getMaximumPersons() + { + return $this->maximumPersons; + } + + /** + * Set deposit + * + * @param float $deposit + * + * @return FewoLodging + */ + public function setDeposit($deposit) + { + $this->deposit = $deposit; + + return $this; + } + + /** + * Get deposit + * + * @return float + */ + public function getDeposit() + { + return $this->deposit; + } + + /** + * Set onlyWeekday + * + * @param integer $onlyWeekday + * + * @return FewoLodging + */ + public function setOnlyWeekday($onlyWeekday) + { + $this->onlyWeekday = $onlyWeekday; + + return $this; + } + + /** + * Get onlyWeekday + * + * @return integer + */ + public function getOnlyWeekday() + { + return $this->onlyWeekday; + } + + /** + * Set calendarVisible + * + * @param boolean $calendarVisible + * + * @return FewoLodging + */ + public function setCalendarVisible($calendarVisible) + { + $this->calendarVisible = $calendarVisible; + + return $this; + } + + /** + * Get calendarVisible + * + * @return boolean + */ + public function getCalendarVisible() + { + return $this->calendarVisible; + } + + /** + * Set type + * + * @param \AppBundle\Entity\FewoLodgingType $type + * + * @return FewoLodging + */ + public function setType(\AppBundle\Entity\FewoLodgingType $type = null) + { + $this->type = $type; + + return $this; + } + + /** + * Get type + * + * @return \AppBundle\Entity\FewoLodgingType + */ + public function getType() + { + return $this->type; + } + + /** + * Add price + * + * @param \AppBundle\Entity\FewoPrice $price + * + * @return FewoLodging + */ + public function addPrice(\AppBundle\Entity\FewoPrice $price) + { + $this->prices[] = $price; + + return $this; + } + + /** + * Remove price + * + * @param \AppBundle\Entity\FewoPrice $price + */ + public function removePrice(\AppBundle\Entity\FewoPrice $price) + { + $this->prices->removeElement($price); + } + + /** + * Get prices + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getPrices() + { + return $this->prices; + } + + /** + * Add image + * + * @param \AppBundle\Entity\FewoLodgingImage $image + * + * @return FewoLodging + */ + public function addImage(\AppBundle\Entity\FewoLodgingImage $image) + { + $this->images[] = $image; + + return $this; + } + + /** + * Remove image + * + * @param \AppBundle\Entity\FewoLodgingImage $image + */ + public function removeImage(\AppBundle\Entity\FewoLodgingImage $image) + { + $this->images->removeElement($image); + } + + /** + * Get images + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getImages() + { + return $this->images; + } + + /** + * Add reservation + * + * @param \AppBundle\Entity\FewoReservation $reservation + * + * @return FewoLodging + */ + public function addReservation(\AppBundle\Entity\FewoReservation $reservation) + { + $this->reservations[] = $reservation; + + return $this; + } + + /** + * Remove reservation + * + * @param \AppBundle\Entity\FewoReservation $reservation + */ + public function removeReservation(\AppBundle\Entity\FewoReservation $reservation) + { + $this->reservations->removeElement($reservation); + } + + /** + * Get reservations + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getReservations() + { + return $this->reservations; + } + + /** + * Set page + * + * @param \AppBundle\Entity\Page $page + * + * @return FewoLodging + */ + public function setPage(\AppBundle\Entity\Page $page = null) + { + $this->page = $page; + + return $this; + } + + /** + * Get page + * + * @return \AppBundle\Entity\Page + */ + public function getPage() + { + return $this->page; + } + + + + function __toString() + { + return $this->name; + } + +} diff --git a/trunk/src/AppBundle/Entity/FewoLodgingImage.php b/trunk/src/AppBundle/Entity/FewoLodgingImage.php new file mode 100644 index 00000000..dd96c932 --- /dev/null +++ b/trunk/src/AppBundle/Entity/FewoLodgingImage.php @@ -0,0 +1,167 @@ +id; + } + + /** + * Set file + * + * @param string $file + * + * @return FewoLodgingImage + */ + public function setFile($file) + { + $this->file = $file; + + return $this; + } + + /** + * Get file + * + * @return string + */ + public function getFile() + { + return $this->file; + } + + /** + * Set description + * + * @param string $description + * + * @return FewoLodgingImage + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set lodging + * + * @param \AppBundle\Entity\FewoLodging $lodging + * + * @return FewoLodgingImage + */ + public function setLodging(\AppBundle\Entity\FewoLodging $lodging = null) + { + $this->lodging = $lodging; + + return $this; + } + + /** + * Get lodging + * + * @return \AppBundle\Entity\FewoLodging + */ + public function getLodging() + { + return $this->lodging; + } + + function __toString() + { + return $this->file; + } + + /** + * Set fileName + * + * @param string $fileName + * + * @return FewoLodgingImage + */ + public function setFileName($fileName) + { + $this->fileName = $fileName; + + return $this; + } + + /** + * Get fileName + * + * @return string + */ + public function getFileName() + { + return $this->fileName; + } +} diff --git a/trunk/src/AppBundle/Entity/FewoLodgingRepository.php b/trunk/src/AppBundle/Entity/FewoLodgingRepository.php new file mode 100644 index 00000000..748a9ea3 --- /dev/null +++ b/trunk/src/AppBundle/Entity/FewoLodgingRepository.php @@ -0,0 +1,17 @@ +id; + } + + /** + * Set name + * + * @param string $name + * + * @return FewoLodgingType + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + function __toString() + { + return $this->name; + } + + +} diff --git a/trunk/src/AppBundle/Entity/FewoPrice.php b/trunk/src/AppBundle/Entity/FewoPrice.php new file mode 100644 index 00000000..e53d60b4 --- /dev/null +++ b/trunk/src/AppBundle/Entity/FewoPrice.php @@ -0,0 +1,163 @@ +id; + } + + /** + * Set perNight + * + * @param float $perNight + * + * @return FewoPrice + */ + public function setPerNight($perNight) + { + $this->perNight = $perNight; + + return $this; + } + + /** + * Get perNight + * + * @return float + */ + public function getPerNight() + { + return $this->perNight; + } + + /** + * Set flatPrice + * + * @param float $flatPrice + * + * @return FewoPrice + */ + public function setFlatPrice($flatPrice) + { + $this->flatPrice = $flatPrice; + + return $this; + } + + /** + * Get flatPrice + * + * @return float + */ + public function getFlatPrice() + { + return $this->flatPrice; + } + + /** + * Set lodging + * + * @param \AppBundle\Entity\FewoLodging $lodging + * + * @return FewoPrice + */ + public function setLodging(\AppBundle\Entity\FewoLodging $lodging = null) + { + $this->lodging = $lodging; + + return $this; + } + + /** + * Get lodging + * + * @return \AppBundle\Entity\FewoLodging + */ + public function getLodging() + { + return $this->lodging; + } + + /** + * Set season + * + * @param \AppBundle\Entity\FewoSeason $season + * + * @return FewoPrice + */ + public function setSeason(\AppBundle\Entity\FewoSeason $season = null) + { + $this->season = $season; + + return $this; + } + + /** + * Get season + * + * @return \AppBundle\Entity\FewoSeason + */ + public function getSeason() + { + return $this->season; + } +} diff --git a/trunk/src/AppBundle/Entity/FewoReservation.php b/trunk/src/AppBundle/Entity/FewoReservation.php new file mode 100644 index 00000000..6a07afe7 --- /dev/null +++ b/trunk/src/AppBundle/Entity/FewoReservation.php @@ -0,0 +1,204 @@ +id; + } + + /** + * Set fromDate + * + * @param \DateTime $fromDate + * + * @return FewoReservation + */ + public function setFromDate($fromDate) + { + $this->fromDate = $fromDate; + + return $this; + } + + /** + * Get fromDate + * + * @return \DateTime + */ + public function getFromDate() + { + return $this->fromDate; + } + + /** + * Set toDate + * + * @param \DateTime $toDate + * + * @return FewoReservation + */ + public function setToDate($toDate) + { + $this->toDate = $toDate; + + return $this; + } + + /** + * Get toDate + * + * @return \DateTime + */ + public function getToDate() + { + return $this->toDate; + } + + /** + * Set status + * + * @param integer $status + * + * @return FewoReservation + */ + public function setStatus($status) + { + $this->status = $status; + + return $this; + } + + /** + * Get status + * + * @return integer + */ + public function getStatus() + { + return $this->status; + } + + /** + * Set lodging + * + * @param \AppBundle\Entity\FewoLodging $lodging + * + * @return FewoReservation + */ + public function setLodging(\AppBundle\Entity\FewoLodging $lodging = null) + { + $this->lodging = $lodging; + + return $this; + } + + /** + * Get lodging + * + * @return \AppBundle\Entity\FewoLodging + */ + public function getLodging() + { + return $this->lodging; + } + + /** + * Set type + * + * @param integer $type + * + * @return FewoReservation + */ + public function setType($type) + { + $this->type = $type; + + return $this; + } + + /** + * Get type + * + * @return integer + */ + public function getType() + { + return $this->type; + } + + /** + * @Assert\Callback + */ + public function validate(ExecutionContextInterface $context, $payload) + { + //$context-> + } + + +} diff --git a/trunk/src/AppBundle/Entity/FewoSeason.php b/trunk/src/AppBundle/Entity/FewoSeason.php new file mode 100644 index 00000000..4dbd86d1 --- /dev/null +++ b/trunk/src/AppBundle/Entity/FewoSeason.php @@ -0,0 +1,245 @@ +prices = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set fromDate + * + * @param \DateTime $fromDate + * + * @return FewoSeason + */ + public function setFromDate($fromDate) + { + $this->fromDate = $fromDate; + + return $this; + } + + /** + * Get fromDate + * + * @return \DateTime + */ + public function getFromDate() + { + return $this->fromDate; + } + + /** + * Set toDate + * + * @param \DateTime $toDate + * + * @return FewoSeason + */ + public function setToDate($toDate) + { + $this->toDate = $toDate; + + return $this; + } + + /** + * Get toDate + * + * @return \DateTime + */ + public function getToDate() + { + return $this->toDate; + } + + /** + * Set minimumStay + * + * @param integer $minimumStay + * + * @return FewoSeason + */ + public function setMinimumStay($minimumStay) + { + $this->minimumStay = $minimumStay; + + return $this; + } + + /** + * Get minimumStay + * + * @return integer + */ + public function getMinimumStay() + { + return $this->minimumStay; + } + + /** + * Set description + * + * @param string $description + * + * @return FewoSeason + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Add price + * + * @param \AppBundle\Entity\FewoPrice $price + * + * @return FewoSeason + */ + public function addPrice(\AppBundle\Entity\FewoPrice $price) + { + $this->prices[] = $price; + + return $this; + } + + /** + * Remove price + * + * @param \AppBundle\Entity\FewoPrice $price + */ + public function removePrice(\AppBundle\Entity\FewoPrice $price) + { + $this->prices->removeElement($price); + } + + /** + * Get prices + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getPrices() + { + return $this->prices; + } + + /** + * Set name + * + * @param string $name + * + * @return FewoSeason + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + function __toString() + { + return $this->name; + } + +} diff --git a/trunk/src/AppBundle/Entity/Page.php b/trunk/src/AppBundle/Entity/Page.php index b68a8dd7..b03e5f2c 100644 --- a/trunk/src/AppBundle/Entity/Page.php +++ b/trunk/src/AppBundle/Entity/Page.php @@ -100,10 +100,18 @@ class Page * @var TravelProgram * * @ORM\OneToOne(targetEntity="AppBundle\Entity\TravelProgram", inversedBy="page") - * @ORM\JoinColumn(name="travel_program", referencedColumnName="id") + * @ORM\JoinColumn(name="travel_program", referencedColumnName="id", onDelete="SET NULL") */ private $travelProgram; + /** + * @var FewoLodging + * + * @ORM\OneToOne(targetEntity="AppBundle\Entity\FewoLodging", inversedBy="page") + * @ORM\JoinColumn(name="fewo_lodging", referencedColumnName="id", onDelete="SET NULL") + */ + private $fewoLodging; + /** * @var integer * @@ -1070,6 +1078,30 @@ class Page return $this->travelProgram; } + /** + * Set fewoLodging + * + * @param \AppBundle\Entity\FewoLodging $fewoLodging + * + * @return Page + */ + public function setFewoLodging(\AppBundle\Entity\FewoLodging $fewoLodging = null) + { + $this->fewoLodging = $fewoLodging; + + return $this; + } + + /** + * Get fewoLodging + * + * @return \AppBundle\Entity\FewoLodging + */ + public function getFewoLodging() + { + return $this->fewoLodging; + } + /** * @param string|null $realUrlPath * diff --git a/trunk/src/AppBundle/Entity/Traveler.php b/trunk/src/AppBundle/Entity/Traveler.php index f11d4b1c..76f099fb 100644 --- a/trunk/src/AppBundle/Entity/Traveler.php +++ b/trunk/src/AppBundle/Entity/Traveler.php @@ -16,7 +16,7 @@ class Traveler /** * @Assert\NotNull - * @ Assert\Choice(choices={1,2}) + * @Assert\Choice(choices={1,2}) */ private $sex; diff --git a/trunk/src/AppBundle/Export/FewoBookingSternToursCrmExporter.php b/trunk/src/AppBundle/Export/FewoBookingSternToursCrmExporter.php new file mode 100644 index 00000000..de65a327 --- /dev/null +++ b/trunk/src/AppBundle/Export/FewoBookingSternToursCrmExporter.php @@ -0,0 +1,144 @@ +createLead($fewoBookingRequest); + if ($lead === null) + { + $this->warn('Failed creating lead in CRM', $fewoBookingRequest, Logger::ERROR); + return false; + } + $bookingUrl = $this->createBooking($fewoBookingRequest, $fewoLodging, $fewoPrice, $lead['customer_id'], $lead['id']); + if ($bookingUrl === false) + { + $this->warn('Failed creating booking in CRM', $fewoBookingRequest, Logger::ERROR); + return false; + } + + /* + if(!$this->createTraveler($bookingUrl, $fewoBookingRequest)) + { + $this->warn('Failed creating traveler in CRM.', $fewoBookingRequest); + } + */ + + return $bookingUrl; + } + + private function createLead(FewoBookingRequest $fewoBookingRequest) + { + $resp = $this->httpPost('lead', ['lead' => [ + 'customerForm' => [ + 'salutation_id' => $fewoBookingRequest->getSalutation(), + 'name' => $fewoBookingRequest->getLastName(), + 'firstname' => $fewoBookingRequest->getFirstName(), + 'street' => $fewoBookingRequest->getStreetAddress(), + 'zip' => $fewoBookingRequest->getZipCode(), + 'city' => $fewoBookingRequest->getCity(), + 'country_id' => $fewoBookingRequest->getNation(), + 'phone' => $fewoBookingRequest->getPhone(), + 'fax' => $fewoBookingRequest->getFax(), + 'email' => $fewoBookingRequest->getEmail() + ], + 'request_date' => (new \DateTime())->format('Y-m-d'), + 'sf_guard_user_id' => self::API_USER_ID, + 'status_id' => 7, // 'gebucht' + 'travelperiod_start' => $fewoBookingRequest->getFromDate()->format('Y-m-d'), + 'travelperiod_end' => $fewoBookingRequest->getToDate()->format('Y-m-d'), + //'travelcategory_id' + 'is_closed' => 1, + 'website_id' => self::WEBSITE_ID, + 'initialcontacttype_id' => 14, + // 'travelperiod_length + 'remarks' => $fewoBookingRequest->getNotes() + ]]); + + if ($resp['success']) + { + $ret = $this->httpGet($resp['location']); + if ($ret == null) + { + $this->warn('Failed retrieving newly created lead object', $fewoBookingRequest); + } + return $ret; + } + return null; + } + + private function createBooking(FewoBookingRequest $fewoBookingRequest, FewoLodging $lodging, FewoPrice $price, $customerId, $leadId) + { + $resp = $this->httpPost('booking', ['booking' => [ + 'booking_date' => (new \DateTime())->format('Y-m-d'), + 'customer_id' => $customerId, + 'lead_id' => $leadId, + //'travel_country_id' => $tp->getTravelCountry(), + //'travel_category_id' => $tp->getTravelCategory(), + //'travelagenda_id' => $tp->getTravelAgenda(), + 'sf_guard_user_id' => self::API_USER_ID, + 'branch_id' => 4, + 'website_id' => self::WEBSITE_ID, + 'title' => $lodging->getName(), + 'start_date' => $fewoBookingRequest->getFromDate()->format('Y-m-d'), + 'end_date' => $fewoBookingRequest->getToDate()->format('Y-m-d'), + 'pax' => $fewoBookingRequest->getTravelerCount(), + 'travel_number' => $lodging->getName()." - ".$price->getSeason()->getName(), + 'price' => $fewoBookingRequest->getTotalPrice(), + + 'participant_salutation_id' => $fewoBookingRequest->getSalutation(), + 'participant_name' => $fewoBookingRequest->getLastName(), + 'participant_firstname' => $fewoBookingRequest->getFirstName(), + //'participant_birthdate' => $bookingRequest->getTravelers()[0]->getBirthDate(), + ]]); + + if (!$resp['success']) + { + return false; + } + return $resp['location']; + } + + private function createTraveler($bookingUrl, FewoBookingRequest $fewoBookingRequest) + { + $resp = $this->httpPost($bookingUrl .'/participant.json', ['participant' => [ + 'participant_salutation_id' => $fewoBookingRequest->getSalutation(), + 'participant_name' => $fewoBookingRequest->getLastName(), + 'participant_firstname' => $fewoBookingRequest->getFirstName(), + //'participant_birthdate' => $traveler->getBirthDate(), + ]], true); + return $resp['success']; + } + + private function warn($msg, FewoBookingRequest $fewoBookingRequest = null, $level = Logger::WARNING) + { + $this->logger->log($level, 'SternToursCrmBookingExporter: '. $msg); + $this->logger->log($level, '*** Date: '. (new \DateTime())->format('d.m.Y')); + + if ($fewoBookingRequest !== null) + { + $this->logger->log($level, '*** Booking date: '. $fewoBookingRequest->getFromDate()->format('d.m.Y') . + ' - '. $fewoBookingRequest->getToDate()->format('d.m.Y') .')'); + + $this->logger->log($level, '*** User name: '. $fewoBookingRequest->getFirstName() .' '. $fewoBookingRequest->getLastName()); + } + } +} \ No newline at end of file diff --git a/trunk/src/AppBundle/Form/FewoBookingRequestType.php b/trunk/src/AppBundle/Form/FewoBookingRequestType.php new file mode 100644 index 00000000..13ba9859 --- /dev/null +++ b/trunk/src/AppBundle/Form/FewoBookingRequestType.php @@ -0,0 +1,118 @@ + 1, + 'Frau' => 2 + ]; + + public static $NATION_CHOICES = [ + 'Deutschland' => 27, + 'Österreich' => 34, + 'Schweiz' => 181, + 'Niederlande' => 196, + 'Sonstiges' => 197, + ]; + + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'lodging' => null, + 'maxPersons' => null, + 'toDate' => null, + 'data_class' => 'AppBundle\Entity\FewoBookingRequest', + ]); + + $resolver->setAllowedTypes('lodging', ['AppBundle\Entity\FewoLodging']); + $resolver->setAllowedTypes('toDate', ['string', 'NULL']); + + } + + /** + * @param FormBuilderInterface $builder + * @param array $options + */ + public function buildForm(FormBuilderInterface $builder, array $options) + { + $maxPersons = $options['maxPersons']; + $toDate = $options['toDate']; + $toDateDateTime = new \DateTime($toDate); + + $TRAVELERS_CHOICES = [ + '1' => 1, + ]; + + if($maxPersons > 1) + { + for($i = 2; $i <= $maxPersons; $i++) + { + $TRAVELERS_CHOICES[] = $i; + } + } + + $builder + ->add('toDate', StDateType::class, [ + //options + //'widget' => 'single_text', + 'data' => $toDateDateTime, + 'format' => 'd.M.y' + ]) + ->add('travelerCount', ChoiceType::class, [ + 'choices' => $TRAVELERS_CHOICES, + 'constraints' => [ + new NotNull(), + new Choice(['choices' => $TRAVELERS_CHOICES]) + ] + ]) + ->add('salutation', ChoiceType::class,[ + 'choices' => self::$SALUTATION_CHOICES, + 'constraints' => [ + new NotNull(), + new Choice(['choices' => self::$SALUTATION_CHOICES]) + ] + ]) + ->add('firstName') + ->add('lastName') + ->add('streetAddress') + ->add('zipCode') + ->add('city') + ->add('phone') + ->add('fax') + ->add('email') + ->add('notes', TextareaType::class, ['required' => false]) + ; + + } +} \ No newline at end of file diff --git a/trunk/src/AppBundle/Form/FewoLodgingImageType.php b/trunk/src/AppBundle/Form/FewoLodgingImageType.php new file mode 100644 index 00000000..6d7afff1 --- /dev/null +++ b/trunk/src/AppBundle/Form/FewoLodgingImageType.php @@ -0,0 +1,46 @@ +add('file', FileType::class, [ + + ]) + ->add('fileName') + ->add('description') + ; + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'AppBundle\Entity\FewoLodgingImage' + )); + + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() + { + return 'appbundle_fewolodgingimage'; + } + + +} diff --git a/trunk/src/AppBundle/Form/FewoLodgingType.php b/trunk/src/AppBundle/Form/FewoLodgingType.php new file mode 100644 index 00000000..bbc85032 --- /dev/null +++ b/trunk/src/AppBundle/Form/FewoLodgingType.php @@ -0,0 +1,92 @@ + 0, + 'Montag' => 1, + 'Dienstag' => 2, + 'Mittwoch' => 3, + 'Donnerstag' => 4, + 'Freitag' => 5, + 'Samstag' => 6, + 'Sonntag' => 7 + ]; + + + + /** + * {@inheritdoc} + */ + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder + ->add('name') + ->add('description') + ->add('equipment') + ->add('adress1') + ->add('adress2') + ->add('zipCode') + ->add('city') + ->add('maximumPersons', TextType::class, [ + + ]) + ->add('deposit') + ->add('onlyWeekday', ChoiceType::class, [ + 'choices' => self::$WEEKDAY_CHOICES, + 'constraints' => [ + new Choice(['choices' => self::$WEEKDAY_CHOICES]) + ] + ]) + ->add('calendarVisible') + ->add('type', EntityType::class, [ + 'placeholder' => '(Bitte wählen) *', + 'class' => 'AppBundle\Entity\FewoLodgingType', + 'constraints' => [ + new NotNull() + ] + ]) + + ; + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'AppBundle\Entity\FewoLodging' + )); + + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() + { + return 'appbundle_fewolodging'; + } + + +} diff --git a/trunk/src/AppBundle/Form/FewoPriceType.php b/trunk/src/AppBundle/Form/FewoPriceType.php new file mode 100644 index 00000000..7b1cd707 --- /dev/null +++ b/trunk/src/AppBundle/Form/FewoPriceType.php @@ -0,0 +1,60 @@ +add('perNight') + ->add('flatPrice') + ->add('season', EntityType::class, [ + 'placeholder' => 'Bitte wählen', + 'class' => 'AppBundle\Entity\FewoSeason', + 'choices' => $lodging->getChoosableSeasons(), + 'constraints' => [ + new NotNull(), + new Choice([ + 'choices' => $lodging->getChoosableSeasons() + ] + )] + + ]) + ; + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'lodging' => null, + 'data_class' => 'AppBundle\Entity\FewoPrice' + )); + $resolver->setAllowedTypes('lodging', ['AppBundle\Entity\FewoLodging']); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() + { + return 'appbundle_fewoprice'; + } + + +} diff --git a/trunk/src/AppBundle/Form/FewoReservationType.php b/trunk/src/AppBundle/Form/FewoReservationType.php new file mode 100644 index 00000000..264cf136 --- /dev/null +++ b/trunk/src/AppBundle/Form/FewoReservationType.php @@ -0,0 +1,95 @@ + 0, + 'Nicht verfügbar' => 1, + ]; + + public static $TYPE_CHOICES = [ + 'Buchung' => 0, + 'Händisch' => 1 + ]; + + + /** + * {@inheritdoc} + */ + public function buildForm(FormBuilderInterface $builder, array $options) + { + $lodging = $options['lodging']; + $fromDate = $options['fromDate']; + $fromDateDateTime = new \DateTime($fromDate); + $lodgingArr[] = $lodging; + + $builder + ->add('lodging', EntityType::class, [ + 'class' => 'AppBundle\Entity\FewoLodging', + 'choices' => $lodgingArr, + 'constraints' => [ + new Choice(['choices' => $lodgingArr]) + ], + 'required'=> true + ]) + ->add('fromDate', StDateType::class, [ + //options + 'data' => $fromDateDateTime + ]) + ->add('toDate', StDateType::class, [ + ]) + ->add('status', ChoiceType::class, [ + 'placeholder' => 'Status (Bitte wählen) *', + 'choices' => self::$STATUS_CHOICES, + 'constraints' => [ + new Choice(['choices' => self::$STATUS_CHOICES]) + ], + 'required' => true, + ]) + ->add('type', ChoiceType::class, [ + 'placeholder' => 'Buchungstyp (Bitte wählen) *', + 'choices' => self::$TYPE_CHOICES, + 'constraints' => [ + new Choice(['choices' => self::$TYPE_CHOICES]) + ], + 'required' => true, + ]) + //->add('lodging') // wird händisch gesetzt + ; + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'lodging' => null, + 'fromDate' => null, + 'data_class' => 'AppBundle\Entity\FewoReservation' + )); + $resolver->setAllowedTypes('lodging', ['AppBundle\Entity\FewoLodging']); + $resolver->setAllowedTypes('fromDate', ['string', 'NULL']); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() + { + return 'appbundle_feworeservation'; + } + + +} diff --git a/trunk/src/AppBundle/Form/FewoSeasonType.php b/trunk/src/AppBundle/Form/FewoSeasonType.php new file mode 100644 index 00000000..4cfe2147 --- /dev/null +++ b/trunk/src/AppBundle/Form/FewoSeasonType.php @@ -0,0 +1,63 @@ +add('name') + ->add('fromDate', StDateType::class, [ + //options + ]) + ->add('toDate', StDateType::class, [ + //options + ]) + ->add('minimumStay', TextType::class, [ + + ]) + ->add('description') + ; + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'AppBundle\Entity\FewoSeason' + )); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() + { + return 'appbundle_fewoseason'; + } + + +} diff --git a/trunk/src/AppBundle/Listener/DoctrineFileListener.php b/trunk/src/AppBundle/Listener/DoctrineFileListener.php new file mode 100644 index 00000000..c9bb3bb5 --- /dev/null +++ b/trunk/src/AppBundle/Listener/DoctrineFileListener.php @@ -0,0 +1,76 @@ +uploader = $uploader; + } + + public function prePersist(LifecycleEventArgs $args) + { + $entity = $args->getEntity(); + + $this->uploadFile($entity); + } + + public function preUpdate(PreUpdateEventArgs $args) + { + $entity = $args->getEntity(); + + $this->uploadFile($entity); + } + + public function preRemove(LifecycleEventArgs $args) + { + $entity = $args->getEntity(); + + $this->deleteFile($entity); + } + + private function uploadFile($entity) + { + + if (!$entity instanceof FewoLodgingImage) + { + return; + } + + $file = $entity->getFile(); + + + // man könnte hier noch anpassungen tätigen, wie zb. dass man den dateinamen selbst über fileName angeben kann + // oder man nutzt (so wie es jetzt ist) fileName dafür, es als alt-Name usw. zu benutzen und der dateiname bleibt kryptisch + + + // only upload new files + if (!$file instanceof UploadedFile) + { + return; + } + + $fileName = $this->uploader->upload($file); + $entity->setFile($fileName); + } + + private function deleteFile($entity) + { + if(!$entity instanceof FewoLodgingImage) + { + return; + } + + $this->uploader->delete($entity); + } +} \ No newline at end of file diff --git a/trunk/src/AppBundle/Listener/KernelControllerListener.php b/trunk/src/AppBundle/Listener/KernelControllerListener.php index 32a3aa07..1fb9a026 100644 --- a/trunk/src/AppBundle/Listener/KernelControllerListener.php +++ b/trunk/src/AppBundle/Listener/KernelControllerListener.php @@ -145,6 +145,18 @@ class KernelControllerListener } $request->attributes->set('_controller', 'AppBundle:Cms:travelProgram'); } + elseif ($node->getFewoLodging() != null && ($restOfPath == '/fewo-buchen' || $restOfPath == '/fewo-berechne-gesamtpreis')) + { + $request->attributes->set('fewoTravelProgramPage', $node); + $request->attributes->set('action', $restOfPath); + $request->attributes->set('_controller', 'AppBundle:FewoBooking:index'); + } + elseif ($node->getFewoLodging() != null) + { + $request->attributes->set('fewoLodgingPage', $node); + $request->attributes->set('action', $restOfPath); + $request->attributes->set('_controller', 'AppBundle:Cms:fewoLodging'); + } else { $handler = $node->getTemplate() ? ucfirst($node->getTemplate()) : 'Default'; diff --git a/trunk/src/AppBundle/Resources/assets/less/includes/travel.less b/trunk/src/AppBundle/Resources/assets/less/includes/travel.less index 10d8c374..344ad0ae 100644 --- a/trunk/src/AppBundle/Resources/assets/less/includes/travel.less +++ b/trunk/src/AppBundle/Resources/assets/less/includes/travel.less @@ -506,4 +506,21 @@ } .widget .sidebar-price .btn { color:#ffffff !important; +} + +.calendarEven{ + float: left; + width: 50%; +} + +.calendarOdd{ + float: left; + width: 50%; +} + +.calendarGradient{ + background: -webkit-gradient(linear, left top, right bottom, color-stop(1%, darkgray), color-stop(52%, darkgray), color-stop(52%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(100%, #f2f2f2)); + background: -moz-gradient(linear, left top, right bottom, color-stop(1%, darkgray), color-stop(52%, darkgray), color-stop(52%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(100%, #f2f2f2)); + background: -o-gradient(linear, left top, right bottom, color-stop(1%, darkgray), color-stop(52%, darkgray), color-stop(52%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(100%, #f2f2f2)); + background: gradient(linear, left top, right bottom, color-stop(1%, darkgray), color-stop(52%, darkgray), color-stop(52%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(100%, #f2f2f2)); } \ No newline at end of file diff --git a/trunk/src/AppBundle/Resources/public/css/custom.css b/trunk/src/AppBundle/Resources/public/css/custom.css index 0cd4e478..57c47d19 100644 --- a/trunk/src/AppBundle/Resources/public/css/custom.css +++ b/trunk/src/AppBundle/Resources/public/css/custom.css @@ -1057,6 +1057,20 @@ a[id^="video_"]:before, .widget .sidebar-price .btn { color: #ffffff !important; } +.calendarEven { + float: left; + width: 50%; +} +.calendarOdd { + float: left; + width: 50%; +} +.calendarGradient { + background: -webkit-gradient(linear, left top, right bottom, color-stop(1%, #a9a9a9), color-stop(52%, #a9a9a9), color-stop(52%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(100%, #f2f2f2)); + background: -moz-gradient(linear, left top, right bottom, color-stop(1%, #a9a9a9), color-stop(52%, #a9a9a9), color-stop(52%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(100%, #f2f2f2)); + background: -o-gradient(linear, left top, right bottom, color-stop(1%, #a9a9a9), color-stop(52%, #a9a9a9), color-stop(52%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(100%, #f2f2f2)); + background: gradient(linear, left top, right bottom, color-stop(1%, #a9a9a9), color-stop(52%, #a9a9a9), color-stop(52%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(100%, #f2f2f2)); +} /* 7) SHORTCODES =============================================================== diff --git a/trunk/src/AppBundle/Resources/public/js/fewoBooking.js b/trunk/src/AppBundle/Resources/public/js/fewoBooking.js new file mode 100644 index 00000000..1c5be351 --- /dev/null +++ b/trunk/src/AppBundle/Resources/public/js/fewoBooking.js @@ -0,0 +1,32 @@ +$(document).ready(function() { + + var frm$ = $('.st-booking-form'); + var summary$ = $('.st-booking-summary'); + + var toDateDay$ = $('#fewo_booking_request_toDate_day'); + var toDateMonth$ = $('#fewo_booking_request_toDate_month'); + var toDateYear$ = $('#fewo_booking_request_toDate_year'); + + frm$.find('input, select').change(function() { + var tmp = location.href.split('?'); + var tmp2 = tmp[0].split('/'); + tmp2.pop(); + var url = tmp2.join('/') + '/fewo-berechne-gesamtpreis'; + if (tmp[1]) + { + url += '?'+ tmp[1]; + } + + $.ajax({ + url: url, + type: 'post', + data: frm$.serialize() + + }).then(function(r) { + summary$.html(r); + + }, function() { + summary$.html('Aufgrund eines Fehlers konnte kein Angebot ermittelt werden.'); + }) + }); +}); \ No newline at end of file diff --git a/trunk/src/AppBundle/Service/FileManager.php b/trunk/src/AppBundle/Service/FileManager.php new file mode 100644 index 00000000..6d8916be --- /dev/null +++ b/trunk/src/AppBundle/Service/FileManager.php @@ -0,0 +1,37 @@ +targetDir = $targetDir; + } + + public function upload(UploadedFile $file) + { + $fileName = md5(uniqid()).'.'.$file->guessExtension(); + + $file->move($this->getTargetDir(), $fileName); + + return $fileName; + } + + public function delete(FewoLodgingImage $image) + { + $filesystem = new Filesystem(); + + $filesystem->remove($this->getTargetDir().'/'.$image->getFile()); + } + + public function getTargetDir() + { + return $this->targetDir; + } +} \ No newline at end of file diff --git a/trunk/src/AppBundle/Util/LodgingCalendarUtil.php b/trunk/src/AppBundle/Util/LodgingCalendarUtil.php new file mode 100644 index 00000000..8b4de53a --- /dev/null +++ b/trunk/src/AppBundle/Util/LodgingCalendarUtil.php @@ -0,0 +1,620 @@ +em = $entityManager; + } + + + + private function daysInMonth($month, $year) + { + return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31); + } + + public function getCalendarWithPadding() + { + $calendar = null; + $currentMonth = date('n'); + $currentYear = date('Y'); + $weekDays = ['So','Mo','Di','Mi','Do','Fr','Sa']; + + setlocale(LC_TIME, "german"); + + for($m = $currentMonth; $m < ($currentMonth + 12); $m++) + { + if($m < 13) + { + $actualMonth = $m; + $actualCurrentYear = $currentYear; + } + else + { + $actualMonth = $m % 12; + $actualCurrentYear = $currentYear + 1; + } + + $date = getdate(mktime(0,0,0, $actualMonth, 1, $actualCurrentYear)); + $weekDay = $weekDays[$date['wday']]; + + $numberDays = $this->daysInMonth($actualMonth, $actualCurrentYear); + $data = null; + + $actualStartingWeekDay = $date['wday']; + + if($actualStartingWeekDay == 0) + { + $actualStartingWeekDay = 7; + } + + for($fwd = 0; $fwd < $actualStartingWeekDay - 1; $fwd++) + { + $data[] = 0; + } + + for($d = 1; $d <= $numberDays; $d++) + { + $data[] = $d; + } + + $startIndex = count($data); + + for($lwd = $startIndex; $lwd < 42; $lwd++) + { + $data[] = 0; + } + + $calendar[] = [ + 'numberDays' => $numberDays, + 'monthNumber' => $actualMonth, + 'monthName' => utf8_encode(strftime("%B", mktime(0, 0, 0, $actualMonth, 1, $actualCurrentYear))), + 'year' => $actualCurrentYear, + 'startWeekDay' => $weekDay, + 'data' => $data, + 'marked' => 0 + ]; + } + + return $calendar; + } + + + public function getCalendar() + { + + $calendar = null; + $currentMonth = date('n'); + $currentYear = date('Y'); + $weekDays = ['So','Mo','Di','Mi','Do','Fr','Sa']; + + setlocale(LC_TIME, "german"); + + for($m = $currentMonth; $m < ($currentMonth + 12); $m++) + { + if($m < 13) + { + $actualMonth = $m; + $actualCurrentYear = $currentYear; + } + else + { + $actualMonth = $m % 12; + $actualCurrentYear = $currentYear + 1; + } + + $date = getdate(mktime(0,0,0, $actualMonth, 1, $actualCurrentYear)); + $weekDay = $weekDays[$date['wday']]; + + $numberDays = $this->daysInMonth($actualMonth, $actualCurrentYear); + $data = null; + + // alle Wochentage + for($d = 1; $d <= $numberDays; $d++) + { + $data[] = $d; + } + + $calendar[] = [ + 'numberDays' => $numberDays, + 'monthNumber' => $actualMonth, + 'monthName' => utf8_encode(strftime("%B", mktime(0, 0, 0, $actualMonth, 1, $actualCurrentYear))), + 'year' => $actualCurrentYear, + 'startWeekDay' => $weekDay, + 'data' => $data, + 'marked' => 0 + ]; + } + + return $calendar; + } + + /** + * @param FewoLodging $lodging + * @return array|null + */ + public function getReservations(FewoLodging $lodging) + { + $reservations = $lodging->getReservations(); + $ret = null; + + for($i = 0; $i < count($reservations); $i++) + { + $fromDate = $reservations[$i]->getFromDate(); + $toDate = $reservations[$i]->getToDate(); + + $ret[] = [ + 'startDay' => $fromDate->format('j'), + 'startMonth' => $fromDate->format('n'), + 'startYear' => $fromDate->format('Y'), + 'endDay' => $toDate->format('j'), + 'endMonth' => $toDate->format('n'), + 'endYear' => $toDate->format('Y') + ]; + } + + return $ret; + } + + private function getMonthIndex($calendar, $month) + { + $result = 0; + for($i = 0; $i < count($calendar); $i++) + { + if($calendar[$i]['monthNumber'] == $month) + { + $result = $i; + break; + } + } + return $result; + } + + + /** + * @param $calendar + * @param \DateTime $fromDate + * @param \DateTime $toDate + * @param $appendix + * @return mixed + */ + private function markCalendarDays($calendar, \DateTime $fromDate, \DateTime $toDate, $appendix, $reservationMode = false) + { + $startDay = $fromDate->format('j'); + $startMonth = $fromDate->format('n'); + $startYear = $fromDate->format('Y'); + $endDay = $toDate->format('j'); + $endMonth = $toDate->format('n'); + $endYear = $toDate->format('Y'); + $today = new \DateTime(); + $todayDay = $today->format('j'); + $todayMonth = $today->format('n'); + $todayYear = $today->format('Y'); + + + if($startMonth < $todayMonth && $startYear == $todayYear) + { + $startDay = 1; + $startMonth = $today->format('n'); + $startYear = $today->format('Y'); + } + + $startCalendarIndex = $this->getMonthIndex($calendar, $startMonth); + $endCalendarIndex = $this->getMonthIndex($calendar, $endMonth); + + + if($startCalendarIndex == $endCalendarIndex) + { + $data = $calendar[$startCalendarIndex]['data']; + + $calendar[$startCalendarIndex]['marked'] = 1; + + $startIndex = $startDay - 1; + $endIndex = $endDay - 1; + + $firstDay = explode(',', $data[$startIndex]); + + if(count($firstDay) > 1 && $reservationMode == false) + $startIndex = $startIndex + 1; + + for($i = $startIndex; $i <= $endIndex; $i++) + { + + if($i == $startIndex && $reservationMode) + { + $data[$i] = $data[$i].$appendix.",from"; + } elseif($i == $endIndex && $reservationMode) { + $data[$i] = $data[$i].$appendix.",to"; + } else { + $data[$i] = $data[$i].$appendix; + } + } + $calendar[$startCalendarIndex]['data'] = $data; + } + else + { + $data = $calendar[$startCalendarIndex]['data']; + + $calendar[$startCalendarIndex]['marked'] = 1; + + $startIndex = $startDay - 1; + + $firstDay = explode(',', $data[$startIndex]); + + if(count($firstDay) > 1 && $reservationMode == false) + $startIndex = $startIndex + 1; + + $endIndex = count($data) - 1; + for($i = $startIndex; $i <= $endIndex; $i++) + { + if($i == $startIndex && $reservationMode) + { + $data[$i] = $data[$i].$appendix.",from"; + } else { + $data[$i] = $data[$i].$appendix; + } + } + $calendar[$startCalendarIndex]['data'] = $data; + + $data = $calendar[$endCalendarIndex]['data']; + + $calendar[$endCalendarIndex]['marked'] = 1; + + $startIndex = 0; + $endIndex = $endDay - 1; + for($i = $startIndex; $i <= $endIndex; $i++) + { + if($i == $endIndex && $reservationMode) + { + $data[$i] = $data[$i].$appendix.",to"; + } else { + $data[$i] = $data[$i].$appendix; + } + } + $calendar[$endCalendarIndex]['data'] = $data; + + for($i = $startCalendarIndex + 1; $i < $endCalendarIndex; $i++) + { + $data = $calendar[$i]['data']; + + $calendar[$i]['marked'] = 1; + + $startIndex = 0; + $endIndex = count($data) - 1; + for($j = $startIndex; $j <= $endIndex; $j++) + { + $data[$j] = $data[$j].$appendix; + } + $calendar[$i]['data'] = $data; + } + } + return $calendar; + } + + private function mergeCalendars($calendar, $extensionCalendar, $withFromTo = false) + { + for($i = 0; $i < 12; $i++) + { + if($calendar[$i]['marked'] == 1 && $extensionCalendar[$i]['marked'] == 1) + { + $calendarData = $calendar[$i]['data']; + $extensionCalendarData = $extensionCalendar[$i]['data']; + + $endIndex = count($calendarData); + + for($j = 0; $j < $endIndex; $j++) + { + if(strlen($extensionCalendarData[$j]) > 2) + { + if($withFromTo) + { + $calDay = explode(',', $calendarData[$j]); + $extCalDay = explode(',', $extensionCalendarData[$j]); + + if(count ($calDay) > 1 && $calDay[1] == "reservable" && count($extCalDay) > 2 && $extCalDay[2] == 'to') + { + $calendarData[$j] = $extensionCalendarData[$j].",reservable".','.$calDay[2]; + } + else + $calendarData[$j] = $extensionCalendarData[$j]; + + } + else + { + $calendarData[$j] = $extensionCalendarData[$j]; + } + } + } + + $calendar[$i]['data'] = $calendarData; + } + } + + return $calendar; + } + + public function mergeWithPaddedCalendar($calendar, $paddedCalendar) + { + for($i = 0; $i < count($paddedCalendar); $i++) + { + $calendarDataCurrMonth = $calendar[$i]['data']; + $paddedCalendarDataCurrMonth = $paddedCalendar[$i]['data']; + $startIndex = array_search(1, $paddedCalendarDataCurrMonth); + for($j = 0; $j < count($calendarDataCurrMonth); $j++, $startIndex++) + { + $paddedCalendarDataCurrMonth[$startIndex] = $calendarDataCurrMonth[$j]; + } + $paddedCalendar[$i]['data'] = $paddedCalendarDataCurrMonth; + } + return $paddedCalendar; + } + + private function isNextDay($current, $next) + { + $result = false; + + $calculatedNextDate = date('d.m.Y', strtotime($current." + 1 day")); + + + if($calculatedNextDate == $next) + { + $result = true; + } + + return $result; + } + + private function getMonthFromCalendar($calendar, $monthNumber) + { + $result = []; + + for($i = 0; $i < count($calendar); $i++) + { + if($calendar[$i]['monthNumber'] == $monthNumber) + { + $result = $calendar[$i]; + } + } + + return $result; + } + + /** + * @param FewoLodging $lodging + * @param $calendar + * @return array|null + */ + private function filterReservableDays(FewoLodging $lodging, $calendar) + { + $priceRepo = $this->em->getRepository('AppBundle:FewoPrice'); + + $today = new \DateTime(); + $seasons = $lodging->getSeasons(); + $prices = $lodging->getPrices(); + $cleanCalendar = $this->getCalendar(); + + $potentiallyReservableDays = []; + $actuallyReservableDays = []; + $lastReservablePriceId = 0; + $priceId = 0; + + for($currMonthIndex = 0; $currMonthIndex < count($calendar); $currMonthIndex++) + { + $currMonth = $calendar[$currMonthIndex]; + $data = $currMonth['data']; + + for($currDayIndex = 0; $currDayIndex < count($data); $currDayIndex++) + { + $currDay = explode(',', $data[$currDayIndex]); + + if(count($currDay) > 1) + { + if($currDay[1] == "reservable") + { + $priceId = $currDay[2]; + + if($lastReservablePriceId == 0) + $lastReservablePriceId = $priceId; + + + if($lastReservablePriceId != $priceId) + { + $price = $priceRepo->find($lastReservablePriceId); + /** @var FewoSeason $season */ + $season = $price->getSeason(); + + $actuallyReservableDays = $this->processPotentiallyReservableDays($potentiallyReservableDays, $season->getMinimumStay()); + $this->processRest($actuallyReservableDays, $lastReservablePriceId, $cleanCalendar); + + $lastReservablePriceId = $priceId; + $potentiallyReservableDays = []; + $actuallyReservableDays = []; + + } + + $currentDayDate = date("d.m.Y", strtotime($currMonth['year']."-".$currMonth['monthNumber']."-".$currDay[0])); + $potentiallyReservableDays[] = $currentDayDate; + } + elseif(count($currDay) > 2 && $currDay[2] == "from") + { + $currentDayDate = date("d.m.Y", strtotime($currMonth['year']."-".$currMonth['monthNumber']."-".$currDay[0])); + $potentiallyReservableDays[] = $currentDayDate; + } + + } + else + { + if($lastReservablePriceId == $priceId) + { + $price = $priceRepo->find($lastReservablePriceId); + /** @var FewoSeason $season */ + $season = $price->getSeason(); + + $actuallyReservableDays = $this->processPotentiallyReservableDays($potentiallyReservableDays, $season->getMinimumStay()); + $this->processRest($actuallyReservableDays, $lastReservablePriceId, $cleanCalendar); + + $lastReservablePriceId = $priceId; + $potentiallyReservableDays = []; + $actuallyReservableDays = []; + } + } + } + + } + return $cleanCalendar; + } + + private function processPotentiallyReservableDays($potentiallyReservableDays, $minimumStay) + { + $coherentDays = []; + $actuallyReservableDays = []; + //$coherentDays[] = $potentiallyReservableDays[0]; + for($i = 1; $i < count($potentiallyReservableDays); $i++) + { + + if($this->isNextDay($potentiallyReservableDays[$i - 1], $potentiallyReservableDays[$i])) + { + if(count($coherentDays) == 0) + { + $coherentDays[] = $potentiallyReservableDays[$i - 1]; + } + $coherentDays[] = $potentiallyReservableDays[$i]; + } + else + { + if(count($coherentDays) < $minimumStay) + { + $coherentDays = []; + $coherentDays[] = $potentiallyReservableDays[$i]; + } + else + { + $coherentDaysCount = count($coherentDays); + + $offset = $coherentDaysCount - ($minimumStay - 1); + + $coherentDays = array_splice($coherentDays, 0, $offset); + for($j = 0; $j < count($coherentDays); $j++) + { + $actuallyReservableDays[] = $coherentDays[$j]; + } + $coherentDays = []; + } + } + } + + if(count($coherentDays) > 0) + { + $coherentDaysCount = count($coherentDays); + + $offset = $coherentDaysCount - ($minimumStay - 1); + + $coherentDays = array_splice($coherentDays, 0, $offset); + for($j = 0; $j < count($coherentDays); $j++) + { + $actuallyReservableDays[] = $coherentDays[$j]; + } + } + + return $actuallyReservableDays; + } + + private function processRest($actuallyReservableDays, $priceId, &$cleanCalendar) + { + for($currMonthIndex = 0; $currMonthIndex < count($cleanCalendar); $currMonthIndex++) + { + $currMonth = $cleanCalendar[$currMonthIndex]; + $data = $currMonth['data']; + + $startIndex = array_search(1, $data); + $endIndex = $startIndex + ($currMonth['numberDays']); + + for($currDayIndex = $startIndex; $currDayIndex < $endIndex; $currDayIndex++) + { + $currDay = explode(',', $data[$currDayIndex]); + + $currentDate = date("d.m.Y", strtotime($currMonth['year']."-".$currMonth['monthNumber']."-".$currDay[0])); + + if(in_array($currentDate, $actuallyReservableDays)) + { + $data[$currDayIndex] = $data[$currDayIndex].",reservable,".$priceId; + $currMonth['marked'] = 1; + } + } + $currMonth['data'] = $data; + $cleanCalendar[$currMonthIndex] = $currMonth; + } + + } + + + /** + * @param FewoLodging $lodging + * @param $calendar + * @return mixed + */ + public function markCalendarDaysWithReservations(FewoLodging $lodging, $calendar) + { + $today = new \DateTime(); + $pricesCalendar = $calendar; + $reservationsCalendar = $calendar; + + $reservations = $lodging->getReservations(); + $prices = $lodging->getPrices(); + + $lodgingId = $lodging->getId(); + + foreach($prices as $price) + { + /** @var FewoSeason $season */ + $season = $price->getSeason(); + $appendix = ',reservable,'.$price->getId(); + $fromDate = $season->getFromDate(); + $toDate = $season->getToDate(); + + if($toDate < $today) + { + + } + else + { + $pricesCalendar = $this->markCalendarDays($pricesCalendar, $fromDate, $toDate, $appendix, false); + } + } + + foreach($reservations as $reservation) + { + $reservationId = $reservation->getId(); + $appendix = ','.$reservationId; + $fromDate = $reservation->getFromDate(); + $toDate = $reservation->getToDate(); + + $reservationsCalendar = $this->markCalendarDays($reservationsCalendar, $fromDate, $toDate, $appendix, true); + } + + $mergedPricesAndReservationsCalendar = $this->mergeCalendars($pricesCalendar, $reservationsCalendar, false); + $actuallyReservableDaysCalendar = $this->filterReservableDays($lodging, $mergedPricesAndReservationsCalendar); + $resultCalendar = $this->mergeCalendars($actuallyReservableDaysCalendar, $reservationsCalendar, true); + + return $resultCalendar; + } + + public function convertDate($date) + { + $result = substr($date, 0, 2).'.'.substr($date, 2, 2).'.'.substr($date, 4, 4); + return $result; + } + +} \ No newline at end of file diff --git a/trunk/src/AppBundle/Validator/Constraints/FewoBookingRequest.php b/trunk/src/AppBundle/Validator/Constraints/FewoBookingRequest.php new file mode 100644 index 00000000..3e246361 --- /dev/null +++ b/trunk/src/AppBundle/Validator/Constraints/FewoBookingRequest.php @@ -0,0 +1,18 @@ += $fromDate && $date <= $toDate) + { + $result = true; + } + return $result; + } + + private function alreadyReserved($fromDate, $toDate, $reservationFromDate, $reservationToDate) + { + $result = true; + + if($fromDate >= $reservationToDate || $toDate <= $reservationFromDate) + { + $result = false; + } + + return $result; + } + + + /** + * Checks if the passed value is valid. + * + * @param FewoBookingRequest $bookingRequest The value that should be validated + * @param Constraint $constraint The constraint for the validation + */ + public function validate($bookingRequest, Constraint $constraint) + { + $fromDate = $bookingRequest->getFromDate(); + $toDate = $bookingRequest->getToDate(); + + $lodging = $bookingRequest->getLodging(); + $price = $bookingRequest->getPrice(); + $season = $price->getSeason(); + $reservations = $lodging->getReservations(); + + $timeDiff = date_diff($fromDate, $toDate); + $numberDays = $timeDiff->days + 1; + + $withinSeason = false; + $alreadyReserved = false; + + if($fromDate >= $season->getFromDate() + && $toDate <= $season->getToDate()) + { + $withinSeason = true; + } + + /** @var FewoReservation $reservation */ + foreach($reservations as $reservation) + { + $reservationFromDate = $reservation->getFromDate(); + $reservationToDate = $reservation->getToDate(); + + + if($this->alreadyReserved($fromDate, $toDate, $reservationFromDate, $reservationToDate)) + { + $alreadyReserved = true; + } + + } + + if(!$withinSeason) + { + $this->context->buildViolation("Zeitraum außerhalb der Saison!") + ->addViolation(); + } + + if($alreadyReserved) + { + $this->context->buildViolation("Es gibt bereits Reservierungen innerhalb des gewünschten Zeitraums!") + ->addViolation(); + } + + if($numberDays < $season->getMinimumStay()) + { + $this->context->buildViolation("Mindestanzahl an Tagen nicht erreicht!") + ->addViolation(); + } + + if($bookingRequest->getTravelerCount() > $lodging->getMaximumPersons()) + { + $this->context->buildViolation("Anzahl der Reisenden übersteigt die maximale Personenanzahl!") + ->addViolation(); + } + } +} \ No newline at end of file diff --git a/trunk/src/AppBundle/Validator/Constraints/FewoReservation.php b/trunk/src/AppBundle/Validator/Constraints/FewoReservation.php new file mode 100644 index 00000000..f0963d23 --- /dev/null +++ b/trunk/src/AppBundle/Validator/Constraints/FewoReservation.php @@ -0,0 +1,18 @@ += $reservationToDate || $toDate <= $reservationFromDate) + { + $result = false; + } + + return $result; + } + + + /** + * Checks if the passed value is valid. + * + * @param FewoReservation $reservation The value that should be validated + * @param Constraint $constraint The constraint for the validation + */ + public function validate($reservation, Constraint $constraint) + { + $lodging = $reservation->getLodging(); + $reservations = $lodging->getReservations(); + $seasons = $lodging->getSeasons(); + + $withinAnySeason = false; + $alreadyReserved = false; + + for($i = 0; $i < count($seasons); $i++) + { + if($reservation->getFromDate() >= $seasons[$i]->getFromDate() + && $reservation->getToDate() <= $seasons[$i]->getToDate()) + { + $withinAnySeason = true; + } + } + + foreach($reservations as $reservation) + { + $reservationFromDate = $reservation->getFromDate(); + $reservationToDate = $reservation->getToDate(); + + + if($this->alreadyReserved($reservation->getFromDate(), $reservation->getToDate(), $reservationFromDate, $reservationToDate)) + { + $alreadyReserved = true; + } + } + + if(!$withinAnySeason) + { + $this->context->buildViolation($constraint->message) + ->addViolation(); + } + + if($alreadyReserved) + { + $this->context->buildViolation("Es gibt bereits Reservierungen innerhalb des gewünschten Zeitraums!") + ->addViolation(); + } + + } +} \ No newline at end of file