* Anreise-Wochentag nun per Saison statt Objekt definierbar * Anreise-Wochentag wird für buchbare Tage im Kalender berücksichtigt * Kalenderblätter bis zum Ende des spätesten bekannten Saisonende * Datepicker erlaubt nur noch mögliche Reiseenddaten anzuklicken im Fewo-Buchungsformular * Algogrithmus zur Bestimmung buchbarer Kalendereinträge komplett umgeschrieben, da bisher Reservierungen von nur einer Nacht nicht berücksichtigt werden konnten * Upload mehrerer Bilder gleichzeitig nun möglich * Beim Upload von Bildern werden diese gleich in JPEG umgewandelt, komprimiert und für den Slider zugeschnitten * Behoben: CRM-Export funktioniert teilweise nicht * Für CMS-Template "overview" können nun twig-Variablen per JSON in Spalte cms_settings gesetzt werden (=> Kulturreisensuche ausblendbar für Fewo-Übersichtsseite) * Sonstiges: * Falls CRM-Export nicht funktioniert, wird dies in der Buchungs-Mail für den Service deutlich gemacht SQL: ALTER TABLE fewo_lodging DROP only_weekday; ALTER TABLE fewo_season ADD only_weekday INT DEFAULT NULL; git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3359 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
parent
45977fd4de
commit
1a0388311e
26 changed files with 485 additions and 254 deletions
|
|
@ -4,16 +4,20 @@
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<section class="clearfix">
|
<section class="clearfix">
|
||||||
<div class="content-copy">
|
<div class="content-copy">
|
||||||
<h1>Neues Bild für "{{ lodging.name }}" anlegen</h1>
|
<h1>Bild für "{{ lodging.name }}" anlegen / bearbeiten</h1>
|
||||||
|
|
||||||
<form class="st-booking-form" method="post" enctype="multipart/form-data">
|
<form class="st-booking-form" method="post" enctype="multipart/form-data">
|
||||||
|
|
||||||
{{ form_errors(form) }}
|
{{ form_errors(form) }}
|
||||||
|
|
||||||
<div id="message"></div>
|
|
||||||
|
|
||||||
<div class="form-box">
|
<div class="form-box">
|
||||||
|
{% if is_new %}
|
||||||
{{ form_row(form.file, {label: 'Bild'}) }}
|
{{ form_row(form.file, {label: 'Bild'}) }}
|
||||||
|
{% else %}
|
||||||
|
<div>
|
||||||
|
<img src="{{ asset('uploads/images/' ~ image_file_name) }}" alt="{{ image.description }}" style="width:456px;height:151px;" >
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{{ form_row(form.fileName, {label: 'Name'}) }}
|
{{ form_row(form.fileName, {label: 'Name'}) }}
|
||||||
{{ form_row(form.description, {label: 'Beschreibung'}) }}
|
{{ form_row(form.description, {label: 'Beschreibung'}) }}
|
||||||
|
|
||||||
|
|
@ -25,7 +29,8 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div><!-- end form-box -->
|
</div><!-- end form-box -->
|
||||||
{{ form_rest(form) }}
|
|
||||||
|
{{ form_widget(form._token) }}
|
||||||
</form>
|
</form>
|
||||||
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id }}"
|
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id }}"
|
||||||
class="btn btn-primary"
|
class="btn btn-primary"
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
{% extends 'admin.html.twig' %}
|
||||||
|
{% form_theme form 'default/form/theme.html.twig' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<section class="clearfix">
|
||||||
|
<div class="content-copy">
|
||||||
|
<h1>Mehrere Bilder für "{{ lodging.name }}" hochladen</h1>
|
||||||
|
|
||||||
|
<form class="st-booking-form" method="post" enctype="multipart/form-data">
|
||||||
|
|
||||||
|
{{ form_errors(form) }}
|
||||||
|
|
||||||
|
<div class="form-box">
|
||||||
|
{{ form(form) }}
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<div class="col-md-12 col-sm-12 col-xs-12">
|
||||||
|
<button type="submit" value="SEND" id="submit"
|
||||||
|
class="btn btn-primary btn-lg border-radius"
|
||||||
|
>
|
||||||
|
Speichern
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id }}"
|
||||||
|
class="btn btn-primary"
|
||||||
|
rel="nofollow"
|
||||||
|
>
|
||||||
|
Zurück
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{% endblock body %}
|
||||||
|
|
@ -24,7 +24,6 @@
|
||||||
{{ form_row(form.city, {'label': 'Ort'}) }}
|
{{ form_row(form.city, {'label': 'Ort'}) }}
|
||||||
{{ form_row(form.maximumPersons, {'label': 'Maximale Personenanzahl'}) }}
|
{{ form_row(form.maximumPersons, {'label': 'Maximale Personenanzahl'}) }}
|
||||||
{{ form_row(form.deposit, {'label': 'Kaution'}) }}
|
{{ form_row(form.deposit, {'label': 'Kaution'}) }}
|
||||||
{{ form_row(form.onlyWeekday, {'label': 'Exklusiver Wochentag'}) }}
|
|
||||||
|
|
||||||
{#
|
{#
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
|
|
@ -52,13 +51,17 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for image in lodging.images %}
|
{% for image in lodging.images %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="{{ asset('uploads/images/' ~ image.file) }}" alt="{{ image.description }}" style="width:228px;height:128px;" ></td>
|
<td><img src="{{ asset('uploads/images/' ~ image.file) }}" alt="{{ image.description }}" style="width:228px;height:75px;" ></td>
|
||||||
<td>{{ image.fileName }}</td>
|
<td>{{ image.fileName }}</td>
|
||||||
<td>{{ image.description }}</td>
|
<td>{{ image.description }}</td>
|
||||||
<td>
|
<td>
|
||||||
|
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/images/' ~ image.id }}"
|
||||||
|
class="btn btn-primary"
|
||||||
|
>
|
||||||
|
Bearbeiten
|
||||||
|
</a>
|
||||||
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/images/' ~ image.id ~ '/delete' }}"
|
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/images/' ~ image.id ~ '/delete' }}"
|
||||||
class="btn btn-primary"
|
class="btn btn-primary"
|
||||||
rel="nofollow"
|
|
||||||
>
|
>
|
||||||
Löschen
|
Löschen
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -71,12 +74,12 @@
|
||||||
<h4>Keine Bilder vorhanden</h4>
|
<h4>Keine Bilder vorhanden</h4>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/images/new' }}"
|
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/images/new' }}" class="btn btn-primary">
|
||||||
class="btn btn-primary"
|
|
||||||
rel="nofollow"
|
|
||||||
>
|
|
||||||
Hinzufügen
|
Hinzufügen
|
||||||
</a>
|
</a>
|
||||||
|
<a href="/admin/fewo/lodgings/{{ lodging.id }}/images/multi-upload" class="btn btn-primary">
|
||||||
|
Mehrere Bilder hochladen
|
||||||
|
</a>
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
<table class="table">
|
<table class="table">
|
||||||
{% for monthIndex in 0..11 %}
|
{% for calendar_month in calendar %}
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="7">
|
<th colspan="7">
|
||||||
{{ calendar[monthIndex]['monthName'] }} {{ calendar[monthIndex]['year'] }}
|
{{ calendar_month['monthName'] }} {{ calendar_month['year'] }}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
{% for dayIndex in 0..6 %}
|
{% for dayIndex in 0..6 %}
|
||||||
{# @var dayState \AppBundle\Util\CalendarDayState #}
|
{# @var dayState \AppBundle\Util\CalendarDayState #}
|
||||||
{% set dayState = calendar[monthIndex]['data'][(weekIndex * 7) + dayIndex] %}
|
{% set dayState = calendar_month['data'][(weekIndex * 7) + dayIndex] %}
|
||||||
|
|
||||||
{% set is_past_date = dayState.date is not empty and date(dayState.date) < date('now') %}
|
{% set is_past_date = dayState.date is not empty and date(dayState.date) < date('now') %}
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
{{ dayState.day }}
|
{{ dayState.day }}
|
||||||
</a>
|
</a>
|
||||||
{% elseif dayState.isBookable and not is_past_date %}
|
{% elseif dayState.isBookable and not is_past_date %}
|
||||||
<a href="/admin/fewo/lodgings/{{ lodging.id }}/reservations/new/{{ dayState.day < 10 ? '0':'' }}{{dayState.day}}{{ calendar[monthIndex]['monthNumber'] < 10 ? '0':'' }}{{calendar[monthIndex]['monthNumber']}}{{calendar[monthIndex]['year']}}">
|
<a href="/admin/fewo/lodgings/{{ lodging.id }}/reservations/new/{{ dayState.day < 10 ? '0':'' }}{{dayState.day}}{{ calendar_month['monthNumber'] < 10 ? '0':'' }}{{calendar_month['monthNumber']}}{{calendar_month['year']}}">
|
||||||
{{ dayState.day }}
|
{{ dayState.day }}
|
||||||
</a>
|
</a>
|
||||||
{% elseif dayState.day == 0 %}
|
{% elseif dayState.day == 0 %}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@
|
||||||
{{ form_row(form.city, {label: 'Ort'}) }}
|
{{ form_row(form.city, {label: 'Ort'}) }}
|
||||||
{{ form_row(form.maximumPersons, {label: 'Maximale Personenanzahl'}) }}
|
{{ form_row(form.maximumPersons, {label: 'Maximale Personenanzahl'}) }}
|
||||||
{{ form_row(form.deposit, {label: 'Kaution'}) }}
|
{{ form_row(form.deposit, {label: 'Kaution'}) }}
|
||||||
{{ form_row(form.onlyWeekday, {label: 'Exklusiver Wochentag'}) }}
|
|
||||||
|
|
||||||
{#
|
{#
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,7 @@
|
||||||
{{ form_row(form.toDate, {label: 'Bis'}) }}
|
{{ form_row(form.toDate, {label: 'Bis'}) }}
|
||||||
{{ form_row(form.minimumStay, {label: 'Mindestbelegung in Tagen'}) }}
|
{{ form_row(form.minimumStay, {label: 'Mindestbelegung in Tagen'}) }}
|
||||||
{{ form_row(form.description, {label: 'Beschreibung'}) }}
|
{{ form_row(form.description, {label: 'Beschreibung'}) }}
|
||||||
|
{{ form_row(form.onlyWeekday, {label: 'Exklusiver Wochentag'}) }}
|
||||||
|
|
||||||
|
|
||||||
<div class="col-md-12 col-sm-12 col-xs-12">
|
<div class="col-md-12 col-sm-12 col-xs-12">
|
||||||
<button type="submit" value="SEND" id="submit"
|
<button type="submit" value="SEND" id="submit"
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
{{ form_row(form.toDate, {label: 'Bis'}) }}
|
{{ form_row(form.toDate, {label: 'Bis'}) }}
|
||||||
{{ form_row(form.minimumStay, {label: 'Mindestbelegung in Tagen'}) }}
|
{{ form_row(form.minimumStay, {label: 'Mindestbelegung in Tagen'}) }}
|
||||||
{{ form_row(form.description, {label: 'Beschreibung'}) }}
|
{{ form_row(form.description, {label: 'Beschreibung'}) }}
|
||||||
|
{{ form_row(form.onlyWeekday, {label: 'Exklusiver Wochentag'}) }}
|
||||||
|
|
||||||
|
|
||||||
<div class="col-md-12 col-sm-12 col-xs-12">
|
<div class="col-md-12 col-sm-12 col-xs-12">
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{% for monthIndex in 0..11 %}
|
{% for calendar_month in calendar %}
|
||||||
<div class="col-xs-12 col-sm-6">
|
<div class="col-xs-12 col-sm-6">
|
||||||
<table class="table calendar-table">
|
<table class="table calendar-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="7">
|
<th colspan="7">
|
||||||
{{ calendar[monthIndex]['monthName'] }} {{ calendar[monthIndex]['year'] }}
|
{{ calendar_month['monthName'] }} {{ calendar_month['year'] }}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
{% for dayIndex in 0..6 %}
|
{% for dayIndex in 0..6 %}
|
||||||
{# @var dayState \AppBundle\Util\CalendarDayState #}
|
{# @var dayState \AppBundle\Util\CalendarDayState #}
|
||||||
{% set dayState = calendar[monthIndex]['data'][(weekIndex * 7) + dayIndex] %}
|
{% set dayState = calendar_month['data'][(weekIndex * 7) + dayIndex] %}
|
||||||
|
|
||||||
{% set is_past_date = dayState.date is not empty and date(dayState.date) < date('now') %}
|
{% set is_past_date = dayState.date is not empty and date(dayState.date) < date('now') %}
|
||||||
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
<td class="{{ cell_class }}">
|
<td class="{{ cell_class }}">
|
||||||
{% if dayState.isBookable and not is_past_date %}
|
{% if dayState.isBookable and not is_past_date %}
|
||||||
<a href="{{ page.urlPath }}/buchen?pnr={{ dayState.price.id }}&fd={{ dayState.day < 10 ? '0':'' }}{{dayState.day}}{{ calendar[monthIndex]['monthNumber'] < 10 ? '0':'' }}{{calendar[monthIndex]['monthNumber']}}{{calendar[monthIndex]['year']}}"
|
<a href="{{ page.urlPath }}/buchen?pnr={{ dayState.price.id }}&fd={{ dayState.day < 10 ? '0':'' }}{{dayState.day}}{{ calendar_month['monthNumber'] < 10 ? '0':'' }}{{calendar_month['monthNumber']}}{{calendar_month['year']}}"
|
||||||
style="color: #80B176;"
|
style="color: #80B176;"
|
||||||
rel="nofollow"
|
rel="nofollow"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ form_label(form.toDate, 'Reiseende') }}</td>
|
<td>{{ form_label(form.toDate, 'Reiseende') }}</td>
|
||||||
<td>
|
<td>
|
||||||
{{ form_widget(form.toDate) }}
|
{{ form_widget(form.toDate, {attr: {'data-allowed-dates': allowed_to_dates}}) }}
|
||||||
{{ form_errors(form.toDate) }}
|
{{ form_errors(form.toDate) }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
@ -132,6 +132,10 @@
|
||||||
{{ form_field_pho(form.city, 'Ort') }}
|
{{ form_field_pho(form.city, 'Ort') }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-12 col-sm-12 col-xs-12">
|
||||||
|
{{ form_field_pho(form.nation, 'Land') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col-md-6 col-sm-6 col-xs-12">
|
<div class="col-md-6 col-sm-6 col-xs-12">
|
||||||
{{ form_field_pho(form.phone, 'Telefon tagsüber') }}
|
{{ form_field_pho(form.phone, 'Telefon tagsüber') }}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,13 @@ use AppBundle\Service\FileManager;
|
||||||
use AppBundle\Util;
|
use AppBundle\Util;
|
||||||
use Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\FileSystemCacheTest;
|
use Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\FileSystemCacheTest;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||||
use Symfony\Component\HttpFoundation\File;
|
use Symfony\Component\HttpFoundation\File;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||||
|
|
@ -159,17 +162,17 @@ class AdminController extends Controller
|
||||||
|
|
||||||
$lodging = null;
|
$lodging = null;
|
||||||
|
|
||||||
$calendarUtil = $this->container->get('app.lodging_calendar_util');
|
$calendarService = $this->container->get('app.lodging_calendar_util');
|
||||||
|
|
||||||
$lodging = $fewoLodgingRepo->find($lodgingId);
|
$lodging = $fewoLodgingRepo->find($lodgingId);
|
||||||
$reservations = $calendarUtil->getReservations($lodging);
|
$reservations = $calendarService->getReservations($lodging);
|
||||||
|
|
||||||
$paddedCalendar = $calendarUtil->getCalendarWithPadding();
|
$paddedCalendar = $calendarService->getCalendarWithPadding($calendarService->getMinCalendarEntriesByLodging($lodging));
|
||||||
$calendar = $calendarUtil->getCalendar();
|
$calendar = $calendarService->getCalendar($lodging);
|
||||||
if (count($lodging->getPrices()->toArray()) != 0)
|
if (count($lodging->getPrices()->toArray()) != 0)
|
||||||
{
|
{
|
||||||
$calendar = $calendarUtil->getCalendarWithReservations($lodging);
|
$calendar = $calendarService->createCalendarAndFillDayStates($lodging);
|
||||||
$calendar = $calendarUtil->mergeWithPaddedCalendar($calendar, $paddedCalendar);
|
$calendar = $calendarService->mergeWithPaddedCalendar($calendar, $paddedCalendar);
|
||||||
} else {
|
} else {
|
||||||
$calendar = $paddedCalendar;
|
$calendar = $paddedCalendar;
|
||||||
}
|
}
|
||||||
|
|
@ -230,16 +233,13 @@ class AdminController extends Controller
|
||||||
|
|
||||||
$lodging = $fewoLodgingRepo->find($lodgingId);
|
$lodging = $fewoLodgingRepo->find($lodgingId);
|
||||||
|
|
||||||
$calendarUtil = $this->container->get('app.lodging_calendar_util');
|
$calendarService = $this->container->get('app.lodging_calendar_util');
|
||||||
|
|
||||||
$reservations = $calendarUtil->getReservations($lodging);
|
$paddedCalendar = $calendarService->getCalendarWithPadding($calendarService->getMinCalendarEntriesByLodging($lodging));
|
||||||
|
|
||||||
$paddedCalendar = $calendarUtil->getCalendarWithPadding();
|
|
||||||
$calendar = $calendarUtil->getCalendar();
|
|
||||||
if (count($lodging->getPrices()->toArray()) != 0)
|
if (count($lodging->getPrices()->toArray()) != 0)
|
||||||
{
|
{
|
||||||
$calendar = $calendarUtil->getCalendarWithReservations($lodging);
|
$calendar = $calendarService->createCalendarAndFillDayStates($lodging);
|
||||||
$calendar = $calendarUtil->mergeWithPaddedCalendar($calendar, $paddedCalendar);
|
$calendar = $calendarService->mergeWithPaddedCalendar($calendar, $paddedCalendar);
|
||||||
} else {
|
} else {
|
||||||
$calendar = $paddedCalendar;
|
$calendar = $paddedCalendar;
|
||||||
}
|
}
|
||||||
|
|
@ -771,51 +771,133 @@ class AdminController extends Controller
|
||||||
return $this->redirect('/admin/fewo/seasons');
|
return $this->redirect('/admin/fewo/seasons');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/admin/fewo/lodgings/{lodgingId}/images/multi-upload", requirements={"lodgingId": "\d+"})
|
||||||
|
*/
|
||||||
|
public function adminFewoImageMultiUploadAction(Request $request, $lodgingId)
|
||||||
|
{
|
||||||
|
$em = $this->getEntityManager();
|
||||||
|
$lodging = $em->getRepository('AppBundle:FewoLodging')->find($lodgingId);
|
||||||
|
if (!$lodging)
|
||||||
|
{
|
||||||
|
throw new HttpException(404, 'Unbekannte lodging-ID: '. $lodgingId);
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = $this->createForm(FileType::class, null, [
|
||||||
|
'multiple' => true
|
||||||
|
]);
|
||||||
|
if ($request->getMethod() == 'POST')
|
||||||
|
{
|
||||||
|
$form->handleRequest($request);
|
||||||
|
if ($form->isValid())
|
||||||
|
{
|
||||||
|
$uploader = $this->container->get('app.image_uploader');
|
||||||
|
foreach ($form->getData() as $uploadedFile)
|
||||||
|
{
|
||||||
|
$image = new FewoLodgingImage();
|
||||||
|
$image->setFile($uploadedFile);
|
||||||
|
$image->setLodging($lodging);
|
||||||
|
$image->setFileName('');
|
||||||
|
$image->setDescription('');
|
||||||
|
$em->persist($image);
|
||||||
|
$em->flush();
|
||||||
|
}
|
||||||
|
return $this->redirect('/admin/fewo/lodgings/'. $lodging->getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('default/admin/fewoImageMultiUpload.html.twig', [
|
||||||
|
'form' => $form->createView(),
|
||||||
|
'lodging' => $lodging,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/admin/fewo/lodgings/{lodgingId}/images/new", requirements={"lodgingId": "\d+"})
|
* @Route("/admin/fewo/lodgings/{lodgingId}/images/new", requirements={"lodgingId": "\d+"})
|
||||||
*/
|
*/
|
||||||
public function adminFewoNewImageAction(Request $request, $lodgingId)
|
public function adminFewoNewImageAction(Request $request, $lodgingId)
|
||||||
|
{
|
||||||
|
$lodging = $this->getEntityManager()->getRepository('AppBundle:FewoLodging')->find($lodgingId);
|
||||||
|
if (!$lodging)
|
||||||
|
{
|
||||||
|
throw new HttpException(404, 'Unbekannte lodging-ID: '. $lodgingId);
|
||||||
|
}
|
||||||
|
return $this->processImageForm($request, null, $lodging);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/admin/fewo/lodgings/{lodgingId}/images/{imageId}", requirements={"lodgingId": "\d+", "imageId": "\d+"})
|
||||||
|
*/
|
||||||
|
public function adminFewoEditImageAction(Request $request, $lodgingId, $imageId)
|
||||||
|
{
|
||||||
|
/** @var FewoLodgingImage $image */
|
||||||
|
$image = $this->getEntityManager()->getRepository('AppBundle:FewoLodgingImage')->find($imageId);
|
||||||
|
if (!$image || $image->getLodging()->getId() != $lodgingId)
|
||||||
|
{
|
||||||
|
throw new HttpException(404, 'Unbekannte FewoLodgingImage-ID oder lodging-ID passt nicht: '.
|
||||||
|
$imageId .' / '. $lodgingId);
|
||||||
|
}
|
||||||
|
return $this->processImageForm($request, $image);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @param FewoLodgingImage $image
|
||||||
|
* @param FewoLodging|null $lodging
|
||||||
|
*
|
||||||
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
|
*/
|
||||||
|
public function processImageForm(Request $request, $image, $lodging = null)
|
||||||
{
|
{
|
||||||
$em = $this->getEntityManager();
|
$em = $this->getEntityManager();
|
||||||
$fewoLodgingRepo = $em->getRepository('AppBundle:FewoLodging');
|
|
||||||
|
|
||||||
$lodging = $fewoLodgingRepo->find($lodgingId);
|
if ($image == null)
|
||||||
|
{
|
||||||
|
$isNew = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$isNew = false;
|
||||||
|
$lodging = $image->getLodging();
|
||||||
|
$imageFileName = $image->getFile();
|
||||||
|
}
|
||||||
|
|
||||||
$image = null;
|
if ($request->getMethod() != 'POST' && $image == null)
|
||||||
if ($request->getMethod() != 'POST')
|
|
||||||
{
|
{
|
||||||
$image = new FewoLodgingImage();
|
$image = new FewoLodgingImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = $this->createForm(FewoLodgingImageType::class, $image, [
|
$form = $this->createForm(FewoLodgingImageType::class, $image);
|
||||||
|
|
||||||
]);
|
|
||||||
|
|
||||||
if ($request->getMethod() == 'POST')
|
if ($request->getMethod() == 'POST')
|
||||||
{
|
{
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
$image = $form->getData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($request->getMethod() == 'POST' && $form->isValid())
|
if ($request->getMethod() == 'POST' && $form->isValid())
|
||||||
{
|
{
|
||||||
|
$image = $form->getData();
|
||||||
if($lodging == null)
|
if ($isNew)
|
||||||
{
|
{
|
||||||
return $this->redirect('/admin/fewo/lodgings');
|
|
||||||
}
|
|
||||||
|
|
||||||
$image->setLodging($lodging);
|
$image->setLodging($lodging);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$image->setFile($imageFileName);
|
||||||
|
}
|
||||||
$em->persist($image);
|
$em->persist($image);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return $this->redirect('/admin/fewo/lodgings/'.$lodgingId);
|
return $this->redirect('/admin/fewo/lodgings/'. ($lodging->getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('default/admin/imagesNew.html.twig', [
|
return $this->render('default/admin/fewoImage.html.twig', [
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
'lodging' => $lodging,
|
'lodging' => $lodging,
|
||||||
|
'is_new' => $isNew,
|
||||||
|
'image_file_name' => $isNew ? null : $imageFileName,
|
||||||
|
'image' => $image,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,14 @@ class BookingController extends Controller
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$crmBookingUrl = $this->get('app.booking_exporter')->process($bookingRequest, $travelDate, $bookingPriceInfo);
|
$crmBookingUrl = $this->get('app.booking_exporter')->process($bookingRequest, $travelDate, $bookingPriceInfo);
|
||||||
|
if (!$crmBookingUrl)
|
||||||
|
{
|
||||||
|
$crmBookingUrl = '[CRM-EXPORT FEHLGESCHLAGEN]';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$crmBookingUrl = preg_replace('/\\/api/', '', $crmBookingUrl).'/edit';
|
$crmBookingUrl = preg_replace('/\\/api/', '', $crmBookingUrl).'/edit';
|
||||||
|
}
|
||||||
|
|
||||||
$this->get('mailer')->send(\Swift_Message::newInstance()
|
$this->get('mailer')->send(\Swift_Message::newInstance()
|
||||||
->setSubject('Ihr Buchungsauftrag bei STERN TOURS')
|
->setSubject('Ihr Buchungsauftrag bei STERN TOURS')
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,16 @@ class CmsController extends Controller
|
||||||
|
|
||||||
public function overviewAction(Page $page)
|
public function overviewAction(Page $page)
|
||||||
{
|
{
|
||||||
return $this->render('default/pages/cms/overview.html.twig', [
|
$settings = $page->getCmsSettings();
|
||||||
|
if (!is_array($settings))
|
||||||
|
{
|
||||||
|
$settings = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('default/pages/cms/overview.html.twig', array_merge($settings, [
|
||||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
// TODO
|
]));
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function travelProgramOverviewAction(Page $page)
|
public function travelProgramOverviewAction(Page $page)
|
||||||
|
|
@ -126,17 +131,14 @@ class CmsController extends Controller
|
||||||
|
|
||||||
public function fewoLodgingAction(Page $page)
|
public function fewoLodgingAction(Page $page)
|
||||||
{
|
{
|
||||||
//$calendarUtil = new Util\LodgingCalendarUtil();
|
$calendarService = $this->container->get('app.lodging_calendar_util');
|
||||||
$calendarUtil = $this->container->get('app.lodging_calendar_util');
|
|
||||||
//$fewoLodgingRepo = $this->getEntityManager()->getRepository('AppBundle:FewoLodging');
|
|
||||||
$lodging = $page->getFewoLodging();
|
$lodging = $page->getFewoLodging();
|
||||||
|
|
||||||
$paddedCalendar = $calendarUtil->getCalendarWithPadding();
|
$paddedCalendar = $calendarService->getCalendarWithPadding($calendarService->getMinCalendarEntriesByLodging($lodging));
|
||||||
$calendar = $calendarUtil->getCalendar();
|
|
||||||
if (count($lodging->getPrices()->toArray()) != 0)
|
if (count($lodging->getPrices()->toArray()) != 0)
|
||||||
{
|
{
|
||||||
$calendar = $calendarUtil->getCalendarWithReservations($lodging);
|
$calendar = $calendarService->createCalendarAndFillDayStates($lodging);
|
||||||
$calendar = $calendarUtil->mergeWithPaddedCalendar($calendar, $paddedCalendar);
|
$calendar = $calendarService->mergeWithPaddedCalendar($calendar, $paddedCalendar);
|
||||||
} else {
|
} else {
|
||||||
$calendar = $paddedCalendar;
|
$calendar = $paddedCalendar;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,7 @@ class FewoBookingController extends Controller
|
||||||
*/
|
*/
|
||||||
public function indexAction(Page $fewoTravelProgramPage, $action, Request $request)
|
public function indexAction(Page $fewoTravelProgramPage, $action, Request $request)
|
||||||
{
|
{
|
||||||
|
$calendarService = $this->container->get('app.lodging_calendar_util');
|
||||||
//$calendarUtils = new Util\LodgingCalendarUtil();
|
|
||||||
$calendarUtil = $this->container->get('app.lodging_calendar_util');
|
|
||||||
$em = $this->getEntityManager();
|
$em = $this->getEntityManager();
|
||||||
//$fewoLodgingRepo = $em->getRepository('AppBundle:FewoLodging');
|
//$fewoLodgingRepo = $em->getRepository('AppBundle:FewoLodging');
|
||||||
$fewoPriceRepo = $em->getRepository('AppBundle:FewoPrice');
|
$fewoPriceRepo = $em->getRepository('AppBundle:FewoPrice');
|
||||||
|
|
@ -66,7 +64,7 @@ class FewoBookingController extends Controller
|
||||||
$season = $price->getSeason();
|
$season = $price->getSeason();
|
||||||
$minimumStay = $season->getMinimumStay();
|
$minimumStay = $season->getMinimumStay();
|
||||||
|
|
||||||
$fromDate = $calendarUtil->convertDate($fromDate);
|
$fromDate = $calendarService->convertDate($fromDate);
|
||||||
$fromDateTime = new \DateTime($fromDate);
|
$fromDateTime = new \DateTime($fromDate);
|
||||||
$toDate = '';
|
$toDate = '';
|
||||||
|
|
||||||
|
|
@ -82,16 +80,59 @@ class FewoBookingController extends Controller
|
||||||
$fewoBookingRequest->setLodging($lodging);
|
$fewoBookingRequest->setLodging($lodging);
|
||||||
$fewoBookingRequest->setPrice($price);
|
$fewoBookingRequest->setPrice($price);
|
||||||
|
|
||||||
|
$allowedToDateStrs = [];
|
||||||
|
if (!$lodging->getPrices()->isEmpty())
|
||||||
|
{
|
||||||
|
$nightsSinceFromDate = 0;
|
||||||
|
$calendar = $calendarService->createCalendarAndFillDayStates($lodging);
|
||||||
|
$areAllowedToDatesCollected = false;
|
||||||
|
foreach ($calendar as $calendarMonth)
|
||||||
|
{
|
||||||
|
if ($calendarMonth['year'] < $fromDateTime->format('Y') ||
|
||||||
|
$calendarMonth['monthNumber'] < $fromDateTime->format('n'))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
/** @var Util\CalendarDayState[] $dayStates */
|
||||||
|
$dayStates = $calendarMonth['data'];
|
||||||
|
$i = 0;
|
||||||
|
if ($calendarMonth['year'] == $fromDateTime->format('Y') &&
|
||||||
|
$calendarMonth['monthNumber'] == $fromDateTime->format('n'))
|
||||||
|
{
|
||||||
|
$i = intval($fromDateTime->format('j')) - 1;
|
||||||
|
}
|
||||||
|
for (; $i < count($dayStates); ++$i)
|
||||||
|
{
|
||||||
|
if ($nightsSinceFromDate >= $season->getMinimumStay())
|
||||||
|
{
|
||||||
|
$dayState = $dayStates[$i];
|
||||||
|
if ($dayState->getIsInSeason() && (!$dayState->getIsReserved() ||
|
||||||
|
($dayState->getIsReservationBegin() && !$dayState->getIsReservationEnd())))
|
||||||
|
{
|
||||||
|
$allowedToDateStrs[] = $dayState->getDate()->format('Y-m-d');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$areAllowedToDatesCollected = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++$nightsSinceFromDate;
|
||||||
|
}
|
||||||
|
if ($areAllowedToDatesCollected)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($allowedToDateStrs))
|
||||||
|
{
|
||||||
|
$toDate = $allowedToDateStrs[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($request->getMethod() != 'POST')
|
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->setFromDate($fromDate);
|
||||||
$fewoBookingRequest->setToDate($toDate);
|
$fewoBookingRequest->setToDate($toDate);
|
||||||
$fewoBookingRequest->setNumberDays($minimumStay);
|
$fewoBookingRequest->setNumberDays($minimumStay);
|
||||||
|
|
@ -144,7 +185,14 @@ class FewoBookingController extends Controller
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$crmBookingUrl = $this->get('app.fewo_booking_exporter')->process($fewoBookingRequest, $lodging, $price);//, $travelDate, $bookingPriceInfo);
|
$crmBookingUrl = $this->get('app.fewo_booking_exporter')->process($fewoBookingRequest, $lodging, $price);//, $travelDate, $bookingPriceInfo);
|
||||||
|
if (!$crmBookingUrl)
|
||||||
|
{
|
||||||
|
$crmBookingUrl = '[CRM-EXPORT FEHLGESCHLAGEN]';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$crmBookingUrl = preg_replace('/\\/api/', '', $crmBookingUrl) . '/edit';
|
$crmBookingUrl = preg_replace('/\\/api/', '', $crmBookingUrl) . '/edit';
|
||||||
|
}
|
||||||
|
|
||||||
$this->get('mailer')->send(\Swift_Message::newInstance()
|
$this->get('mailer')->send(\Swift_Message::newInstance()
|
||||||
->setSubject('Ihr FeWo-Buchungsauftrag bei STERN TOURS')
|
->setSubject('Ihr FeWo-Buchungsauftrag bei STERN TOURS')
|
||||||
|
|
@ -208,9 +256,9 @@ class FewoBookingController extends Controller
|
||||||
'fewo_price' => $price,
|
'fewo_price' => $price,
|
||||||
'total_price' => $totalPrice,
|
'total_price' => $totalPrice,
|
||||||
'total_price_per_night' => $perDayTotalPrice,
|
'total_price_per_night' => $perDayTotalPrice,
|
||||||
|
'allowed_to_dates' => implode(';', $allowedToDateStrs),
|
||||||
'page' => $fewoTravelProgramPage,
|
'page' => $fewoTravelProgramPage,
|
||||||
'show_search_sidebar_widget' => false,
|
'show_search_sidebar_widget' => false,
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,13 +125,6 @@ class FewoLodging
|
||||||
//------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------
|
||||||
// Kalender
|
// Kalender
|
||||||
|
|
||||||
/**
|
|
||||||
* @var integer
|
|
||||||
*
|
|
||||||
* @ORM\Column(name="only_weekday", type="integer", nullable=true)
|
|
||||||
*/
|
|
||||||
private $onlyWeekday;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \AppBundle\Entity\FewoReservation
|
* @var \AppBundle\Entity\FewoReservation
|
||||||
*
|
*
|
||||||
|
|
@ -411,30 +404,6 @@ class FewoLodging
|
||||||
return $this->deposit;
|
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
|
* Set calendarVisible
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace AppBundle\Entity;
|
namespace AppBundle\Entity;
|
||||||
|
use Doctrine\ORM\Query\Expr\OrderBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FewoLodgingRepository
|
* FewoLodgingRepository
|
||||||
|
|
@ -10,8 +11,21 @@ namespace AppBundle\Entity;
|
||||||
*/
|
*/
|
||||||
class FewoLodgingRepository extends \Doctrine\ORM\EntityRepository
|
class FewoLodgingRepository extends \Doctrine\ORM\EntityRepository
|
||||||
{
|
{
|
||||||
public function findWithChoosableSeasons($lodgingId)
|
/**
|
||||||
|
* @param FewoLodging $lodging
|
||||||
|
*
|
||||||
|
* @return FewoSeason|null
|
||||||
|
*/
|
||||||
|
public function findLatestSeasonEndForLodging($lodging)
|
||||||
{
|
{
|
||||||
|
$qb = $this->getEntityManager()->createQueryBuilder();
|
||||||
|
$qb->select('s');
|
||||||
|
$qb->from('AppBundle:FewoSeason', 's');
|
||||||
|
$qb->innerJoin('s.prices', 'p');
|
||||||
|
$qb->where($qb->expr()->eq('p.lodging', $lodging->getId()));
|
||||||
|
$qb->addOrderBy('s.toDate', 'DESC');
|
||||||
|
$qb->setMaxResults(1);
|
||||||
|
return $qb->getQuery()->getOneOrNullResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,14 @@ class FewoSeason
|
||||||
* @ORM\Column(name="description", type="text", nullable=true)
|
* @ORM\Column(name="description", type="text", nullable=true)
|
||||||
*/
|
*/
|
||||||
private $description;
|
private $description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var integer
|
||||||
|
*
|
||||||
|
* @ORM\Column(name="only_weekday", type="integer", nullable=true)
|
||||||
|
*/
|
||||||
|
private $onlyWeekday;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
|
|
@ -242,4 +250,28 @@ class FewoSeason
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set onlyWeekday
|
||||||
|
*
|
||||||
|
* @param integer $onlyWeekday
|
||||||
|
*
|
||||||
|
* @return FewoSeason
|
||||||
|
*/
|
||||||
|
public function setOnlyWeekday($onlyWeekday)
|
||||||
|
{
|
||||||
|
$this->onlyWeekday = $onlyWeekday;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get onlyWeekday
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function getOnlyWeekday()
|
||||||
|
{
|
||||||
|
return $this->onlyWeekday;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1255,13 +1255,13 @@ class Page
|
||||||
/**
|
/**
|
||||||
* Set cmsSettings
|
* Set cmsSettings
|
||||||
*
|
*
|
||||||
* @param string $cmsSettings
|
* @param mixed $cmsSettings
|
||||||
*
|
*
|
||||||
* @return Page
|
* @return Page
|
||||||
*/
|
*/
|
||||||
public function setCmsSettings($cmsSettings)
|
public function setCmsSettings($cmsSettings)
|
||||||
{
|
{
|
||||||
$this->cmsSettings = $cmsSettings;
|
$this->cmsSettings = is_array($cmsSettings) ? json_encode($cmsSettings) : $cmsSettings;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
@ -1269,10 +1269,15 @@ class Page
|
||||||
/**
|
/**
|
||||||
* Get cmsSettings
|
* Get cmsSettings
|
||||||
*
|
*
|
||||||
* @return string
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getCmsSettings()
|
public function getCmsSettings()
|
||||||
|
{
|
||||||
|
$ret = json_decode($this->cmsSettings, true);
|
||||||
|
if (empty($ret) || !is_array($ret))
|
||||||
{
|
{
|
||||||
return $this->cmsSettings;
|
return $this->cmsSettings;
|
||||||
}
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ class Traveler
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Assert\NotBlank()
|
* @Assert\NotBlank()
|
||||||
|
* @Assert\Date()
|
||||||
*/
|
*/
|
||||||
private $birthDate;
|
private $birthDate;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,17 +50,17 @@ class FewoBookingSternToursCrmExporter extends SternToursCrmExporter
|
||||||
$resp = $this->httpPost('lead', ['lead' => [
|
$resp = $this->httpPost('lead', ['lead' => [
|
||||||
'customerForm' => [
|
'customerForm' => [
|
||||||
'salutation_id' => $fewoBookingRequest->getSalutation(),
|
'salutation_id' => $fewoBookingRequest->getSalutation(),
|
||||||
'name' => $fewoBookingRequest->getLastName(),
|
'name' => $fewoBookingRequest->getLastName(), // required
|
||||||
'firstname' => $fewoBookingRequest->getFirstName(),
|
'firstname' => $fewoBookingRequest->getFirstName(),
|
||||||
'street' => $fewoBookingRequest->getStreetAddress(),
|
'street' => $fewoBookingRequest->getStreetAddress(),
|
||||||
'zip' => $fewoBookingRequest->getZipCode(),
|
'zip' => $fewoBookingRequest->getZipCode(),
|
||||||
'city' => $fewoBookingRequest->getCity(),
|
'city' => $fewoBookingRequest->getCity(),
|
||||||
'country_id' => $fewoBookingRequest->getNation(),
|
'country_id' => $fewoBookingRequest->getNation(), // required
|
||||||
'phone' => $fewoBookingRequest->getPhone(),
|
'phone' => $fewoBookingRequest->getPhone(),
|
||||||
'fax' => $fewoBookingRequest->getFax(),
|
'fax' => $fewoBookingRequest->getFax(),
|
||||||
'email' => $fewoBookingRequest->getEmail()
|
'email' => $fewoBookingRequest->getEmail()
|
||||||
],
|
],
|
||||||
'request_date' => (new \DateTime())->format('Y-m-d'),
|
'request_date' => (new \DateTime())->format('Y-m-d'), // required
|
||||||
'sf_guard_user_id' => self::API_USER_ID,
|
'sf_guard_user_id' => self::API_USER_ID,
|
||||||
'status_id' => 7, // 'gebucht'
|
'status_id' => 7, // 'gebucht'
|
||||||
'travelperiod_start' => $fewoBookingRequest->getFromDate()->format('Y-m-d'),
|
'travelperiod_start' => $fewoBookingRequest->getFromDate()->format('Y-m-d'),
|
||||||
|
|
@ -73,6 +73,9 @@ class FewoBookingSternToursCrmExporter extends SternToursCrmExporter
|
||||||
'remarks' => $fewoBookingRequest->getNotes()
|
'remarks' => $fewoBookingRequest->getNotes()
|
||||||
]]);
|
]]);
|
||||||
|
|
||||||
|
//Util::varDump($resp);
|
||||||
|
//die();
|
||||||
|
|
||||||
if ($resp['success'])
|
if ($resp['success'])
|
||||||
{
|
{
|
||||||
$ret = $this->httpGet($resp['location']);
|
$ret = $this->httpGet($resp['location']);
|
||||||
|
|
@ -98,10 +101,10 @@ class FewoBookingSternToursCrmExporter extends SternToursCrmExporter
|
||||||
'branch_id' => 4,
|
'branch_id' => 4,
|
||||||
'website_id' => self::WEBSITE_ID,
|
'website_id' => self::WEBSITE_ID,
|
||||||
'title' => $lodging->getName(),
|
'title' => $lodging->getName(),
|
||||||
'start_date' => $fewoBookingRequest->getFromDate()->format('Y-m-d'),
|
'start_date' => $fewoBookingRequest->getFromDate()->format('Y-m-d'), // required
|
||||||
'end_date' => $fewoBookingRequest->getToDate()->format('Y-m-d'),
|
'end_date' => $fewoBookingRequest->getToDate()->format('Y-m-d'), // required
|
||||||
'pax' => $fewoBookingRequest->getTravelerCount(),
|
'pax' => $fewoBookingRequest->getTravelerCount(),
|
||||||
'travel_number' => $lodging->getName()." - ".$price->getSeason()->getName(),
|
'travel_number' => substr($lodging->getName()." - ".$price->getSeason()->getName(), 0, 30),
|
||||||
'price' => $fewoBookingRequest->getTotalPrice(),
|
'price' => $fewoBookingRequest->getTotalPrice(),
|
||||||
|
|
||||||
'participant_salutation_id' => $fewoBookingRequest->getSalutation(),
|
'participant_salutation_id' => $fewoBookingRequest->getSalutation(),
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,13 @@ class FewoBookingRequestType extends AbstractType
|
||||||
])
|
])
|
||||||
->add('firstName')
|
->add('firstName')
|
||||||
->add('lastName')
|
->add('lastName')
|
||||||
|
->add('nation', ChoiceType::class, [
|
||||||
|
'choices' => self::$NATION_CHOICES,
|
||||||
|
'constraints' => [
|
||||||
|
new NotNull(),
|
||||||
|
new Choice(['choices' => self::$NATION_CHOICES])
|
||||||
|
]
|
||||||
|
])
|
||||||
->add('streetAddress')
|
->add('streetAddress')
|
||||||
->add('zipCode')
|
->add('zipCode')
|
||||||
->add('city')
|
->add('city')
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class FewoLodgingImageType extends AbstractType
|
||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('file', FileType::class, [
|
->add('file', FileType::class, [
|
||||||
|
'data_class' => null
|
||||||
])
|
])
|
||||||
->add('fileName')
|
->add('fileName')
|
||||||
->add('description')
|
->add('description')
|
||||||
|
|
|
||||||
|
|
@ -21,18 +21,6 @@ use AppBundle\Entity\FewoSeason;
|
||||||
|
|
||||||
class FewoLodgingType extends AbstractType
|
class FewoLodgingType extends AbstractType
|
||||||
{
|
{
|
||||||
public static $WEEKDAY_CHOICES = [
|
|
||||||
'keiner' => 0,
|
|
||||||
'Montag' => 1,
|
|
||||||
'Dienstag' => 2,
|
|
||||||
'Mittwoch' => 3,
|
|
||||||
'Donnerstag' => 4,
|
|
||||||
'Freitag' => 5,
|
|
||||||
'Samstag' => 6,
|
|
||||||
'Sonntag' => 7
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
|
@ -65,12 +53,6 @@ class FewoLodgingType extends AbstractType
|
||||||
->add('deposit', null, [
|
->add('deposit', null, [
|
||||||
'required' => true,
|
'required' => true,
|
||||||
])
|
])
|
||||||
->add('onlyWeekday', ChoiceType::class, [
|
|
||||||
'choices' => self::$WEEKDAY_CHOICES,
|
|
||||||
'constraints' => [
|
|
||||||
new Choice(['choices' => self::$WEEKDAY_CHOICES])
|
|
||||||
]
|
|
||||||
])
|
|
||||||
//->add('calendarVisible')
|
//->add('calendarVisible')
|
||||||
->add('type', EntityType::class, [
|
->add('type', EntityType::class, [
|
||||||
'placeholder' => '(Bitte wählen) *',
|
'placeholder' => '(Bitte wählen) *',
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,17 @@ use Symfony\Component\Validator\Constraints\NotNull;
|
||||||
|
|
||||||
class FewoSeasonType extends AbstractType
|
class FewoSeasonType extends AbstractType
|
||||||
{
|
{
|
||||||
|
public static $WEEKDAY_CHOICES = [
|
||||||
|
'beliebig' => NULL,
|
||||||
|
'Sonntag' => 0,
|
||||||
|
'Montag' => 1,
|
||||||
|
'Dienstag' => 2,
|
||||||
|
'Mittwoch' => 3,
|
||||||
|
'Donnerstag' => 4,
|
||||||
|
'Freitag' => 5,
|
||||||
|
'Samstag' => 6,
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
@ -38,6 +49,12 @@ class FewoSeasonType extends AbstractType
|
||||||
|
|
||||||
])
|
])
|
||||||
->add('description')
|
->add('description')
|
||||||
|
->add('onlyWeekday', ChoiceType::class, [
|
||||||
|
'choices' => self::$WEEKDAY_CHOICES,
|
||||||
|
'constraints' => [
|
||||||
|
new Choice(['choices' => self::$WEEKDAY_CHOICES])
|
||||||
|
]
|
||||||
|
])
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -514,7 +514,24 @@ jQuery(document).ready(function($) {
|
||||||
dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
|
dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
|
||||||
dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
|
dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
|
||||||
dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
|
dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
|
||||||
firstDay: 1
|
firstDay: 1,
|
||||||
|
beforeShowDay: function(date) {
|
||||||
|
var allowedDateStrListStr = $(this).attr('data-allowed-dates');
|
||||||
|
if (allowedDateStrListStr)
|
||||||
|
{
|
||||||
|
var allowedDatesStrList = allowedDateStrListStr.split(';');
|
||||||
|
for (var i = 0; i < allowedDatesStrList.length; ++i)
|
||||||
|
{
|
||||||
|
var allowedDate = new Date(allowedDatesStrList[i]);
|
||||||
|
if (allowedDate.getDate() === date.getDate() && allowedDate.getMonth() === date.getMonth() &&
|
||||||
|
allowedDate.getYear() === date.getYear())
|
||||||
|
{
|
||||||
|
return [true, '', ''];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [false, '', '']
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function initAutoEndDate(startTxt$, endTxt$)
|
function initAutoEndDate(startTxt$, endTxt$)
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,56 @@ class FileManager
|
||||||
$this->targetDir = $targetDir;
|
$this->targetDir = $targetDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MAX_DEST_WIDTH = 848;
|
||||||
|
const MAX_DEST_HEIGHT = 280;
|
||||||
|
|
||||||
public function upload(UploadedFile $file)
|
public function upload(UploadedFile $file)
|
||||||
{
|
{
|
||||||
$fileName = md5(uniqid()).'.'.$file->guessExtension();
|
$baseFileName = md5(uniqid());
|
||||||
|
$fileName = $baseFileName.'.'.$file->guessExtension();
|
||||||
|
|
||||||
$file->move($this->getTargetDir(), $fileName);
|
$file->move($this->getTargetDir(), $fileName);
|
||||||
|
$path = $this->getTargetDir() .'/'. $fileName;
|
||||||
|
$imgInfo = getimagesize($path);
|
||||||
|
if ($imgInfo !== false)
|
||||||
|
{
|
||||||
|
$srcWidth = $imgInfo[0];
|
||||||
|
$srcHeight = $imgInfo[1];
|
||||||
|
switch ($imgInfo[2]) {
|
||||||
|
case IMAGETYPE_GIF : $src = imagecreatefromgif($path); break;
|
||||||
|
case IMAGETYPE_JPEG : $src = imagecreatefromjpeg($path); break;
|
||||||
|
case IMAGETYPE_PNG : $src = imagecreatefrompng($path); break;
|
||||||
|
// default: // #TODO Warning
|
||||||
|
}
|
||||||
|
if (isset($src))
|
||||||
|
{
|
||||||
|
$tmp = imagecreatetruecolor(848, 280);
|
||||||
|
$destWidth = self::MAX_DEST_HEIGHT * $srcWidth / $srcHeight;
|
||||||
|
if ($destWidth < self::MAX_DEST_WIDTH)
|
||||||
|
{
|
||||||
|
$destWidth = self::MAX_DEST_WIDTH;
|
||||||
|
$destHeight = $destWidth * $srcHeight / $srcWidth;
|
||||||
|
$destX = 0;
|
||||||
|
$destY = ($destHeight - self::MAX_DEST_HEIGHT) / 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$destHeight = self::MAX_DEST_HEIGHT;
|
||||||
|
$destX = ($destWidth - self::MAX_DEST_WIDTH) / 2;
|
||||||
|
$destY = 0;
|
||||||
|
}
|
||||||
|
imagecopyresampled($tmp, $src, 0, 0, $destX, $destY,
|
||||||
|
$destWidth, $destHeight, $srcWidth, $srcHeight);
|
||||||
|
$newFileName = md5(uniqid()) .'.jpg';
|
||||||
|
if (imagejpeg($tmp, $this->getTargetDir() .'/'. $newFileName, 80))
|
||||||
|
{
|
||||||
|
$filesystem = new Filesystem();
|
||||||
|
$filesystem->remove($this->getTargetDir() .'/'. $fileName);
|
||||||
|
return $newFileName;
|
||||||
|
}
|
||||||
|
// else #TODO warn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $fileName;
|
return $fileName;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class LodgingCalendarService
|
||||||
return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
|
return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCalendarWithPadding()
|
public function getCalendarWithPadding($months)
|
||||||
{
|
{
|
||||||
$calendar = null;
|
$calendar = null;
|
||||||
$currentMonth = date('n');
|
$currentMonth = date('n');
|
||||||
|
|
@ -35,7 +35,7 @@ class LodgingCalendarService
|
||||||
|
|
||||||
setlocale(LC_TIME, "german");
|
setlocale(LC_TIME, "german");
|
||||||
|
|
||||||
for($m = $currentMonth; $m < ($currentMonth + 12); $m++)
|
for($m = $currentMonth; $m < ($currentMonth + $months); $m++)
|
||||||
{
|
{
|
||||||
if($m < 13)
|
if($m < 13)
|
||||||
{
|
{
|
||||||
|
|
@ -117,9 +117,9 @@ class LodgingCalendarService
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getCalendar()
|
public function getCalendar($lodging)
|
||||||
{
|
{
|
||||||
|
$months = $this->getMinCalendarEntriesByLodging($lodging);
|
||||||
$calendar = null;
|
$calendar = null;
|
||||||
$currentMonth = date('n');
|
$currentMonth = date('n');
|
||||||
$currentYear = date('Y');
|
$currentYear = date('Y');
|
||||||
|
|
@ -127,7 +127,7 @@ class LodgingCalendarService
|
||||||
|
|
||||||
setlocale(LC_TIME, "german");
|
setlocale(LC_TIME, "german");
|
||||||
|
|
||||||
for($m = $currentMonth; $m < ($currentMonth + 12); $m++)
|
for($m = $currentMonth; $m < ($currentMonth + $months); $m++)
|
||||||
{
|
{
|
||||||
if($m < 13)
|
if($m < 13)
|
||||||
{
|
{
|
||||||
|
|
@ -180,6 +180,22 @@ class LodgingCalendarService
|
||||||
return $calendar;
|
return $calendar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve needed number of months to generate a calendar which includes all available seasons
|
||||||
|
*
|
||||||
|
* @param FewoLodging $lodging
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getMinCalendarEntriesByLodging($lodging)
|
||||||
|
{
|
||||||
|
$latestSeason = $this->em->getRepository('AppBundle:FewoLodging')->findLatestSeasonEndForLodging($lodging);
|
||||||
|
$curMonthDate = new \DateTime();
|
||||||
|
$curMonthDate->setDate($curMonthDate->format('Y'), $curMonthDate->format('n'), 1);
|
||||||
|
$seasonMonthDate = new \DateTime($latestSeason->getToDate()->format('Y-m-d'));
|
||||||
|
$seasonMonthDate->setDate($seasonMonthDate->format('Y'), $seasonMonthDate->format('n'), 1);
|
||||||
|
return 2 + intval($seasonMonthDate->diff($curMonthDate)->format('%m'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param FewoLodging $lodging
|
* @param FewoLodging $lodging
|
||||||
|
|
@ -426,7 +442,7 @@ class LodgingCalendarService
|
||||||
|
|
||||||
private function mergeCalendars($calendar, $extensionCalendar, $withFromTo = false)
|
private function mergeCalendars($calendar, $extensionCalendar, $withFromTo = false)
|
||||||
{
|
{
|
||||||
for($i = 0; $i < 12; $i++)
|
for($i = 0; $i < count($calendar); $i++)
|
||||||
{
|
{
|
||||||
/** @var CalendarDayState[] $calendarData */
|
/** @var CalendarDayState[] $calendarData */
|
||||||
$calendarData = $calendar[$i]['data'];
|
$calendarData = $calendar[$i]['data'];
|
||||||
|
|
@ -584,10 +600,8 @@ class LodgingCalendarService
|
||||||
*/
|
*/
|
||||||
private function filterReservableDays(FewoLodging $lodging, $calendar)
|
private function filterReservableDays(FewoLodging $lodging, $calendar)
|
||||||
{
|
{
|
||||||
|
/** @var CalendarDayState[] $potentiallyReservableDays */
|
||||||
$potentiallyReservableDays = [];
|
$potentiallyReservableDays = [];
|
||||||
$priceId = 0;
|
|
||||||
/** @var FewoPrice $lastReservablePrice */
|
|
||||||
$lastReservablePrice = null;
|
|
||||||
|
|
||||||
for ($currMonthIndex = 0; $currMonthIndex < count($calendar); $currMonthIndex++)
|
for ($currMonthIndex = 0; $currMonthIndex < count($calendar); $currMonthIndex++)
|
||||||
{
|
{
|
||||||
|
|
@ -599,140 +613,81 @@ class LodgingCalendarService
|
||||||
{
|
{
|
||||||
$currDay = $data[$currDayIndex];
|
$currDay = $data[$currDayIndex];
|
||||||
|
|
||||||
if ($currDay->getPrice() !== $lastReservablePrice && !$currDay->getIsInSeason())
|
// We passed the season end? => All days in the stack are not reservable, as their minimum stay
|
||||||
|
// requirement would mean their reservation end is outside a season
|
||||||
|
if (!$currDay->getIsInSeason())
|
||||||
{
|
{
|
||||||
$actuallyReservableDays = $this->processPotentiallyReservableDays($potentiallyReservableDays,
|
while (!empty($potentiallyReservableDays))
|
||||||
$lastReservablePrice->getSeason()->getMinimumStay());
|
{
|
||||||
$this->processRest($actuallyReservableDays, $lastReservablePrice, $calendar);
|
$potentiallyReservableDay = array_pop($potentiallyReservableDays);
|
||||||
$potentiallyReservableDays = [];
|
$potentiallyReservableDay->setIsBookable(false);
|
||||||
}
|
}
|
||||||
if ($currDay->getIsInSeason() && (!$currDay->getIsReserved() || $currDay->getIsReservationBegin() ||
|
$currDay->setIsBookable(false);
|
||||||
$currDay->getIsReservationEnd()))
|
continue;
|
||||||
{
|
|
||||||
$currentDayDate = date("d.m.Y", strtotime($currMonth['year']."-".
|
|
||||||
$currMonth['monthNumber']."-".$currDay->getDay()));
|
|
||||||
$potentiallyReservableDays[] = $currentDayDate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$lastReservablePrice = $currDay->getIsInSeason() ? $currDay->getPrice() : null;
|
$currSeason = $currDay->getPrice()->getSeason();
|
||||||
}
|
|
||||||
}
|
// Process the stack of reservable days and set reservable=true, if their minimum stay requirement could
|
||||||
if ($lastReservablePrice !== null)
|
// be fulfilled. Set reservable=false if there is no chance for the stack entry to be reservable.
|
||||||
|
// Remove potentially reservable days from the stack for which a final decision has been made.
|
||||||
|
if (!$currDay->getIsReserved() || $currDay->getIsReservationBegin())
|
||||||
{
|
{
|
||||||
$actuallyReservableDays = $this->processPotentiallyReservableDays($potentiallyReservableDays,
|
foreach ($potentiallyReservableDays as $k => $potentiallyReservableDay)
|
||||||
$lastReservablePrice->getSeason()->getMinimumStay());
|
{
|
||||||
$this->processRest($actuallyReservableDays, $lastReservablePrice, $calendar);
|
$nights = intval($potentiallyReservableDay->getDate()->diff($currDay->getDate())->format('%a'));
|
||||||
|
if ($nights >= $currSeason->getMinimumStay())
|
||||||
|
{
|
||||||
|
$potentiallyReservableDay->setIsBookable(true);
|
||||||
|
unset($potentiallyReservableDays[$k]);
|
||||||
}
|
}
|
||||||
|
elseif ($currDay->getIsReservationBegin())
|
||||||
|
{
|
||||||
|
// Reservation begin => We are absolutely sure that this day is not reservable
|
||||||
|
$potentiallyReservableDay->setIsBookable(false);
|
||||||
|
unset($potentiallyReservableDays[$k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the current calendar day to stack, as we need to analyse the following days in order to be able
|
||||||
|
// to decide if the day is reservable or not.
|
||||||
|
if ((!$currDay->getIsReserved() || $currDay->getIsReservationEnd()) &&
|
||||||
|
($currSeason->getOnlyWeekday() == null || $currSeason->getOnlyWeekday() == $currDay->getDate()->format('w')))
|
||||||
|
{
|
||||||
|
$potentiallyReservableDays[] = $currDay;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$currDay->setIsBookable(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remaining entries in the stack are definitely not reservable. Otherwise they would have been processed before.
|
||||||
|
foreach ($potentiallyReservableDays as $potentiallyReservableDay)
|
||||||
|
{
|
||||||
|
$potentiallyReservableDay->setIsBookable(false);
|
||||||
|
}
|
||||||
|
|
||||||
return $calendar;
|
return $calendar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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, FewoPrice $price, &$cleanCalendar)
|
|
||||||
{
|
|
||||||
for($currMonthIndex = 0; $currMonthIndex < count($cleanCalendar); $currMonthIndex++)
|
|
||||||
{
|
|
||||||
$currMonth = $cleanCalendar[$currMonthIndex];
|
|
||||||
/** @var CalendarDayState[] $data */
|
|
||||||
$data = $currMonth['data'];
|
|
||||||
|
|
||||||
for($currDayIndex = 0; $currDayIndex < count($data); $currDayIndex++)
|
|
||||||
{
|
|
||||||
$currDay = $data[$currDayIndex];
|
|
||||||
|
|
||||||
$currentDate = date("d.m.Y", strtotime($currMonth['year']."-".$currMonth['monthNumber']."-".$currDay->getDay()));
|
|
||||||
|
|
||||||
if (in_array($currentDate, $actuallyReservableDays))
|
|
||||||
{
|
|
||||||
//$data[$currDayIndex]->setIsInSeason(true);
|
|
||||||
//$data[$currDayIndex]->setIsReserved(false); // todo ?
|
|
||||||
$data[$currDayIndex]->setIsBookable(true);
|
|
||||||
//$data[$currDayIndex]->setIsReservationBegin(false);
|
|
||||||
//$data[$currDayIndex]->setIsReservationEnd(false); // todo ?
|
|
||||||
//$data[$currDayIndex]->setPrice($price);
|
|
||||||
|
|
||||||
$currMonth['marked'] = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$currMonth['data'] = $data;
|
|
||||||
$cleanCalendar[$currMonthIndex] = $currMonth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param FewoLodging $lodging
|
* @param FewoLodging $lodging
|
||||||
* @param $calendar
|
* @param $calendar
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
*
|
||||||
|
* createCalendarAndFillDayStates
|
||||||
*/
|
*/
|
||||||
public function getCalendarWithReservations(FewoLodging $lodging)
|
public function createCalendarAndFillDayStates(FewoLodging $lodging)
|
||||||
{
|
{
|
||||||
$today = new \DateTime();
|
$pricesCalendar = $this->getCalendar($lodging);
|
||||||
$pricesCalendar = $this->getCalendar();
|
$reservationsCalendar = $this->getCalendar($lodging);
|
||||||
$reservationsCalendar = $this->getCalendar();
|
|
||||||
|
|
||||||
$reservations = $lodging->getReservations();
|
$reservations = $lodging->getReservations();
|
||||||
$prices = $lodging->getPrices();
|
$prices = $lodging->getPrices();
|
||||||
|
|
||||||
$lodgingId = $lodging->getId();
|
|
||||||
|
|
||||||
foreach ($prices as $price)
|
foreach ($prices as $price)
|
||||||
{
|
{
|
||||||
/** @var FewoSeason $season */
|
/** @var FewoSeason $season */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue