* 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
|
|
@ -24,10 +24,13 @@ use AppBundle\Service\FileManager;
|
|||
use AppBundle\Util;
|
||||
use Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\FileSystemCacheTest;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||
use Symfony\Component\HttpFoundation\File;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||
|
|
@ -159,17 +162,17 @@ class AdminController extends Controller
|
|||
|
||||
$lodging = null;
|
||||
|
||||
$calendarUtil = $this->container->get('app.lodging_calendar_util');
|
||||
$calendarService = $this->container->get('app.lodging_calendar_util');
|
||||
|
||||
$lodging = $fewoLodgingRepo->find($lodgingId);
|
||||
$reservations = $calendarUtil->getReservations($lodging);
|
||||
$reservations = $calendarService->getReservations($lodging);
|
||||
|
||||
$paddedCalendar = $calendarUtil->getCalendarWithPadding();
|
||||
$calendar = $calendarUtil->getCalendar();
|
||||
$paddedCalendar = $calendarService->getCalendarWithPadding($calendarService->getMinCalendarEntriesByLodging($lodging));
|
||||
$calendar = $calendarService->getCalendar($lodging);
|
||||
if (count($lodging->getPrices()->toArray()) != 0)
|
||||
{
|
||||
$calendar = $calendarUtil->getCalendarWithReservations($lodging);
|
||||
$calendar = $calendarUtil->mergeWithPaddedCalendar($calendar, $paddedCalendar);
|
||||
$calendar = $calendarService->createCalendarAndFillDayStates($lodging);
|
||||
$calendar = $calendarService->mergeWithPaddedCalendar($calendar, $paddedCalendar);
|
||||
} else {
|
||||
$calendar = $paddedCalendar;
|
||||
}
|
||||
|
|
@ -230,16 +233,13 @@ class AdminController extends Controller
|
|||
|
||||
$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 = $calendarUtil->getCalendarWithPadding();
|
||||
$calendar = $calendarUtil->getCalendar();
|
||||
$paddedCalendar = $calendarService->getCalendarWithPadding($calendarService->getMinCalendarEntriesByLodging($lodging));
|
||||
if (count($lodging->getPrices()->toArray()) != 0)
|
||||
{
|
||||
$calendar = $calendarUtil->getCalendarWithReservations($lodging);
|
||||
$calendar = $calendarUtil->mergeWithPaddedCalendar($calendar, $paddedCalendar);
|
||||
$calendar = $calendarService->createCalendarAndFillDayStates($lodging);
|
||||
$calendar = $calendarService->mergeWithPaddedCalendar($calendar, $paddedCalendar);
|
||||
} else {
|
||||
$calendar = $paddedCalendar;
|
||||
}
|
||||
|
|
@ -771,51 +771,133 @@ class AdminController extends Controller
|
|||
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+"})
|
||||
*/
|
||||
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();
|
||||
$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')
|
||||
if ($request->getMethod() != 'POST' && $image == null)
|
||||
{
|
||||
$image = new FewoLodgingImage();
|
||||
}
|
||||
|
||||
$form = $this->createForm(FewoLodgingImageType::class, $image, [
|
||||
|
||||
]);
|
||||
$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)
|
||||
$image = $form->getData();
|
||||
if ($isNew)
|
||||
{
|
||||
return $this->redirect('/admin/fewo/lodgings');
|
||||
$image->setLodging($lodging);
|
||||
}
|
||||
else
|
||||
{
|
||||
$image->setFile($imageFileName);
|
||||
}
|
||||
|
||||
$image->setLodging($lodging);
|
||||
$em->persist($image);
|
||||
$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(),
|
||||
'lodging' => $lodging,
|
||||
'is_new' => $isNew,
|
||||
'image_file_name' => $isNew ? null : $imageFileName,
|
||||
'image' => $image,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,14 @@ class BookingController extends Controller
|
|||
$em->flush();
|
||||
|
||||
$crmBookingUrl = $this->get('app.booking_exporter')->process($bookingRequest, $travelDate, $bookingPriceInfo);
|
||||
$crmBookingUrl = preg_replace('/\\/api/', '', $crmBookingUrl) .'/edit';
|
||||
if (!$crmBookingUrl)
|
||||
{
|
||||
$crmBookingUrl = '[CRM-EXPORT FEHLGESCHLAGEN]';
|
||||
}
|
||||
else
|
||||
{
|
||||
$crmBookingUrl = preg_replace('/\\/api/', '', $crmBookingUrl).'/edit';
|
||||
}
|
||||
|
||||
$this->get('mailer')->send(\Swift_Message::newInstance()
|
||||
->setSubject('Ihr Buchungsauftrag bei STERN TOURS')
|
||||
|
|
|
|||
|
|
@ -49,11 +49,16 @@ class CmsController extends Controller
|
|||
|
||||
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,
|
||||
'page' => $page,
|
||||
// TODO
|
||||
]);
|
||||
]));
|
||||
}
|
||||
|
||||
public function travelProgramOverviewAction(Page $page)
|
||||
|
|
@ -126,17 +131,14 @@ 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');
|
||||
$calendarService = $this->container->get('app.lodging_calendar_util');
|
||||
$lodging = $page->getFewoLodging();
|
||||
|
||||
$paddedCalendar = $calendarUtil->getCalendarWithPadding();
|
||||
$calendar = $calendarUtil->getCalendar();
|
||||
$paddedCalendar = $calendarService->getCalendarWithPadding($calendarService->getMinCalendarEntriesByLodging($lodging));
|
||||
if (count($lodging->getPrices()->toArray()) != 0)
|
||||
{
|
||||
$calendar = $calendarUtil->getCalendarWithReservations($lodging);
|
||||
$calendar = $calendarUtil->mergeWithPaddedCalendar($calendar, $paddedCalendar);
|
||||
$calendar = $calendarService->createCalendarAndFillDayStates($lodging);
|
||||
$calendar = $calendarService->mergeWithPaddedCalendar($calendar, $paddedCalendar);
|
||||
} else {
|
||||
$calendar = $paddedCalendar;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,9 +43,7 @@ class FewoBookingController extends Controller
|
|||
*/
|
||||
public function indexAction(Page $fewoTravelProgramPage, $action, Request $request)
|
||||
{
|
||||
|
||||
//$calendarUtils = new Util\LodgingCalendarUtil();
|
||||
$calendarUtil = $this->container->get('app.lodging_calendar_util');
|
||||
$calendarService = $this->container->get('app.lodging_calendar_util');
|
||||
$em = $this->getEntityManager();
|
||||
//$fewoLodgingRepo = $em->getRepository('AppBundle:FewoLodging');
|
||||
$fewoPriceRepo = $em->getRepository('AppBundle:FewoPrice');
|
||||
|
|
@ -66,7 +64,7 @@ class FewoBookingController extends Controller
|
|||
$season = $price->getSeason();
|
||||
$minimumStay = $season->getMinimumStay();
|
||||
|
||||
$fromDate = $calendarUtil->convertDate($fromDate);
|
||||
$fromDate = $calendarService->convertDate($fromDate);
|
||||
$fromDateTime = new \DateTime($fromDate);
|
||||
$toDate = '';
|
||||
|
||||
|
|
@ -82,16 +80,59 @@ class FewoBookingController extends Controller
|
|||
$fewoBookingRequest->setLodging($lodging);
|
||||
$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')
|
||||
{
|
||||
$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);
|
||||
|
|
@ -144,7 +185,14 @@ class FewoBookingController extends Controller
|
|||
$em->flush();
|
||||
|
||||
$crmBookingUrl = $this->get('app.fewo_booking_exporter')->process($fewoBookingRequest, $lodging, $price);//, $travelDate, $bookingPriceInfo);
|
||||
$crmBookingUrl = preg_replace('/\\/api/', '', $crmBookingUrl) . '/edit';
|
||||
if (!$crmBookingUrl)
|
||||
{
|
||||
$crmBookingUrl = '[CRM-EXPORT FEHLGESCHLAGEN]';
|
||||
}
|
||||
else
|
||||
{
|
||||
$crmBookingUrl = preg_replace('/\\/api/', '', $crmBookingUrl) . '/edit';
|
||||
}
|
||||
|
||||
$this->get('mailer')->send(\Swift_Message::newInstance()
|
||||
->setSubject('Ihr FeWo-Buchungsauftrag bei STERN TOURS')
|
||||
|
|
@ -208,9 +256,9 @@ class FewoBookingController extends Controller
|
|||
'fewo_price' => $price,
|
||||
'total_price' => $totalPrice,
|
||||
'total_price_per_night' => $perDayTotalPrice,
|
||||
'allowed_to_dates' => implode(';', $allowedToDateStrs),
|
||||
'page' => $fewoTravelProgramPage,
|
||||
'show_search_sidebar_widget' => false,
|
||||
|
||||
]);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue