init without trunk
This commit is contained in:
parent
ed24ac4994
commit
bb809e7233
14652 changed files with 177862 additions and 94817 deletions
1326
src/AppBundle/Controller/AdminController.php
Normal file
1326
src/AppBundle/Controller/AdminController.php
Normal file
File diff suppressed because it is too large
Load diff
1089
src/AppBundle/Controller/BookingController.php
Normal file
1089
src/AppBundle/Controller/BookingController.php
Normal file
File diff suppressed because it is too large
Load diff
429
src/AppBundle/Controller/CmsController.php
Normal file
429
src/AppBundle/Controller/CmsController.php
Normal file
|
|
@ -0,0 +1,429 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
|
||||
* @date 02/22/2017
|
||||
*/
|
||||
|
||||
namespace AppBundle\Controller;
|
||||
|
||||
|
||||
use AppBundle\Entity\FewoPrice;
|
||||
use AppBundle\Entity\Page;
|
||||
use AppBundle\Entity\SunstarTravelProgram;
|
||||
use AppBundle\Entity\FewoLodgingGroup;
|
||||
use AppBundle\Form\SearchRequestType;
|
||||
use AppBundle\Form\TtSearchRequestType;
|
||||
use AppBundle\Listener\KernelControllerListener;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use AppBundle\Util;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Controller for CMS pages. CMS pages are represented by Page instances (i.e. entries of the page database table).
|
||||
* The template property of a Page object defines the action method below. If a travel program is assigned then the
|
||||
* travelProgramAction is used. If no template is specified, then the defaultAction is used.
|
||||
* If there is no action method, the defaultAction is called and the template name is passed as an argument. A twig
|
||||
* file with this template will be rendered in this case.
|
||||
*
|
||||
* The view templates can be found pages/cms.
|
||||
*
|
||||
* Also see {@link KernelControllerListener}, which handles routing.
|
||||
*
|
||||
* @package AppBundle\Controller
|
||||
*/
|
||||
class CmsController extends Controller
|
||||
{
|
||||
/**
|
||||
* @return EntityManager
|
||||
*/
|
||||
private function getEntityManager()
|
||||
{
|
||||
return $this->getDoctrine()->getManager();
|
||||
}
|
||||
|
||||
public function defaultAction(Page $page, $template = 'default')
|
||||
{
|
||||
return $this->render('default/pages/cms/'. $template .'.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'site_loading' => 'default',
|
||||
'page' => $page,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function iqTravelGuideAction($api, $template = 'TravelGuide')
|
||||
{
|
||||
|
||||
/* $travel_guide_content = false;
|
||||
if($page->getTravelGuideContentId() > 0){
|
||||
$repo = $this->getEntityManager()->getRepository('AppBundle:TravelGuides');
|
||||
$travel_guide_content = $repo->findByID($page->getTravelGuideContentId());
|
||||
}
|
||||
*/
|
||||
return $this->render('default/pages/cms/iq'. $template .'.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'site_loading' => 'default',
|
||||
'api' => $api,
|
||||
'breadcrumb_entries' => $api->bread_crumb,
|
||||
'iq_page_title' => $api->title,
|
||||
'iq_page_description' => $api->description,
|
||||
// 'search_form' => $this->createForm(SearchRequestType::class)->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function travelGuideAction(Page $page, $template = 'default')
|
||||
{
|
||||
if(!empty($page->getTemplate())) {
|
||||
$template = $page->getTemplate();
|
||||
}
|
||||
$travel_guide_content = false;
|
||||
if($page->getTravelGuideContentId() > 0){
|
||||
$repo = $this->getEntityManager()->getRepository('AppBundle:TravelGuides');
|
||||
$travel_guide_content = $repo->findByID($page->getTravelGuideContentId());
|
||||
}
|
||||
|
||||
return $this->render('default/pages/cms/'. $template .'.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'site_loading' => 'default',
|
||||
'travel_guide_content' => $travel_guide_content,
|
||||
'page' => $page,
|
||||
]);
|
||||
}
|
||||
|
||||
public function ssSudanTourAction(Page $page, $template = 'default')
|
||||
{
|
||||
|
||||
|
||||
$slugs = array(
|
||||
'nilschiff-ss-sudan' => [0, 1],
|
||||
'bruecke-nilschiff-ss-sudan' => [31, 1],
|
||||
'sonnendeck-nilschiff-ss-sudan' => [32, 1],
|
||||
'agatha-christie-suite-nilschiff-ss-sudan' => [1, 2],
|
||||
'lady-duff-gordon-suite-nilschiff-ss-sudan' => [2, 2],
|
||||
'hercule-poirot-kabine-nilschiff-ss-sudan' => [3, 2],
|
||||
'gustave-flaubert-kabine-nilschiff-ss-sudan' => [4, 2],
|
||||
'herodote-kabine-nilschiff-ss-sudan' => [5, 2],
|
||||
'vivant-denon-kabine-nilschiff-ss-sudan' => [6, 2],
|
||||
'yacoubian-kabine-nilschiff-ss-sudan' => [7, 2],
|
||||
'le-roi-farouk-kabine-nilschiff-ss-sudan' => [8, 2],
|
||||
'mariette-auguste-pacha-kabine-nilschiff-ss-sudan' => [9, 2],
|
||||
'gerard-de-nerval-kabine-nilschiff-ss-sudan' => [10, 2],
|
||||
'ferdinand-de-lesseps-kabine-nilschiff-ss-sudan' => [11, 2],
|
||||
'david-roberts-kabine-nilschiff-ss-sudan' => [12, 2],
|
||||
'alexandre-le-grand-kabine-nilschiff-ss-sudan' => [14, 2],
|
||||
'john-mason-cook-kabine-nilschiff-ss-sudan' => [15, 2],
|
||||
'howard-carter-kabine-nilschiff-ss-sudan' => [16, 2],
|
||||
'le-venitien-inconnu-kabine-nilschiff-ss-sudan' => [17, 2],
|
||||
'suite-18-nilschiff-ss-sudan' => [18, 2],
|
||||
'reine-victoria-suite-nilschiff-ss-sudan' => [19, 3],
|
||||
'oum-kalsoum-suite-nilschiff-ss-sudan' => [20, 3],
|
||||
'naguib-mahfouz-kabine-nilschiff-ss-sudan' => [21, 3],
|
||||
'geoffroy-st-hilaire-kabine-nilschiff-ss-sudan' => [22, 3],
|
||||
'jean-francois-champollion-kabine-nilschiff-ss-sudan' => [23, 3],
|
||||
'samuel-shepheard-kabine-nilschiff-ss-sudan' => [24, 3],
|
||||
'bar-nilschiff-ss-sudan' => [33, 3],
|
||||
'restaurant-nilschiff-ss-sudan' => [34, 3],
|
||||
'maschinenraum-nilschiff-ss-sudan' => [35, 4],
|
||||
'kueche-ss-sudan' => [36, 4],
|
||||
|
||||
);
|
||||
$tour_id = 0;
|
||||
$tour_tap = 1;
|
||||
if(isset($slugs[$page->getSlug()])){
|
||||
$tour_id = $slugs[$page->getSlug()][0];
|
||||
$tour_tap = $slugs[$page->getSlug()][1];
|
||||
}
|
||||
|
||||
return $this->render('default/pages/cms/'. $page->getTemplate() .'.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'site_loading' => 'default',
|
||||
'page' => $page,
|
||||
'tour_id' => $tour_id,
|
||||
'tour_tap' => $tour_tap,
|
||||
]);
|
||||
}
|
||||
|
||||
public function ssSudanAction(Page $page, $template = 'default')
|
||||
{
|
||||
$repo = $this->getEntityManager()->getRepository('AppBundle:Page');
|
||||
|
||||
$box_childs = $repo->findParentsWithShowNav(437);
|
||||
return $this->render('default/pages/cms/'. $page->getTemplate() .'.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'site_loading' => 'default',
|
||||
'page' => $page,
|
||||
'box_childs' => $box_childs,
|
||||
'tour_id' => 0,
|
||||
'tour_tap' => 2,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function nilecruiseAction(Page $page, $template = 'nilecruise')
|
||||
{
|
||||
//read stern 1 + 6
|
||||
//read vermittelte
|
||||
$repo = $this->getEntityManager()->getRepository('AppBundle:Page');
|
||||
$slug_page = $repo->findOneBy(['slug' => 'aegypten-rundreisen']);
|
||||
|
||||
$childPages = $this->getEntityManager()->getRepository('AppBundle:Page')->getChildrenWithTravelProgramsAndDates($slug_page);
|
||||
|
||||
$nonMediated = [];
|
||||
$mediated = [];
|
||||
foreach ($childPages as $childPage)
|
||||
{
|
||||
if ($childPage->getStatus() == 1 && $childPage->getTravelProgram() &&
|
||||
$childPage->getTravelProgram()->getIsMediated())
|
||||
{
|
||||
$mediated[] = $childPage;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(in_array($childPage->getSlug(), ['stern1', 'stern2', 'stern3', 'stern4', 'stern5', 'stern6'])){
|
||||
$nonMediated[] = $childPage;
|
||||
}
|
||||
}
|
||||
}
|
||||
// We only need a separation if there are mediated AND non mediated travel programs
|
||||
if (empty($nonMediated) && !empty($mediated))
|
||||
{
|
||||
$childPages = $mediated;
|
||||
$mediated = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
$childPages = $nonMediated;
|
||||
}
|
||||
|
||||
return $this->render('default/pages/cms/'. $page->getTemplate() .'.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'site_loading' => 'default',
|
||||
'page' => $page,
|
||||
'child_pages' => $childPages,
|
||||
'mediated_child_pages' => $mediated,
|
||||
]);
|
||||
}
|
||||
|
||||
public function overviewAction(Page $page)
|
||||
{
|
||||
|
||||
$settings = $page->getCmsSettings();
|
||||
if (!is_array($settings))
|
||||
{
|
||||
$settings = [];
|
||||
}
|
||||
|
||||
$fewoLodgingGroupRepo = $this->getEntityManager()->getRepository('AppBundle:FewoLodgingGroup');
|
||||
$lodgingGroups = $fewoLodgingGroupRepo->findAll();
|
||||
|
||||
|
||||
return $this->render('default/pages/cms/overview.html.twig', array_merge($settings, [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'site_loading' => 'overview',
|
||||
'page' => $page,
|
||||
'lodgingGroups' => $lodgingGroups,
|
||||
]));
|
||||
}
|
||||
|
||||
public function travelProgramOverviewAction(Page $page)
|
||||
{
|
||||
$childPages =
|
||||
$this->getEntityManager()->getRepository('AppBundle:Page')->getChildrenWithTravelProgramsAndDates($page);
|
||||
|
||||
$nonMediated = [];
|
||||
$mediated = [];
|
||||
foreach ($childPages as $childPage)
|
||||
{
|
||||
if ($childPage->getStatus() == 1 && $childPage->getTravelProgram() &&
|
||||
$childPage->getTravelProgram()->getIsMediated())
|
||||
{
|
||||
$mediated[] = $childPage;
|
||||
}
|
||||
else
|
||||
{
|
||||
$nonMediated[] = $childPage;
|
||||
}
|
||||
}
|
||||
// We only need a separation if there are mediated AND non mediated travel programs
|
||||
if (empty($nonMediated) && !empty($mediated))
|
||||
{
|
||||
$childPages = $mediated;
|
||||
$mediated = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
$childPages = $nonMediated;
|
||||
}
|
||||
|
||||
return $this->render('default/pages/cms/travelProgramOverview.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'site_loading' => 'program',
|
||||
'page' => $page,
|
||||
'child_pages' => $childPages,
|
||||
'mediated_child_pages' => $mediated,
|
||||
]);
|
||||
}
|
||||
|
||||
public function traveltainmentAction(Page $page)
|
||||
{
|
||||
$destination = array_search($page->getBumaDestination(), TtSearchRequestType::$DESTINATION_CHOICES);
|
||||
$form = $this->createForm(TtSearchRequestType::class, [
|
||||
'topRegion' => $destination ? $destination : null,
|
||||
], [
|
||||
'country' => $page->getCountry(),
|
||||
]);
|
||||
|
||||
return $this->render('default/pages/cms/traveltainment.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'site_loading' => 'default',
|
||||
'page' => $page,
|
||||
'show_search_sidebar_widget' => false,
|
||||
'tt_search_form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function travelProgramAction(Page $page)
|
||||
{
|
||||
$this->getDoctrine()->getRepository('AppBundle:TravelPeriod')->getTrueTravelPeriods($page->getTravelProgram());
|
||||
|
||||
// replace this example code with whatever you need
|
||||
return $this->render('default/pages/cms/travelProgram.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'site_loading' => 'program',
|
||||
'page' => $page,
|
||||
'show_offers_sidebar_widget' => false,
|
||||
'travel_program' => $page->getTravelProgram(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function fewoLodgingAction(Page $page)
|
||||
{
|
||||
$calendarService = $this->container->get('app.lodging_calendar_util');
|
||||
$lodging = $page->getFewoLodging();
|
||||
|
||||
$prices = $lodging->getPricesFilterNow();
|
||||
$lodging->setPrices($prices);
|
||||
$paddedCalendar = $calendarService->getCalendarWithPadding($calendarService->getMinCalendarEntriesByLodging($lodging));
|
||||
if (count($lodging->getPrices()->toArray()) != 0)
|
||||
{
|
||||
$calendar = $calendarService->calendarAndFillDayStates($paddedCalendar, $lodging);
|
||||
// $calendar = $calendarService->mergeWithPaddedCalendar($calendar, $paddedCalendar);
|
||||
} else {
|
||||
$calendar = $paddedCalendar;
|
||||
}
|
||||
$imgs = array();
|
||||
$imgs_pre = array();
|
||||
$imgs_post = array();
|
||||
|
||||
$lodgingGroup = $lodging->getGroup();
|
||||
foreach ($lodgingGroup->getImages() as $image) {
|
||||
if($image->getComp() == 'pre'){
|
||||
$imgs_pre[] = $image;
|
||||
}
|
||||
if($image->getComp() == 'post'){
|
||||
$imgs_post[] = $image;
|
||||
}
|
||||
}
|
||||
foreach ($lodging->getImages() as $image) {
|
||||
$imgs[] = $image;
|
||||
}
|
||||
|
||||
|
||||
return $this->render('default/pages/cms/fewoTravelProgram.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'site_loading' => 'program',
|
||||
'page' => $page,
|
||||
'fewo_lodging' => $lodging,
|
||||
'slider_imgs' => array_merge ($imgs_pre, $imgs, $imgs_post),
|
||||
//'lodging' => $lodging, //so wurde es im AdminController aufgerufen
|
||||
'calendar' => $calendar,
|
||||
'show_search_sidebar_widget' => false,
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
public function pdfAction(Page $page)
|
||||
{
|
||||
$travelProgram = $page->getTravelProgram();
|
||||
$program_id = $travelProgram->getId();
|
||||
|
||||
if($program_id != NULL)
|
||||
{
|
||||
|
||||
$url = Util::getBaseUrl().$page->getUrlPath();
|
||||
|
||||
// Initialisierung
|
||||
$pdfObj = $this->container->get('app.pdf');
|
||||
$pdfObj->SetMargins(PDF_MARGIN_LEFT, 40, PDF_MARGIN_RIGHT);
|
||||
$pdfObj->SetAutoPageBreak(true, 65);
|
||||
$pdfObj->AddPage();
|
||||
|
||||
// Erzeugen des HTML über das Twig-Template
|
||||
$pageHTML = $this->render('default/pages/cms/travelProgramPDF.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'page' => $page,
|
||||
'show_offers_sidebar_widget' => false,
|
||||
'travel_program' => $page->getTravelProgram()
|
||||
]);
|
||||
|
||||
|
||||
// Filtern von Hyper-Links
|
||||
$filteredContent = preg_replace('#<p><a(.*)>(.*)</a></p>#Uis', '', $pageHTML->getContent());
|
||||
$filteredContent = preg_replace('#<a(.*)>#Uis', '', $filteredContent);
|
||||
$filteredContent = preg_replace('#</a>#Uis', '', $filteredContent);
|
||||
//$filteredContent = str_replace('*', '<img src="https://www.stern-tours.de/images/icons/star-mini.png" />', $filteredContent);
|
||||
|
||||
|
||||
// $filteredContent = str_replace('*', '<img src="/assetic/sun.jpg" height="6" width="6" />', $filteredContent);
|
||||
|
||||
// Schreiben des HTML
|
||||
$pdfObj->writeHTML('<strong>Reiseangebot zu finden unter:</strong><br /><a href="'.$url.'"style="text-decoration: none!; font-size: 10px; color: black;">'.$url.'</a><br />');
|
||||
$pdfObj->writeHTML($filteredContent);
|
||||
|
||||
// Ersetzen der Umlaute
|
||||
$germanLetters = array("/ä/","/ö/","/ü/","/Ä/","/Ö/","/Ü/","/ß/");
|
||||
$replace = array("ae","oe","ue","Ae","Oe","Ue","ss");
|
||||
$filename = preg_replace($germanLetters, $replace, $travelProgram->getTitle());
|
||||
|
||||
header('Link: <'.$travelProgram->getUrl().'>; rel="canonical"');
|
||||
|
||||
$pdfObj->Output($filename.'.pdf', 'D');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*
|
||||
* @todo This is actually the same as overview, but with different sidebar. Utilize cmsSettings field of page entity for such requirements
|
||||
*/
|
||||
public function jugendreisenAction(Page $page)
|
||||
{
|
||||
return $this->render('default/pages/cms/overview.html.twig', [
|
||||
'page' => $page,
|
||||
'site_loading' => 'default',
|
||||
'show_search_sidebar_widget' => false,
|
||||
'show_offers_sidebar_widget' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
public function sunstarAction(Page $page)
|
||||
{
|
||||
/** @var SunstarTravelProgram[] $sunstarTravelPrograms */
|
||||
$sunstarTravelPrograms = $this->getDoctrine()->getRepository('AppBundle:SunstarTravelProgram')
|
||||
->findBy(['destination' => $page->getCmsSettings()]);
|
||||
|
||||
return $this->render('default/pages/cms/sunstar.html.twig', [
|
||||
'page' => $page,
|
||||
'site_loading' => 'default',
|
||||
'show_search_sidebar_widget' => false,
|
||||
'show_offers_sidebar_widget' => false,
|
||||
'sunstar_travel_programs' => $sunstarTravelPrograms,
|
||||
]);
|
||||
}
|
||||
}
|
||||
312
src/AppBundle/Controller/ComponentController.php
Normal file
312
src/AppBundle/Controller/ComponentController.php
Normal file
|
|
@ -0,0 +1,312 @@
|
|||
<?php
|
||||
|
||||
namespace AppBundle\Controller;
|
||||
|
||||
use AppBundle\Entity\Page;
|
||||
use AppBundle\Entity\TravelCountry;
|
||||
use AppBundle\Form\SearchRequestType;
|
||||
use AppBundle\Util;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
|
||||
/**
|
||||
* Controller for re-usable view components. They are normally included by a render twig-expression. Example:
|
||||
*
|
||||
* <code>{{ render(controller('AppBundle:Component:travelGuideSidebarWidget', {country: page.country})) }}</code>
|
||||
*/
|
||||
class ComponentController extends Controller
|
||||
{
|
||||
|
||||
private $headerContent;
|
||||
/**
|
||||
* @return EntityManager
|
||||
*/
|
||||
public function getEntityManager()
|
||||
{
|
||||
return $this->getDoctrine()->getManager();
|
||||
}
|
||||
|
||||
|
||||
public function getHeaderContent(){
|
||||
|
||||
if(!$this->headerContent){
|
||||
$this->headerContent = Util::loadFromApi('cms/header/info', ['url'=>""]);
|
||||
}
|
||||
return $this->headerContent;
|
||||
|
||||
}
|
||||
|
||||
public function headerAction()
|
||||
{
|
||||
$navPages = $this->getEntityManager()->getRepository('AppBundle:Page')->findTopCountryNavPages();
|
||||
|
||||
$content = $this->getHeaderContent();
|
||||
|
||||
$local = [];
|
||||
foreach ($content->local as $key=>$value){
|
||||
$local[$key] = $value;
|
||||
}
|
||||
|
||||
$phone = [];
|
||||
foreach ($content->phone as $key=>$value){
|
||||
$phone[$key] = $value;
|
||||
}
|
||||
|
||||
|
||||
return $this->render('default/components/header.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'nav_pages' => $navPages,
|
||||
'content' => $content,
|
||||
'local' => $local,
|
||||
'phone' => $phone,
|
||||
]);
|
||||
}
|
||||
|
||||
public function footerAction()
|
||||
{
|
||||
$content = $this->getHeaderContent();
|
||||
return $this->render('default/components/footer.html.twig', [
|
||||
'content' => $content,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function breadcrumbAction(Page $page)
|
||||
{
|
||||
return $this->render('default/components/breadcrumb.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'breadcrumb_entries' => Util::createBreadcrumb($page),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function navSidebarApiWidgetAction($api, $title = 'Reiseführer')
|
||||
{
|
||||
|
||||
return $this->render('default/components/sidebar/navSidebarApiWidgetInner.html.twig', [
|
||||
'api'=>$api,
|
||||
'title' => "Reiseführer",
|
||||
]);
|
||||
}
|
||||
|
||||
public function navSidebarWidgetAction(Page $page, $title = 'Reiseprogramme')
|
||||
{
|
||||
if(!empty($page->getTitle())){
|
||||
$title = $page->getTitle();
|
||||
}
|
||||
$pageRepo = $this->getEntityManager()->getRepository('AppBundle:Page');
|
||||
$view = [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'page' => $page,
|
||||
'slider_title' => $title,
|
||||
|
||||
];
|
||||
|
||||
if ($page->getHasChildren())
|
||||
{
|
||||
if ($page->getLvl() == 0)
|
||||
{
|
||||
$view['nav_pages'] = $page->getChildren();
|
||||
|
||||
$view['nav_child_pages'] = [];
|
||||
}
|
||||
else
|
||||
{
|
||||
$view['nav_pages'] = $pageRepo->getSiblings($page);
|
||||
$view['nav_child_pages'] = $page->getChildren();
|
||||
}
|
||||
$view['nav_open_node'] = $page;
|
||||
}
|
||||
else
|
||||
{
|
||||
$parent = $page->getParent();
|
||||
if ($parent)
|
||||
{
|
||||
$view['nav_pages'] = $pageRepo->getSiblings($parent);
|
||||
if (empty($view['nav_pages']))
|
||||
{
|
||||
$view['nav_pages'] = $pageRepo->getSiblings($page);
|
||||
}
|
||||
else
|
||||
{
|
||||
$view['nav_child_pages'] = $pageRepo->getSiblings($page);
|
||||
}
|
||||
$view['nav_open_node'] = $parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
$view['nav_pages'] = $pageRepo->getSiblings($page);
|
||||
$view['nav_child_pages'] = [];
|
||||
$view['nav_open_node'] = null;
|
||||
}
|
||||
}
|
||||
return $this->render('default/components/sidebar/navSidebarWidgetInner.html.twig', $view);
|
||||
}
|
||||
|
||||
public function searchSidebarApiWidgetAction($api, $title = 'Suche')
|
||||
{
|
||||
$combinedDestination = null;
|
||||
$destination = null;
|
||||
//todo need Country by name
|
||||
if(isset($api->sites[0]->country_id)){
|
||||
$repo = $this->getEntityManager()->getRepository('AppBundle:TravelCountry');
|
||||
$destination = $repo->find($api->sites[0]->country_id);
|
||||
}
|
||||
return $this->render('default/components/sidebar/searchSidebarWidgetInner.html.twig', [
|
||||
'slider_title' => "suche",
|
||||
'search_form' => $this->createForm(SearchRequestType::class, [
|
||||
'c' =>$destination,
|
||||
'c2' => $combinedDestination,
|
||||
])->createView()
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function searchSidebarWidgetAction(Page $page, $title = 'Suche')
|
||||
{
|
||||
$combinedDestination = null;
|
||||
if ($page->getTravelProgram())
|
||||
{
|
||||
$countries = $page->getTravelProgram()->getCountries();
|
||||
$destination = $countries->first();
|
||||
if (count($countries) > 1)
|
||||
{
|
||||
$combinedDestination = $countries[1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$destination = $page->getCountry();
|
||||
}
|
||||
|
||||
return $this->render('default/components/sidebar/searchSidebarWidgetInner.html.twig', [
|
||||
'slider_title' => "suche",
|
||||
'search_form' => $this->createForm(SearchRequestType::class, [
|
||||
'c' => $destination,
|
||||
'c2' => $combinedDestination,
|
||||
])->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
public function travelGuideSidebarWidgetAction(TravelCountry $country, $title = 'Reiseführer')
|
||||
{
|
||||
$repo = $this->getEntityManager()->getRepository('AppBundle:Page');
|
||||
$rootPage = $repo->find(13);
|
||||
$pages = $repo->getChildrenQueryBuilder($rootPage)
|
||||
->andWhere('IDENTITY(node.country) = '. $country->getId())
|
||||
->andWhere('node.status > 0')
|
||||
->getQuery()
|
||||
->execute()
|
||||
;
|
||||
return $this->render('default/components/sidebar/pageSliderSidebarWidget.html.twig', [
|
||||
'slider_title' => $title,
|
||||
'target_widget' => 'travel-leader-widget',
|
||||
'pages' => $pages
|
||||
]);
|
||||
}
|
||||
|
||||
public function travelMagazineSidebarWidgetAction(TravelCountry $country, $title = 'Reisemagazin')
|
||||
{
|
||||
$repo = $this->getEntityManager()->getRepository('AppBundle:Page');
|
||||
$rootPage = $repo->find(2803);
|
||||
$pages = $repo->getChildrenQueryBuilder($rootPage)
|
||||
->andWhere('IDENTITY(node.country) = '. $country->getId())
|
||||
->andWhere('node.status > 0')
|
||||
->getQuery()
|
||||
->execute()
|
||||
;
|
||||
return $this->render('default/components/sidebar/pageSliderSidebarWidget.html.twig', [
|
||||
'slider_title' => $title,
|
||||
'target_widget' => 'travel-magazine-widget',
|
||||
'pages' => $pages
|
||||
]);
|
||||
}
|
||||
|
||||
public function offersSidebarWidgetAction(TravelCountry $country = null, $title = 'Angebote')
|
||||
{
|
||||
return $this->render('default/components/sidebar/pageSliderSidebarWidget.html.twig', [
|
||||
'slider_title' => $title,
|
||||
'target_widget' => 'offer-widget',
|
||||
'pages' => $this->getOffersByCountry($country),
|
||||
]);
|
||||
}
|
||||
|
||||
public function offersCarouselAction(TravelCountry $country = null)
|
||||
{
|
||||
return $this->render('default/components/multiPageBoxCarousel.html.twig', [
|
||||
'pages' => $this->getOffersByCountry($country),
|
||||
]);
|
||||
}
|
||||
|
||||
private function getOffersByCountry(TravelCountry $country = null)
|
||||
{
|
||||
$repo = $this->getDoctrine()->getRepository('AppBundle:Page');
|
||||
return $country === null
|
||||
? $repo->findOffers()
|
||||
: $repo->findWithTravelProgramsOfCountry($country)
|
||||
;
|
||||
}
|
||||
|
||||
public function feedbacksSidebarWidgetAction(TravelCountry $country, $title = 'Kundenfeedback')
|
||||
{
|
||||
return $this->render(':default/components/sidebar:textSliderSidebarWidget.html.twig', [
|
||||
'slider_title' => $title,
|
||||
'target_widget' => 'feedback-widget',
|
||||
'slides' => $this->getDoctrine()->getRepository('AppBundle:Page')->findFeedbacks(
|
||||
$country->getFeedbackPage()->getId()),
|
||||
'theme' => 'gray-box',
|
||||
]);
|
||||
}
|
||||
|
||||
public function makeSidebarWidgetAction($site_loading = 'default', Page $page = null, $api=null, $search_form = null){
|
||||
|
||||
$show_seal_of_approval = false;
|
||||
//default
|
||||
switch ($site_loading){
|
||||
case 'home' :
|
||||
$site = 'home';
|
||||
break;
|
||||
case 'search' :
|
||||
$site = 'search';
|
||||
break;
|
||||
case 'default' :
|
||||
$site = 'default';
|
||||
break;
|
||||
case 'overview' :
|
||||
$site = 'overview';
|
||||
break;
|
||||
case 'program' :
|
||||
$site = 'program';
|
||||
break;
|
||||
case 'booking' :
|
||||
$site = 'booking';
|
||||
$show_seal_of_approval = true;
|
||||
break;
|
||||
case 'bookingconfirm' :
|
||||
$site = 'bookingconfirm';
|
||||
$show_seal_of_approval = true;
|
||||
break;
|
||||
default :
|
||||
$site = 'default';
|
||||
break;
|
||||
}
|
||||
$sidebarRepo = $this->getEntityManager()->getRepository('AppBundle:SidebarWidget');
|
||||
$widgets = $sidebarRepo->findWidgetsBy($site);
|
||||
|
||||
$vars = [ 'page' => $page,
|
||||
'api' => $api,
|
||||
'site_loading' => $site_loading,
|
||||
'widgets' => $widgets,
|
||||
'show_seal_of_approval' => $show_seal_of_approval,
|
||||
'loop_half' => ceil(count($widgets) / 2)
|
||||
];
|
||||
if($search_form != null){
|
||||
$vars['search_form'] = $search_form;
|
||||
}
|
||||
return $this->render(':default/components/sidebar:sidebar.html.twig', $vars);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
527
src/AppBundle/Controller/DefaultController.php
Normal file
527
src/AppBundle/Controller/DefaultController.php
Normal file
|
|
@ -0,0 +1,527 @@
|
|||
<?php
|
||||
|
||||
namespace AppBundle\Controller;
|
||||
|
||||
use AppBundle\Entity\BreadcrumbEntry;
|
||||
use AppBundle\Entity\ContactRequest;
|
||||
use AppBundle\Entity\Page;
|
||||
use AppBundle\Form\ContactRequestType;
|
||||
use AppBundle\Form\SearchRequestType;
|
||||
use AppBundle\Form\TtSearchRequestType;
|
||||
use AppBundle\Util;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Gedmo\Tree\TreeListener;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class DefaultController extends Controller
|
||||
{
|
||||
/**
|
||||
* @return EntityManager
|
||||
*/
|
||||
public function getEntityManager()
|
||||
{
|
||||
return $this->getDoctrine()->getManager();
|
||||
}
|
||||
|
||||
public function defaultAction(Request $request)
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/")
|
||||
*/
|
||||
public function homeAction()
|
||||
{
|
||||
return $this->render('default/pages/home.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'site_loading' => 'home',
|
||||
'canonical_url' => Util::getBaseUrl(),
|
||||
'show_search_sidebar_widget' => false,
|
||||
'show_offers_sidebar_widget' => false,
|
||||
'search_form' => $this->createForm(SearchRequestType::class)->createView(),
|
||||
'tt_search_form' => $this->createForm(TtSearchRequestType::class)->createView(),
|
||||
'country_pages' => $this->getEntityManager()->getRepository('AppBundle:Page')->findCountryPages(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/suche")
|
||||
*/
|
||||
public function searchAction(Request $request)
|
||||
{
|
||||
$form = $this->createForm(SearchRequestType::class);
|
||||
if (empty($request->query->get('b')))
|
||||
{
|
||||
$request->query->set('b', (new \DateTime('+5 day'))->format('d.m.Y'));
|
||||
}
|
||||
if (empty($request->query->get('e')))
|
||||
{
|
||||
$request->query->set('e', (new \DateTime('+31 day'))->format('d.m.Y'));
|
||||
}
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid())
|
||||
{
|
||||
$data = $form->getData();
|
||||
|
||||
$destinationIds = [];
|
||||
if (!empty($data['c']))
|
||||
{
|
||||
$destinationIds = [$data['c']->getId()];
|
||||
}
|
||||
if (!empty($destinationIds) && !empty($data['c2']))
|
||||
{
|
||||
$destinationIds[] = $data['c2']->getId();
|
||||
}
|
||||
$r = $this->getDoctrine()->getRepository('AppBundle:TravelPeriod')->getTravelProgramsWithTravelDatesForTimePeriod(
|
||||
$data['b'], $data['e'], $destinationIds, count($destinationIds) > 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$r = [];
|
||||
}
|
||||
|
||||
return $this->render('default/pages/search.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'site_loading' => 'search',
|
||||
'breadcrumb_entries' => [new BreadcrumbEntry('Suchen')],
|
||||
'search_form' => $form->createView(),
|
||||
'travel_programs' => $r,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/tt-suche")
|
||||
*/
|
||||
public function ttSearchAction(Request $request)
|
||||
{
|
||||
$form = $this->createForm(TtSearchRequestType::class);
|
||||
if (empty($request->query->get('termin')))
|
||||
{
|
||||
$request->query->set('termin', (new \DateTime('+5 day'))->format('d.m.Y'));
|
||||
}
|
||||
if (empty($request->query->get('ruecktermin')))
|
||||
{
|
||||
$request->query->set('ruecktermin', (new \DateTime('+19 day'))->format('d.m.Y'));
|
||||
}
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid())
|
||||
{
|
||||
$data = $form->getData();
|
||||
|
||||
//$ttUrl = "http://dtps-ibe.traveltainment.de/hotel/?&taid=DRS32"; //ibe=package";
|
||||
|
||||
/*$requests = "&ibe=package&aidgiata=49720&ddate=".date("Y-m-d", 1523397600)."&depap=TXL&rdate=".date("Y-m-d", 1524002400)."&dur=6,2&brand=FTI&oid=ASW318;PAUS;;DSQF&adult=2";*/
|
||||
$ttUrl = "";
|
||||
$ttUrl .= '&ddate=' . $data['termin']->format('d.m.Y');
|
||||
$ttUrl .= '&rdate=' . $data['ruecktermin']->format('d.m.Y');
|
||||
if (!empty($data['dauer'])){
|
||||
$ttUrl .= '&dur='.str_replace("_", ",", $data['dauer']);
|
||||
}
|
||||
$ttUrl .= '&adult=2';
|
||||
if (!empty($data['t']))
|
||||
{
|
||||
$ttUrl .= '&adult='. $data['t'];
|
||||
$count = 0;
|
||||
for ($i = 0; $i < 3; ++$i)
|
||||
{
|
||||
if (!empty($data['child'.$i]))
|
||||
{
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
$ttUrl .= '&child='. $count;
|
||||
}
|
||||
// $ttUrl .= '&ibes=';
|
||||
if (!empty($data['topRegion']))
|
||||
{
|
||||
if(isset(TtSearchRequestType::$DESTINATION_CHOICES[$data['topRegion']])){
|
||||
// $ttUrl .= 'hotel&rgid='. TtSearchRequestType::$DESTINATION_CHOICES[$data['topRegion']];
|
||||
$ttUrl .= '&rid='. TtSearchRequestType::$DESTINATION_CHOICES[$data['topRegion']];
|
||||
$ttUrl = "https://dtps-ibe.traveltainment.de/hotel/?&taid=DRS32".$ttUrl;
|
||||
}else{
|
||||
// $ttUrl .= 'package&rgid='. $data['topRegion'];
|
||||
$ttUrl .= '&rid='. $data['topRegion'];
|
||||
$ttUrl = "https://dtps-ibe.traveltainment.de/offer/?&taid=DRS32".$ttUrl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//https://dtps-ibe.traveltainment.de/hotel?taid=DRS32&ddate=2018-07-25&rdate=2018-08-08&adult=2&rid=2202
|
||||
//http://dtps-ibe.traveltainment.de/hotel?taid=DRS32&ddate=2018-07-25&rdate=2018-08-08&dur=6,14&adult=1&child=0&rgid=2202
|
||||
else
|
||||
{
|
||||
//$ttUrl .= 'package';
|
||||
$ttUrl = "https://dtps-ibe.traveltainment.de/offer/?&taid=DRS32".$ttUrl;
|
||||
}
|
||||
if (!empty($data['abflughafen'])) $ttUrl .= '&depap='. $data['abflughafen'];
|
||||
if (!empty($data['shotel'])) $ttUrl .= '&accom='. urlencode($data['shotel']);
|
||||
if (!empty($data['kategorie'])) $ttUrl .= '&stars='. $data['kategorie'];
|
||||
if (!empty($data['zimmer'])) $ttUrl .= '&room='. $data['zimmer'];
|
||||
if (!empty($data['verpflegung'])) $ttUrl .= '&board='. $data['verpflegung'];
|
||||
if (!empty($data['hbfges'])) $ttUrl .= '&raavg='. $data['hbfges'];
|
||||
if (!empty($data['hbfanz'])) $ttUrl .= '&hbfanz='. $data['hbfanz'];
|
||||
if (!empty($data['hbfempf'])) $ttUrl .= '&racnt='. $data['hbfempf'];
|
||||
//if ($data['familie_kinder'] ?? false) $ttUrl .= '&familie_kinder=0';
|
||||
//if ($data['strand'] ?? false) $ttUrl .= '&beach=0';
|
||||
//if ($data['wellness'] ?? false) $ttUrl .= '&wellness=0';
|
||||
//if ($data['typ'] ?? false) $ttUrl .= '&typ=0';
|
||||
if (!empty($data['sportangebot'])) $ttUrl .= '&sports='. $data['sportangebot'];
|
||||
|
||||
/*$ttUrl = 'http://www.vidado.com/booking/ibe_bp2/index.php?CID=8ce65750ce5af9d9a6b22c9b04772ea7&formular=4&engine=pauschal&showresult=1';
|
||||
$ttUrl .= '&termin=' . $data['termin']->format('d.m.Y');
|
||||
$ttUrl .= '&ruecktermin=' . $data['ruecktermin']->format('d.m.Y');
|
||||
if (!empty($data['dauer'])) $ttUrl .= '&dauer='. $data['dauer'];
|
||||
if (!empty($data['t']))
|
||||
{
|
||||
$ttUrl .= '&personen=25'. str_repeat(';25', $data['t'] - 1);
|
||||
for ($i = 0; $i < 3; ++$i)
|
||||
{
|
||||
if (!empty($data['child'.$i]))
|
||||
{
|
||||
$ttUrl .= ';'. $data['child'. $i];
|
||||
}
|
||||
}
|
||||
}
|
||||
$ttUrl .= '&detail=';
|
||||
if (!empty($data['topRegion']) && isset(TtSearchRequestType::$DESTINATION_CHOICES[$data['topRegion']]))
|
||||
{
|
||||
$ttUrl .= 'hotel&topRegion='. TtSearchRequestType::$DESTINATION_CHOICES[$data['topRegion']];
|
||||
}
|
||||
else
|
||||
{
|
||||
$ttUrl .= 'zielgebiet';
|
||||
}
|
||||
if (!empty($data['abflughafen'])) $ttUrl .= '&abflughafen='. $data['abflughafen'];
|
||||
if (!empty($data['shotel'])) $ttUrl .= '&shotel='. urlencode($data['shotel']);
|
||||
if (!empty($data['kategorie'])) $ttUrl .= '&kategorie='. $data['kategorie'];
|
||||
if (!empty($data['zimmer'])) $ttUrl .= '&zimmer='. $data['zimmer'];
|
||||
if (!empty($data['verpflegung'])) $ttUrl .= '&verpflegung='. $data['verpflegung'];
|
||||
if (!empty($data['hbfges'])) $ttUrl .= '&hbfges='. $data['hbfges'];
|
||||
if (!empty($data['hbfanz'])) $ttUrl .= '&hbfanz='. $data['hbfanz'];
|
||||
if (!empty($data['hbfempf'])) $ttUrl .= '&hbfempf='. $data['hbfempf'];
|
||||
if ($data['familie_kinder'] ?? false) $ttUrl .= '&familie_kinder=0';
|
||||
if ($data['strand'] ?? false) $ttUrl .= '&strand=0';
|
||||
if ($data['wellness'] ?? false) $ttUrl .= '&wellness=0';
|
||||
if ($data['typ'] ?? false) $ttUrl .= '&typ=0';
|
||||
if (!empty($data['sportangebot'])) $ttUrl .= '&sportangebot='. $data['sportangebot'];
|
||||
*/
|
||||
|
||||
}else{
|
||||
if(strpos($_SERVER['QUERY_STRING'], 'ttexpedient')){
|
||||
|
||||
$get_array = array();
|
||||
parse_str($_SERVER['QUERY_STRING'], $get_array);
|
||||
|
||||
if(!empty($get_array['detail'])) { $det=$get_array['detail']; }
|
||||
else { $det=""; }
|
||||
|
||||
if(!empty($get_array['IFF'])) { $iff=$get_array['IFF']; }
|
||||
else { $iff=""; }
|
||||
|
||||
if(!empty($get_array['abflughafen'])) { $airp=$get_array['abflughafen']; }
|
||||
else { $airp=""; }
|
||||
|
||||
if(!empty($get_array['sleistung'])) { $sleist=$get_array['sleistung']; }
|
||||
else { $sleist=""; }
|
||||
|
||||
if(!empty($get_array['showresult'])) { $show=$get_array['showresult']; }
|
||||
else { $show=""; }
|
||||
|
||||
if(!empty($get_array['personen'])) { $pers=$get_array['personen']; }
|
||||
else { $pers=""; }
|
||||
|
||||
if(!empty($get_array['marke'])) { $va=$get_array['marke']; }
|
||||
else { $va=""; }
|
||||
|
||||
if(!empty($get_array['termin'])) { $hin=$get_array['termin']; }
|
||||
else { $hin=""; }
|
||||
|
||||
if(!empty($get_array['ruecktermin'])) { $rueck=$get_array['ruecktermin']; }
|
||||
else { $rueck=""; }
|
||||
|
||||
if(!empty($get_array['dauer'])) { $dau=$get_array['dauer']; }
|
||||
else { $dau=""; }
|
||||
|
||||
if(!empty($get_array['bplink'])) { $bli=$get_array['bplink']; }
|
||||
else { $bli=""; }
|
||||
|
||||
if(!empty($get_array['ttexpedient'])) { $exp=$get_array['ttexpedient']; }
|
||||
|
||||
|
||||
else { $exp=""; }
|
||||
if($dau != "" && strpos($dau, "_")){
|
||||
$dau = explode("_", $dau);
|
||||
asort($dau);
|
||||
$dau = implode(",", $dau);
|
||||
}
|
||||
$adult = substr_count($pers, '25');
|
||||
$child = "";
|
||||
$ps = explode(';', $pers);
|
||||
|
||||
foreach ($ps as $p) {
|
||||
if($p < 25){
|
||||
$child .= $p.",";
|
||||
}
|
||||
}
|
||||
$board = "";
|
||||
$room = "";
|
||||
|
||||
if($sleist != "" && strpos($sleist, ";")) {
|
||||
$eleist = explode(';', $sleist);
|
||||
$v = end($eleist);
|
||||
if(strpos($v, "F") !== false){
|
||||
$board = 2;
|
||||
}
|
||||
if(strpos($v, "H") !== false){
|
||||
$board = 3;
|
||||
}
|
||||
if(strpos($v, "V") !== false){
|
||||
$board = 4;
|
||||
}
|
||||
if(strpos($v, "A") !== false){
|
||||
$board = 5;
|
||||
}
|
||||
if(strpos($v, "EZ") !== false){
|
||||
$room = 1;
|
||||
}
|
||||
if(strpos($v, "DZ") !== false){
|
||||
$room = 2;
|
||||
}
|
||||
if(strpos($v, "FZ") !== false){
|
||||
$room = 3;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$child = rtrim($child, ',');
|
||||
$url = "https://dtps-ibe.traveltainment.de/offer?taid=DRS32";
|
||||
$url .= '&ibe=package&adult='.$adult.'&ddate='.date("Y-m-d", $hin).'&rdate='.date("Y-m-d", $rueck).'&depap='.$airp.'&aid='.$iff.'&brand='.$va.'&dur='.$dau.'&child='.$child.'&board='.$board.'&room='.$room.'&dur=exact';
|
||||
|
||||
|
||||
|
||||
$ttUrl = urldecode($url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->render('default/pages/ttSearch.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'site_loading' => 'search',
|
||||
'breadcrumb_entries' => [new BreadcrumbEntry('Suchen')],
|
||||
'tt_search_form' => $form->createView(),
|
||||
'tt_url' => $ttUrl ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/kontakt")
|
||||
*/
|
||||
public function contactAction(Request $request)
|
||||
{
|
||||
$form = $this->createForm(ContactRequestType::class);
|
||||
$breadcrumbEntries = [new BreadcrumbEntry('Kontaktformular')];
|
||||
|
||||
$re_error = "";
|
||||
if ($request->getMethod() == 'POST')
|
||||
{
|
||||
$error = false;
|
||||
|
||||
if(empty($request->get('g-recaptcha-response'))){
|
||||
$re_error = 'Bitte lösen Sie das reCAPTCHA.';
|
||||
$error = true;
|
||||
}
|
||||
//your site secret key
|
||||
$secret = '6LfjBm8UAAAAANKNzGhSiMaoEg9mUswlaZkOHgI4';
|
||||
//get verify response data
|
||||
$verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$request->get('g-recaptcha-response'));
|
||||
$responseData = json_decode($verifyResponse);
|
||||
|
||||
|
||||
if($responseData->success != true ){
|
||||
$re_error = 'Bitte lösen Sie das reCAPTCHA';
|
||||
$error = true;
|
||||
}
|
||||
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid() && !$error)
|
||||
{
|
||||
/** @var ContactRequest $contactRequest */
|
||||
$contactRequest = $form->getData();
|
||||
|
||||
$crmLeadUrl = $this->get('app.contact_exporter')->process($contactRequest);
|
||||
if ($crmLeadUrl)
|
||||
{
|
||||
$crmLeadUrl = preg_replace('/\\/api\\/lead/', '/leads', $crmLeadUrl) .'/edit';
|
||||
}
|
||||
else
|
||||
{
|
||||
$crmLeadUrl = '[Übertragung zum CRM fehlgeschlagung]';
|
||||
}
|
||||
|
||||
$this->get('mailer')->send(\Swift_Message::newInstance()
|
||||
->setSubject('Kontaktformular (stern-tours.de)')
|
||||
->setFrom('stern@stern-tours.de', 'STERN TOURS')
|
||||
->setTo('stern@stern-tours.de')
|
||||
->setBody(
|
||||
$this->renderView('default/email/contactServiceEmail.txt.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'crm_url' => $crmLeadUrl,
|
||||
'contact_request' => $contactRequest,
|
||||
]),
|
||||
'text/plain', 'utf-8'
|
||||
)
|
||||
);
|
||||
|
||||
// #TODO This will lead to multiple submissions. Redirect instead!
|
||||
return $this->render('default/pages/contactConfirmation.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'breadcrumb_entries' => $breadcrumbEntries,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('default/pages/contact.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'site_loading' => 'default',
|
||||
'breadcrumb_entries' => $breadcrumbEntries,
|
||||
'contact_form' => $form->createView(),
|
||||
're_error' => $re_error,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/sitemap")
|
||||
*/
|
||||
public function sitemapAction()
|
||||
{
|
||||
$repo = $this->getDoctrine()->getRepository('AppBundle:Page');
|
||||
$rootNodes = $repo->getRootNodesQueryBuilder()
|
||||
->andWhere('node.status = 1')
|
||||
->andWhere('node.lvl = 0')
|
||||
->getQuery()
|
||||
->execute()
|
||||
;
|
||||
/** @var Page[] $pageNodes Actually no entity objects but associative arrays representing page entities */
|
||||
$pageNodes = [];
|
||||
foreach ($rootNodes as $rootNode)
|
||||
{
|
||||
$pageNodes[] = $repo->buildTree($repo->getNodesHierarchyQueryBuilder($rootNode, false, [], true)
|
||||
->leftJoin('node.travelProgram', 'tp')
|
||||
->andWhere('(tp.id IS NULL OR tp.status = 1)')
|
||||
->andWhere('node.status = 1')
|
||||
->getQuery()
|
||||
->getArrayResult()
|
||||
)[0];
|
||||
}
|
||||
return $this->render('default/pages/sitemap.html.twig', [
|
||||
'breadcrumb_entries' => [new BreadcrumbEntry('Sitemap')],
|
||||
'site_loading' => 'default',
|
||||
'page_nodes' => $pageNodes
|
||||
]);
|
||||
}
|
||||
|
||||
/*
|
||||
Suche Kindknoten
|
||||
Für jeden Kindknoten
|
||||
++LFT
|
||||
Setze LFT
|
||||
f()
|
||||
++LFT
|
||||
RGT = LFT
|
||||
Setze RGT
|
||||
*/
|
||||
|
||||
/**
|
||||
* @Route("/create-tree")
|
||||
*/
|
||||
public function createTreeAction()
|
||||
{
|
||||
set_time_limit(0);
|
||||
ini_set('memory_limit', '2048M');
|
||||
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$em->getConnection()->executeUpdate(
|
||||
'UPDATE page SET lvl = NULL, lft = NULL, rgt = NULL, parent_id = NULL, tree_root = NULL');
|
||||
|
||||
foreach ($em->getEventManager()->getListeners() as $event => $listeners) {
|
||||
foreach ($listeners as $hash => $listener) {
|
||||
if ($listener instanceof TreeListener)
|
||||
{
|
||||
$em->getEventManager()->removeEventListener($event, $listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$em->beginTransaction();
|
||||
|
||||
// Add missing owner relation for catalog root pages (e.g. children of 'aegypten-reisen')
|
||||
$em->getConnection()->executeUpdate('UPDATE page SET owner = 47 WHERE catalog_id = 3 AND owner = 0');
|
||||
$em->getConnection()->executeUpdate('UPDATE page SET owner = 66 WHERE catalog_id = 6 AND owner = 0');
|
||||
$em->getConnection()->executeUpdate('UPDATE page SET owner = 2803 WHERE catalog_id = 14 AND owner = 0');
|
||||
// Add missing owner relation
|
||||
$em->getConnection()->executeUpdate('UPDATE page SET owner = 13 WHERE id in (1314,1426,1472,1548)');
|
||||
|
||||
$lft = 0;
|
||||
$this->createTree(0, $lft, 0);
|
||||
$em->flush();
|
||||
|
||||
// Reset the owner field to avoid problems in the old website
|
||||
$em->getConnection()->executeUpdate('UPDATE page SET owner = 0 WHERE parent_id = 47 AND catalog_id = 3');
|
||||
$em->getConnection()->executeUpdate('UPDATE page SET owner = 0 WHERE parent_id = 66 AND catalog_id = 6');
|
||||
$em->getConnection()->executeUpdate('UPDATE page SET owner = 0 WHERE parent_id = 2803 AND catalog_id = 14');
|
||||
$em->getConnection()->executeUpdate('UPDATE page SET owner = 0 WHERE id in (1314,1426,1472,1548)');
|
||||
|
||||
$em->commit();
|
||||
|
||||
die("DONE.");
|
||||
}
|
||||
|
||||
private function createTree($owner, &$lft, $lvl, $root = null)
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$qb = $em->createQueryBuilder()->from('AppBundle:Page', 'p')->select('p');
|
||||
$qb->where($qb->expr()->eq('p.owner', $owner));
|
||||
if ($owner == 0)
|
||||
{
|
||||
$qb->orWhere('p.owner IS NULL');
|
||||
}
|
||||
$qb->orderBy('p.order');
|
||||
$qb->addOrderBy('p.title');
|
||||
$pages = $qb->getQuery()->execute();
|
||||
foreach ($pages as $page)
|
||||
{
|
||||
/** @var Page $page */
|
||||
|
||||
if ($owner == 0)
|
||||
{
|
||||
$root = $page->getId();
|
||||
}
|
||||
|
||||
++$lft;
|
||||
$page->setLft($lft);
|
||||
$page->setLvl($lvl);
|
||||
$page->setRoot($em->getReference('AppBundle:Page', $root));
|
||||
if ($owner != 0)
|
||||
{
|
||||
$page->setParent($em->getReference('AppBundle:Page', $owner));
|
||||
}
|
||||
|
||||
$this->createTree($page->getId(), $lft, $lvl + 1, $root);
|
||||
|
||||
++$lft;
|
||||
$page->setRgt($lft);
|
||||
|
||||
$em->persist($page);
|
||||
}
|
||||
}
|
||||
}
|
||||
466
src/AppBundle/Controller/FewoBookingController.php
Normal file
466
src/AppBundle/Controller/FewoBookingController.php
Normal file
|
|
@ -0,0 +1,466 @@
|
|||
<?php
|
||||
namespace AppBundle\Controller;
|
||||
|
||||
//TODO bereinigen
|
||||
use AppBundle\Entity\BookingRequest;
|
||||
use AppBundle\Entity\BreadcrumbEntry;
|
||||
use AppBundle\Entity\FewoLodging;
|
||||
use AppBundle\Entity\FewoPrice;
|
||||
use AppBundle\Entity\Page;
|
||||
use AppBundle\Entity\TravelDate;
|
||||
use AppBundle\Entity\Traveler;
|
||||
use AppBundle\Entity\TravelPeriodPrice;
|
||||
use AppBundle\Entity\TravelPeriodPriceType;
|
||||
use AppBundle\Form\BookingRequestType;
|
||||
use AppBundle\Form\FewoReservationType;
|
||||
use AppBundle\Util;
|
||||
|
||||
|
||||
use AppBundle\Entity\FewoSeason;
|
||||
use AppBundle\Entity\FewoBookingRequest;
|
||||
use AppBundle\Form\FewoBookingRequestType;
|
||||
use AppBundle\Entity\FewoReservation;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class FewoBookingController extends Controller
|
||||
{
|
||||
|
||||
private $calendar;
|
||||
|
||||
public function getEntityManager()
|
||||
{
|
||||
return $this->getDoctrine()->getManager();
|
||||
}
|
||||
|
||||
private function initCalender($lodging){
|
||||
|
||||
$calendarService = $this->container->get('app.lodging_calendar_util');
|
||||
$paddedCalendar = $calendarService->getCalendarWithPadding($calendarService->getMinCalendarEntriesByLodging($lodging));
|
||||
if (count($lodging->getPrices()->toArray()) != 0) {
|
||||
$this->calendar = $calendarService->calendarAndFillDayStates($paddedCalendar, $lodging);
|
||||
} else {
|
||||
$this->calendar = $paddedCalendar;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param FewoLodging $lodging
|
||||
* @param $endDate
|
||||
* @return array
|
||||
*/
|
||||
public function reservationDays(FewoLodging $lodging, $endDate)
|
||||
{
|
||||
$reservations = $lodging->getReservationsFilter(new \DateTime(), $endDate);
|
||||
|
||||
$days = array();
|
||||
foreach($reservations as $reservation) {
|
||||
|
||||
$setFromIntervall = clone $reservation->getFromDate();
|
||||
$fromDate = $reservation->getFromDate();
|
||||
$toDate = $reservation->getToDate();
|
||||
|
||||
// $diff = $fromDate->diff($toDate);
|
||||
$interval = \DateInterval::createFromDateString('1 day');
|
||||
$period = new \DatePeriod($setFromIntervall->modify('+1 day'), $interval, $toDate);
|
||||
|
||||
//days
|
||||
foreach ($period as $dt) {
|
||||
$days[] = $dt->format("d.m.Y");
|
||||
}
|
||||
}
|
||||
return $days;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param FewoLodging $lodging
|
||||
* @param $endDate
|
||||
* @return array
|
||||
*/
|
||||
public function classByDays(FewoLodging $lodging, $endDate)
|
||||
{
|
||||
$ret = array();
|
||||
foreach ($this->calendar as $month => $calendar_month) {
|
||||
foreach ($calendar_month['data'] as $key => $day) {
|
||||
if($day && $day->getDate()){
|
||||
$toClass = "";
|
||||
|
||||
if($day->getIsBookable() && !$day->getIsPastDate()) {
|
||||
$toClass .= " bookable";
|
||||
}
|
||||
|
||||
$ret[$day->getDate()->format("d.m.Y")] = $day->getCssClass()."".$toClass;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FewoLodging $lodging
|
||||
* @return bool
|
||||
*/
|
||||
private function getSeasonLast(FewoLodging $lodging)
|
||||
{
|
||||
$lodgingPrices = $lodging->getPrices();
|
||||
$season = false;
|
||||
$lastDate = new \DateTime();
|
||||
foreach($lodgingPrices as $price)
|
||||
{
|
||||
if($price->getSeason()){
|
||||
if($price->getSeason()->getToDate() > $lastDate){
|
||||
$season = $price->getSeason();
|
||||
$lastDate = $price->getSeason()->getToDate();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return $season;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FewoBookingRequest $fewoBookingRequest
|
||||
* @param FewoLodging $fewoLodging
|
||||
*/
|
||||
private function checkIsPossible(FewoBookingRequest $fewoBookingRequest, FewoLodging $lodging){
|
||||
|
||||
$fromDate = clone $fewoBookingRequest->getFromDate();
|
||||
$toDate = clone $fewoBookingRequest->getToDate();
|
||||
|
||||
|
||||
$interval = \DateInterval::createFromDateString('1 day');
|
||||
$period = new \DatePeriod($fromDate, $interval, $toDate->modify('+1 day'));
|
||||
$check_days = array();
|
||||
//days
|
||||
foreach ($period as $dt) {
|
||||
$check_days[] = $dt->format("d.m.Y");
|
||||
}
|
||||
|
||||
foreach ($this->calendar as $month => $calendar_month) {
|
||||
foreach ($calendar_month['data'] as $key => $day) {
|
||||
if($day && $day->getDate()) {
|
||||
if (in_array($day->getDate()->format("d.m.Y"), $check_days)) {
|
||||
if($day->getIsReserved() || $day->getIsPastDate()) {
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function indexAction(Page $fewoTravelProgramPage, $action, Request $request)
|
||||
{
|
||||
$calendarService = $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());
|
||||
}
|
||||
|
||||
$lodging = $fewoTravelProgramPage->getFewoLodging();
|
||||
$this->initCalender($lodging);
|
||||
|
||||
$maxPersons = $lodging->getMaximumPersons();
|
||||
$maxAdults = $lodging->getMaximumAdults();
|
||||
$maxChilds = $lodging->getMaximumChilds();
|
||||
|
||||
|
||||
$fewoBookingRequest = new FewoBookingRequest();
|
||||
$fewoBookingRequest->setLodging($lodging);
|
||||
|
||||
$reservation = new FewoReservation();
|
||||
$lastSeason = $this->getSeasonLast($lodging);
|
||||
|
||||
$reservationDays = $this->reservationDays($lodging, $lastSeason->getToDate());
|
||||
$classByDays = $this->classByDays($lodging, $lastSeason->getToDate());
|
||||
|
||||
|
||||
|
||||
//first init for form ...
|
||||
$fromDate = $request->query->get('fd');
|
||||
$priceId = $request->query->get('pnr');
|
||||
$price = $fewoPriceRepo->find($priceId);
|
||||
$season = $price->getSeason();
|
||||
$minimumStay = $season->getMinimumStay();
|
||||
|
||||
$fromDate = $calendarService->convertDate($fromDate);
|
||||
$fromDateTime = new \DateTime($fromDate);
|
||||
|
||||
$toDate = new \DateTime($fromDate);
|
||||
$toDate->modify('+'.$season->getMinimumStay().' day');
|
||||
$toDate = $toDate->format('d.m.Y');
|
||||
$toDateTime = new \DateTime($toDate);
|
||||
|
||||
$fewoBookingRequest->setFromDate($fromDateTime);
|
||||
$fewoBookingRequest->setToDate($toDateTime);
|
||||
$fewoBookingRequest->setNumberDays($minimumStay);
|
||||
$fewoBookingRequest->setPrice($price);
|
||||
|
||||
$nationalities = $this->getDoctrine()
|
||||
->getRepository('AppBundle:TravelNationality')
|
||||
->createQueryBuilder('n')
|
||||
->getQuery()->getResult(Query::HYDRATE_ARRAY);
|
||||
|
||||
$form = $this->createForm(FewoBookingRequestType::class, $fewoBookingRequest, [
|
||||
'lodging' => $lodging,
|
||||
'maxPersons' => $maxPersons,
|
||||
'maxAdults' => $maxAdults,
|
||||
'maxChilds' => $maxChilds,
|
||||
'nationalities' => $nationalities,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate,
|
||||
]);
|
||||
|
||||
//overwrite is an request from form
|
||||
if ($request->getMethod() == 'POST')
|
||||
{
|
||||
$form->handleRequest($request);
|
||||
$fewoBookingRequest = $form->getData();
|
||||
|
||||
$finalFromDate = $fewoBookingRequest->getFromDate();
|
||||
$finalToDate = $fewoBookingRequest->getToDate();
|
||||
|
||||
$timeDiff = date_diff($finalFromDate, $finalToDate);
|
||||
$numberDays = $timeDiff->days;
|
||||
$season = $fewoLodgingRepo->findSeasonForLodgingBy($lodging, $finalFromDate);
|
||||
if($season){
|
||||
$price = $fewoPriceRepo->findOneBy(['lodging' => $lodging, 'season' => $season]);
|
||||
if($price){
|
||||
$season = $price->getSeason();
|
||||
$minimumStay = $season->getMinimumStay();
|
||||
$fewoBookingRequest->setPrice($price);
|
||||
$fewoBookingRequest->setNumberDays($numberDays);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$isPossible = $this->checkIsPossible($fewoBookingRequest, $lodging);
|
||||
$priceResult = $this->calculatePriceNew($fewoBookingRequest, $lodging, $price);
|
||||
$totalPrice = 0;
|
||||
$perDayTotalPrice = 0;
|
||||
// $totalPrice = $this->calculatePrice($fewoBookingRequest, $lodging, $price);
|
||||
//$perDayTotalPrice = $this->calculatePerDayTotalPrice($fewoBookingRequest, $price);
|
||||
$fewoBookingRequest->setTotalPrice($priceResult['price_total']);
|
||||
|
||||
$isPossible = true;
|
||||
|
||||
if($action == '/buchen')
|
||||
{
|
||||
|
||||
if ($request->getMethod() == 'POST' && $form->isValid() && $isPossible)
|
||||
{
|
||||
$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();
|
||||
|
||||
//TODO add to new CRM
|
||||
$crmBookingUrl = $this->get('app.fewo_booking_exporter')->process($fewoBookingRequest, $lodging, $price, $priceResult, $reservation->getId());//, $travelDate, $bookingPriceInfo);
|
||||
if (!$crmBookingUrl)
|
||||
{
|
||||
$crmBookingUrl = '[CRM-EXPORT FEHLGESCHLAGEN]';
|
||||
}
|
||||
|
||||
/* else
|
||||
{
|
||||
$crmBookingUrl = preg_replace('/\\/api/', '', $crmBookingUrl) . '/edit';
|
||||
}
|
||||
*/
|
||||
$this->get('mailer')->send(\Swift_Message::newInstance()
|
||||
->setSubject('Ihre FeWo-Mietauftrag 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,
|
||||
'priceResult' => $priceResult,
|
||||
'isPossible' => $isPossible,
|
||||
]),
|
||||
'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')
|
||||
//->setTo('kevin@adametz.media')
|
||||
->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,
|
||||
'priceResult' => $priceResult,
|
||||
'isPossible' => $isPossible,
|
||||
|
||||
]),
|
||||
'text/plain', 'utf-8'
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
return $this->render('default/pages/fewoBookingConfirmation.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'site_loading' => 'bookingconfirm',
|
||||
'page' => $fewoTravelProgramPage,
|
||||
'fewo_booking_request' => $fewoBookingRequest,
|
||||
'fewo_lodging' => $lodging,
|
||||
'fewo_price' => $price,
|
||||
'total_price' => $totalPrice,
|
||||
'total_price_per_night' => $perDayTotalPrice,
|
||||
'show_search_sidebar_widget' => false,
|
||||
'isPossible' => $isPossible,
|
||||
'priceResult' => $priceResult,
|
||||
]);
|
||||
}
|
||||
|
||||
// GET
|
||||
return $this->render('default/pages/fewoBooking.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'site_loading' => 'booking',
|
||||
'fewo_booking_request' => $fewoBookingRequest,
|
||||
'lodging' => $lodging,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate,
|
||||
'fewo_lodging' => $lodging,
|
||||
'fewo_price' => $price,
|
||||
'total_price' => $totalPrice,
|
||||
'total_price_per_night' => $perDayTotalPrice,
|
||||
'page' => $fewoTravelProgramPage,
|
||||
'show_search_sidebar_widget' => false,
|
||||
'lastSeason' => $lastSeason,
|
||||
'reservationDays' => $reservationDays,
|
||||
'classByDays' => $classByDays,
|
||||
'terms_filename' => $this->getDoctrine()->getRepository('AppBundle:TravelOrganizer')->find(1)->getFileName(),
|
||||
'isPossible' => $isPossible,
|
||||
'priceResult' => $priceResult,
|
||||
]);
|
||||
|
||||
}
|
||||
elseif($action == '/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,
|
||||
'isPossible' => $isPossible,
|
||||
'priceResult' => $priceResult,
|
||||
]);
|
||||
|
||||
}
|
||||
throw new \Exception('Unknown FewoBookingController action: '. $action);
|
||||
}
|
||||
|
||||
private function calculatePriceNew(FewoBookingRequest $fewoBookingRequest, FewoLodging $lodging){
|
||||
|
||||
|
||||
$fromDate = clone $fewoBookingRequest->getFromDate();
|
||||
$toDate = clone $fewoBookingRequest->getToDate();
|
||||
|
||||
|
||||
$interval = \DateInterval::createFromDateString('1 day');
|
||||
$period = new \DatePeriod($fromDate, $interval, $toDate);
|
||||
$check_days = array();
|
||||
//days
|
||||
foreach ($period as $dt) {
|
||||
$check_days[] = $dt->format("d.m.Y");
|
||||
}
|
||||
|
||||
$result = [];
|
||||
$result['total'] = 0;
|
||||
$result['price_total'] = 0;
|
||||
$result['deposit'] = $lodging->getDeposit();
|
||||
$result['flatPrice'] = 0;
|
||||
$result['days'] = 0;
|
||||
$result['season'] = [];
|
||||
$frist_day = false;
|
||||
foreach ($this->calendar as $month => $calendar_month) {
|
||||
foreach ($calendar_month['data'] as $key => $day) {
|
||||
if($day && $day->getDate()) {
|
||||
if (in_array($day->getDate()->format("d.m.Y"), $check_days)) {
|
||||
|
||||
if(!empty($day->getPrice())){
|
||||
$season = $day->getPrice()->getSeason()->getName();
|
||||
if(!isset($result['season'][$season])){
|
||||
$result['season'][$season]['fromDay'] = $day->getDate()->format("d.m.Y");
|
||||
$result['flatPrice'] = $day->getPrice()->getFlatPrice();
|
||||
$result['season'][$season]['price'] = 0;
|
||||
$result['season'][$season]['numberDays'] = 0;
|
||||
$result['season'][$season]['perNight'] = $day->getPrice()->getPerNight();
|
||||
$result['season'][$season]['minimumStay'] = $day->getPrice()->getSeason()->getMinimumStay();
|
||||
}
|
||||
|
||||
if(!$frist_day){
|
||||
$result['season'][$season]['price'] += $day->getPrice()->getPerNight();
|
||||
$result['season'][$season]['numberDays'] ++;
|
||||
$result['season'][$season]['toDay'] = $day->getDate()->format("d.m.Y");
|
||||
$result['total'] += $day->getPrice()->getPerNight();
|
||||
|
||||
$result['days'] ++;
|
||||
|
||||
}else{
|
||||
$frist_day = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$result['total_price'] = $result['flatPrice'] + $result['total'] + $result['deposit'];
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
34
src/AppBundle/Controller/ImageController.php
Normal file
34
src/AppBundle/Controller/ImageController.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace AppBundle\Controller;
|
||||
|
||||
|
||||
use AppBundle\Util;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class ImageController extends Controller
|
||||
{
|
||||
public function showAction()
|
||||
{
|
||||
|
||||
$path = Util::getRootDir();
|
||||
$path .= 'web/images/placeholder-image.png';
|
||||
$image_name = 'placeholder-image.png';
|
||||
|
||||
|
||||
$file = file_get_contents($path);
|
||||
$headers = array('Content-Type' => 'image/jpeg',
|
||||
'Content-Disposition' => 'inline; filename="' . $image_name . '"');
|
||||
|
||||
|
||||
|
||||
|
||||
//return 'data:image/image/jpeg;base64,'.base64_encode($file);
|
||||
|
||||
return new Response($file, 200, $headers);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
256
src/AppBundle/Controller/MyActionController.php
Normal file
256
src/AppBundle/Controller/MyActionController.php
Normal file
|
|
@ -0,0 +1,256 @@
|
|||
|
||||
|
||||
|
||||
|
||||
Verschieben Reiseführer
|
||||
|
||||
Türkei
|
||||
ID 1548
|
||||
|
||||
|
||||
tree_root = 5
|
||||
parent_id = 5
|
||||
lft = last in root lft 4570
|
||||
rgt =last in parent_id + 1 = 4728
|
||||
|
||||
slug = reisefuehrer
|
||||
title = Türkei Reiseführer
|
||||
|
||||
|
||||
Update subsite parent_id=1548
|
||||
|
||||
UPDATE page SET lft=page.lft+1000 WHERE parent_id=1548
|
||||
UPDATE page SET rgt=page.rgt+1000 WHERE parent_id=1548
|
||||
UPDATE page SET tree_root=5 WHERE parent_id=1548
|
||||
|
||||
|
||||
|
||||
301 KernelControllerListener
|
||||
|
||||
https://www.sterntours.de/reisefuehrer/tuerkei
|
||||
->
|
||||
https://www.sterntours.de/tuerkei-reisen/reisefuehrer
|
||||
|
||||
|
||||
|
||||
https://www.sterntours.de/reisefuehrer/tuerkei/stadt-milet
|
||||
->
|
||||
https://www.sterntours.de/tuerkei-reisen/reisefuehrer/stadt-milet
|
||||
|
||||
-----
|
||||
|
||||
Jordanien
|
||||
ID; 1472
|
||||
|
||||
OWNer 266
|
||||
|
||||
tree_root = 266
|
||||
parent_id = 266
|
||||
lft = last in root lft 4278
|
||||
rgt =last in parent_id + 1 = 4327
|
||||
|
||||
|
||||
4600
|
||||
4651
|
||||
|
||||
|
||||
UPDATE page SET lft=page.lft+1000 WHERE parent_id=1472
|
||||
UPDATE page SET rgt=page.rgt+1000 WHERE parent_id=1472
|
||||
UPDATE page SET tree_root=266 WHERE parent_id=1472
|
||||
|
||||
301 KernelControllerListener
|
||||
|
||||
https://www.sterntours.de/reisefuehrer/jordanien
|
||||
->
|
||||
https://www.sterntours.de/jordanien-reisen/reisefuehrer
|
||||
|
||||
https://www.sterntours.de/reisefuehrer/jordanien/petra
|
||||
->
|
||||
https://www.sterntours.de/jordanien-reisen/reisefuehrer/petra
|
||||
|
||||
|
||||
-----
|
||||
Oman
|
||||
ID; 3056
|
||||
//reisefuehrer
|
||||
OWNer 2957
|
||||
|
||||
tree_root = 2957
|
||||
parent_id = 2957
|
||||
4508
|
||||
4599
|
||||
|
||||
lft = last in root lft 4508
|
||||
rgt =last in parent_id + 1 = 4599
|
||||
|
||||
|
||||
UPDATE page SET lft=page.lft+1000 WHERE parent_id=3056
|
||||
UPDATE page SET rgt=page.rgt+1000 WHERE parent_id=3056
|
||||
UPDATE page SET tree_root=2957 WHERE parent_id=3056
|
||||
|
||||
301 KernelControllerListener
|
||||
|
||||
https://www.sterntours.de/reisefuehrer/oman
|
||||
->
|
||||
https://www.sterntours.de/oman-reisen/reisefuehrer
|
||||
|
||||
https://www.sterntours.de/reisefuehrer/oman/muscat
|
||||
->
|
||||
https://www.sterntours.de/oman-reisen/reisefuehrer/muscat
|
||||
|
||||
|
||||
|
||||
|
||||
-----
|
||||
ISRAEL
|
||||
ID; 1426
|
||||
//reisefuehrer
|
||||
OWNer 280
|
||||
|
||||
tree_root = 280
|
||||
parent_id = 280
|
||||
4508
|
||||
4599
|
||||
|
||||
lft = last in root lft 4508
|
||||
rgt =last in parent_id + 1 = 4599
|
||||
|
||||
|
||||
UPDATE page SET lft=page.lft+1000 WHERE parent_id=1426
|
||||
UPDATE page SET rgt=page.rgt+1000 WHERE parent_id=1426
|
||||
UPDATE page SET tree_root=280 WHERE parent_id=1426
|
||||
|
||||
301 KernelControllerListener
|
||||
|
||||
https://www.sterntours.de/reisefuehrer/israel
|
||||
->
|
||||
https://www.sterntours.de/israel-reisen/reisefuehrer
|
||||
|
||||
https://www.sterntours.de/reisefuehrer/israel/eilat
|
||||
->
|
||||
https://www.sterntours.de/israel-reisen/reisefuehrer/eilat
|
||||
|
||||
|
||||
aegypten
|
||||
ID; 1314
|
||||
//reisefuehrer
|
||||
OWNer 47
|
||||
|
||||
tree_root = 47
|
||||
parent_id = 47
|
||||
599
|
||||
1322
|
||||
|
||||
|
||||
|
||||
lft = last in root lft 1382
|
||||
rgt =last in parent_id + 1 = 1507
|
||||
|
||||
|
||||
UPDATE page SET lft=page.lft-2000 WHERE parent_id=1314
|
||||
UPDATE page SET rgt=page.rgt-2000 WHERE parent_id=1314
|
||||
UPDATE page SET tree_root=47 WHERE parent_id=1314
|
||||
|
||||
301 KernelControllerListener
|
||||
|
||||
https://www.sterntours.de/reisefuehrer/israel
|
||||
->
|
||||
https://www.sterntours.de/israel-reisen/reisefuehrer
|
||||
|
||||
https://www.sterntours.de/reisefuehrer/israel/eilat
|
||||
->
|
||||
https://www.sterntours.de/israel-reisen/reisefuehrer/eilat
|
||||
|
||||
|
||||
UPDATE page SET lft=page.lft+1000 WHERE tree_root=13 AND country_id=11
|
||||
UPDATE page SET rgt=page.rgt+1000 WHERE tree_root=13 AND country_id=11
|
||||
UPDATE page SET tree_root=5 WHERE tree_root=13 AND country_id=11
|
||||
|
||||
|
||||
|
||||
5
|
||||
tuerkei-reisen
|
||||
4515
|
||||
4572
|
||||
|
||||
tuerkei-reisemagazin
|
||||
2808
|
||||
tree_root 5
|
||||
parent_id 5
|
||||
|
||||
4676
|
||||
4677
|
||||
|
||||
reisemagazin/tuerkei-reisemagazin
|
||||
tuerkei-reisen/tuerkei-reisemagazin
|
||||
|
||||
|
||||
----
|
||||
|
||||
47
|
||||
aegypten-reisen
|
||||
599
|
||||
1508
|
||||
|
||||
aegypten-reisemagazin
|
||||
2806
|
||||
tree_root 47
|
||||
parent_id 47
|
||||
|
||||
3732
|
||||
3741
|
||||
|
||||
reisemagazin/aegypten
|
||||
reisemagazin/aegypten/aegypten-nil
|
||||
aegypten-reisen/aegypten-reisemagazin
|
||||
|
||||
|
||||
----
|
||||
|
||||
280
|
||||
israel-reisen
|
||||
3971
|
||||
4600
|
||||
|
||||
israel-reisemagazin
|
||||
2804
|
||||
tree_root 280
|
||||
parent_id 280
|
||||
|
||||
|
||||
reisemagazin/israel
|
||||
reisemagazin/israel/xxx
|
||||
israel-reisen/israel-reisemagazin
|
||||
|
||||
----
|
||||
|
||||
266
|
||||
jordanien-reisen
|
||||
3971
|
||||
4600
|
||||
|
||||
jordanien-reisemagazin
|
||||
2805
|
||||
tree_root 266
|
||||
parent_id 266
|
||||
|
||||
|
||||
reisemagazin/jordanien
|
||||
reisemagazin/jordanien/xx
|
||||
jordanien-reisen/jordanien-reisemagazin
|
||||
|
||||
----
|
||||
|
||||
165
|
||||
marokko-urlaub
|
||||
4598
|
||||
4614
|
||||
|
||||
marokko-reisemagazin
|
||||
2807
|
||||
tree_root 266
|
||||
parent_id 266
|
||||
|
||||
|
||||
reisemagazin/marokko
|
||||
marokko-reisen/marokko-reisemagazin
|
||||
Loading…
Add table
Add a link
Reference in a new issue