init without trunk

This commit is contained in:
Kevin Adametz 2020-07-09 12:49:32 +02:00
parent ed24ac4994
commit bb809e7233
14652 changed files with 177862 additions and 94817 deletions

View file

@ -0,0 +1,9 @@
<?php
namespace AppBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AppBundle extends Bundle
{
}

View file

@ -0,0 +1,69 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 03/24/2017
*/
namespace AppBundle\Command;
use AppBundle\Entity\SunstarTravelProgram;
use AppBundle\Util;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class SunstarImportCommand extends ContainerAwareCommand
{
protected function configure()
{
$this->setName('sterntours:import-sunstar');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var \Doctrine\ORM\EntityManager $em */
$em = $this->getContainer()->get('doctrine')->getManager();
$conn = $em->getConnection();
$r = Util::httpGet('https://www.jugendreisen-spezialist.de/sterntours-export/index.php', [
'Authorization: Basic c3Rlcm50b3VyczpvbW1DVm5OY2lXTDRSMUhw'
]);
$tpDataEntries = json_decode($r['content'], true);
$conn->beginTransaction();
try
{
$metadata = $em->getClassMetaData('AppBundle:SunstarTravelProgram');
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
$metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
$conn->query('SET FOREIGN_KEY_CHECKS=0');
$conn->query('DELETE FROM '. $metadata->getTableName());
$conn->query('SET FOREIGN_KEY_CHECKS=1');
$i = 0;
foreach ($tpDataEntries as $tpData)
{
++$i;
$sunTp = new SunstarTravelProgram();
$sunTp->setId($i);
$sunTp->setTitle($tpData['title']);
$sunTp->setDescription($tpData['description']);
$sunTp->setDestination($tpData['destination_name']);
$sunTp->setUrl($tpData['url']);
$sunTp->setImageUrl('https://www.jugendreisen-spezialist.de'. $tpData['image_url']);
$sunTp->setDuration($tpData['duration']);
$sunTp->setMinimumPrice($tpData['minimum_price']);
$sunTp->setMinimumAge($tpData['minimum_age']);
$sunTp->setMaximumAge($tpData['maximum_age']);
$em->persist($sunTp);
$em->flush();
}
$conn->commit();
}
catch (\Exception $e)
{
$conn->rollBack();
throw $e;
}
}
}

View file

@ -0,0 +1,97 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 03/10/2017
*/
namespace AppBundle\Command;
use AppBundle\Util;
use Doctrine\ORM\EntityManager;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class TripodoExportCommand extends ContainerAwareCommand
{
protected function configure()
{
$this->setName('sterntours:export-tripodo');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var EntityManager $em */
$em = $this->getContainer()->get('doctrine')->getManager();
$logger = $this->getContainer()->get('logger');
$regex = '/(\(\s*)?(((https?:\/\/)?www\.stern-?tours\.de[^\s\)]*)|([^\s]+@stern-?tours\.de)|(030\s*(-\s*)?700\s*94\s*100))(\s*\))?/';
$baseUrl = 'https://www.sterntours.de';
$xml = '<?xml version="1.0" encoding="UTF-8"?>' ."\n<travels>\n";
$travelPrograms = $em->getRepository('AppBundle:TravelProgram')->getProgramsToExport();
foreach ($travelPrograms as $travelProgram)
{
$em->getRepository('AppBundle:TravelPeriod')->getTrueTravelPeriods($travelProgram);
$vars = [
'travel_program' => $travelProgram,
'base_url' => $this->getContainer()->getParameter('base_url'),
];
// Link / E-Mail / Tel. zu Stern Tours entfernen
$vars['html_description'] = preg_replace($regex, '', $travelProgram->getHtmlDescription());
$vars['included'] = preg_replace($regex, '', $travelProgram->getIncluded());
$vars['advices'] = preg_replace($regex, '', $travelProgram->getAdvices());
$vars['included'] = Util::convertUrisInHtmlToAbsolute($vars['included'], $baseUrl);
$vars['advices'] = Util::convertUrisInHtmlToAbsolute($vars['advices'], $baseUrl);
$vars['subtitle'] = Util::convertUrisInHtmlToAbsolute($travelProgram->getSubtitle(), $baseUrl);
// Video-Link entfernen
$vars['html_description'] = preg_replace('/<p>\s*<a.*?href\s*="#".*?<\/a>\s*<\/p>/', '', $vars['html_description']);
// Überschriften hervorheben
$vars['html_description'] = preg_replace('/<h2>(.*?)<\/h2>/', '<p><b>\1</b></p>', $vars['html_description']);
$vars['html_description'] = preg_replace('/<h3>(.*?)<\/h3>/', '<p><b>\1</b></p>', $vars['html_description']);
$vars['html_description'] = Util::convertUrisInHtmlToAbsolute(
html_entity_decode($vars['html_description'], ENT_COMPAT, 'UTF-8'), $baseUrl);
$xml .= $this->getContainer()->get('templating')->render('default/tripodo.xml.twig', $vars);
}
$xml .= '</travels>';
file_put_contents('travels.xml', $xml);
$host = $this->getContainer()->getParameter('tripodo_host');
if (!$host)
{
$logger->error('Tripodo export failed. No host specified ("tripodo_host").');
return;
}
$user = $this->getContainer()->getParameter('tripodo_user');
if (!$host)
{
$logger->error('Tripodo export failed. No user name specified ("tripodo_user").');
return;
}
$pass = $this->getContainer()->getParameter('tripodo_pass');
if (!$pass)
{
$logger->error('Tripodo export failed. No password specified ("tripodo_pass").');
return;
}
$conn = ftp_connect($host);
if(ftp_login($conn, $user, $pass))
{
$stream = fopen('travels.xml', 'r');
ftp_fput($conn, 'travels.xml', $stream, FTP_BINARY);
fclose($stream);
}
ftp_close($conn);
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View 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,
]);
}
}

View 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);
}
}

View 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);
}
}
}

View 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;
}
}

View 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);
}
}

View 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

View file

@ -0,0 +1,47 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 10/31/2016
*/
namespace AppBundle\DoctrineExtensions\Query\MySql;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
class DateAdd extends FunctionNode
{
public $firstDateExpression = null;
public $intervalExpression = null;
public $unit = null;
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->firstDateExpression = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_COMMA);
$parser->match(Lexer::T_IDENTIFIER);
$this->intervalExpression = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_IDENTIFIER);
/* @var $lexer Lexer */
$lexer = $parser->getLexer();
$this->unit = $lexer->token['value'];
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
return 'DATE_ADD(' .
$this->firstDateExpression->dispatch($sqlWalker) . ', INTERVAL ' .
$this->intervalExpression->dispatch($sqlWalker) . ' ' . $this->unit .
')';
}
}

View file

@ -0,0 +1,899 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 12/16/2016
*/
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use AppBundle\Validator\Constraints as AppBundleAssert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
/**
* Class BookingRequest
* @package AppBundle\Entity
* @AppBundleAssert\BookingRequest
*/
class BookingRequest
{
// Used in SternToursCrmBookingExports, expected to be equivalent to sex (as defined in Traveler)
const MR = 1;
const MRS = 2;
/**
* @var TravelDeparturePoint $departure
*/
private $departure;
private $singleRoomCount;
private $doubleRoomCount;
private $tripleRoomCount;
private $singleRoomChildCount;
private $doubleRoomChildCount;
private $tripleRoomChildCount;
private $extraBookingDaysBefore;
private $extraBookingDaysAfter;
private $roomCount;
/**
* @var TravelInsurance $insurance
*/
private $insurance;
private $comfort = false;
private $travelOptions = [];
private $salutation;
/**
* @Assert\NotBlank()
*/
private $firstName;
/**
* @Assert\NotBlank()
*/
private $lastName;
/**
* @Assert\NotBlank()
*/
private $streetAddress;
/**
* @Assert\NotBlank()
*/
private $zipCode;
/**
* @Assert\NotBlank()
*/
private $city;
private $nation;
/**
* @Assert\NotBlank()
*/
private $phone;
private $mobile;
/**
* @Assert\NotBlank()
*/
private $email;
private $travelers = [];
private $singleRooms = [];
private $doubleRooms = [];
private $tripleRooms = [];
private $singleChildRooms = [];
private $doubleChildRooms = [];
private $tripleChildRooms = [];
private $notes;
/**
* @Assert\IsTrue()
*/
private $acceptTerms = false;
private $acceptLegalRights = false;
private $acceptPrivacy = false;
/**
* BookingRequest constructor.
*/
public function __construct()
{
for($i = 0; $i < 4; ++$i)
{
$this->singleRooms[] = new Room(1);
}
for($i = 0; $i < 4; ++$i)
{
$this->singleChildRooms[] = new Room(4);
}
for($i = 0; $i < 3; ++$i)
{
$this->doubleRooms[] = new Room(2);
}
for($i = 0; $i < 3; ++$i)
{
$this->doubleChildRooms[] = new Room(5);
}
for($i = 0; $i < 2; ++$i)
{
$this->tripleRooms[] = new Room(3);
}
for($i = 0; $i < 2; ++$i)
{
$this->tripleChildRooms[] = new Room(6);
}
}
/**
* @return TravelDeparturePoint
*/
public function getDeparture()
{
return $this->departure;
}
/**
* @param TravelDeparturePoint $departure
*/
public function setDeparture(TravelDeparturePoint $departure)
{
$this->departure = $departure;
}
/**
* @return mixed
*/
public function getTravelerCount()
{
$allUsedTravelersCount = 0;
for($i = 0; $i < $this->singleRoomCount; ++$i)
{
$allUsedTravelersCount += $this->singleRooms[$i]->getTravelerCount();
}
for($i = 0; $i < $this->singleRoomChildCount; ++$i)
{
$allUsedTravelersCount += $this->singleChildRooms[$i]->getTravelerCount();
}
for($i = 0; $i < $this->doubleRoomCount; ++$i)
{
$allUsedTravelersCount += $this->doubleRooms[$i]->getTravelerCount();
}
for($i = 0; $i < $this->doubleRoomChildCount; ++$i)
{
$allUsedTravelersCount += $this->doubleChildRooms[$i]->getTravelerCount();
}
for($i = 0; $i < $this->tripleRoomCount; ++$i)
{
$allUsedTravelersCount += $this->tripleRooms[$i]->getTravelerCount();
}
for($i = 0; $i < $this->tripleRoomChildCount; ++$i)
{
$allUsedTravelersCount += $this->tripleChildRooms[$i]->getTravelerCount();
}
return $allUsedTravelersCount;
}
public function getChildrenCount()
{
$allUsedChildrenCount = 0;
for($i = 0; $i < $this->singleRoomCount; ++$i)
{
$allUsedChildrenCount += 0;//$this->singleRooms[$i]->getTravelerCount();
}
for($i = 0; $i < $this->singleRoomChildCount; ++$i)
{
$allUsedChildrenCount += 1;//$this->singleRooms[$i]->getTravelerCount();
}
for($i = 0; $i < $this->doubleRoomCount; ++$i)
{
$allUsedChildrenCount += 0;//$this->singleRooms[$i]->getTravelerCount();
}
for($i = 0; $i < $this->doubleRoomChildCount; ++$i)
{
$allUsedChildrenCount += 1;//$this->singleRooms[$i]->getTravelerCount();
}
for($i = 0; $i < $this->tripleRoomCount; ++$i)
{
$allUsedChildrenCount += 0;//$this->singleRooms[$i]->getTravelerCount();
}
for($i = 0; $i < $this->tripleRoomChildCount; ++$i)
{
$allUsedChildrenCount += 1;//$this->singleRooms[$i]->getTravelerCount();
}
return $allUsedChildrenCount;
}
/**
* @param mixed $travelerCount
*/
public function setTravelerCount($travelerCount)
{
$this->travelerCount = $travelerCount;
}
/**
* @return mixed
*/
public function getRoomCount()
{
return $this->roomCount;
}
/**
* @param mixed $travelers
*/
public function setRoomCount($travelers)
{
// nicht so kompliziert
// übliche Anzahl der Reisenden war 2 -> Standardraum: 1 Doppelzimmer
$this->travelerCount = $travelers;
if($travelers % 2 != 0)
{
$times = ($travelers - 1) / 2;
$this->singleRoomCount = 1;
$this->doubleRoomCount = $times;
$this->tripleRoomCount = 0;
$this->roomCount = $times + 1;
}
else
{
$times = $travelers / 2;
$this->singleRoomCount = 0;
$this->doubleRoomCount = $times;
$this->tripleRoomCount = 0;
$this->roomCount = $times;
}
}
/**
* @return mixed
*/
public function getSingleRoomCount()
{
return $this->singleRoomCount;
}
/**
* @param mixed $singleRoomCount
*/
public function setSingleRoomCount($singleRoomCount)
{
$this->singleRoomCount = $singleRoomCount;
}
/**
* @return mixed
*/
public function getDoubleRoomCount()
{
return $this->doubleRoomCount;
}
/**
* @param mixed $doubleRoomCount
*/
public function setDoubleRoomCount($doubleRoomCount)
{
$this->doubleRoomCount = $doubleRoomCount;
}
/**
* @return mixed
*/
public function getTripleRoomCount()
{
return $this->tripleRoomCount;
}
/**
* @param mixed $tripleRoomCount
*/
public function setTripleRoomCount($tripleRoomCount)
{
$this->tripleRoomCount = $tripleRoomCount;
}
/**
* @return mixed
*/
public function getSingleRoomChildCount()
{
return $this->singleRoomChildCount;
}
/**
* @param mixed $singleRoomChildCount
*/
public function setSingleRoomChildCount($singleRoomChildCount)
{
$this->singleRoomChildCount = $singleRoomChildCount;
}
/**
* @return mixed
*/
public function getDoubleRoomChildCount()
{
return $this->doubleRoomChildCount;
}
/**
* @param mixed $doubleRoomChildCount
*/
public function setDoubleRoomChildCount($doubleRoomChildCount)
{
$this->doubleRoomChildCount = $doubleRoomChildCount;
}
/**
* @return mixed
*/
public function getTripleRoomChildCount()
{
return $this->tripleRoomChildCount;
}
/**
* @param mixed $tripleRoomChildCount
*/
public function setTripleRoomChildCount($tripleRoomChildCount)
{
$this->tripleRoomChildCount = $tripleRoomChildCount;
}
/**
* @return mixed
*/
public function getExtraBookingDaysBefore()
{
return $this->extraBookingDaysBefore;
}
/**
* @param mixed $extraBookingDaysBefore
*/
public function setExtraBookingDaysBefore($extraBookingDaysBefore)
{
$this->extraBookingDaysBefore = $extraBookingDaysBefore;
}
/**
* @return mixed
*/
public function getExtraBookingDaysAfter()
{
return $this->extraBookingDaysAfter;
}
/**
* @param mixed $extraBookingDaysAfter
*/
public function setExtraBookingDaysAfter($extraBookingDaysAfter)
{
$this->extraBookingDaysAfter = $extraBookingDaysAfter;
}
/**
* @return TravelInsurance
*/
public function getInsurance()
{
return $this->insurance;
}
/**
* @param TravelInsurance $insurance
*/
public function setInsurance(TravelInsurance $insurance)
{
$this->insurance = $insurance;
}
/**
* @return mixed
*/
public function getComfort()
{
return $this->comfort;
}
/**
* @param mixed $comfort
*/
public function setComfort($comfort)
{
$this->comfort = $comfort;
}
/**
* @return TravelOption[]
*/
public function getTravelOptions()
{
return $this->travelOptions;
}
/**
* @param mixed $travelOptions
*/
public function setTravelOptions($travelOptions)
{
$this->travelOptions = $travelOptions;
}
/**
* @return int
*/
public function getSalutation()
{
return $this->salutation;
}
/**
* @param int $salutation
*/
public function setSalutation($salutation)
{
$this->salutation = $salutation;
}
/**
* @return string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* @param string $firstName
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
}
/**
* @return string
*/
public function getLastName()
{
return $this->lastName;
}
/**
* @param string $lastName
*/
public function setLastName($lastName)
{
$this->lastName = $lastName;
}
/**
* @return string
*/
public function getStreetAddress()
{
return $this->streetAddress;
}
/**
* @param string $streetAddress
*/
public function setStreetAddress($streetAddress)
{
$this->streetAddress = $streetAddress;
}
/**
* @return string
*/
public function getZipCode()
{
return $this->zipCode;
}
/**
* @param string $zipCode
*/
public function setZipCode($zipCode)
{
$this->zipCode = $zipCode;
}
/**
* @return string
*/
public function getCity()
{
return $this->city;
}
/**
* @param string $city
*/
public function setCity($city)
{
$this->city = $city;
}
/**
* @return int
*/
public function getNation()
{
return $this->nation;
}
/**
* @param int $nation
*/
public function setNation($nation)
{
$this->nation = $nation;
}
/**
* @return string
*/
public function getPhone()
{
return $this->phone;
}
/**
* @param string $phone
*/
public function setPhone($phone)
{
$this->phone = $phone;
}
/**
* @return string
*/
public function getMobile()
{
return $this->mobile;
}
/**
* @param string $mobile
*/
public function setMobile($mobile)
{
$this->mobile = $mobile;
}
/**
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* @param string $email
*/
public function setEmail($email)
{
$this->email = $email;
}
// get und set der Travelers liegt jetzt in Room; sollte so nicht mehr verwendet werden!
/**
* @return Traveler[]
*/
public function getTravelers()
{
$allUsedTravelers = [];
// könnte man eventuell in eine for-Schleife packen, wenn man garantiert, dass es immer gleich viele Räume von jedem Typ gibt
for ($i = 0; $i < $this->singleRoomCount; ++$i)
{
$allUsedTravelers = array_merge($allUsedTravelers, $this->singleRooms[$i]->getTravelers());
}
for ($i = 0; $i < $this->singleRoomChildCount; ++$i)
{
$allUsedTravelers = array_merge($allUsedTravelers, $this->singleChildRooms[$i]->getTravelers());
}
for ($i = 0; $i < $this->doubleRoomCount; ++$i)
{
$allUsedTravelers = array_merge($allUsedTravelers, $this->doubleRooms[$i]->getTravelers());
}
for ($i = 0; $i < $this->doubleRoomChildCount; ++$i)
{
$allUsedTravelers = array_merge($allUsedTravelers, $this->doubleChildRooms[$i]->getTravelers());
}
for ($i = 0; $i < $this->tripleRoomCount; ++$i)
{
$allUsedTravelers = array_merge($allUsedTravelers, $this->tripleRooms[$i]->getTravelers());
}
for ($i = 0; $i < $this->tripleRoomChildCount; ++$i)
{
$allUsedTravelers = array_merge($allUsedTravelers, $this->tripleChildRooms[$i]->getTravelers());
}
// $this->travelers = $allUsedTravelers; // schlecht, getter sollte kein setter sein
// return $this->travelers; // aber wenn man es so verwenden würde, dann sollte man auch das verwenden
return $allUsedTravelers;
}
/**
* @param Traveler[] $travelers
*/
public function setTravelers($travelers)
{
$this->travelers = $travelers;
}
/**
* @return Room[]
*/
public function getSingleRooms()
{
return $this->singleRooms;
}
/**
* @param Room[] $singleRooms
*/
public function setSingleRooms($singleRooms)
{
$this->singleRooms = $singleRooms;
}
/**
* @return Room[]
*/
public function getDoubleRooms()
{
return $this->doubleRooms;
}
/**
* @param Room[] $doubleRooms
*/
public function setDoubleRooms($doubleRooms)
{
$this->doubleRooms = $doubleRooms;
}
/**
* @return Room[]
*/
public function getTripleRooms()
{
return $this->tripleRooms;
}
/**
* @param Room[] $tripleRooms
*/
public function setTripleRooms($tripleRooms)
{
$this->tripleRooms = $tripleRooms;
}
/**
* @return Room[]
*/
public function getSingleChildRooms()
{
return $this->singleChildRooms;
}
/**
* @param Room[] $singleChildRooms
*/
public function setSingleChildRooms($singleChildRooms)
{
$this->singleChildRooms = $singleChildRooms;
}
/**
* @return Room[]
*/
public function getDoubleChildRooms()
{
return $this->doubleChildRooms;
}
/**
* @param Room[] $doubleChildRooms
*/
public function setDoubleChildRooms($doubleChildRooms)
{
$this->doubleChildRooms = $doubleChildRooms;
}
/**
* @return Room[]
*/
public function getTripleChildRooms()
{
return $this->tripleChildRooms;
}
/**
* @param Room[] $tripleChildRooms
*/
public function setTripleChildRooms($tripleChildRooms)
{
$this->tripleChildRooms = $tripleChildRooms;
}
/**
* @return Room[]
*/
public function getRooms()
{
$allRooms = [];
$allRooms = array_merge($allRooms, $this->singleRooms);
$allRooms = array_merge($allRooms, $this->singleChildRooms);
$allRooms = array_merge($allRooms, $this->doubleRooms);
$allRooms = array_merge($allRooms, $this->doubleChildRooms);
$allRooms = array_merge($allRooms, $this->tripleRooms);
$allRooms = array_merge($allRooms, $this->tripleChildRooms);
return $allRooms;
}
/**
* @param Room[] $tripleRooms
*/
public function setRooms($rooms)
{
// falls man es braucht, nachziehen und oder umstrukturieren (booking.html.twig)
}
public function getOccupiedRooms()
{
$allRooms = [];
for($i = 0; $i < $this->singleRoomCount; $i++)
{
$allRooms[] = $this->singleRooms[$i];
//$allRooms = array_push($allRooms, $this->singleRooms[$i]);
}
for($i = 0; $i < $this->singleRoomChildCount; $i++)
{
$allRooms[] = $this->singleChildRooms[$i];
//$allChildRooms = array_push($allChildRooms, $this->singleChildRooms[$i]);
}
for($i = 0; $i < $this->doubleRoomCount; $i++)
{
$allRooms[] = $this->doubleRooms[$i];
//$allRooms = array_push($allRooms, $this->doubleRooms[$i]);
}
for($i = 0; $i < $this->doubleRoomChildCount; $i++)
{
$allRooms[] = $this->doubleChildRooms[$i];
//$allChildRooms = array_push($allChildRooms, $this->doubleChildRooms[$i]);
}
for($i = 0; $i < $this->tripleRoomCount; $i++)
{
$allRooms[] = $this->tripleRooms[$i];
//$allRooms = array_push($allRooms, $this->tripleRooms[$i]);
}
for($i = 0; $i < $this->tripleRoomChildCount; $i++)
{
$allRooms[] = $this->tripleChildRooms[$i];
//$allChildRooms = array_push($allChildRooms, $this->tripleChildRooms[$i]);
}
return $allRooms;
}
/*
public function addTraveler(Traveler $traveler)
{
$this->travelers[] = $traveler;
}
*/
/**
* @return string
*/
public function getNotes()
{
return $this->notes;
}
/**
* @param string $notes
*/
public function setNotes($notes)
{
$this->notes = $notes;
}
/**
* @return bool
*/
public function isAcceptTerms()
{
return $this->acceptTerms;
}
/**
* @param bool $acceptTerms
*/
public function setAcceptTerms($acceptTerms)
{
$this->acceptTerms = $acceptTerms;
}
/**
* @return mixed
*/
public function isAcceptLegalRights()
{
return $this->acceptLegalRights;
}
/**
* @param mixed $acceptLegalRights
*/
public function setAcceptLegalRights($acceptLegalRights)
{
$this->acceptLegalRights = $acceptLegalRights;
}
/**
* @return mixed
*/
public function isAcceptPrivacy()
{
return $this->acceptPrivacy;
}
/**
* @param mixed $acceptPrivacy
*/
public function setAcceptPrivacy($acceptPrivacy)
{
$this->acceptPrivacy = $acceptPrivacy;
}
/**
* @Assert\Callback
*/
public function validate(ExecutionContextInterface $context, $payload)
{
//$context->
}
}

View file

@ -0,0 +1,44 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 12/08/2016
*/
namespace AppBundle\Entity;
class BreadcrumbEntry
{
private $title;
private $url;
/**
* BreadcrumbEntry constructor.
*
* @param $title
* @param $url
*/
public function __construct($title, $url = null)
{
$this->title = $title;
$this->url = $url;
}
/**
* @return String
*/
public function getTitle()
{
return $this->title;
}
/**
* @return String
*/
public function getUrl()
{
return $this->url;
}
}

View file

@ -0,0 +1,253 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* CMSContent
*
* @ORM\Table(name="c_m_s_contents")
* @ORM\Entity(repositoryClass="AppBundle\Entity\CMSContentRepository")
*/
class CMSContent
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="slug", type="string", length=255, unique=true)
*/
private $slug;
/**
* @var string
*
* @ORM\Column(name="field", type="string", length=10)
*/
private $field;
/**
* @var string
*
* @ORM\Column(name="text", type="string", length=255, nullable=true)
*/
private $text;
/**
* @var string
*
* @ORM\Column(name="full_text", type="text", nullable=true)
*/
private $fullText;
/**
* @var int
*
* @ORM\Column(name="integer", type="integer", nullable=true)
*/
private $integer;
/**
* @var string
*
* @ORM\Column(name="decimal", type="decimal", precision=15, scale=2, nullable=true)
*/
private $decimal;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return CMSContent
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set slug
*
* @param string $slug
*
* @return CMSContent
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set field
*
* @param string $field
*
* @return CMSContent
*/
public function setField($field)
{
$this->field = $field;
return $this;
}
/**
* Get field
*
* @return string
*/
public function getField()
{
return $this->field;
}
/**
* Set text
*
* @param string $text
*
* @return CMSContent
*/
public function setText($text)
{
$this->text = $text;
return $this;
}
/**
* Get text
*
* @return string
*/
public function getText()
{
return $this->text;
}
/**
* Set fullText
*
* @param string $fullText
*
* @return CMSContent
*/
public function setFullText($fullText)
{
$this->fullText = $fullText;
return $this;
}
/**
* Get fullText
*
* @return string
*/
public function getFullText()
{
return $this->fullText;
}
/**
* Set integer
*
* @param integer $integer
*
* @return CMSContent
*/
public function setInteger($integer)
{
$this->integer = $integer;
return $this;
}
/**
* Get integer
*
* @return int
*/
public function getInteger()
{
return $this->integer;
}
/**
* Set decimal
*
* @param string $decimal
*
* @return CMSContent
*/
public function setDecimal($decimal)
{
$this->decimal = $decimal;
return $this;
}
/**
* Get decimal
*
* @return string
*/
public function getDecimal()
{
return $this->decimal;
}
}

View file

@ -0,0 +1,25 @@
<?php
namespace AppBundle\Entity;
/**
* CMSContentRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class CMSContentRepository extends \Doctrine\ORM\EntityRepository
{
public function findBySlug($slug)
{
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('c');
$qb->from('AppBundle:CMSContent', 'c');
$qb->where('c.slug = :slug');
$qb->setParameter('slug', $slug);
$qb->setMaxResults(1);
return $qb->getQuery()->getOneOrNullResult();
}
}

View file

@ -0,0 +1,285 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* CMSInfo
*
* @ORM\Table(name="c_m_s_infos")
* @ORM\Entity(repositoryClass="AppBundle\Entity\CMSInfoRepository")
*/
class CMSInfo
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="slug", type="string", length=255, unique=true)
*/
private $slug;
/**
* @var string
*
* @ORM\Column(name="type", type="string", length=10)
*/
private $type;
/**
* @var string
*
* @ORM\Column(name="text", type="string", length=255, nullable=true)
*/
private $text;
/**
* @var string
*
* @ORM\Column(name="full_text", type="text", nullable=true)
*/
private $fullText;
/**
* @var int
*
* @ORM\Column(name="integer", type="integer", nullable=true)
*/
private $integer;
/**
* @var string
*
* @ORM\Column(name="decimal", type="decimal", precision=15, scale=2, nullable=true)
*/
private $decimal;
/**
* @var string
*
* @ORM\Column(name="bool", type="boolean", nullable=true)
*/
private $bool;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return CMSInfo
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set slug
*
* @param string $slug
*
* @return CMSInfo
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set type
*
* @param string $type
*
* @return CMSInfo
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Get type
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Set text
*
* @param string $text
*
* @return CMSInfo
*/
public function setText($text)
{
$this->text = $text;
return $this;
}
/**
* Get text
*
* @return string
*/
public function getText()
{
return $this->text;
}
/**
* Set fullText
*
* @param string $fullText
*
* @return CMSInfo
*/
public function setFullText($fullText)
{
$this->fullText = $fullText;
return $this;
}
/**
* Get fullText
*
* @return string
*/
public function getFullText()
{
return $this->fullText;
}
/**
* Set integer
*
* @param integer $integer
*
* @return CMSInfo
*/
public function setInteger($integer)
{
$this->integer = $integer;
return $this;
}
/**
* Get integer
*
* @return int
*/
public function getInteger()
{
return $this->integer;
}
/**
* Set decimal
*
* @param string $decimal
*
* @return CMSInfo
*/
public function setDecimal($decimal)
{
$this->decimal = $decimal;
return $this;
}
/**
* Get decimal
*
* @return string
*/
public function getDecimal()
{
return $this->decimal;
}
/**
* Set bool
*
* @param string $bool
*
* @return CMSInfo
*/
public function setBool($bool)
{
$this->bool = $bool;
return $this;
}
/**
* Get bool
*
* @return string
*/
public function getBool()
{
return $this->bool;
}
}

View file

@ -0,0 +1,25 @@
<?php
namespace AppBundle\Entity;
/**
* CMSContentRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class CMSInfoRepository extends \Doctrine\ORM\EntityRepository
{
public function findBySlug($slug)
{
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('c');
$qb->from('AppBundle:CMSContent', 'c');
$qb->where('c.slug = :slug');
$qb->setParameter('slug', $slug);
$qb->setMaxResults(1);
return $qb->getQuery()->getOneOrNullResult();
}
}

View file

@ -0,0 +1,97 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Catalog
*
* @ORM\Table(name="catalog")
* @ORM\Entity
*/
class Catalog
{
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255, nullable=true)
*/
private $title;
/**
* @var string
*
* @ORM\Column(name="slug", type="string", length=255, nullable=true)
*/
private $slug;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Set title
*
* @param string $title
*
* @return Catalog
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set slug
*
* @param string $slug
*
* @return Catalog
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
}

View file

@ -0,0 +1,398 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 02/21/2017
*/
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
class ContactRequest
{
const MR = 1;
const MRS = 2;
/** @var int|null $salutation */
private $salutation;
/** @var string|null $firstName */
private $firstName;
/** @var string|null $lastName */
private $lastName;
/** @var string|null $streetAddress */
private $streetAddress;
/** @var string|null $zipCode */
private $zipCode;
/** @var string|null $city */
private $city;
/** @var int|null $nation */
private $nation;
/** @var string|null $phone */
private $phone;
/** @var string|null $mobilePhone */
private $mobilePhone;
/** @var string|null $email */
private $email;
/**
* @var string|null $travelerCount */
private $travelerCount;
/** @var string|null $notes */
private $notes;
/** @var string|null $departure0 */
private $departure0;
/** @var string|null $departure1 */
private $departure1;
/** @var string|null $departure2 */
private $departure2;
/** @var \DateTime|null $start */
private $start;
/** @var \DateTime|null $end */
private $end;
private $acceptPrivacy = false;
private $acceptProcessing = false;
/**
* @var int|null $duration
* @Assert\Type(type="integer", message="Bitte geben Sie eine gültige Ganzzahl für die Dauer in Tagen ein")
*/
private $duration;
/**
* @return int|null
*/
public function getSalutation()
{
return $this->salutation;
}
/**
* @param int|null $salutation
*/
public function setSalutation($salutation)
{
$this->salutation = $salutation;
}
/**
* @return null|string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* @param null|string $firstName
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
}
/**
* @return null|string
*/
public function getLastName()
{
return $this->lastName;
}
/**
* @param null|string $lastName
*/
public function setLastName($lastName)
{
$this->lastName = $lastName;
}
/**
* @return null|string
*/
public function getStreetAddress()
{
return $this->streetAddress;
}
/**
* @param null|string $streetAddress
*/
public function setStreetAddress($streetAddress)
{
$this->streetAddress = $streetAddress;
}
/**
* @return null|string
*/
public function getZipCode()
{
return $this->zipCode;
}
/**
* @param null|string $zipCode
*/
public function setZipCode($zipCode)
{
$this->zipCode = $zipCode;
}
/**
* @return null|string
*/
public function getCity()
{
return $this->city;
}
/**
* @param null|string $city
*/
public function setCity($city)
{
$this->city = $city;
}
/**
* @return int|null
*/
public function getNation()
{
return $this->nation;
}
/**
* @param int|null $nation
*/
public function setNation($nation)
{
$this->nation = $nation;
}
/**
* @return null|string
*/
public function getPhone()
{
return $this->phone;
}
/**
* @param null|string $phone
*/
public function setPhone($phone)
{
$this->phone = $phone;
}
/**
* @return null|string
*/
public function getMobilePhone()
{
return $this->mobilePhone;
}
/**
* @param null|string $mobilePhone
*/
public function setMobilePhone($mobilePhone)
{
$this->mobilePhone = $mobilePhone;
}
/**
* @return null|string
*/
public function getEmail()
{
return $this->email;
}
/**
* @param null|string $email
*/
public function setEmail($email)
{
$this->email = $email;
}
/**
* @return null|string
*/
public function getTravelerCount()
{
return $this->travelerCount;
}
/**
* @param null|string $travelerCount
*/
public function setTravelerCount($travelerCount)
{
$this->travelerCount = $travelerCount;
}
/**
* @return null|string
*/
public function getNotes()
{
return $this->notes;
}
/**
* @param null|string $notes
*/
public function setNotes($notes)
{
$this->notes = $notes;
}
/**
* @return null|string
*/
public function getDeparture0()
{
return $this->departure0;
}
/**
* @param null|string $departure0
*/
public function setDeparture0($departure0)
{
$this->departure0 = $departure0;
}
/**
* @return null|string
*/
public function getDeparture1()
{
return $this->departure1;
}
/**
* @param null|string $departure1
*/
public function setDeparture1($departure1)
{
$this->departure1 = $departure1;
}
/**
* @return null|string
*/
public function getDeparture2()
{
return $this->departure2;
}
/**
* @param null|string $departure2
*/
public function setDeparture2($departure2)
{
$this->departure2 = $departure2;
}
/**
* @return \DateTime|null
*/
public function getStart()
{
return $this->start;
}
/**
* @param \DateTime|null $start
*/
public function setStart($start)
{
$this->start = $start;
}
/**
* @return \DateTime|null
*/
public function getEnd()
{
return $this->end;
}
/**
* @param \DateTime|null $end
*/
public function setEnd($end)
{
$this->end = $end;
}
/**
* @return int|null
*/
public function getDuration()
{
return $this->duration;
}
/**
* @param int|null $duration
*/
public function setDuration($duration)
{
$this->duration = $duration;
}
/**
* @return mixed
*/
public function isAcceptPrivacy()
{
return $this->acceptPrivacy;
}
/**
* @param mixed $acceptPrivacy
*/
public function setAcceptPrivacy($acceptPrivacy)
{
$this->acceptPrivacy = $acceptPrivacy;
}
/**
* @return mixed
*/
public function isAcceptProcessing()
{
return $this->acceptProcessing;
}
/**
* @param mixed $acceptProcessing
*/
public function setAcceptProcessing($acceptProcessing)
{
$this->acceptProcessing = $acceptProcessing;
}
}

View file

@ -0,0 +1,510 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 12/16/2016
*/
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use AppBundle\Validator\Constraints as AppBundleAssert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
//TODO im folgenden fehlt noch die Validierung
/**
* Class BookingRequest
* @package AppBundle\Entity
* @AppBundleAssert\FewoBookingRequest
*/
class FewoBookingRequest
{
// Used in SternToursCrmBookingExports, expected to be equivalent to sex (as defined in Traveler)
const MR = 1;
const MRS = 2;
/**
* @Assert\DateTime()
*/
private $fromDate;
/**
* @Assert\DateTime()
*/
private $toDate;
private $numberDays;
private $totalPrice;
private $salutation;
/**
* @Assert\NotBlank()
*/
private $firstName;
/**
* @Assert\NotBlank()
*/
private $lastName;
/**
* @Assert\NotBlank()
*/
private $streetAddress;
/**
* @Assert\NotBlank()
*/
private $zipCode;
/**
* @Assert\NotBlank()
*/
private $city;
private $nation;
/**
* @Assert\NotBlank()
*/
private $phone;
private $mobile;
/**
* @Assert\NotBlank()
*/
private $email;
private $notes;
private $travelerCount;
private $travelerCountAdult;
private $travelerCountChild;
// private $acceptTerms = false;
private $acceptPrivacy = false;
private $acceptRentalConditions = false;
// private $acceptProcessing = false;
private $lodging;
private $season;
private $price;
/**
* BookingRequest constructor.
*/
public function __construct()
{
}
/**
* @return mixed
*/
public function getFromDate()
{
return $this->fromDate;
}
/**
* @param mixed $fromDate
*/
public function setFromDate($fromDate)
{
$this->fromDate = $fromDate;
}
/**
* @return mixed
*/
public function getToDate()
{
return $this->toDate;
}
/**
* @param mixed $toDate
*/
public function setToDate($toDate)
{
$this->toDate = $toDate;
}
/**
* @return mixed
*/
public function getSalutation()
{
return $this->salutation;
}
/**
* @param mixed $salutation
*/
public function setSalutation($salutation)
{
$this->salutation = $salutation;
}
/**
* @return mixed
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* @param mixed $firstName
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
}
/**
* @return mixed
*/
public function getLastName()
{
return $this->lastName;
}
/**
* @param mixed $lastName
*/
public function setLastName($lastName)
{
$this->lastName = $lastName;
}
/**
* @return mixed
*/
public function getStreetAddress()
{
return $this->streetAddress;
}
/**
* @param mixed $streetAddress
*/
public function setStreetAddress($streetAddress)
{
$this->streetAddress = $streetAddress;
}
/**
* @return mixed
*/
public function getZipCode()
{
return $this->zipCode;
}
/**
* @param mixed $zipCode
*/
public function setZipCode($zipCode)
{
$this->zipCode = $zipCode;
}
/**
* @return mixed
*/
public function getCity()
{
return $this->city;
}
/**
* @param mixed $city
*/
public function setCity($city)
{
$this->city = $city;
}
/**
* @return mixed
*/
public function getNation()
{
return $this->nation;
}
/**
* @param mixed $nation
*/
public function setNation($nation)
{
$this->nation = $nation;
}
/**
* @return mixed
*/
public function getPhone()
{
return $this->phone;
}
/**
* @param mixed $phone
*/
public function setPhone($phone)
{
$this->phone = $phone;
}
/**
* @return mixed
*/
public function getMobile()
{
return $this->mobile;
}
/**
* @param mixed $mobile
*/
public function setMobile($mobile)
{
$this->mobile = $mobile;
}
/**
* @return mixed
*/
public function getEmail()
{
return $this->email;
}
/**
* @param mixed $email
*/
public function setEmail($email)
{
$this->email = $email;
}
/**
* @return mixed
*/
public function getNotes()
{
return $this->notes;
}
/**
* @param mixed $notes
*/
public function setNotes($notes)
{
$this->notes = $notes;
}
/**
* @return mixed
*/
public function getTravelerCount()
{
$this->travelerCount = $this->travelerCountAdult + $this->travelerCountChild;
return $this->travelerCount;
}
/**
* @param mixed $travelerCount
*/
public function setTravelerCount($travelerCount)
{
$this->travelerCount = $this->travelerCountAdult + $this->travelerCountChild;
// $this->travelerCount = $travelerCount;
}
/**
* @return mixed
*/
public function getTravelerCountAdult()
{
return $this->travelerCountAdult;
}
/**
* @param mixed $travelerCountAdult
*/
public function setTravelerCountAdult($travelerCountAdult)
{
$this->travelerCountAdult = $travelerCountAdult;
}
/**
* @return mixed
*/
public function getTravelerCountChild()
{
return $this->travelerCountChild;
}
/**
* @param mixed $travelerCountChild
*/
public function setTravelerCountChild($travelerCountChild)
{
$this->travelerCountChild = $travelerCountChild;
}
/* public function getAcceptTerms()
{
return $this->acceptTerms;
}
public function setAcceptTerms($acceptTerms)
{
$this->acceptTerms = $acceptTerms;
}
*/
/**
* @return mixed
*/
public function isAcceptPrivacy()
{
return $this->acceptPrivacy;
}
/**
* @param mixed $acceptPrivacy
*/
public function setAcceptPrivacy($acceptPrivacy)
{
$this->acceptPrivacy = $acceptPrivacy;
}
/**
* @return mixed
*/
public function isAcceptRentalConditions()
{
return $this->acceptRentalConditions;
}
/**
* @param mixed $acceptRentalConditions
*/
public function setAcceptRentalConditions($acceptRentalConditions)
{
$this->acceptRentalConditions = $acceptRentalConditions;
}
/*
public function isAcceptProcessing()
{
return $this->acceptProcessing;
}
public function setAcceptProcessing($acceptProcessing)
{
$this->acceptProcessing = $acceptProcessing;
}
*/
public function getNumberDays()
{
return $this->numberDays;
}
/**
* @param mixed $numberDays
*/
public function setNumberDays($numberDays)
{
$this->numberDays = $numberDays;
}
/**
* @return mixed
*/
public function getTotalPrice()
{
return $this->totalPrice;
}
/**
* @param mixed $totalPrice
*/
public function setTotalPrice($totalPrice)
{
$this->totalPrice = $totalPrice;
}
/**
* @return FewoLodging
*/
public function getLodging()
{
return $this->lodging;
}
/**
* @param FewoLodging $lodging
*/
public function setLodging($lodging)
{
$this->lodging = $lodging;
}
/**
* @return FewoSeason
*/
public function getSeason()
{
return $this->season;
}
/**
* @param FewoSeason $season
*/
public function setSeason($season)
{
$this->season = $season;
}
/**
* @return FewoPrice
*/
public function getPrice()
{
return $this->price;
}
/**
* @param FewoPrice $price
*/
public function setPrice($price)
{
$this->price = $price;
}
/**
* @Assert\Callback
*/
public function validate(ExecutionContextInterface $context, $payload)
{
//$context->
}
}

View file

@ -0,0 +1,755 @@
<?php
namespace AppBundle\Entity;
use AppBundle\AppBundle;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table
* @ORM\Entity(repositoryClass="AppBundle\Entity\FewoLodgingRepository")
*/
class FewoLodging
{
//------------------------------------------------------------------------------------------------------------------
// Allgemein
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
*/
private $name;
/**
* @var \AppBundle\Entity\FewoLodgingGroup
*
* @ORM\ManyToOne(targetEntity="FewoLodgingGroup", inversedBy="lodgings")
)
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="group_id", referencedColumnName="id")
* })
*/
private $group;
/**
* @var \AppBundle\Entity\FewoLodgingType
*
* @ORM\ManyToOne(targetEntity="FewoLodgingType")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="type_id", referencedColumnName="id")
* })
*/
private $type;
/**
* @var text
*
* @ORM\Column(name="description", type="text", nullable=false)
*/
private $description;
/**
* @var text
*
* @ORM\Column(name="equipment", type="text", nullable=false)
*/
private $equipment;
//------------------------------------------------------------------------------------------------------------------
// Adresse
/**
* @var string
*
* @ORM\Column(name="adress1", type="string", length=255, nullable=false)
*/
private $adress1;
/**
* @var string
*
* @ORM\Column(name="adress2", type="string", length=255, nullable=true)
*/
private $adress2;
/**
* @var string
*
* @ORM\Column(name="zip_code", type="string", length=255, nullable=false)
*/
private $zipCode;
/**
* @var string
*
* @ORM\Column(name="city", type="string", length=255, nullable=false)
*/
private $city;
//------------------------------------------------------------------------------------------------------------------
// Preise
/**
* @var integer
*
* @ORM\Column(name="maximum_persons", type="integer", nullable=false)
*/
private $maximumPersons;
/**
* @var integer
*
* @ORM\Column(name="maximum_adults", type="integer", nullable=false)
*/
private $maximumAdults;
/**
* @var integer
*
* @ORM\Column(name="maximum_childs", type="integer", nullable=false)
*/
private $maximumChilds;
/**
* @var float
*
* @ORM\Column(name="deposit", type="float", scale=2, nullable=false)
*/
private $deposit;
/**
* @var \AppBundle\Entity\FewoPrice
*
* @ORM\OneToMany(targetEntity="FewoPrice", mappedBy="lodging", cascade={"persist", "remove"})
*/
private $prices;
//------------------------------------------------------------------------------------------------------------------
// Bilder
/**
* @ORM\OneToMany(targetEntity="FewoLodgingImage", mappedBy="lodging", cascade={"persist", "remove"})
* @ORM\OrderBy({"pos" = "ASC"})
*/
private $images;
//------------------------------------------------------------------------------------------------------------------
// Kalender
/**
* @var \AppBundle\Entity\FewoReservation
*
* @ORM\OneToMany(targetEntity="FewoReservation", mappedBy="lodging", cascade={"persist", "remove"})
* @ORM\OrderBy({"fromDate" = "DESC"})
*/
private $reservations;
/**
* @var boolean
*
* @ORM\Column(name="calendar_visible", type="boolean", nullable=true)
*/
private $calendarVisible;
private $choosableSeasons;
/**
* @ORM\OneToOne(targetEntity="AppBundle\Entity\Page", mappedBy="fewoLodging")
*/
private $page;
public function getChoosableSeasons()
{
return $this->choosableSeasons;
}
public function setChoosableSeasons($choosableSeasons)
{
$this->choosableSeasons = $choosableSeasons;
}
public function getSeasons()
{
$prices = $this->getPrices();
$seasons = null;
for($i = 0; $i < count($prices); $i++)
{
$seasons[] = $prices->get($i)->getSeason();
}
return $seasons;
}
/**
* Constructor
*/
public function __construct()
{
$this->prices = new \Doctrine\Common\Collections\ArrayCollection();
$this->images = new \Doctrine\Common\Collections\ArrayCollection();
$this->reservations = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return FewoLodging
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set description
*
* @param string $description
*
* @return FewoLodging
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set equipment
*
* @param string $equipment
*
* @return FewoLodging
*/
public function setEquipment($equipment)
{
$this->equipment = $equipment;
return $this;
}
/**
* Get equipment
*
* @return string
*/
public function getEquipment()
{
return $this->equipment;
}
/**
* Set adress1
*
* @param string $adress1
*
* @return FewoLodging
*/
public function setAdress1($adress1)
{
$this->adress1 = $adress1;
return $this;
}
/**
* Get adress1
*
* @return string
*/
public function getAdress1()
{
return $this->adress1;
}
/**
* Set adress2
*
* @param string $adress2
*
* @return FewoLodging
*/
public function setAdress2($adress2)
{
$this->adress2 = $adress2;
return $this;
}
/**
* Get adress2
*
* @return string
*/
public function getAdress2()
{
return $this->adress2;
}
/**
* Set zipCode
*
* @param string $zipCode
*
* @return FewoLodging
*/
public function setZipCode($zipCode)
{
$this->zipCode = $zipCode;
return $this;
}
/**
* Get zipCode
*
* @return string
*/
public function getZipCode()
{
return $this->zipCode;
}
/**
* Set city
*
* @param string $city
*
* @return FewoLodging
*/
public function setCity($city)
{
$this->city = $city;
return $this;
}
/**
* Get city
*
* @return string
*/
public function getCity()
{
return $this->city;
}
/**
* Set maximumPersons
*
* @param integer $maximumPersons
*
* @return FewoLodging
*/
public function setMaximumPersons($maximumPersons)
{
$this->maximumPersons = $maximumPersons;
return $this;
}
/**
* Get maximumPersons
*
* @return integer
*/
public function getMaximumPersons()
{
return $this->maximumPersons;
}
/**
* Set maximumAdults
*
* @param integer $maximumAdults
*
* @return FewoLodging
*/
public function setMaximumAdults($maximumAdults)
{
$this->maximumAdults = $maximumAdults;
return $this;
}
/**
* Get maximumAdults
*
* @return integer
*/
public function getMaximumAdults()
{
return $this->maximumAdults;
}
/**
* Set maximumChilds
*
* @param integer $maximumChilds
*
* @return FewoLodging
*/
public function setMaximumChilds($maximumChilds)
{
$this->maximumChilds = $maximumChilds;
return $this;
}
/**
* Get maximumChilds
*
* @return integer
*/
public function getMaximumChilds()
{
return $this->maximumChilds;
}
/**
* Set deposit
*
* @param float $deposit
*
* @return FewoLodging
*/
public function setDeposit($deposit)
{
$this->deposit = $deposit;
return $this;
}
/**
* Get deposit
*
* @return float
*/
public function getDeposit()
{
return $this->deposit;
}
/**
* Set calendarVisible
*
* @param boolean $calendarVisible
*
* @return FewoLodging
*/
public function setCalendarVisible($calendarVisible)
{
$this->calendarVisible = $calendarVisible;
return $this;
}
/**
* Get calendarVisible
*
* @return boolean
*/
public function getCalendarVisible()
{
return $this->calendarVisible;
}
/**
* Set type
*
* @param \AppBundle\Entity\FewoLodgingGroup $group
*
* @return FewoLodging
*/
public function setGroup(\AppBundle\Entity\FewoLodgingGroup $group = null)
{
$this->group = $group;
return $this;
}
/**
* Get type
*
* @return \AppBundle\Entity\FewoLodgingGroup
*/
public function getGroup()
{
return $this->group;
}
/**
* Set type
*
* @param \AppBundle\Entity\FewoLodgingType $type
*
* @return FewoLodging
*/
public function setType(\AppBundle\Entity\FewoLodgingType $type = null)
{
$this->type = $type;
return $this;
}
/**
* Get type
*
* @return \AppBundle\Entity\FewoLodgingType
*/
public function getType()
{
return $this->type;
}
/**
* Add price
*
* @param \AppBundle\Entity\FewoPrice $price
*
* @return FewoLodging
*/
public function addPrice(\AppBundle\Entity\FewoPrice $price)
{
$this->prices[] = $price;
return $this;
}
/**
* Remove price
*
* @param \AppBundle\Entity\FewoPrice $price
*/
public function removePrice(\AppBundle\Entity\FewoPrice $price)
{
$this->prices->removeElement($price);
}
/**
* Get prices
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getPrices()
{
return $this->prices;
}
/**
* Set Price
*
* @param \Doctrine\Common\Collections\Collection
*
* @return FewoLodging
*/
public function setPrices($prices)
{
$this->prices = $prices;
}
/**
* Get prices
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getPricesFilter($dateFrom, $dateTo)
{
return $this->getPrices()->filter(function(FewoPrice $price) use ($dateFrom, $dateTo) {
if(!empty($price->getSeason()))
return ($price->getSeason()->getFromDate() >= $dateFrom && $price->getSeason()->getFromDate() <= $dateTo) ||
($price->getSeason()->getToDate() >= $dateFrom && $price->getSeason()->getToDate() <= $dateTo);
});
}
public function getPricesByFromDateFilter($fromDate)
{
return $this->getPrices()->filter(function(FewoPrice $price) use ($fromDate) {
if(!empty($price->getSeason()))
var_dump($price->getSeason()->getFromDate() );
echo "<br>";
return ($price->getSeason()->getFromDate() >= $fromDate && $price->getSeason()->getToDate() <= $fromDate);
});
}
/**
* Get prices
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getPricesFilterNow()
{
$now = new \DateTime();
return $this->getPrices()->filter(function(FewoPrice $price) use ($now) {
if(!empty($price->getSeason()))
return ($price->getSeason()->getToDate() >= $now);
});
}
/**
* Add image
*
* @param \AppBundle\Entity\FewoLodgingImage $image
*
* @return FewoLodging
*/
public function addImage(\AppBundle\Entity\FewoLodgingImage $image)
{
$this->images[] = $image;
return $this;
}
/**
* Remove image
*
* @param \AppBundle\Entity\FewoLodgingImage $image
*/
public function removeImage(\AppBundle\Entity\FewoLodgingImage $image)
{
$this->images->removeElement($image);
}
/**
* Get images
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getImages()
{
return $this->images;
}
/**
* Add reservation
*
* @param \AppBundle\Entity\FewoReservation $reservation
*
* @return FewoLodging
*/
public function addReservation(\AppBundle\Entity\FewoReservation $reservation)
{
$this->reservations[] = $reservation;
return $this;
}
/**
* Remove reservation
*
* @param \AppBundle\Entity\FewoReservation $reservation
*/
public function removeReservation(\AppBundle\Entity\FewoReservation $reservation)
{
$this->reservations->removeElement($reservation);
}
/**
* Get reservations
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getReservations()
{
return $this->reservations;
}
/**
* Get reservationsFilter
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getReservationsFilter($dateFrom, $dateTo)
{
return $this->getReservations()->filter(function(FewoReservation $reservation) use ($dateFrom, $dateTo) {
return ($reservation->getFromDate() >= $dateFrom && $reservation->getFromDate() <= $dateTo) ||
($reservation->getToDate() >= $dateFrom && $reservation->getToDate() <= $dateTo);
});
}
/**
* Set page
*
* @param \AppBundle\Entity\Page $page
*
* @return FewoLodging
*/
public function setPage(\AppBundle\Entity\Page $page = null)
{
$this->page = $page;
return $this;
}
/**
* Get page
*
* @return \AppBundle\Entity\Page
*/
public function getPage()
{
return $this->page;
}
function __toString()
{
return $this->name;
}
}

View file

@ -0,0 +1,141 @@
<?php
namespace AppBundle\Entity;
use AppBundle\AppBundle;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table
* @ORM\Entity
*/
class FewoLodgingGroup
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity="FewoLodging", mappedBy="group", cascade={"persist", "remove"})
*/
private $lodgings;
//------------------------------------------------------------------------------------------------------------------
// Bilder
/**
* @ORM\OneToMany(targetEntity="FewoLodgingGroupImage", mappedBy="lodgingGroup", cascade={"persist", "remove"})
* @ORM\OrderBy({"pos" = "ASC"})
*/
private $images;
/**
* Constructor
*/
public function __construct()
{
$this->images = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Get lodgings
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getLodgings()
{
return $this->lodgings;
}
/**
* Add image
*
* @param \AppBundle\Entity\FewoLodgingGroupImage $image
*
* @return FewoLodging
*/
public function addImage(\AppBundle\Entity\FewoLodgingGroupImage $image)
{
$this->images[] = $image;
return $this;
}
/**
* Remove image
*
* @param \AppBundle\Entity\FewoLodgingGroupImage $image
*/
public function removeImage(\AppBundle\Entity\FewoLodgingGroupImage $image)
{
$this->images->removeElement($image);
}
/**
* Get images
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getImages()
{
return $this->images;
}
/**
* Set name
*
* @param string $name
*
* @return FewoLodgingType
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
function __toString()
{
return $this->name;
}
}

View file

@ -0,0 +1,234 @@
<?php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table
* @ORM\Entity
*/
class FewoLodgingGroupImage
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="full_file_name", type="string", length=255, nullable=false)
* @Assert\Image(maxSize="15000000", mimeTypes={"image/jpeg", "image/png"})
*/
private $file;
/**
* @var string
*
* @ORM\Column(name="file_name", type="string", length=255, nullable=false)
* @Assert\NotBlank
*/
private $fileName;
/**
* @var string
*
* @ORM\Column(name="comp", type="string", length=4, nullable=true)
* @Assert\NotBlank
*/
private $comp;
/**
* @var string
*
* @ORM\Column(name="pos", type="integer", nullable=false)
* @Assert\NotBlank
*/
private $pos;
/**
* @var string
*
* @ORM\Column(name="description", type="string", length=255, nullable=true)
*/
private $description;
/**
* @var \AppBundle\Entity\FewoLodgingGroup
*
* @ORM\ManyToOne(targetEntity="FewoLodgingGroup", inversedBy="images")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="group_id", referencedColumnName="id", onDelete="SET NULL")
* })
*/
private $lodgingGroup;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set file
*
* @param string $file
*
* @return FewoLodgingGroupImage
*/
public function setFile($file)
{
$this->file = $file;
return $this;
}
/**
* Get file
*
* @return string
*/
public function getFile()
{
return $this->file;
}
/**
* Set description
*
* @param string $description
*
* @return FewoLodgingGroupImage
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set comp
*
* @param string $comp
*
* @return FewoLodgingGroupImage
*/
public function setComp($comp)
{
$this->comp = $comp;
return $this;
}
/**
* Get comp
*
* @return string
*/
public function getComp()
{
return $this->comp;
}
/**
* Set pos
*
* @param string $pos
*
* @return FewoLodgingGroupImage
*/
public function setPos($pos)
{
$this->pos = $pos;
return $this;
}
/**
* Get pos
*
* @return string
*/
public function getPos()
{
return $this->pos;
}
/**
* Set lodgingGroup
*
* @param \AppBundle\Entity\FewoLodgingGroup $lodgingGroup
*
* @return FewoLodgingGroupImage
*/
public function setLodgingGroup(\AppBundle\Entity\FewoLodgingGroup $lodgingGroup = null)
{
$this->lodgingGroup = $lodgingGroup;
return $this;
}
/**
* Get lodgingGroup
*
* @return \AppBundle\Entity\FewoLodgingGroup
*/
public function getLodgingGroup()
{
return $this->lodgingGroup;
}
function __toString()
{
return $this->file;
}
/**
* Set fileName
*
* @param string $fileName
*
* @return FewoLodgingGroupImage
*/
public function setFileName($fileName)
{
$this->fileName = $fileName;
return $this;
}
/**
* Get fileName
*
* @return string
*/
public function getFileName()
{
return $this->fileName;
}
}

View file

@ -0,0 +1,200 @@
<?php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table
* @ORM\Entity
*/
class FewoLodgingImage
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="full_file_name", type="string", length=255, nullable=false)
* @Assert\Image(maxSize="15000000", mimeTypes={"image/jpeg", "image/png"})
*/
private $file;
/**
* @var string
*
* @ORM\Column(name="file_name", type="string", length=255, nullable=false)
* @Assert\NotBlank
*/
private $fileName;
/**
* @var string
*
* @ORM\Column(name="pos", type="integer", nullable=false)
* @Assert\NotBlank
*/
private $pos;
/**
* @var string
*
* @ORM\Column(name="description", type="string", length=255, nullable=true)
*/
private $description;
/**
* @var \AppBundle\Entity\FewoLodging
*
* @ORM\ManyToOne(targetEntity="FewoLodging", inversedBy="images")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="lodging_id", referencedColumnName="id", onDelete="SET NULL")
* })
*/
private $lodging;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set file
*
* @param string $file
*
* @return FewoLodgingImage
*/
public function setFile($file)
{
$this->file = $file;
return $this;
}
/**
* Get file
*
* @return string
*/
public function getFile()
{
return $this->file;
}
/**
* Set pos
*
* @param string $pos
*
* @return FewoLodgingImage
*/
public function setPos($pos)
{
$this->pos = $pos;
return $this;
}
/**
* Get pos
*
* @return string
*/
public function getPos()
{
return $this->pos;
}
/**
* Set description
*
* @param string $description
*
* @return FewoLodgingImage
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set lodging
*
* @param \AppBundle\Entity\FewoLodging $lodging
*
* @return FewoLodgingImage
*/
public function setLodging(\AppBundle\Entity\FewoLodging $lodging = null)
{
$this->lodging = $lodging;
return $this;
}
/**
* Get lodging
*
* @return \AppBundle\Entity\FewoLodging
*/
public function getLodging()
{
return $this->lodging;
}
function __toString()
{
return $this->file;
}
/**
* Set fileName
*
* @param string $fileName
*
* @return FewoLodgingImage
*/
public function setFileName($fileName)
{
$this->fileName = $fileName;
return $this;
}
/**
* Get fileName
*
* @return string
*/
public function getFileName()
{
return $this->fileName;
}
}

View file

@ -0,0 +1,47 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Query\Expr\OrderBy;
/**
* FewoLodgingRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class FewoLodgingRepository extends \Doctrine\ORM\EntityRepository
{
/**
* @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();
}
public function findSeasonForLodgingBy($lodging, $fromDate)
{
$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->andWhere('s.fromDate <= :fromDate');
$qb->andWhere('s.toDate >= :fromDate');
$qb->setParameter('fromDate', $fromDate);
$qb->addOrderBy('s.fromDate', 'DESC');
$qb->setMaxResults(1);
return $qb->getQuery()->getOneOrNullResult();
}
}

View file

@ -0,0 +1,70 @@
<?php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table
* @ORM\Entity
*/
class FewoLodgingType
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return FewoLodgingType
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
function __toString()
{
return $this->name;
}
}

View file

@ -0,0 +1,163 @@
<?php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table
* @ORM\Entity
*/
class FewoPrice
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \AppBundle\Entity\FewoLodging
*
* @ORM\ManyToOne(targetEntity="FewoLodging", inversedBy="prices")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="lodging_id", referencedColumnName="id")
* })
*/
private $lodging;
/**
* @var \AppBundle\Entity\FewoSeason
*
* @ORM\ManyToOne(targetEntity="FewoSeason", inversedBy="prices")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="season_id", referencedColumnName="id", onDelete="SET NULL")
* })
*/
private $season;
/**
* @var float
*
* @ORM\Column(name="per_night", type="float", scale=2, nullable=false)
*/
private $perNight;
/**
* @var float
*
* @ORM\Column(name="flat_price", type="float", scale=2, nullable=false)
*/
private $flatPrice;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set perNight
*
* @param float $perNight
*
* @return FewoPrice
*/
public function setPerNight($perNight)
{
$this->perNight = $perNight;
return $this;
}
/**
* Get perNight
*
* @return float
*/
public function getPerNight()
{
return $this->perNight;
}
/**
* Set flatPrice
*
* @param float $flatPrice
*
* @return FewoPrice
*/
public function setFlatPrice($flatPrice)
{
$this->flatPrice = $flatPrice;
return $this;
}
/**
* Get flatPrice
*
* @return float
*/
public function getFlatPrice()
{
return $this->flatPrice;
}
/**
* Set lodging
*
* @param \AppBundle\Entity\FewoLodging $lodging
*
* @return FewoPrice
*/
public function setLodging(\AppBundle\Entity\FewoLodging $lodging = null)
{
$this->lodging = $lodging;
return $this;
}
/**
* Get lodging
*
* @return \AppBundle\Entity\FewoLodging
*/
public function getLodging()
{
return $this->lodging;
}
/**
* Set season
*
* @param \AppBundle\Entity\FewoSeason $season
*
* @return FewoPrice
*/
public function setSeason(\AppBundle\Entity\FewoSeason $season = null)
{
$this->season = $season;
return $this;
}
/**
* Get season
*
* @return \AppBundle\Entity\FewoSeason
*/
public function getSeason()
{
return $this->season;
}
}

View file

@ -0,0 +1,204 @@
<?php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use AppBundle\Validator\Constraints as AppBundleAssert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table
* @ORM\Entity
* @AppBundleAssert\FewoReservation
*/
class FewoReservation
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \AppBundle\Entity\FewoLodging
*
* @ORM\ManyToOne(targetEntity="FewoLodging", inversedBy="reservations")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="lodging_id", referencedColumnName="id", onDelete="SET NULL")
* })
*/
private $lodging;
/**
* @var \DateTime
*
* @ORM\Column(name="from_date", type="date", nullable=false)
*/
private $fromDate;
/**
* @var \DateTime
*
* @ORM\Column(name="to_date", type="date", nullable=false)
*/
private $toDate;
// belegt, nicht verfügbar
/**
* @var integer
*
* @ORM\Column(name="status", type="integer", nullable=false)
*/
private $status;
/**
* @var integer
*
* @ORM\Column(name="type", type="integer", nullable=true)
*/
private $type;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set fromDate
*
* @param \DateTime $fromDate
*
* @return FewoReservation
*/
public function setFromDate($fromDate)
{
$this->fromDate = $fromDate;
return $this;
}
/**
* Get fromDate
*
* @return \DateTime
*/
public function getFromDate()
{
return $this->fromDate;
}
/**
* Set toDate
*
* @param \DateTime $toDate
*
* @return FewoReservation
*/
public function setToDate($toDate)
{
$this->toDate = $toDate;
return $this;
}
/**
* Get toDate
*
* @return \DateTime
*/
public function getToDate()
{
return $this->toDate;
}
/**
* Set status
*
* @param integer $status
*
* @return FewoReservation
*/
public function setStatus($status)
{
$this->status = $status;
return $this;
}
/**
* Get status
*
* @return integer
*/
public function getStatus()
{
return $this->status;
}
/**
* Set lodging
*
* @param \AppBundle\Entity\FewoLodging $lodging
*
* @return FewoReservation
*/
public function setLodging(\AppBundle\Entity\FewoLodging $lodging = null)
{
$this->lodging = $lodging;
return $this;
}
/**
* Get lodging
*
* @return \AppBundle\Entity\FewoLodging
*/
public function getLodging()
{
return $this->lodging;
}
/**
* Set type
*
* @param integer $type
*
* @return FewoReservation
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Get type
*
* @return integer
*/
public function getType()
{
return $this->type;
}
/**
* @Assert\Callback
*/
public function validate(ExecutionContextInterface $context, $payload)
{
//$context->
}
}

View file

@ -0,0 +1,277 @@
<?php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints\Date;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table
* @ORM\Entity
*/
class FewoSeason
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
// es gab hier lodgings, wird aber über prices geholt
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
*/
private $name;
/**
* @var \AppBundle\Entity\FewoPrice
*
* @ORM\OneToMany(targetEntity="FewoPrice", mappedBy="season", cascade={"persist", "remove"})
*/
private $prices;
/**
* @var \DateTime
*
* @ORM\Column(name="from_date", type="date", nullable=false)
*/
private $fromDate;
/**
* @var \DateTime
*
* @ORM\Column(name="to_date", type="date", nullable=false)
*/
private $toDate;
/**
* @var integer
*
* @ORM\Column(name="minimum_stay", type="integer", nullable=false)
*/
private $minimumStay;
/**
* @var string
*
* @ORM\Column(name="description", type="text", nullable=true)
*/
private $description;
/**
* @var integer
*
* @ORM\Column(name="only_weekday", type="integer", nullable=true)
*/
private $onlyWeekday;
/**
* Constructor
*/
public function __construct()
{
$this->prices = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set fromDate
*
* @param \DateTime $fromDate
*
* @return FewoSeason
*/
public function setFromDate($fromDate)
{
$this->fromDate = $fromDate;
return $this;
}
/**
* Get fromDate
*
* @return \DateTime
*/
public function getFromDate()
{
return $this->fromDate;
}
/**
* Set toDate
*
* @param \DateTime $toDate
*
* @return FewoSeason
*/
public function setToDate($toDate)
{
$this->toDate = $toDate;
return $this;
}
/**
* Get toDate
*
* @return \DateTime
*/
public function getToDate()
{
return $this->toDate;
}
/**
* Set minimumStay
*
* @param integer $minimumStay
*
* @return FewoSeason
*/
public function setMinimumStay($minimumStay)
{
$this->minimumStay = $minimumStay;
return $this;
}
/**
* Get minimumStay
*
* @return integer
*/
public function getMinimumStay()
{
return $this->minimumStay;
}
/**
* Set description
*
* @param string $description
*
* @return FewoSeason
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Add price
*
* @param \AppBundle\Entity\FewoPrice $price
*
* @return FewoSeason
*/
public function addPrice(\AppBundle\Entity\FewoPrice $price)
{
$this->prices[] = $price;
return $this;
}
/**
* Remove price
*
* @param \AppBundle\Entity\FewoPrice $price
*/
public function removePrice(\AppBundle\Entity\FewoPrice $price)
{
$this->prices->removeElement($price);
}
/**
* Get prices
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getPrices()
{
return $this->prices;
}
/**
* Set name
*
* @param string $name
*
* @return FewoSeason
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
function __toString()
{
return $this->name;
}
/**
* 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;
}
}

View file

@ -0,0 +1,206 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* FlightPeriod
*
* @ORM\Table(name="flight_period", uniqueConstraints={@ORM\UniqueConstraint(name="UK_start_date_end_date_travel_arrival_point", columns={"start_date", "end_date", "travel_arrival_point_id"})}, indexes={@ORM\Index(name="FK_flight_period_travel_arrival_point", columns={"travel_arrival_point_id"})})
* @ORM\Entity(repositoryClass="AppBundle\Entity\FlightPeriodRepository")
*/
class FlightPeriod
{
/**
* @var \DateTime
*
* @ORM\Column(name="start_date", type="date", nullable=true)
*/
private $startDate;
/**
* @var \DateTime
*
* @ORM\Column(name="end_date", type="date", nullable=true)
*/
private $endDate;
/**
* @var float
*
* @ORM\Column(name="price", type="float", precision=10, scale=2, nullable=true)
*/
private $price;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \AppBundle\Entity\TravelArrivalPoint
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelArrivalPoint")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="travel_arrival_point_id", referencedColumnName="id")
* })
*/
private $travelArrivalPoint;
/**
* @ORM\OneToMany(targetEntity="AppBundle\Entity\TravelDeparturePoint", mappedBy="flightPeriod")
*/
private $departures;
/**
* Set startDate
*
* @param \DateTime $startDate
*
* @return FlightPeriod
*/
public function setStartDate($startDate)
{
$this->startDate = $startDate;
return $this;
}
/**
* Get startDate
*
* @return \DateTime
*/
public function getStartDate()
{
return $this->startDate;
}
/**
* Set endDate
*
* @param \DateTime $endDate
*
* @return FlightPeriod
*/
public function setEndDate($endDate)
{
$this->endDate = $endDate;
return $this;
}
/**
* Get endDate
*
* @return \DateTime
*/
public function getEndDate()
{
return $this->endDate;
}
/**
* Set price
*
* @param float $price
*
* @return FlightPeriod
*/
public function setPrice($price)
{
$this->price = $price;
return $this;
}
/**
* Get price
*
* @return float
*/
public function getPrice()
{
return $this->price;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set travelArrivalPoint
*
* @param \AppBundle\Entity\TravelArrivalPoint $travelArrivalPoint
*
* @return FlightPeriod
*/
public function setTravelArrivalPoint(\AppBundle\Entity\TravelArrivalPoint $travelArrivalPoint = null)
{
$this->travelArrivalPoint = $travelArrivalPoint;
return $this;
}
/**
* Get travelArrivalPoint
*
* @return \AppBundle\Entity\TravelArrivalPoint
*/
public function getTravelArrivalPoint()
{
return $this->travelArrivalPoint;
}
/**
* Constructor
*/
public function __construct()
{
$this->departures = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add departure
*
* @param \AppBundle\Entity\TravelDeparturePoint $departure
*
* @return FlightPeriod
*/
public function addDeparture(\AppBundle\Entity\TravelDeparturePoint $departure)
{
$this->departures[] = $departure;
return $this;
}
/**
* Remove departure
*
* @param \AppBundle\Entity\TravelDeparturePoint $departure
*/
public function removeDeparture(\AppBundle\Entity\TravelDeparturePoint $departure)
{
$this->departures->removeElement($departure);
}
/**
* Get departures
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getDepartures()
{
return $this->departures;
}
}

View file

@ -0,0 +1,59 @@
<?php
namespace AppBundle\Entity;
/**
* FlightPeriodRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class FlightPeriodRepository extends \Doctrine\ORM\EntityRepository
{
public function getIndexedFlightPeriodsForTimePeriod($startDate, $endDate, $arrivalPointIds = null)
{
$qb = $this->getEntityManager()->createQueryBuilder();
$qb
->from('AppBundle:FlightPeriod', 'fp')
->addSelect('fp')
->leftJoin('fp.departures', 'fp_dep')
->addSelect('fp_dep')
;
if ($startDate !== null)
{
$qb->where('fp.startDate >= :startDate');
$qb->setParameter('startDate', $startDate);
}
if ($endDate !== null)
{
$qb->andWhere('fp.endDate <= :endDate');
$qb->setParameter('endDate', $endDate);
}
if (!empty($arrivalPointIds))
{
if (is_array($arrivalPointIds))
{
$qb->andWhere($qb->expr()->in('IDENTITY(fp.travelArrivalPoint)', $arrivalPointIds));
}
else
{
$qb->andWhere($qb->expr()->eq('IDENTITY(fp.travelArrivalPoint)', $arrivalPointIds));
}
}
$unindexedFlightPeriods = $qb->getQuery()->getResult();
$ret = [];
// Index by CONCAT(start date, end date, arrival point id):
/** @var FlightPeriod $flightPeriod */
foreach ($unindexedFlightPeriods as $flightPeriod)
{
$ret[$flightPeriod->getStartDate()->format('Y-m-d') .
$flightPeriod->getEndDate()->format('Y-m-d') .
$flightPeriod->getTravelArrivalPoint()->getId()] = $flightPeriod;
}
return $ret;
}
}

View file

@ -0,0 +1,97 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Keyword
*
* @ORM\Table(name="keyword", uniqueConstraints={@ORM\UniqueConstraint(name="value", columns={"value"})})
* @ORM\Entity
*/
class Keyword
{
/**
* @var string
*
* @ORM\Column(name="value", type="string", length=250, nullable=false)
*/
private $value;
/**
* @var string
*
* @ORM\Column(name="url", type="string", length=200, nullable=true)
*/
private $url;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Set value
*
* @param string $value
*
* @return Keyword
*/
public function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* Get value
*
* @return string
*/
public function getValue()
{
return $this->value;
}
/**
* Set url
*
* @param string $url
*
* @return Keyword
*/
public function setUrl($url)
{
$this->url = $url;
return $this;
}
/**
* Get url
*
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,186 @@
<?php
namespace AppBundle\Entity;
use Gedmo\Tree\Entity\Repository\NestedTreeRepository;
use Doctrine\ORM\Query\Expr;
/**
* PageRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class PageRepository extends NestedTreeRepository
{
/**
* @param Page $page
* @return Page[]|array
*
* @todo Optimize performance by adapting search algorithm's optimizations
*/
public function getChildrenWithTravelProgramsAndDates(Page $page)
{
$pages = $this->getChildrenQueryBuilder($page)
->leftJoin('node.travelProgram', 'tp')
->addSelect('tp')
->andWhere('tp.status > 0')
->andWhere('node.status > 0')
->orderBy('node.order')
->addOrderBy('tp.position')
->addOrderBy('node.title')
->getQuery()
->execute();
/** @var Page $childPage */
foreach ($pages as &$childPage)
{
if ($childPage->getTravelProgram())
{
$this->getEntityManager()->getRepository('AppBundle:TravelPeriod')->getTrueTravelPeriods(
$childPage->getTravelProgram());
}
}
return $pages;
}
public function findWithTravelProgramsOfCountry(TravelCountry $country)
{
return $this->createQueryBuilder('node')
->innerJoin('node.travelProgram', 'tp')
->innerJoin('tp.countries', 'c')
->where('c.id = '. $country->getId())
->andWhere('node.status = 1')
->andWhere('tp.status = 1')
->getQuery()
->execute()
;
}
/**
* @return Page[]
*/
public function findOffers()
{
$ret = [];
$countries = $this->getEntityManager()->getRepository('AppBundle:TravelCountry')->findAll();
foreach ($countries as $country)
{
$ret = array_merge($ret, $this->createQueryBuilder('node')
->innerJoin('node.travelProgram', 'tp')
->addSelect('tp')
->innerJoin('tp.countries', 'c')
->where('c.id = '. $country->getId())
->andWhere('node.status = 1')
->andWhere('tp.status = 1')
->orderBy('node.order')
->addOrderBy('tp.position')
->addOrderBy('node.title')
->setMaxResults(3)
->getQuery()
->execute()
);
}
shuffle($ret);
return $ret;
}
public function findCountryPages()
{
return $this->createQueryBuilder('node')
->innerJoin('node.country', 'country')
->where('node.status > 0')
->andWhere('node.template = \'overview\'')
->andWhere('node.lvl = 0')
->orderBy('node.lft,node.title')
->getQuery()
->execute()
;
}
public function findTopCountryNavPages()
{
return $this->createQueryBuilder('node')
->innerJoin('node.country', 'country')
->leftJoin('node.children', 'childPage', Expr\Join::WITH, 'childPage.status > 0')
->addSelect('childPage')
->where('node.status > 0')
->andWhere('node.template = \'overview\'')
->andWhere('node.lvl = 0')
->andWhere('node.order > 0')
->orderBy('node.order,node.title, childPage.lft, childPage.title')
->getQuery()
->execute()
;
}
public function findFeedbacks($rootPageId)
{
$qb = $this->createQueryBuilder('node');
return $qb
->where($qb->expr()->eq('node.parent', $rootPageId))
->andWhere('node.showInNavi = 1')
->andWhere('node.status = 1')
->orderBy('node.order')
->getQuery()
->execute()
;
}
public function findParentsWithShowNav($rootPageId)
{
$qb = $this->createQueryBuilder('node');
$pages = $qb->innerJoin('node.travelProgram', 'tp')
->addSelect('tp')
->where($qb->expr()->eq('node.parent', $rootPageId))
->andWhere('node.showInNavi = 1')
->andWhere('node.status = 1')
->andWhere('tp.status > 0')
->orderBy('node.order')
->getQuery()
->execute()
;
foreach ($pages as &$childPage)
{
if ($childPage->getTravelProgram())
{
// var_dump($childPage->getTravelProgram()->getId());
// $this->getEntityManager()->getRepository('AppBundle:TravelPeriod')->getTrueTravelPeriods($childPage->getTravelProgram());
}
}
return $pages;
}
/**
* @param Page $page
*
* @return Page[]|\Doctrine\Common\Collections\Collection
*/
public function getSiblings(Page $page)
{
$parent = $page->getParent();
if (!$parent)
{
// On purpose, we don't treat root pages as if they were siblings
return [];
}
$siblings = $parent->getChildren();
foreach ($siblings as &$sibling)
{
$sibling->setParent($parent);
}
// Da diese Methode nur für die Navigation verwendet wird, kann man hier vorfiltern
$filteredSiblings = [];
foreach ($siblings as &$sibling)
{
if($sibling->getStatus() == 1 && $sibling->getShowInNavi() == 1)
{
$filteredSiblings[] = $sibling;
}
}
return $filteredSiblings;
}
}

View file

@ -0,0 +1,96 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 02/15/2017
*/
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Redirect
*
* @ORM\Table(name="redirect")
* @ORM\Entity(repositoryClass="AppBundle\Entity\RedirectRepository")
*/
class Redirect
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @ORM\Column(type="string", length=200, nullable=false, unique=true)
*/
private $sourceUrlPath;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Page")
* @ORM\JoinColumn(name="page_id", referencedColumnName="id", nullable=false)
*/
protected $page;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set sourceUrlPath
*
* @param string $sourceUrlPath
*
* @return Redirect
*/
public function setSourceUrlPath($sourceUrlPath)
{
$this->sourceUrlPath = $sourceUrlPath;
return $this;
}
/**
* Get sourceUrlPath
*
* @return string
*/
public function getSourceUrlPath()
{
return $this->sourceUrlPath;
}
/**
* Set page
*
* @param \AppBundle\Entity\Page $page
*
* @return Redirect
*/
public function setPage(\AppBundle\Entity\Page $page = null)
{
$this->page = $page;
return $this;
}
/**
* Get page
*
* @return \AppBundle\Entity\Page
*/
public function getPage()
{
return $this->page;
}
}

View file

@ -0,0 +1,13 @@
<?php
namespace AppBundle\Entity;
/**
* RedirectRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class RedirectRepository extends \Doctrine\ORM\EntityRepository
{
}

View file

@ -0,0 +1,151 @@
<?php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
class Room
{
// von BookingRequest abgeguckt, brauch ich das überhaupt, wenn ich bei $type ein Assert habe?
const SINGLE = 1;
const DOUBLE = 2;
const TRIPLE = 3;
const SINGLECHILD = 4;
const DOUBLECHILD = 5;
const TRIPLECHILD = 6;
/**
* @Assert\NotNull
* @Assert\Choice(choices={1,2,3})
*/
private $type;
private $child = false;
/**
* @Assert\Valid
*/
private $travelers = [];
private $travelerCount;
private $childrenCount;
public function __construct($type)
{
$child = 0;
if($type == 4){
$type = 1;
$child = 1;
$this->child = true;
}
if($type == 5){
$type = 2;
$child = 1;
$this->child = true;
}
if($type == 6){
$type = 3;
$child = 1;
$this->child = true;
}
$this->type = $type;
for($i = 0; $i < $this->type; $i++)
{
$this->travelers[] = new Traveler();
}
for($i = 0; $i < $child; $i++)
{
$temp = new Traveler();
$temp->setChild(true);
$this->travelers[] = $temp;
$this->childrenCount++;
}
$this->travelerCount = $type;
}
/**
* @return int
*/
public function getType()
{
return $this->type;
}
/**
* @param int $type
*/
public function setType($type)
{
$this->type = $type;
}
/**
* @return int
*/
public function getChild()
{
return $this->child;
}
/**
* @param int $child
*/
public function setChild($child)
{
$this->child = $child;
}
/**
* @return Traveler[]
*/
public function getTravelers()
{
return $this->travelers;
}
/**
* @param Traveler[] $travelers
*/
public function setTravelers($travelers)
{
$this->travelers = $travelers;
}
/**
* @return mixed
*/
public function getTravelerCount()
{
return $this->travelerCount;
}
/**
* @param mixed $travelerCount
*/
public function setTravelerCount($travelerCount)
{
$this->travelerCount = $travelerCount;
}
/**
* @return mixed
*/
public function getChildrenCount()
{
return $this->childrenCount;
}
/**
* @param mixed $childrenCount
*/
public function setChildrenCount($childrenCount)
{
$this->childrenCount = $childrenCount;
}
}

View file

@ -0,0 +1,61 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 12/08/2016
*/
namespace AppBundle\Entity;
class SearchFewoRequest
{
private $from;
private $to;
/**
* SearchFewoRequest constructor.
*
* @param $from
* @param $to
*/
public function __construct($from = null, $to = null)
{
$this->from = $from;
$this->to = $to;
}
/**
* @return string
*/
public function getFrom()
{
return $this->from;
}
/**
* @return string
*/
public function getTo()
{
return $this->to;
}
/**
* @return string
*/
public function setFrom($value)
{
return $this->from = $value;
}
/**
* @return string
*/
public function setTo($value)
{
return $this->to = $value;
}
}

View file

@ -0,0 +1,237 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* SidebarWidget
*
* @ORM\Table(name="sidebar_widgets")
* @ORM\Entity(repositoryClass="AppBundle\Entity\SidebarWidgetRepository")
*/
class SidebarWidget
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="component", type="string", length=255, nullable=true)
*/
private $component;
/**
* @var string
*
* @ORM\Column(name="html", type="text", length=65535, nullable=true)
*/
private $html;
/**
* @var string
*
* @ORM\Column(name="show_at", type="text", length=65535, nullable=true)
*/
private $showAt;
/**
* @var int
*
* @ORM\Column(name="pos", type="integer", nullable=true)
*/
private $pos;
/**
* @var boolean
*
* @ORM\Column(name="active", type="boolean", nullable=false)
*/
private $active;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return SidebarWidget
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set component
*
* @param string $component
*
* @return SidebarWidget
*/
public function setComponent($component)
{
$this->component = $component;
return $this;
}
/**
* Get component
*
* @return string
*/
public function getComponent()
{
return $this->component;
}
/**
* Set html
*
* @param string $html
*
* @return SidebarWidget
*/
public function setHtml($html)
{
$this->html = $html;
return $this;
}
/**
* Get html
*
* @return string
*/
public function getHtml()
{
return $this->html;
}
/**
* Set showAt
*
* @param string $showAt
*
* @return SidebarWidget
*/
public function setShowAt($showAt)
{
$this->showAt = $showAt;
return $this;
}
/**
* Get showAt
*
* @return string
*/
public function getShowAt()
{
return $this->showAt == null ? null : json_decode($this->showAt);
//return $this->showAt;
}
/**
* @param int $weekday Weekday as returned by date format 'w'
*
* @return bool
*/
public function getIsShowAt($site)
{
if ($this->showAt == null)
{
return false;
}
return in_array($site, json_decode($this->showAt));
}
/**
* Set pos
*
* @param integer $pos
*
* @return SidebarWidget
*/
public function setPos($pos)
{
$this->pos = $pos;
return $this;
}
/**
* Get pos
*
* @return int
*/
public function getPos()
{
return $this->pos;
}
/**
* Set active
*
* @param boolean $active
*
* @return SidebarWidget
*/
public function setActive($active)
{
$this->active = $active;
return $this;
}
/**
* Get active
*
* @return bool
*/
public function getActive()
{
return $this->active;
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace AppBundle\Entity;
/**
* SidebarWidgetRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class SidebarWidgetRepository extends \Doctrine\ORM\EntityRepository
{
public function findWidgetsBy($site)
{
$qb = $this->createQueryBuilder('sidebar_widget');
$qb->where('sidebar_widget.active = 1')
->addOrderBy('sidebar_widget.pos', 'ASC');
$results = $qb->getQuery()->getResult();
$ret = [];
foreach ($results as $result)
{
if($result->getIsShowAt($site)){
$ret[] = $result;
}
}
return $ret;
}
}

View file

@ -0,0 +1,306 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 03/24/2017
*/
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Redirect
*
* @ORM\Table
* @ORM\Entity
*/
class SunstarTravelProgram
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $title;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $description;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $destination;
/**
* @ORM\Column(type="string", length=200, nullable=true)
*/
protected $url;
/**
* @ORM\Column(type="string", length=200, nullable=true)
*/
protected $imageUrl;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
protected $duration;
/**
* @ORM\Column(type="float", nullable=true)
*/
protected $minimumPrice;
/**
* @ORM\Column(type="integer", nullable=true)
*/
protected $minimumAge;
/**
* @ORM\Column(type="integer", nullable=true)
*/
protected $maximumAge;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id)
{
$this->id = $id;
}
/**
* Set title
*
* @param string $title
*
* @return SunstarTravelProgram
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set description
*
* @param string $description
*
* @return SunstarTravelProgram
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set destination
*
* @param string $destination
*
* @return SunstarTravelProgram
*/
public function setDestination($destination)
{
$this->destination = $destination;
return $this;
}
/**
* Get destination
*
* @return string
*/
public function getDestination()
{
return $this->destination;
}
/**
* Set url
*
* @param string $url
*
* @return SunstarTravelProgram
*/
public function setUrl($url)
{
$this->url = $url;
return $this;
}
/**
* Get url
*
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set imageUrl
*
* @param string $imageUrl
*
* @return SunstarTravelProgram
*/
public function setImageUrl($imageUrl)
{
$this->imageUrl = $imageUrl;
return $this;
}
/**
* Get imageUrl
*
* @return string
*/
public function getImageUrl()
{
return $this->imageUrl;
}
/**
* Set duration
*
* @param integer $duration
*
* @return SunstarTravelProgram
*/
public function setDuration($duration)
{
$this->duration = $duration;
return $this;
}
/**
* Get duration
*
* @return integer
*/
public function getDuration()
{
return $this->duration;
}
/**
* Set minimumPrice
*
* @param float $minimumPrice
*
* @return SunstarTravelProgram
*/
public function setMinimumPrice($minimumPrice)
{
$this->minimumPrice = $minimumPrice;
return $this;
}
/**
* Get minimumPrice
*
* @return float
*/
public function getMinimumPrice()
{
return $this->minimumPrice;
}
/**
* Set minimumAge
*
* @param integer $minimumAge
*
* @return SunstarTravelProgram
*/
public function setMinimumAge($minimumAge)
{
$this->minimumAge = $minimumAge;
return $this;
}
/**
* Get minimumAge
*
* @return integer
*/
public function getMinimumAge()
{
return $this->minimumAge;
}
/**
* Set maximumAge
*
* @param integer $maximumAge
*
* @return SunstarTravelProgram
*/
public function setMaximumAge($maximumAge)
{
$this->maximumAge = $maximumAge;
return $this;
}
/**
* Get maximumAge
*
* @return integer
*/
public function getMaximumAge()
{
return $this->maximumAge;
}
}

View file

@ -0,0 +1,218 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 12/03/2016
*/
namespace AppBundle\Entity;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="test_tree")
* @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\NestedTreeRepository")
* @Gedmo\Tree(type="nested")
*/
class TestTree
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @Gedmo\TreeLeft
* @ORM\Column(type="integer", nullable=true)
*/
protected $lft;
/**
* @Gedmo\TreeLevel()
* @ORM\Column(type="integer", nullable=true)
*/
protected $lvl;
/**
* @Gedmo\TreeRight
* @ORM\Column(type="integer", nullable=true)
*/
protected $rgt;
/**
* @Gedmo\TreeRoot
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TestTree")
* @ORM\JoinColumn(name="tree_root", referencedColumnName="id", onDelete="CASCADE")
*/
private $root;
/**
* @Gedmo\TreeParent
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TestTree", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $parent;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $value;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set lft
*
* @param integer $lft
*
* @return TestTree
*/
public function setLft($lft)
{
$this->lft = $lft;
return $this;
}
/**
* Get lft
*
* @return integer
*/
public function getLft()
{
return $this->lft;
}
/**
* Set lvl
*
* @param integer $lvl
*
* @return TestTree
*/
public function setLvl($lvl)
{
$this->lvl = $lvl;
return $this;
}
/**
* Get lvl
*
* @return integer
*/
public function getLvl()
{
return $this->lvl;
}
/**
* Set rgt
*
* @param integer $rgt
*
* @return TestTree
*/
public function setRgt($rgt)
{
$this->rgt = $rgt;
return $this;
}
/**
* Get rgt
*
* @return integer
*/
public function getRgt()
{
return $this->rgt;
}
/**
* Set root
*
* @param \AppBundle\Entity\TestTree $root
*
* @return TestTree
*/
public function setRoot(\AppBundle\Entity\TestTree $root = null)
{
$this->root = $root;
return $this;
}
/**
* Get root
*
* @return \AppBundle\Entity\TestTree
*/
public function getRoot()
{
return $this->root;
}
/**
* Set parent
*
* @param \AppBundle\Entity\TestTree $parent
*
* @return TestTree
*/
public function setParent(\AppBundle\Entity\TestTree $parent = null)
{
$this->parent = $parent;
return $this;
}
/**
* Get parent
*
* @return \AppBundle\Entity\TestTree
*/
public function getParent()
{
return $this->parent;
}
/**
* Set value
*
* @param string $value
*
* @return TestTree
*/
public function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* Get value
*
* @return string
*/
public function getValue()
{
return $this->value;
}
}

View file

@ -0,0 +1,188 @@
<?php
namespace AppBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelArrivalPoint
*
* @ORM\Table(name="travel_arrival_point", indexes={@ORM\Index(name="FK_travel_arrival_point_travel_country", columns={"travel_country_id"})})
* @ORM\Entity
*/
class TravelArrivalPoint
{
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \AppBundle\Entity\TravelCountry
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelCountry")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="travel_country_id", referencedColumnName="id")
* })
*/
private $travelCountry;
/**
* @ORM\OneToMany(targetEntity="AppBundle\Entity\TravelDeparturePoint", mappedBy="travelArrivalPoint")
*/
private $departures;
/**
* Set name
*
* @param string $name
*
* @return TravelArrivalPoint
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set travelCountry
*
* @param \AppBundle\Entity\TravelCountry $travelCountry
*
* @return TravelArrivalPoint
*/
public function setTravelCountry(\AppBundle\Entity\TravelCountry $travelCountry = null)
{
$this->travelCountry = $travelCountry;
return $this;
}
/**
* Get travelCountry
*
* @return \AppBundle\Entity\TravelCountry
*/
public function getTravelCountry()
{
return $this->travelCountry;
}
/**
* Constructor
*/
public function __construct()
{
$this->departures = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add departure
*
* @param \AppBundle\Entity\TravelDeparturePoint $departure
*
* @return TravelArrivalPoint
*/
public final function addDeparture(\AppBundle\Entity\TravelDeparturePoint $departure)
{
if (!$this->__areDeparturesInitialized__ && isset($this->__initializer__))
{
// Imitate proxy behavior, because this method is final and therefore ignored by the proxy
$this->__initializer__->__invoke($this, 'addDeparture', [$departure]);
}
$this->departures[] = $departure;
return $this;
}
public $__initializer__;
public $__areDeparturesInitialized__ = false;
/**
* Set departures, because the travel date search algorithm already retrieves them at another place. Therefore
* the proxy must be prevented from loading the entire entity as soon as the manually attached departures are
* accessed. To achieve the prevention, the accessor methods are "final". They imitate the proxy's behavior, in
* case they are called and departures haven't been set manually before.
*
* @param ArrayCollection $departures
*
* @internal
*/
public final function __setDepartures($departures)
{
$this->__areDeparturesInitialized__ = true;
if ($departures === null)
{
$this->departures = null;
}
$this->departures = new ArrayCollection();
foreach ($departures as $departure)
{
$this->departures->add($departure);
}
}
/**
* Remove departure
*
* @param \AppBundle\Entity\TravelDeparturePoint $departure
*/
public final function removeDeparture(\AppBundle\Entity\TravelDeparturePoint $departure)
{
if (!$this->__areDeparturesInitialized__ && isset($this->__initializer__))
{
// Imitate proxy behavior, because this method is final and therefore ignored by the proxy
$this->__initializer__->__invoke($this, 'removeDeparture', [$departure]);
}
$this->departures->removeElement($departure);
}
/**
* Get departures
*
* @return \Doctrine\Common\Collections\Collection|TravelDeparturePoint[]
*/
public final function getDepartures()
{
if (!$this->__areDeparturesInitialized__ && isset($this->__initializer__))
{
// Imitate proxy behavior, because this method is final and therefore ignored by the proxy
$this->__initializer__->__invoke($this, 'getDeparture', []);
}
return $this->departures;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,430 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\ClassMetadata;
/**
* TravelBookingRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class TravelBookingRepository extends \Doctrine\ORM\EntityRepository
{
private $serviceItems = [];
private $arrangements = [];
private function createServiceItem($serviceItemData){
$this->serviceItems[] = $serviceItemData;
}
private function createArrangement($arrangementData)
{
if (isset($arrangementData['data_s']) && is_array($arrangementData['data_s']))
{
$tmp = [];
foreach ($arrangementData['data_s'] as $k => $v)
{
$tmp[] .= $k .': '. $v;
}
$arrangementData['data_s'] = implode("\n", $tmp);
}
$this->arrangements[] = $arrangementData;
}
public function createFromBookingRequest(BookingRequest $bookingRequest, TravelDate $travelDate, $bookingPriceInfo)
{
$tp = $travelDate->getTravelProgram();
$ret = new TravelBooking();
$startDateStr = $travelDate->getStart()->format('Y-m-d');
$ret->setIp($_SERVER['REMOTE_ADDR']);
if(count($tp->getDrafts()) > 0){
$newDrafts = true;
}else{
$newDrafts = false;
}
//##lead createLead
$ret->setSalutationId($bookingRequest->getSalutation());
$ret->setFirstName($bookingRequest->getFirstName());
$ret->setLastName($bookingRequest->getLastName());
$ret->setStreet($bookingRequest->getStreetAddress());
$ret->setZipcode($bookingRequest->getZipCode());
$ret->setCity($bookingRequest->getCity());
$ret->setCountryId($bookingRequest->getNation());
$ret->setPhone($bookingRequest->getPhone());
//phonemobile
$ret->setMobile($bookingRequest->getMobile());
$ret->setEmail($bookingRequest->getEmail());
//remarks
$ret->setComments($bookingRequest->getNotes());
//##booking createBooking
//booking_date
$ret->setCreated(new \DateTime());
//travelperiod_start //start_date
$ret->setSelectedStartDate($travelDate->getStart());
//travelperiod_end //start_date
$ret->setSelectedEndDate($travelDate->getEnd());
$ret->setProgramName($tp->getTitle() . ' ('. $travelDate->getName() .')');
$ret->setProgramId($tp->getId());
$ret->setPeriodId($travelDate->__getTravelPeriod()->getId());
$countries = [];
foreach ($tp->getCountries() as $country){
$countries[] = $country->getCrmId();
}
$ret->setSelectedTravel([
'travel_country_id' => $countries,
'travel_category_id' => $tp->getTravelCategory(),
'travelagenda_id' => $tp->getTravelAgenda(),
'travel_title' => $tp->getTitle(),
'travel_number' => $travelDate->getName()
]);
$ret->setSelectedDeparture([
'name' => $bookingRequest->getDeparture()->getName(),
'extra_charge' => $bookingRequest->getDeparture()->getExtraCharge(),
'extra_charge_total' => $bookingRequest->getTravelerCount()
]);
$ret->setPrice($bookingPriceInfo['totalWithoutInsurance']);
$ret->setPriceTotal($bookingPriceInfo['total']);
$ret->setDepositTotal($bookingPriceInfo['deposit_total']);
$ret->setFinalPayment($bookingPriceInfo['final_payment']);
$ret->setFinalPaymentDate(new \DateTime($bookingPriceInfo['final_payment_date']));
//## traveler createTraveler
$ret->setSelectedAdults($bookingRequest->getTravelerCount());
$ret->setSelectedChilds($bookingRequest->getChildrenCount());
$ret->setParticipantsTotal($bookingRequest->getTravelerCount() + $bookingRequest->getChildrenCount());
$ret->setParticipants($bookingRequest->getTravelers());
if ($tp->getIsMediated()) {
$serviceItemDefaults = [
'travel_company_id' => $tp->getOrganizer()->getCmsId(),
'travel_date' => $startDateStr,
'commission' => 0,
];
foreach ($bookingPriceInfo['rooms'] as $room) {
$this->createServiceItem($serviceItemDefaults + [
'service_price' => $room['price_total'],
'name' => $room['name'],
]);
}
$this->createServiceItem($serviceItemDefaults + [
'service_price' => $bookingRequest->getTravelerCount() * $bookingPriceInfo['departure']->getExtraCharge(),
'name' => $bookingRequest->getTravelerCount() .' x '. $bookingPriceInfo['departure']->getName()
]);
foreach ($bookingRequest->getTravelOptions() as $option) {
$this->createServiceItem($serviceItemDefaults + [
'service_price' => $option->getPrice() * $bookingRequest->getTravelerCount(),
'name' => $bookingRequest->getTravelerCount() .' x '. $option->getName()
]);
}
foreach ($bookingPriceInfo['classOptions'] as $classOption){
$this->createServiceItem($serviceItemDefaults + [
'service_price' => $classOption['count'] * $classOption['price'],
'name' => $classOption['count'] .' x '. $classOption['name']
]);
}
} else {
if($newDrafts){
$ret->setDrafts($this->createNewDrafts($bookingRequest, $tp, $travelDate, $bookingPriceInfo, $startDateStr));
}else{
//no new Drafts - create the old Arrangements
$this->createOldArrangement($bookingRequest, $tp, $travelDate, $bookingPriceInfo, $startDateStr);
}
}
$ret->setServiceItems($this->serviceItems);
$ret->setArrangements($this->arrangements);
$insurance = $bookingRequest->getInsurance();
$ret->setInsuranceName($insurance ? $insurance->getName() : '0'); // #TODO Adapted from v2
if (empty($bookingPriceInfo['insurances']))
{
$ret->setInsurances(false);
}
else
{
$insurances = [];
foreach ($bookingPriceInfo['insurances'] as $insuranceInfo)
{
$insurances[] = [
'travel_company_id' => 30,
'service_price' => $insuranceInfo['count'] * $insuranceInfo['insurancePriceValue'],
'name' => $insuranceInfo['count'] . 'x ' . $insuranceInfo['insurance']->getName() . ' (' .
$insuranceInfo['insurancePrice']->getCode() . ')',
'commission' => round(($insuranceInfo['count'] * $insuranceInfo['insurancePriceValue']) * 20 / 100, 2),
'count' => $insuranceInfo['count'],
'price' => $insuranceInfo['insurancePriceValue'],
'code' => $insuranceInfo['insurancePrice']->getCode(),
'travel_date' => $startDateStr,
];
if ($insuranceInfo['countChild'] > 0) {
$insurances[] = [
'travel_company_id' => 30,
'service_price' => $insuranceInfo['countChild'] * $insuranceInfo['insuranceChildPriceValue'],
'name' => $insuranceInfo['countChild'] . 'x ' . $insuranceInfo['insurance']->getName() . ' (' .
$insuranceInfo['insuranceChildPrice']->getCode() . ')',
'commission' => round(($insuranceInfo['countChild'] * $insuranceInfo['insuranceChildPriceValue']) * 20 / 100, 2),
'count' => $insuranceInfo['countChild'],
'price' => $insuranceInfo['insuranceChildPriceValue'],
'code' => $insuranceInfo['insuranceChildPrice']->getCode(),
'travel_date' => $startDateStr,
];
}
}
$ret->setInsurances($insurances);
}
$ret->setRooms($bookingPriceInfo['rooms']);
if (empty($bookingPriceInfo['options']))
{
$ret->setOptions(false);
}
else
{
$options = [];
foreach ($bookingPriceInfo['options'] as $option)
{
$options[] = [
'name' => $option->getName(),
'price' => $option->getPrice()
];
}
$ret->setOptions($options);
}
$ret->setClassOptions(false);
$ret->setExtraCategory(empty($bookingPriceInfo['classOptions']) ? false : $bookingPriceInfo['classOptions']);
$ret->setAcceptLegalRights($bookingRequest->isAcceptLegalRights());
return $ret;
}
private function createNewDrafts(BookingRequest $bookingRequest, TravelProgram $tp, TravelDate $travelDate, $bookingPriceInfo, $startDateStr){
//make an request omn the new API
$endDateStr = $travelDate->getEnd()->format('Y-m-d');
$rooms = [];
$i = 0;
foreach ($bookingPriceInfo['rooms'] as $room)
{
$rooms[$i] = [
'name' => $room['name'],
'price_adult' => $room['price'],
'adult' => $room['adults'],
'children' => 0,
'price_children' => 0,
'price_children_full' => 0,
'price_adult_full' => $room['price_full'],
];
if($room['children'] > 0){
$rooms[$i]['children'] = $room['children'];
$rooms[$i]['price_children'] = $room['price_children'];
$rooms[$i]['price_children_full'] = $room['price_children_full'];
}
$i++;
}
$class_options = [];
// Actually: extra_category
foreach ($bookingPriceInfo['classOptions'] as $classOption)
{
$class_options[] = [
'name' => $classOption['name'],
'price' => $classOption['price'],
'count' => $classOption['count'],
];
}
$travel_options = [];
$i = 0;
foreach ($bookingRequest->getTravelOptions() as $option)
{
$travel_options[$i] = [
'name' => $option->getName(),
'price_adult' => $option->getPrice(),
'adult' => $bookingRequest->getTravelerCount(),
'children' => 0,
'price_children' => 0,
];
if($bookingRequest->getChildrenCount() > 0){
$travel_options[$i]['children'] = $bookingRequest->getChildrenCount();
$travel_options[$i]['price_children'] = $option->getPriceChildren();
}
$i++;
}
$dis = [];
$i = 0;
foreach ($bookingPriceInfo['discount'] as $discount)
{
$dis[$i] = [
'count' => $discount['count'],
'value' => $discount['value'],
'price' => round($discount['price_discount'], 2)
];
$i++;
}
return [
'travel_program_id' => $tp->getId(),
'comfort' => $bookingRequest->getComfort(),
'booking_before' => $bookingPriceInfo['booking_before'],
'booking_after' => $bookingPriceInfo['booking_after'],
'request_date' => (new \DateTime())->format('Y-m-d'),
'startDateStr' => $startDateStr,
'endDateStr' => $endDateStr,
'departure' => $bookingPriceInfo['departure']->getName(),
'departure_extra_charge' => $bookingPriceInfo['departure']->getExtraCharge(),
'traveler' => ($bookingRequest->getTravelerCount() + $bookingRequest->getChildrenCount()),
'title' => $tp->getTitle(),
'number' => $travelDate->getName(),
'rooms' => $rooms,
'class_options' => $class_options,
'travel_options' => $travel_options,
'discount' => $dis,
];
}
private function createOldArrangement(BookingRequest $bookingRequest, TravelProgram $tp, TravelDate $travelDate, $bookingPriceInfo, $startDateStr){
$viewPosition = 100;
$viewPositionPrice = 50;
$endDateStr = $travelDate->getEnd()->format('Y-m-d');
$arrangementDefaults = [
'state' => (new \DateTime())->format('Y-m-d'),
'in_pdf' => 1
];
$this->createArrangement( $arrangementDefaults + [
'type_id' => 4, // Flug
'type_s' => 'Flug',
'begin' => $startDateStr,
'view_position' => --$viewPosition,
'data_s' => ['Hinflug' => 'von '. $bookingPriceInfo['departure']->getName()],
]);
$this->createArrangement( $arrangementDefaults + [
'type_id' => 26, // Preisinformation
'type_s' => 'Preisinformation',
'view_position' => --$viewPositionPrice,
'data_s' => [
'Name' => 'Abfahrts-/Abflugort '. $bookingPriceInfo['departure']->getName(),
'Preis' => $bookingPriceInfo['departure']->getExtraCharge(),
'Teilnehmer' => ($bookingRequest->getTravelerCount() + $bookingRequest->getChildrenCount()),
],
]);
$this->createArrangement( $arrangementDefaults + [
'type_id' => 24, // Rundreise
'type_s' => 'Rundreise', // Rundreise
'begin' => $startDateStr,
'end' => $endDateStr,
'view_position' => --$viewPosition,
'data_s' => ['Name' => $tp->getTitle() .' ('. $travelDate->getName() .')'],
]);
$roomStrs = [];
foreach ($bookingPriceInfo['rooms'] as $room)
{
$roomStrs[] = '1x '. $room['name'];
$child = array();
if($room['children'] > 0){
$child = [
'Kind' => $room['children'],
'KindPreis' => $room['price_children'],
];
}
$data = [
'Name' => 'pro Person im \''. $room['name'] .'\'',
'Preis' => $room['price'],
'Teilnehmer' => $room['adults'],
];
$this->createArrangement( $arrangementDefaults + [
'type_id' => 26, // Preisinformation
'type_s' => 'Preisinformation',
'view_position' => --$viewPositionPrice,
'data_s' => array_merge($data, $child),
]);
}
$this->createArrangement( $arrangementDefaults + [
'type_id' => 5, // Hotel
'type_s' => 'Hotel',
'begin' => $startDateStr,
'end' => $endDateStr,
'view_position' => --$viewPosition,
'data_s' => ['Zimmer' => implode(', ', $roomStrs)],
]);
// Actually: extra_category
foreach ($bookingPriceInfo['classOptions'] as $classOption)
{
$this->createArrangement( $arrangementDefaults + [
'type_id' => 26, // Preisinformation
'type_s' => 'Preisinformation',
'view_position' => --$viewPositionPrice,
'data_s' => [
'Name' => $classOption['name'],
'Preis' => $classOption['price'],
'Teilnehmer' => $classOption['count'],
],
]);
}
$this->createArrangement( $arrangementDefaults + [
'type_id' => 4, // Flug
'type_s' => 'Flug',
'begin' => $endDateStr,
'view_position' => --$viewPosition,
'data_s' => ['Rückflug' => $bookingRequest->getDeparture()->getName()],
]);
foreach ($bookingRequest->getTravelOptions() as $option)
{
$child = array();
if($option->getPriceChildren() > 0){
$child = [
'Kind' => $bookingRequest->getChildrenCount(),
'KindPreis' => $option->getPriceChildren(),
];
}
$data = [
'Name' => $option->getName(),
'Preis' => $option->getPrice(),
'Teilnehmer' => $bookingRequest->getTravelerCount(),
];
$this->createArrangement($arrangementDefaults + [
'type_id' => 26, // Preisinformation
'type_s' => 'Preisinformation',
'view_position' => --$viewPositionPrice,
'data_s' => array_merge($data, $child)
]);
}
}
}

View file

@ -0,0 +1,97 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelCategory
*
* @ORM\Table(name="travel_category")
* @ORM\Entity
*/
class TravelCategory
{
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="conversion_code", type="text", length=65535, nullable=false)
*/
private $conversionCode;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Set name
*
* @param string $name
*
* @return TravelCategory
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set conversionCode
*
* @param string $conversionCode
*
* @return TravelCategory
*/
public function setConversionCode($conversionCode)
{
$this->conversionCode = $conversionCode;
return $this;
}
/**
* Get conversionCode
*
* @return string
*/
public function getConversionCode()
{
return $this->conversionCode;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
}

View file

@ -0,0 +1,162 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelClass
*
* @ORM\Table(name="travel_class", indexes={@ORM\Index(name="FK_travel_class_travel_program", columns={"program_id"})})
* @ORM\Entity
*/
class TravelClass
{
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="description", type="string", length=255, nullable=true)
*/
private $description;
/**
* @var boolean
*
* @ORM\Column(name="standard", type="boolean", nullable=false)
*/
private $standard = '1';
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \AppBundle\Entity\TravelProgram
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelProgram")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="program_id", referencedColumnName="id")
* })
*/
private $program;
/**
* Set name
*
* @param string $name
*
* @return TravelClass
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set description
*
* @param string $description
*
* @return TravelClass
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set standard
*
* @param boolean $standard
*
* @return TravelClass
*/
public function setStandard($standard)
{
$this->standard = $standard;
return $this;
}
/**
* Get standard
*
* @return boolean
*/
public function getStandard()
{
return $this->standard;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set program
*
* @param \AppBundle\Entity\TravelProgram $program
*
* @return TravelClass
*/
public function setProgram(\AppBundle\Entity\TravelProgram $program = null)
{
$this->program = $program;
return $this;
}
/**
* Get program
*
* @return \AppBundle\Entity\TravelProgram
*/
public function getProgram()
{
return $this->program;
}
}

View file

@ -0,0 +1,414 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelCountry
*
* @ORM\Table(name="travel_country", indexes={@ORM\Index(name="FK_travel_country_page", columns={"feedback_page_id"})})
* @ORM\Entity(repositoryClass="AppBundle\Entity\TravelCountryRepository")
*/
class TravelCountry
{
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="slug", type="string", length=255, nullable=true)
*/
private $slug;
/**
* @var string
*
* @ORM\Column(name="text_before", type="string", length=255, nullable=true)
*/
private $text_before;
/**
* @var string
*
* @ORM\Column(name="text_after", type="string", length=255, nullable=true)
*/
private $text_after;
/**
* @var string
*
* @ORM\Column(name="html_information", type="text", length=65535, nullable=false)
*/
private $htmlInformation;
/**
* @var string
*
* @ORM\Column(name="entry_requirements", type="text", length=65535, nullable=false)
*/
private $entryRequirements;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var integer
*
* @ORM\Column(name="crm_id", type="integer")
*/
private $crmId;
/**
* @var boolean
*
* @ORM\Column(name="active_frontend", type="boolean", nullable=false)
*/
private $active_frontend;
/**
* @var \AppBundle\Entity\Page
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Page")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="feedback_page_id", referencedColumnName="id")
* })
*/
private $feedbackPage;
/**
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\TravelProgram", mappedBy="countries")
*/
private $programs;
/**
* @ORM\OneToMany(targetEntity="AppBundle\Entity\TravelDestination", mappedBy="country")
*/
private $destinations;
/**
* Set name
*
* @param string $crmId
*
* @return TravelCountry
*/
public function setCrmId($crmId)
{
$this->crmId = $crmId;
return $this;
}
/**
* Get crmId
*
* @return string
*/
public function getCrmId()
{
return $this->crmId;
}
/**
* Set name
*
* @param string $name
*
* @return TravelCountry
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set slug
*
* @param string $slug
*
* @return TravelCountry
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set text_before
*
* @param string $text_before
*
* @return TravelCountry
*/
public function setTextBefore($text_before)
{
$this->text_before = $text_before;
return $this;
}
/**
* Get text_before
*
* @return string
*/
public function getTextBefore()
{
return $this->text_before;
}
/**
* Set text_after
*
* @param string $text_after
*
* @return TravelCountry
*/
public function setTextAfter($text_after)
{
$this->text_after = $text_after;
return $this;
}
/**
* Get text_after
*
* @return string
*/
public function getTextAfter()
{
return $this->text_after;
}
/**
* Set htmlInformation
*
* @param string $htmlInformation
*
* @return TravelCountry
*/
public function setHtmlInformation($htmlInformation)
{
$this->htmlInformation = $htmlInformation;
return $this;
}
/**
* Get htmlInformation
*
* @return string
*/
public function getHtmlInformation()
{
return $this->htmlInformation;
}
/**
* Set entryRequirements
*
* @param string $entryRequirements
*
* @return TravelCountry
*/
public function setEntryRequirements($entryRequirements)
{
$this->entryRequirements = $entryRequirements;
return $this;
}
/**
* Get entryRequirements
*
* @return string
*/
public function getEntryRequirements()
{
return $this->entryRequirements;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set active_frontend
*
* @param boolean $active_frontend
*
* @return TravelClass
*/
public function setActiveFrontend($active_frontend)
{
$this->active_frontend = $active_frontend;
return $this;
}
/**
* Get active_frontend
*
* @return boolean
*/
public function getActiveFrontend()
{
return $this->active_frontend;
}
/**
* Set feedbackPage
*
* @param \AppBundle\Entity\Page $feedbackPage
*
* @return TravelCountry
*/
public function setFeedbackPage(\AppBundle\Entity\Page $feedbackPage = null)
{
$this->feedbackPage = $feedbackPage;
return $this;
}
/**
* Get feedbackPage
*
* @return \AppBundle\Entity\Page
*/
public function getFeedbackPage()
{
return $this->feedbackPage;
}
/**
* Constructor
*/
public function __construct()
{
$this->programs = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add program
*
* @param \AppBundle\Entity\TravelProgram $program
*
* @return TravelCountry
*/
public function addProgram(\AppBundle\Entity\TravelProgram $program)
{
$this->programs[] = $program;
return $this;
}
/**
* Remove program
*
* @param \AppBundle\Entity\TravelProgram $program
*/
public function removeProgram(\AppBundle\Entity\TravelProgram $program)
{
$this->programs->removeElement($program);
}
/**
* Get programs
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getPrograms()
{
return $this->programs;
}
function __toString()
{
return $this->name;
}
/**
* Add destination
*
* @param \AppBundle\Entity\TravelDestination $destination
*
* @return TravelCountry
*/
public function addDestination(\AppBundle\Entity\TravelDestination $destination)
{
$this->destinations[] = $destination;
return $this;
}
/**
* Remove destination
*
* @param \AppBundle\Entity\TravelDestination $destination
*/
public function removeDestination(\AppBundle\Entity\TravelDestination $destination)
{
$this->destinations->removeElement($destination);
}
/**
* Get destinations
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getDestinations()
{
return $this->destinations;
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace AppBundle\Entity;
/**
* SidebarWidgetRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class TravelCountryRepository extends \Doctrine\ORM\EntityRepository
{
public function getActiveFrontend()
{
$qb = $this->createQueryBuilder('travel_country');
$qb->where('travel_country.active_frontend = 1')
->addOrderBy('travel_country.id', 'ASC');
$results = $qb->getQuery()->getResult();
/* $ret = [];
foreach ($results as $result)
{
if($result->getIsShowAt($site)){
$ret[] = $result;
}
}*/
return $results;
}
}

View file

@ -0,0 +1,348 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 11/03/2016
*/
namespace AppBundle\Entity;
use AppBundle\Util\DepartureUtil;
use Doctrine\Common\Collections\ArrayCollection;
/**
* TravelDate is a wrapper for TravelPeriod + start date and end date. This entity doesn't represent a database
* table. It was introduced because of requirement to keep the bad original database design in which a TravelPeriod
* serves two purposes:
* - Representing a season
* - Representing a single travel date (by being linked to a TravelPeriodDate-instance)
* Also TravelPeriodDate has two purposes:
* - Representing a time period of a season. From this time period, multiple travel dates are derived by taking
* the possible weekdays into account
* - Holding the start and end date for a TravelPeriod that is not a season (see above)
*
* To avoid further confusion and to slowly move away from this design, "TravelDate" has been invented, which has single
* clearly defined purpose:
* Representing a single travel date, i.e.
* - time period a traveller starts and ends his/her journey
* - prices
* - availability
* - departure locations and their prices
*
* "TravelPeriod" would be a more fitting name, but this name is already in use.
*
* @package AppBundle\Entity
*/
final class TravelDate
{
/** @var String $key */
private $key;
/** @var TravelPeriod $travelPeriod */
private $travelPeriod;
/** @var \DateTime $start */
private $start;
/** @var \DateTime $end */
private $end;
private $index;
/** @var FlightPeriod $flightPeriod */
private $flightPeriod;
private $currencyFactor;
private $travelProgram;
/** @var TravelDeparturePoint[]|null $departures Departures cache */
private $departures = null;
/** @var TravelPeriodPrice[]|null $prices Prices cache */
private $prices = null;
private $calculatedEffectivePrices = false;
/**
* TravelDate constructor.
*
* @param String $key
* @param TravelPeriod $travelPeriod
* @param FlightPeriod|null $flightPeriod
* @param float $currencyFactor
* @param \DateTime $start
* @param \DateTime $end Optional. Computed from travel duration, if not specified.
* @param null $index
*
* @todo Make this object immutable
*/
public function __construct($key, TravelPeriod $travelPeriod, FlightPeriod $flightPeriod = null, $currencyFactor,
\DateTime $start = null, \DateTime $end = null, $index = null)
{
if ($travelPeriod->getIsSeason())
{
if ($index === null)
{
throw new \InvalidArgumentException('Expected numeric value for argument $index due to virtual travel date. Got null.');
}
if ($start === null)
{
throw new \InvalidArgumentException('Expected DateTime value for argument $start due to virtual travel date. Got null.');
}
$this->start = $start;
$this->index = $index;
$this->prices = [];
foreach ($travelPeriod->getPrices() as $price)
{
$this->prices[$price->getPriceTypeId()] = clone $price;
}
}
else
{
$this->start = $travelPeriod->getStartDate();
$this->prices = $travelPeriod->getPrices();
}
$this->flightPeriod = $flightPeriod;
$this->travelProgram = $travelPeriod->getProgram();
$this->key = $key;
$this->travelPeriod = $travelPeriod;
if ($end === null)
{
$this->end = clone $this->start;
$this->end->modify('+'. $this->travelProgram->getProgramDuration() .' day');
}
else
{
$this->end = $end;
}
$this->currencyFactor = $currencyFactor;
}
public static function createForNonSeasonTravelPeriod($key, TravelPeriod $travelPeriod,
FlightPeriod $flightPeriod = null, $currencyFactor)
{
if ($travelPeriod->getIsSeason())
{
throw new \Exception('Expected non-season TravelPeriod instance');
}
return new TravelDate($key, $travelPeriod, $flightPeriod, $currencyFactor);
}
public static function createForSeasonTravelPeriod($key, TravelPeriod $travelPeriod, $index, \DateTime $start,
\DateTime $end = null, FlightPeriod $flightPeriod = null, $currencyFactor)
{
if (!$travelPeriod->getIsSeason())
{
throw new \Exception('Expected season TravelPeriod instance');
}
return new TravelDate($key, $travelPeriod, $flightPeriod, $currencyFactor, $start, $end, $index);
}
/**
* @return String
*/
public function getKey()
{
return $this->key;
}
/**
* @return \DateTime
*/
public function getStart()
{
return $this->start;
}
/**
* @return \DateTime
*/
public function getStartWeekday()
{
return $this->start->format('w');
}
public function getFinalPaymentDate()
{
$pDate = strtotime('-4 week', $this->getStart()->getTimestamp());
if($pDate <= time()){
$pDate = time();
}
return date('d.m.Y',$pDate);
}
public function getFinalPaymentDateStr()
{
$pDate = strtotime('-4 week', $this->getStart()->getTimestamp());
if($pDate <= time()){
return "ist sofort fällig";
}
return "bis zum ".date('d.m.Y',$pDate);
}
/**
* @return \DateTime
*/
public function getEnd()
{
return $this->end;
}
public function getName()
{
return $this->travelPeriod->getIsSeason()
? (trim($this->travelProgram->getProgramCode()) . $this->index)
: $this->travelPeriod->getName()
;
}
public function getStatus()
{
return $this->travelPeriod->getStatus();
}
public function getEffectiveStatus()
{
if ($this->getStatus() == 2 && $this->getStart()->getTimestamp() < time() + 2419200)
{
return 1;
}
return $this->getStatus();
}
public function getDepartures()
{
if ($this->departures === null)
{
if ($this->travelProgram->getIsMediated())
{
$defaultDepartures = $this->travelProgram->getDepartures();
$departures = $this->travelPeriod->getDepartures();
}
else
{
$defaultDepartures = $this->travelProgram->getTravelArrivalPoint()->getDepartures();
$departures = $this->flightPeriod === null ? [] : $this->flightPeriod->getDepartures();
}
$defaultDepartures = DepartureUtil::filterDeparturesByPeriod($defaultDepartures, $this->start, $this->end, true);
$this->departures = DepartureUtil::mergeDeparturesWithDefaults($departures, $defaultDepartures, true);
}
return $this->departures;
}
public function getFlightPrice()
{
if ($this->travelProgram->getIsMediated())
{
return 0;
}
$flightPrice = null;
if ($this->flightPeriod !== null)
{
$flightPrice = $this->flightPeriod->getPrice();
}
if ($flightPrice === null)
{
$flightPrice = $this->travelProgram->getDefaultFlightPrice();
}
return $flightPrice;
}
public function getFlightCalcPrice()
{
$flightPrice = $this->getFlightPrice();
if ($this->travelProgram->getIsMediated())
{
$profitMargin = 1;
}
else
{
$profitMargin = $this->travelProgram->getProfitMargin() / 100 + 1;
}
$currencyFactor = $this->travelProgram->getNettoPricesInEuro() ? 1 : $this->currencyFactor;
return round(($flightPrice * $currencyFactor) * $profitMargin);
}
/**
* @return TravelPeriodPrice[]|\Doctrine\Common\Collections\Collection
*/
public function getPrices()
{
if (!$this->calculatedEffectivePrices)
{
$this->calculatedEffectivePrices = true;
$flightPrice = $this->getFlightPrice();
if ($this->travelProgram->getIsMediated())
{
$profitMargin = 1;
}
else
{
$profitMargin = $this->travelProgram->getProfitMargin() / 100 + 1;
}
$currencyFactor = $this->travelProgram->getNettoPricesInEuro() ? 1 : $this->currencyFactor;
foreach ($this->prices as &$price)
{
$price->setEffectivePrice(round(($flightPrice + $price->getPrice() * $currencyFactor) * $profitMargin));
$price->setEffectiveComfortPrice(round($price->getPriceComfort() * $currencyFactor * $profitMargin));
$price->setEffectiveChildPrice(round(($flightPrice + $price->getPriceChildren() * $currencyFactor) * $profitMargin));
$price->setEffectiveExtraPrice(round($price->getExtraPrice() * $currencyFactor * $profitMargin));
$price->setEffectiveExtraComfortPrice(round($price->getExtraPriceComfort() * $currencyFactor * $profitMargin));
$price->setEffectiveExtraChildPrice(round($price->getExtraPriceChildren() * $currencyFactor * $profitMargin));
}
}
return $this->prices;
}
public function getLowestPrice()
{
$lowest = -1;
foreach ($this->getPrices() as $price)
{
if ($price->getPriceTypeId() == 3)
{
// Use double room if available (#1076)
return $price->getEffectiveDiscountPrice() ?? $price->getEffectivePrice();
}
if ($lowest < 0 || $price->getEffectivePrice() < 0)
{
$lowest = $price->getEffectivePrice();
}
}
return $lowest == -1 ? null : $lowest;
}
public function hasComfortCategory()
{
foreach ($this->getPrices() as $price)
{
if ($price->getPriceComfort() > 0)
{
return true;
}
}
return false;
}
/**
* @return TravelProgram
*/
public function getTravelProgram(): TravelProgram
{
return $this->travelProgram;
}
/**
* @return TravelPeriod
* @internal
*/
public function __getTravelPeriod()
{
return $this->travelPeriod;
}
}

View file

@ -0,0 +1,388 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelDeparturePoint
*
* @ORM\Table(name="travel_departure_point", uniqueConstraints={@ORM\UniqueConstraint(name="UK_flight_period_id_name", columns={"flight_period_id", "name"}), @ORM\UniqueConstraint(name="UK_travel_arrival_point_id_name", columns={"travel_arrival_point_id", "name"}), @ORM\UniqueConstraint(name="UK_program_id_name", columns={"program_id", "name"}), @ORM\UniqueConstraint(name="UK_period_id_name", columns={"period_id", "name"})}, indexes={@ORM\Index(name="FK_travel_departure_point_travel_program", columns={"program_id"}), @ORM\Index(name="FK_travel_departure_point_flight_period", columns={"flight_period_id"}), @ORM\Index(name="FK_travel_departure_point_travel_arrival_point", columns={"travel_arrival_point_id"})})
* @ORM\Entity(repositoryClass="AppBundle\Entity\TravelDeparturePointRepository")
*/
class TravelDeparturePoint
{
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="extra_charge", type="string", length=255, nullable=true)
*/
private $extraCharge;
/**
* @var string
*
* @ORM\Column(name="days", type="string", length=255, nullable=true)
*/
private $days;
/**
* @var string
*
* @ORM\Column(name="flight_time", type="text", length=65535, nullable=true)
*/
private $flightTime;
/**
* @var string
*
* @ORM\Column(name="departure_type", type="string", nullable=true)
*/
private $departureType;
/**
* @var string
*
* @ORM\Column(name="`3letter`", type="string", length=255, nullable=true)
*/
private $three_letter;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \AppBundle\Entity\FlightPeriod
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\FlightPeriod", inversedBy="departures")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="flight_period_id", referencedColumnName="id")
* })
*/
private $flightPeriod;
/**
* @var \AppBundle\Entity\TravelArrivalPoint
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelArrivalPoint", inversedBy="departures")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="travel_arrival_point_id", referencedColumnName="id")
* })
*/
private $travelArrivalPoint;
/**
* @var \AppBundle\Entity\TravelProgram
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelProgram", inversedBy="departures")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="program_id", referencedColumnName="id")
* })
*/
private $program;
/**
* @var TravelPeriod
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelPeriod", inversedBy="departures")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="period_id", referencedColumnName="id")
* })
*/
private $travelPeriod;
private $isVirtual = null;
/**
* Set name
*
* @param string $name
*
* @return TravelDeparturePoint
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set extraCharge
*
* @param string $extraCharge
*
* @return TravelDeparturePoint
*/
public function setExtraCharge($extraCharge)
{
$this->extraCharge = $extraCharge;
return $this;
}
/**
* Get extraCharge
*
* @return float
*/
public function getExtraCharge()
{
return ($this->extraCharge === null || $this->extraCharge === '') ? null : floatval($this->extraCharge);
}
/**
* Set days
*
* @param string $days
*
* @return TravelDeparturePoint
*/
public function setDays($days)
{
$this->days = $days;
return $this;
}
/**
* Get days
*
* @return array|int[]
*/
public function getDays()
{
return $this->days == null ? null : json_decode($this->days);
}
/**
* Set days
*
* @param string $flightTime
*
* @return TravelDeparturePoint
*/
public function setFlightTime($flightTime)
{
$this->flightTime = $flightTime;
return $this;
}
/**
* Get flightTime
*
* @return array|int[]
*/
public function getFlightTime()
{
return $this->flightTime == null ? null : json_decode($this->flightTime, true);
}
/**
* Set departureType
*
* @param string $departureType
*
* @return TravelDeparturePoint
*/
public function setDepartureType($departureType)
{
$this->departureType = $departureType;
return $this;
}
/**
* Get departureType
*
* @return string
*/
public function getDepartureType()
{
return $this->departureType;
}
/**
* Set threeLetter
*
* @param string $threeLetter
*
* @return TravelDeparturePoint
*/
public function setThreeLetter($threeLetter)
{
$this->three_letter = $threeLetter;
return $this;
}
/**
* Get threeLetter
*
* @return string
*/
public function getThreeLetter()
{
return $this->three_letter;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set flightPeriod
*
* @param \AppBundle\Entity\FlightPeriod $flightPeriod
*
* @return TravelDeparturePoint
*/
public function setFlightPeriod(\AppBundle\Entity\FlightPeriod $flightPeriod = null)
{
$this->flightPeriod = $flightPeriod;
return $this;
}
/**
* Get flightPeriod
*
* @return \AppBundle\Entity\FlightPeriod
*/
public function getFlightPeriod()
{
return $this->flightPeriod;
}
/**
* Set travelArrivalPoint
*
* @param \AppBundle\Entity\TravelArrivalPoint $travelArrivalPoint
*
* @return TravelDeparturePoint
*/
public function setTravelArrivalPoint(\AppBundle\Entity\TravelArrivalPoint $travelArrivalPoint = null)
{
$this->travelArrivalPoint = $travelArrivalPoint;
return $this;
}
/**
* Get travelArrivalPoint
*
* @return \AppBundle\Entity\TravelArrivalPoint
*/
public function getTravelArrivalPoint()
{
return $this->travelArrivalPoint;
}
/**
* Set program
*
* @param \AppBundle\Entity\TravelProgram $program
*
* @return TravelDeparturePoint
*/
public function setProgram(\AppBundle\Entity\TravelProgram $program = null)
{
$this->program = $program;
return $this;
}
/**
* Get program
*
* @return \AppBundle\Entity\TravelProgram
*/
public function getProgram()
{
return $this->program;
}
/**
* Set travelPeriod
*
* @param \AppBundle\Entity\TravelPeriod $travelPeriod
*
* @return TravelDeparturePoint
*/
public function setTravelPeriod(\AppBundle\Entity\TravelPeriod $travelPeriod = null)
{
$this->travelPeriod = $travelPeriod;
return $this;
}
/**
* Get travelPeriod
*
* @return \AppBundle\Entity\TravelPeriod
*/
public function getTravelPeriod()
{
return $this->travelPeriod;
}
public function getIsEmpty()
{
return !isset($this->extraCharge) || $this->extraCharge == '';
}
/**
* @return boolean
*/
public function getIsVirtual()
{
return $this->isVirtual;
}
/**
* @param boolean $isVirtual
*/
public function setIsVirtual($isVirtual)
{
$this->isVirtual = $isVirtual;
}
public function __toString()
{
return $this->getName() .' ('. number_format($this->getExtraCharge(), 2, ',', '.') .' €)';
}
}

View file

@ -0,0 +1,162 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelDeparturePointHoliday
*
* @ORM\Table(name="travel_departure_point_holiday", indexes={@ORM\Index(name="FK_travel_departure_point_holiday_travel_departure_point", columns={"departure_point_id"})})
* @ORM\Entity
*/
class TravelDeparturePointHoliday
{
/**
* @var \DateTime
*
* @ORM\Column(name="start_date", type="date", nullable=true)
*/
private $startDate;
/**
* @var \DateTime
*
* @ORM\Column(name="end_date", type="date", nullable=true)
*/
private $endDate;
/**
* @var float
*
* @ORM\Column(name="extra_charge", type="float", precision=10, scale=2, nullable=true)
*/
private $extraCharge;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \AppBundle\Entity\TravelDeparturePoint
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelDeparturePoint")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="departure_point_id", referencedColumnName="id")
* })
*/
private $departurePoint;
/**
* Set startDate
*
* @param \DateTime $startDate
*
* @return TravelDeparturePointHoliday
*/
public function setStartDate($startDate)
{
$this->startDate = $startDate;
return $this;
}
/**
* Get startDate
*
* @return \DateTime
*/
public function getStartDate()
{
return $this->startDate;
}
/**
* Set endDate
*
* @param \DateTime $endDate
*
* @return TravelDeparturePointHoliday
*/
public function setEndDate($endDate)
{
$this->endDate = $endDate;
return $this;
}
/**
* Get endDate
*
* @return \DateTime
*/
public function getEndDate()
{
return $this->endDate;
}
/**
* Set extraCharge
*
* @param float $extraCharge
*
* @return TravelDeparturePointHoliday
*/
public function setExtraCharge($extraCharge)
{
$this->extraCharge = $extraCharge;
return $this;
}
/**
* Get extraCharge
*
* @return float
*/
public function getExtraCharge()
{
return $this->extraCharge;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set departurePoint
*
* @param \AppBundle\Entity\TravelDeparturePoint $departurePoint
*
* @return TravelDeparturePointHoliday
*/
public function setDeparturePoint(\AppBundle\Entity\TravelDeparturePoint $departurePoint = null)
{
$this->departurePoint = $departurePoint;
return $this;
}
/**
* Get departurePoint
*
* @return \AppBundle\Entity\TravelDeparturePoint
*/
public function getDeparturePoint()
{
return $this->departurePoint;
}
}

View file

@ -0,0 +1,8 @@
<?php
namespace AppBundle\Entity;
class TravelDeparturePointRepository extends \Doctrine\ORM\EntityRepository
{
}

View file

@ -0,0 +1,99 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelDestination
*
* @ORM\Table(name="travel_destination", indexes={@ORM\Index(name="FK_travel_destination_travel_country", columns={"country_id"})})
* @ORM\Entity
*/
class TravelDestination
{
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \AppBundle\Entity\TravelCountry
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelCountry", inversedBy="destinations")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="country_id", referencedColumnName="id")
* })
*/
private $country;
/**
* Set name
*
* @param string $name
*
* @return TravelDestination
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set country
*
* @param \AppBundle\Entity\TravelCountry $country
*
* @return TravelDestination
*/
public function setCountry(\AppBundle\Entity\TravelCountry $country = null)
{
$this->country = $country;
return $this;
}
/**
* Get country
*
* @return \AppBundle\Entity\TravelCountry
*/
public function getCountry()
{
return $this->country;
}
}

View file

@ -0,0 +1,224 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelDiscount
*
* @ORM\Table(name="travel_discount", indexes={@ORM\Index(name="FK_discount_travel_period", columns={"period_id"})})
* @ORM\Entity
*/
class TravelDiscount
{
/**
* @var float
*
* @ORM\Column(name="value", type="float", precision=10, scale=2, nullable=true)
*/
private $value;
/**
* @var boolean
*
* @ORM\Column(name="percent", type="boolean", nullable=true)
*/
private $percent = '0';
/**
* @var \DateTime
*
* @ORM\Column(name="start", type="date", nullable=true)
*/
private $start;
/**
* @var \DateTime
*
* @ORM\Column(name="end", type="date", nullable=true)
*/
private $end;
/**
* @var boolean
*
* @ORM\Column(name="priority", type="boolean", nullable=true)
*/
private $priority = '0';
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \AppBundle\Entity\TravelPeriod
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelPeriod", inversedBy="discounts")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="period_id", referencedColumnName="id")
* })
*/
private $period;
/**
* Set value
*
* @param float $value
*
* @return TravelDiscount
*/
public function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* Get value
*
* @return float
*/
public function getValue()
{
return $this->value;
}
/**
* Set percent
*
* @param boolean $percent
*
* @return TravelDiscount
*/
public function setPercent($percent)
{
$this->percent = $percent;
return $this;
}
/**
* Get percent
*
* @return boolean
*/
public function getPercent()
{
return $this->percent;
}
/**
* Set start
*
* @param \DateTime $start
*
* @return TravelDiscount
*/
public function setStart($start)
{
$this->start = $start;
return $this;
}
/**
* Get start
*
* @return \DateTime
*/
public function getStart()
{
return $this->start;
}
/**
* Set end
*
* @param \DateTime $end
*
* @return TravelDiscount
*/
public function setEnd($end)
{
$this->end = $end;
return $this;
}
/**
* Get end
*
* @return \DateTime
*/
public function getEnd()
{
return $this->end;
}
/**
* Set priority
*
* @param boolean $priority
*
* @return TravelDiscount
*/
public function setPriority($priority)
{
$this->priority = $priority;
return $this;
}
/**
* Get priority
*
* @return boolean
*/
public function getPriority()
{
return $this->priority;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set period
*
* @param \AppBundle\Entity\TravelPeriod $period
*
* @return TravelDiscount
*/
public function setPeriod(\AppBundle\Entity\TravelPeriod $period = null)
{
$this->period = $period;
return $this;
}
/**
* Get period
*
* @return \AppBundle\Entity\TravelPeriod
*/
public function getPeriod()
{
return $this->period;
}
}

View file

@ -0,0 +1,97 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelGeneralNote
*
* @ORM\Table(name="travel_general_notes")
* @ORM\Entity
*/
class TravelGeneralNote
{
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="text", type="text", length=65535, nullable=false)
*/
private $text;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Set name
*
* @param string $name
*
* @return TravelGeneralNote
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set text
*
* @param string $text
*
* @return TravelGeneralNote
*/
public function setText($text)
{
$this->text = $text;
return $this;
}
/**
* Get text
*
* @return string
*/
public function getText()
{
return $this->text;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
}

View file

@ -0,0 +1,24 @@
<?php
namespace AppBundle\Entity;
/**
* TravelGuideRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class TravelGuideRepository extends \Doctrine\ORM\EntityRepository
{
public function findByID($id)
{
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('tg');
$qb->from('AppBundle:TravelGuides', 'tg');
$qb->where('tg.id = :id');
$qb->setParameter('id', $id);
$qb->setMaxResults(1);
return $qb->getQuery()->getOneOrNullResult();
}
}

View file

@ -0,0 +1,134 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelGuides
*
* @ORM\Table(name="travel_guides")
* @ORM\Entity(repositoryClass="AppBundle\Entity\TravelGuideRepository")
*/
class TravelGuides
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="slug", type="string", length=255, unique=true)
*/
private $slug;
/**
* @var string
*
* @ORM\Column(name="full_text", type="text", nullable=true)
*/
private $fullText;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return CMSContent
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set slug
*
* @param string $slug
*
* @return CMSContent
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set fullText
*
* @param string $fullText
*
* @return CMSContent
*/
public function setFullText($fullText)
{
$this->fullText = $fullText;
return $this;
}
/**
* Get fullText
*
* @return string
*/
public function getFullText()
{
return $this->fullText;
}
}

View file

@ -0,0 +1,273 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelInsurance
*
* @ORM\Table(name="travel_insurance")
* @ORM\Entity
*/
class TravelInsurance
{
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="internal_name", type="string", length=255, nullable=true)
*/
private $internalName;
/**
* @var string
*
* @ORM\Column(name="included", type="text", length=255, nullable=true)
*/
private $included;
/**
* @var string
*
* @ORM\Column(name="insurance_name", type="string", length=255, nullable=true)
*/
private $insuranceName;
/**
* @var string
*
* @ORM\Column(name="text", type="string", length=255, nullable=true)
*/
private $text;
/**
* @var string
*
* @ORM\Column(name="insurance_pdf", type="string", length=255, nullable=true)
*/
private $insurancePdf;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @ORM\OneToMany(targetEntity="AppBundle\Entity\TravelInsurancePrice", mappedBy="insurance")
*/
protected $prices;
/**
* Set name
*
* @param string $name
*
* @return TravelInsurance
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set internalName
*
* @param string $internalName
*
* @return TravelInsurance
*/
public function setInternalName($internalName)
{
$this->internalName = $internalName;
return $this;
}
/**
* Get internalName
*
* @return string
*/
public function getInternalName()
{
return $this->internalName;
}
/**
* Set insuranceName
*
* @param string $insuranceName
*
* @return TravelInsurance
*/
public function setInsuranceName($insuranceName)
{
$this->insuranceName = $insuranceName;
return $this;
}
/**
* Get insuranceName
*
* @return string
*/
public function getInsuranceName()
{
return $this->insuranceName;
}
/**
* Set text
*
* @param string $text
*
* @return TravelInsurance
*/
public function setText($text)
{
$this->text = $text;
return $this;
}
/**
* Get text
*
* @return string
*/
public function getText()
{
return $this->text;
}
/**
* Set insurancePdf
*
* @param string $insurancePdf
*
* @return TravelInsurance
*/
public function setInsurancePdf($insurancePdf)
{
$this->insurancePdf = $insurancePdf;
return $this;
}
/**
* Get insurancePdf
*
* @return string
*/
public function getInsurancePdf()
{
return $this->insurancePdf;
}
/**
* Set included
*
* @param string $included
*
* @return TravelInsurance
*/
public function setIncluded($included)
{
$this->included = $included;
return $this;
}
/**
* Get included
*
* @return string
*/
public function getIncluded()
{
return $this->included;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Constructor
*/
public function __construct()
{
$this->prices = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add price
*
* @param \AppBundle\Entity\TravelInsurancePrice $price
*
* @return TravelInsurance
*/
public function addPrice(\AppBundle\Entity\TravelInsurancePrice $price)
{
$this->prices[] = $price;
return $this;
}
/**
* Remove price
*
* @param \AppBundle\Entity\TravelInsurancePrice $price
*/
public function removePrice(\AppBundle\Entity\TravelInsurancePrice $price)
{
$this->prices->removeElement($price);
}
/**
* Get prices
*
* @return TravelInsurancePrice[]|\Doctrine\Common\Collections\Collection
*/
public function getPrices()
{
return $this->prices;
}
public function __toString()
{
return $this->getName();
}
}

View file

@ -0,0 +1,256 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelInsurancePrice
*
* @ORM\Table(name="travel_insurance_price", indexes={@ORM\Index(name="FK_travel_insurance_price_travel_insurance", columns={"insurance_id"})})
* @ORM\Entity(repositoryClass="AppBundle\Entity\TravelInsurancePriceRepository")
*/
class TravelInsurancePrice
{
/**
* @var float
*
* @ORM\Column(name="border", type="float", precision=10, scale=2, nullable=true)
*/
private $border;
/**
* @var float
*
* @ORM\Column(name="price", type="float", precision=10, scale=2, nullable=true)
*/
private $price;
/**
* @var float
*
* @ORM\Column(name="price_old", type="float", precision=10, scale=2, nullable=true)
*/
private $price_old;
/**
* @var float
*
* @ORM\Column(name="percent", type="float", precision=10, scale=2, nullable=true)
*/
private $percent;
/**
* @var float
*
* @ORM\Column(name="percent_old", type="float", precision=10, scale=2, nullable=true)
*/
private $percent_old;
/**
* @var string
*
* @ORM\Column(name="code", type="string", length=255, nullable=true)
*/
private $code;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \AppBundle\Entity\TravelInsurance
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelInsurance", inversedBy="prices")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="insurance_id", referencedColumnName="id")
* })
*/
private $insurance;
/**
* Set border
*
* @param float $border
*
* @return TravelInsurancePrice
*/
public function setBorder($border)
{
$this->border = $border;
return $this;
}
/**
* Get border
*
* @return float
*/
public function getBorder()
{
return $this->border;
}
/**
* Set price
*
* @param float $price
*
* @return TravelInsurancePrice
*/
public function setPrice($price)
{
$this->price = $price;
return $this;
}
/**
* Get price
*
* @return float
*/
public function getPrice()
{
return $this->price;
}
/**
* Set price_old
*
* @param float $price_old
*
* @return TravelInsurancePrice
*/
public function setPriceOld($price_old)
{
$this->price_old = $price_old;
return $this;
}
/**
* Get price_old
*
* @return float
*/
public function getPriceOld()
{
return $this->price_old;
}
/**
* Set percent
*
* @param float $percent
*
* @return TravelInsurancePrice
*/
public function setPercent($percent)
{
$this->percent = $percent;
return $this;
}
/**
* Get percent
*
* @return float
*/
public function getPercent()
{
return $this->percent;
}
/**
* Set percent_old
*
* @param float $percent_old
*
* @return TravelInsurancePrice
*/
public function setPercentOld($percent_old)
{
$this->percent_old = $percent_old;
return $this;
}
/**
* Get percent_old
*
* @return float
*/
public function getPercentOld()
{
return $this->percent_old;
}
/**
* Set code
*
* @param string $code
*
* @return TravelInsurancePrice
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
/**
* Get code
*
* @return string
*/
public function getCode()
{
return $this->code;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set insurance
*
* @param \AppBundle\Entity\TravelInsurance $insurance
*
* @return TravelInsurancePrice
*/
public function setInsurance(\AppBundle\Entity\TravelInsurance $insurance = null)
{
$this->insurance = $insurance;
return $this;
}
/**
* Get insurance
*
* @return \AppBundle\Entity\TravelInsurance
*/
public function getInsurance()
{
return $this->insurance;
}
}

View file

@ -0,0 +1,32 @@
<?php
namespace AppBundle\Entity;
use Doctrine\Common\Collections\Collection;
/**
* TravelInsurancePriceRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class TravelInsurancePriceRepository extends \Doctrine\ORM\EntityRepository
{
/**
* @param $insuranceId
* @param $assessmentBasis
*
* @return TravelInsurancePrice|null
*/
public function findOneByInsuranceIdAndAssessmentBasis($insuranceId, $assessmentBasis)
{
$qb = $this->createQueryBuilder('i');
return $qb
->where($qb->expr()->eq('IDENTITY(i.insurance)', $insuranceId))
//->where('IDENTITY(i.insurance) = '. $insuranceId)
->andWhere($qb->expr()->gte('i.border', $assessmentBasis))
->orderBy('i.border')
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
}
}

View file

@ -0,0 +1,68 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelNationality
*
* @ORM\Table(name="travel_nationality")
* @ORM\Entity
*/
class TravelNationality
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return TravelNationality
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
}

View file

@ -0,0 +1,23 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Query;
/**
* TravelNationalityRepository
*/
class TravelNationalityRepository extends \Doctrine\ORM\EntityRepository
{
public function getAllEntries()
{
return $this->createQueryBuilder('n')->select('n')->getQuery()->execute();
}
public function getAllEntriesAsArray()
{
return $this->createQueryBuilder('n')->select('n')->getQuery()->getResult(Query::HYDRATE_ARRAY);
}
}

View file

@ -0,0 +1,128 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelNationalityRequirement
* @ORM\Table(name="travel_nationality_requirement")
* @ORM\Entity(repositoryClass="AppBundle\Entity\TravelNationalityRequirementRepository")
*/
class TravelNationalityRequirement
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var integer
*
* @ORM\Column(name="travel_country_id", type="integer", nullable=true)
*/
private $travelCountryId;
/**
* @var integer
*
* @ORM\Column(name="travel_nationality_id", type="integer", nullable=true)
*/
private $travelNationalityId;
/**
* @var string
*
* @ORM\Column(name="text", type="text", length=65535, nullable=true)
*/
private $text;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set travelCountryId
*
* @param integer $travelCountryId
*
* @return TravelNationalityRequirement
*/
public function setTravelCountryId($travelCountryId)
{
$this->travelCountryId = $travelCountryId;
return $this;
}
/**
* Get travelCountryId
*
* @return int
*/
public function getTravelCountryId()
{
return $this->travelCountryId;
}
/**
* Set travelNationalityId
*
* @param integer $travelNationalityId
*
* @return TravelNationalityRequirement
*/
public function setTravelNationalityId($travelNationalityId)
{
$this->travelNationalityId = $travelNationalityId;
return $this;
}
/**
* Get travelNationalityId
*
* @return int
*/
public function getTravelNationalityId()
{
return $this->travelNationalityId;
}
/**
* Set text
*
* @param string $text
*
* @return TravelNationalityRequirement
*/
public function setText($text)
{
$this->text = $text;
return $this;
}
/**
* Get text
*
* @return string
*/
public function getText()
{
return $this->text;
}
}

View file

@ -0,0 +1,22 @@
<?php
namespace AppBundle\Entity;
/**
* TravelNationalityRequirementRepository
*/
class TravelNationalityRequirementRepository extends \Doctrine\ORM\EntityRepository
{
public function findOneByCountryAndNationality($travel_country_id, $travel_nationality_id)
{
$qb = $this->createQueryBuilder('nr');
return $qb
->where('nr.travelCountryId = '.$travel_country_id)
->andWhere('nr.travelNationalityId = '.$travel_nationality_id)
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
}
}

View file

@ -0,0 +1,195 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelOption
*
* @ORM\Table(name="travel_option")
* @ORM\Entity
*/
class TravelOption
{
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="internal_name", type="string", length=255, nullable=true)
*/
private $internalName;
/**
* @var float
*
* @ORM\Column(name="price", type="float", precision=10, scale=2, nullable=true)
*/
private $price;
/**
* @var float
*
* @ORM\Column(name="price_children", type="float", precision=10, scale=2, nullable=true)
*/
private $priceChildren;
/**
* @var string
*
* @ORM\Column(name="description", type="text", length=65535, nullable=true)
*/
private $description;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Set name
*
* @param string $name
*
* @return TravelOption
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set internalName
*
* @param string $internalName
*
* @return TravelOption
*/
public function setInternalName($internalName)
{
$this->internalName = $internalName;
return $this;
}
/**
* Get internalName
*
* @return string
*/
public function getInternalName()
{
return $this->internalName;
}
/**
* Set price
*
* @param float $price
*
* @return TravelOption
*/
public function setPrice($price)
{
$this->price = $price;
return $this;
}
/**
* Get price
*
* @return float
*/
public function getPrice()
{
return $this->price;
}
/**
* Set priceChildren
*
* @param float $priceChildren
*
* @return TravelOption
*/
public function setPriceChildren($priceChildren)
{
$this->priceChildren = $priceChildren;
return $this;
}
/**
* Get priceChildren
*
* @return float
*/
public function getPriceChildren()
{
return $this->priceChildren;
}
/**
* Set description
*
* @param string $description
*
* @return TravelOption
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
public function __toString()
{
return $this->getName();
}
}

View file

@ -0,0 +1,295 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelOrganizer
*
* @ORM\Table(name="travel_organizer")
* @ORM\Entity
*/
class TravelOrganizer
{
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="insolvency", type="string", length=255, nullable=true)
*/
private $insolvency;
/**
* @var string
*
* @ORM\Column(name="legal_rights", type="text", length=65535, nullable=false)
*/
private $legalRights;
/**
* @var \DateTime
*
* @ORM\Column(name="rules_updated", type="date", nullable=true)
*/
private $rulesUpdated;
/**
* @var string
*
* @ORM\Column(name="file_name", type="string", length=255, nullable=true)
*/
private $fileName;
/**
* @var string
*
* @ORM\Column(name="form_arb", type="string", length=255, nullable=true)
*/
private $formArb;
/**
* @var string
*
* @ORM\Column(name="file_form_page", type="string", length=255, nullable=true)
*/
private $fileFormPage;
/**
* @var integer
*
* @ORM\Column(name="cms_id", type="integer", nullable=true)
*/
private $cmsId;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Set name
*
* @param string $name
*
* @return TravelOrganizer
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set insolvency
*
* @param string $insolvency
*
* @return TravelOrganizer
*/
public function setInsolvency($insolvency)
{
$this->insolvency = $insolvency;
return $this;
}
/**
* Get insolvency
*
* @return string
*/
public function getInsolvency()
{
return $this->insolvency;
}
/**
* Set legalRights
*
* @param string $legalRights
*
* @return TravelOrganizer
*/
public function setLegalRights($legalRights)
{
$this->legalRights = $legalRights;
return $this;
}
/**
* Get legalRights
*
* @return string
*/
public function getLegalRights()
{
return $this->legalRights;
}
/**
* Set rulesUpdated
*
* @param \DateTime $rulesUpdated
*
* @return TravelOrganizer
*/
public function setRulesUpdated($rulesUpdated)
{
$this->rulesUpdated = $rulesUpdated;
return $this;
}
/**
* Get rulesUpdated
*
* @return \DateTime
*/
public function getRulesUpdated()
{
return $this->rulesUpdated;
}
public function getRulesUpdatedTime()
{
if($this->rulesUpdated){
return $this->rulesUpdated->getTimestamp();
}
return ;
}
/**
* Set fileName
*
* @param string $fileName
*
* @return TravelOrganizer
*/
public function setFileName($fileName)
{
$this->fileName = $fileName;
return $this;
}
/**
* Get fileName
*
* @return string
*/
public function getFileName()
{
return $this->fileName;
}
/**
* Set formArb
*
* @param string $formArb
*
* @return TravelOrganizer
*/
public function setFormArb($formArb)
{
$this->formArb = $formArb;
return $this;
}
/**
* Get formArb
*
* @return string
*/
public function getFormArb()
{
return $this->formArb;
}
/**
* Set fileFormPage
*
* @param string $fileFormPage
*
* @return TravelOrganizer
*/
public function setFileFormPage($fileFormPage)
{
$this->fileFormPage = $fileFormPage;
return $this;
}
/**
* Get fileFormPage
*
* @return string
*/
public function getFileFormPage()
{
return $this->fileFormPage;
}
/**
* Set cmsId
*
* @param integer $cmsId
*
* @return TravelOrganizer
*/
public function setCmsId($cmsId)
{
$this->cmsId = $cmsId;
return $this;
}
/**
* Get cmsId
*
* @return integer
*/
public function getCmsId()
{
return $this->cmsId;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
}

View file

@ -0,0 +1,487 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelPeriod
*
* @ORM\Table(name="travel_period", indexes={@ORM\Index(name="FK_travel_period_travel_program", columns={"program_id"}), @ORM\Index(name="FK_travel_period_travel_class", columns={"class"}), @ORM\Index(name="FK_travel_period_travel_arrival_point", columns={"travel_arrival_point_id"})})
* @ORM\Entity(repositoryClass="AppBundle\Entity\TravelPeriodRepository")
*/
class TravelPeriod
{
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @var boolean
*
* @ORM\Column(name="status", type="smallint", nullable=true)
*/
private $status;
/**
* @var integer
*
* @ORM\Column(name="order", type="integer", nullable=true)
*/
private $order;
/**
* @var float
*
* @ORM\Column(name="price_flight_net", type="float", precision=10, scale=2, nullable=false)
*/
private $priceFlightNet = '0.00';
/**
* @var boolean
*
* @ORM\Column(name="is_season", type="boolean", nullable=true)
*/
private $isSeason = '0';
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \AppBundle\Entity\TravelArrivalPoint
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelArrivalPoint")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="travel_arrival_point_id", referencedColumnName="id")
* })
*/
private $travelArrivalPoint;
/**
* @var \AppBundle\Entity\TravelClass
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelClass")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="class", referencedColumnName="id")
* })
*/
private $class;
/**
* @var \AppBundle\Entity\TravelProgram
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelProgram", inversedBy="periods")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="program_id", referencedColumnName="id")
* })
*/
private $program;
/**
* @ORM\OneToMany(targetEntity="AppBundle\Entity\TravelPeriodDate", mappedBy="period")
*/
private $dates;
/**
* @ORM\OneToMany(targetEntity="AppBundle\Entity\TravelDeparturePoint", mappedBy="travelPeriod")
*/
private $departures;
/**
* @ORM\OneToMany(targetEntity="AppBundle\Entity\TravelPeriodPrice", mappedBy="period", indexBy="priceType")
*/
private $prices;
/**
* @ORM\OneToMany(targetEntity="AppBundle\Entity\TravelDiscount", mappedBy="period")
*/
private $discounts;
/*
* @ ORM\OneToOne(targetEntity="AppBundle\Entity\FlightPeriod")
* @ ORM\JoinColumns({
* @ ORM\JoinColumn(name="")
* })
*/
//private $flightPeriod;
/**
* Set name
*
* @param string $name
*
* @return TravelPeriod
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set status
*
* @param integer $status
*
* @return TravelPeriod
*/
public function setStatus($status)
{
$this->status = $status;
return $this;
}
/**
* Get status
*
* @return integer
*/
public function getStatus()
{
return $this->status;
}
/**
* Set order
*
* @param integer $order
*
* @return TravelPeriod
*/
public function setOrder($order)
{
$this->order = $order;
return $this;
}
/**
* Get order
*
* @return integer
*/
public function getOrder()
{
return $this->order;
}
/**
* Set priceFlightNet
*
* @param float $priceFlightNet
*
* @return TravelPeriod
*/
public function setPriceFlightNet($priceFlightNet)
{
$this->priceFlightNet = $priceFlightNet;
return $this;
}
/**
* Get priceFlightNet
*
* @return float
*/
public function getPriceFlightNet()
{
return $this->priceFlightNet;
}
/**
* Set isSeason
*
* @param boolean $isSeason
*
* @return TravelPeriod
*/
public function setIsSeason($isSeason)
{
$this->isSeason = $isSeason;
return $this;
}
/**
* Get isSeason
*
* @return boolean
*/
public function getIsSeason()
{
return $this->isSeason;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set travelArrivalPoint
*
* @param \AppBundle\Entity\TravelArrivalPoint $travelArrivalPoint
*
* @return TravelPeriod
*/
public function setTravelArrivalPoint(\AppBundle\Entity\TravelArrivalPoint $travelArrivalPoint = null)
{
$this->travelArrivalPoint = $travelArrivalPoint;
return $this;
}
/**
* Get travelArrivalPoint
*
* @return \AppBundle\Entity\TravelArrivalPoint
*/
public function getTravelArrivalPoint()
{
return $this->travelArrivalPoint;
}
/**
* Set class
*
* @param \AppBundle\Entity\TravelClass $class
*
* @return TravelPeriod
*/
public function setClass(\AppBundle\Entity\TravelClass $class = null)
{
$this->class = $class;
return $this;
}
/**
* Get class
*
* @return \AppBundle\Entity\TravelClass
*/
public function getClass()
{
return $this->class;
}
/**
* Set program
*
* @param \AppBundle\Entity\TravelProgram $program
*
* @return TravelPeriod
*/
public function setProgram(\AppBundle\Entity\TravelProgram $program = null)
{
$this->program = $program;
return $this;
}
/**
* Get program
*
* @return \AppBundle\Entity\TravelProgram
*/
public function getProgram()
{
return $this->program;
}
/**
* Constructor
*/
public function __construct()
{
$this->dates = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add date
*
* @param \AppBundle\Entity\TravelPeriodDate $date
*
* @return TravelPeriod
*/
public function addDate(\AppBundle\Entity\TravelPeriodDate $date)
{
$this->dates[] = $date;
return $this;
}
/**
* Remove date
*
* @param \AppBundle\Entity\TravelPeriodDate $date
*/
public function removeDate(\AppBundle\Entity\TravelPeriodDate $date)
{
$this->dates->removeElement($date);
}
/**
* Get dates
*
* @return \Doctrine\Common\Collections\Collection|TravelPeriodDate[]
*/
public function getDates()
{
return $this->dates;
}
/**
* Add departure
*
* @param \AppBundle\Entity\TravelDeparturePoint $departure
*
* @return TravelPeriod
*/
public function addDeparture(\AppBundle\Entity\TravelDeparturePoint $departure)
{
$this->departures[] = $departure;
return $this;
}
/**
* Remove departure
*
* @param \AppBundle\Entity\TravelDeparturePoint $departure
*/
public function removeDeparture(\AppBundle\Entity\TravelDeparturePoint $departure)
{
$this->departures->removeElement($departure);
}
/**
* Get departures
*
* @return \Doctrine\Common\Collections\Collection|TravelDeparturePoint[]
*/
public function getDepartures()
{
return $this->departures;
}
/**
* Add price
*
* @param \AppBundle\Entity\TravelPeriodPrice $price
*
* @return TravelPeriod
*/
public function addPrice(\AppBundle\Entity\TravelPeriodPrice $price)
{
$this->prices[] = $price;
return $this;
}
/**
* Remove price
*
* @param \AppBundle\Entity\TravelPeriodPrice $price
*/
public function removePrice(\AppBundle\Entity\TravelPeriodPrice $price)
{
$this->prices->removeElement($price);
}
/**
* Get prices
*
* @return \Doctrine\Common\Collections\Collection|TravelPeriodPrice[]
*/
public function getPrices()
{
return $this->prices;
}
/**
* Add discount
*
* @param \AppBundle\Entity\TravelDiscount $discount
*
* @return TravelPeriod
*/
public function addDiscount(\AppBundle\Entity\TravelDiscount $discount)
{
$this->discounts[] = $discount;
return $this;
}
/**
* Remove discount
*
* @param \AppBundle\Entity\TravelDiscount $discount
*/
public function removeDiscount(\AppBundle\Entity\TravelDiscount $discount)
{
$this->discounts->removeElement($discount);
}
/**
* Get discounts
*
* @return \Doctrine\Common\Collections\Collection|TravelDiscount[]
*/
public function getDiscounts()
{
return $this->discounts;
}
/**
* @return \DateTime
* @throws \Exception
*/
public function getStartDate()
{
if ($this->isSeason)
{
throw new \Exception('Call to getStartDate() is only allowed for non-seasons');
}
return $this->getDates()->first()->getStartDate();
}
/**
* @return \DateTime
* @throws \Exception
*/
public function getEndDate()
{
if ($this->isSeason)
{
throw new \Exception('Call to getEndDate() is only allowed for non-seasons');
}
return $this->getDates()->first()->getEndDate();
}
}

View file

@ -0,0 +1,178 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelPeriodDate
*
* @ORM\Table(name="travel_period_date", indexes={@ORM\Index(name="FK_travel_period_date_travel_period", columns={"period_id"})})
* @ORM\Entity
*/
class TravelPeriodDate
{
/**
* @var integer
*
* @ORM\Column(name="year", type="integer", nullable=true)
*/
private $year;
/**
* @var \DateTime
*
* @ORM\Column(name="start_date", type="date", nullable=true)
*/
private $startDate;
/**
* @var \DateTime
*
* @ORM\Column(name="end_date", type="date", nullable=true)
*/
private $endDate;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \AppBundle\Entity\TravelPeriod
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelPeriod", inversedBy="dates")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="", referencedColumnName="")
* })
*/
private $period;
private $flightPeriod;
/**
* Set year
*
* @param integer $year
*
* @return TravelPeriodDate
*/
public function setYear($year)
{
$this->year = $year;
return $this;
}
/**
* Get year
*
* @return integer
*/
public function getYear()
{
return $this->year;
}
/**
* Set startDate
*
* @param \DateTime $startDate
*
* @return TravelPeriodDate
*/
public function setStartDate($startDate)
{
$this->startDate = $startDate;
return $this;
}
/**
* Get startDate
*
* @return \DateTime
*/
public function getStartDate()
{
return $this->startDate;
}
/**
* Set endDate
*
* @param \DateTime $endDate
*
* @return TravelPeriodDate
*/
public function setEndDate($endDate)
{
$this->endDate = $endDate;
return $this;
}
/**
* Get endDate
*
* @return \DateTime
*/
public function getEndDate()
{
return $this->endDate;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set period
*
* @param \AppBundle\Entity\TravelPeriod $period
*
* @return TravelPeriodDate
*/
public function setPeriod(\AppBundle\Entity\TravelPeriod $period = null)
{
$this->period = $period;
return $this;
}
/**
* Get period
*
* @return \AppBundle\Entity\TravelPeriod
*/
public function getPeriod()
{
return $this->period;
}
/**
* @return mixed
*/
public function getFlightPeriod()
{
return $this->flightPeriod;
}
/**
* @param mixed $flightPeriod
*/
public function setFlightPeriod($flightPeriod)
{
$this->flightPeriod = $flightPeriod;
}
}

View file

@ -0,0 +1,558 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelPeriodPrice
*
* @ORM\Table(name="travel_period_price", uniqueConstraints={@ORM\UniqueConstraint(name="UK_price_type_period_id", columns={"price_type", "period_id"})}, indexes={@ORM\Index(name="FK_travel_period_price_travel_period", columns={"period_id"})})
* @ORM\Entity
*/
class TravelPeriodPrice
{
/**
* @var float
*
* @ORM\Column(name="price_children", type="float", precision=10, scale=2, nullable=true)
*/
private $priceChildren;
/**
* @var float
*
* @ORM\Column(name="price_net", type="float", precision=10, scale=2, nullable=false)
*/
private $price = '0.00';
/**
* @var float
*
* @ORM\Column(name="price_comfort_net", type="float", precision=10, scale=2, nullable=false)
*/
private $priceComfort = '0.00';
/**
* @var float
*
* @ORM\Column(name="extra_price_children", type="float", precision=10, scale=2, nullable=true)
*/
private $extraPriceChildren;
/**
* @var float
*
* @ORM\Column(name="extra_price_net", type="float", precision=10, scale=2, nullable=false)
*/
private $extraPrice = '0.00';
/**
* @var float
*
* @ORM\Column(name="extra_price_comfort_net", type="float", precision=10, scale=2, nullable=false)
*/
private $extraPriceComfort = '0.00';
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \AppBundle\Entity\TravelPeriod
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelPeriod", inversedBy="prices")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="period_id", referencedColumnName="id")
* })
*/
private $period;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelPeriodPriceType")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="price_type", referencedColumnName="id")
* })
*/
private $priceType;
/**
* @ORM\Column(type="integer", nullable=false, name="price_type")
*/
private $priceTypeId;
private $effectivePrice = null;
private $effectiveChildPrice = null;
private $effectiveComfortPrice = null;
private $effectiveExtraPrice = null;
private $effectiveExtraChildPrice = null;
private $effectiveExtraComfortPrice = null;
/**
* @ORM\Column(name="available", type="integer", nullable=false)
*/
private $available;
/**
* Set priceType
*
* @param integer $priceType
*
* @return TravelPeriodPrice
*/
public function setPriceType($priceType)
{
$this->priceType = $priceType;
return $this;
}
/**
* Get priceType
*
* @return integer
*/
public function getPriceType()
{
return $this->priceType;
}
/**
* Set available
*
* @param integer $available
*
* @return TravelPeriodPrice
*/
public function setAvailable($available)
{
$this->available = $available;
return $this;
}
/**
* Get available
*
* @return integer
*/
public function getAvailable()
{
return $this->available;
}
/**
* Set priceChildren
*
* @param float $priceChildren
*
* @return TravelPeriodPrice
*/
public function setPriceChildren($priceChildren)
{
$this->priceChildren = $priceChildren;
return $this;
}
/**
* Get priceChildren
*
* @return float
*/
public function getPriceChildren()
{
return $this->priceChildren;
}
/**
* Set price
*
* @param float $price
*
* @return TravelPeriodPrice
*/
public function setPrice($price)
{
$this->price = $price;
return $this;
}
/**
* Get price
*
* @return float
*/
public function getPrice()
{
return $this->price;
}
/**
* Set priceComfort
*
* @param float $priceComfort
*
* @return TravelPeriodPrice
*/
public function setPriceComfort($priceComfort)
{
$this->priceComfort = $priceComfort;
return $this;
}
/**
* Get priceComfort
*
* @return float
*/
public function getPriceComfort()
{
return $this->priceComfort;
}
/**
* Set extraPriceChildren
*
* @param float $extraPriceChildren
*
* @return TravelPeriodPrice
*/
public function setExtraPriceChildren($extraPriceChildren)
{
$this->extraPriceChildren = $extraPriceChildren;
return $this;
}
/**
* Get extraPriceChildren
*
* @return float
*/
public function getExtraPriceChildren()
{
return $this->extraPriceChildren;
}
/**
* Set extraPrice
*
* @param float $extraPrice
*
* @return TravelPeriodPrice
*/
public function setExtraPrice($extraPrice)
{
$this->extraPrice = $extraPrice;
return $this;
}
/**
* Get extraPrice
*
* @return float
*/
public function getExtraPrice()
{
return $this->extraPrice;
}
/**
* Set extraPriceComfort
*
* @param float $extraPriceComfort
*
* @return TravelPeriodPrice
*/
public function setExtraPriceComfort($extraPriceComfort)
{
$this->extraPriceComfort = $extraPriceComfort;
return $this;
}
/**
* Get extraPriceComfort
*
* @return float
*/
public function getExtraPriceComfort()
{
return $this->extraPriceComfort;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set period
*
* @param \AppBundle\Entity\TravelPeriod $period
*
* @return TravelPeriodPrice
*/
public function setPeriod(\AppBundle\Entity\TravelPeriod $period = null)
{
$this->period = $period;
return $this;
}
/**
* Get period
*
* @return \AppBundle\Entity\TravelPeriod
*/
public function getPeriod()
{
return $this->period;
}
/**
* Set priceTypeId
*
* @param integer $priceTypeId
*
* @return TravelPeriodPrice
*/
public function setPriceTypeId($priceTypeId)
{
$this->priceTypeId = $priceTypeId;
return $this;
}
/**
* Get priceTypeId
*
* @return integer
*/
public function getPriceTypeId()
{
return $this->priceTypeId;
}
/**
* @return float
* @throws \Exception
*/
public function getEffectivePrice()
{
if ($this->effectivePrice === null)
{
throw new \Exception('Effective price must be set from outside before reading it.');
}
return $this->effectivePrice;
}
/**
* @param float $effectivePrice
*/
public function setEffectivePrice($effectivePrice)
{
$this->effectivePrice = $effectivePrice;
}
/**
* @return float
* @throws \Exception
*/
public function getEffectiveExtraPrice()
{
if ($this->effectiveExtraPrice === null)
{
throw new \Exception('EffectiveExtra price must be set from outside before reading it.');
}
return $this->effectiveExtraPrice;
}
/**
* @param float $effectiveExtraPrice
*/
public function setEffectiveExtraPrice($effectiveExtraPrice)
{
$this->effectiveExtraPrice = $effectiveExtraPrice;
}
/**
* Probably getEffectiveDiscountPrice() is the method you are actually looking for.
* @return float|null
*/
public function getDiscountPrice()
{
return $this->calculateDiscountPrice($this->price);
}
/**
* Probably getEffectiveDiscountPrice() is the method you are actually looking for.
* @return float|null
*/
public function getChildDiscountPrice()
{
return $this->calculateDiscountPrice($this->priceChildren);
}
/**
* @return float
* @throws \Exception
*/
public function getEffectiveDiscountPrice()
{
if ($this->effectivePrice === null)
{
throw new \Exception('Effective price must be set from outside before reading effective discount price.');
}
return $this->calculateDiscountPrice($this->effectivePrice);
}
/**
* @return float
* @throws \Exception
*/
public function getEffectiveChildDiscountPrice()
{
if ($this->effectiveChildPrice === null)
{
throw new \Exception('Effective price must be set from outside before reading effective discount price.');
}
return $this->calculateDiscountPrice($this->effectiveChildPrice);
}
/**
* @return float
* @throws \Exception
*
* @todo The child price will not be set yet. This is just a preparation for later
*/
public function getEffectiveChildPrice()
{
if ($this->effectiveChildPrice === null)
{
throw new \Exception('Effective child price must be set from outside before reading it.');
}
return $this->effectiveChildPrice;
}
/**
* @param null $effectiveChildPrice
*/
public function setEffectiveChildPrice($effectiveChildPrice)
{
$this->effectiveChildPrice = $effectiveChildPrice;
}
/**
* @return float
* @throws \Exception
*
* @todo The child price will not be set yet. This is just a preparation for later
*/
public function getEffectiveExtraChildPrice()
{
if ($this->effectiveExtraChildPrice === null)
{
throw new \Exception('Effective Extra child price must be set from outside before reading it.');
}
return $this->effectiveExtraChildPrice;
}
/**
* @param null $effectiveChildPrice
*/
public function setEffectiveExtraChildPrice($effectiveExtraChildPrice)
{
$this->effectiveExtraChildPrice = $effectiveExtraChildPrice;
}
/**
* @return float|null
* @throws \Exception
*/
public function getEffectiveComfortPrice()
{
if ($this->effectiveComfortPrice === null)
{
throw new \Exception('Effective comfort price must be set from outside before reading it.');
}
return $this->effectiveComfortPrice;
}
/**
* @param float|null $effectiveComfortPrice
*/
public function setEffectiveComfortPrice($effectiveComfortPrice)
{
$this->effectiveComfortPrice = $effectiveComfortPrice;
}
/**
* @return float|null
* @throws \Exception
*/
public function getEffectiveExtraComfortPrice()
{
if ($this->effectiveExtraComfortPrice === null)
{
throw new \Exception('Effective Extra comfort price must be set from outside before reading it.');
}
return $this->effectiveExtraComfortPrice;
}
/**
* @param float|null $effectiveExtraComfortPrice
*/
public function setEffectiveExtraComfortPrice($effectiveExtraComfortPrice)
{
$this->effectiveExtraComfortPrice = $effectiveExtraComfortPrice;
}
private function calculateDiscountPrice($price)
{
if ($this->getPeriod() == null)
{
return null;
}
$newPrice = $price;
foreach ($this->getPeriod()->getDiscounts() as $discount)
{
$newPrice -= $discount->getPercent()
? round($newPrice * $discount->getValue() / 100, 2) // #TODO FIXME
: $discount->getValue();
}
$program = $this->getPeriod()->getProgram();
if ($program != null && $program->getDiscount() != null)
{
$newPrice -= $program->getDiscountIsPercentValue()
? round($price * $program->getDiscount() / 100, 2) // #TODO FIXME
: $program->getDiscount();
}
return $price == $newPrice ? null : $newPrice;
}
}

View file

@ -0,0 +1,252 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelPeriodPriceType
*
* @ORM\Table(name="travel_period_price_type")
* @ORM\Entity(repositoryClass="AppBundle\Entity\TravelPeriodPriceTypeRepository")
*/
class TravelPeriodPriceType
{
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="internal_name", type="string", length=255, nullable=true)
*/
private $internalName;
/**
* @var string
*
* @ORM\Column(name="short", type="string", length=255, nullable=true)
*/
private $short;
/**
* @var integer
*
* @ORM\Column(name="max", type="integer", nullable=true)
*/
private $max;
/**
* @var integer
*
* @ORM\Column(name="min_adults", type="integer", nullable=true)
*/
private $minAdults;
/**
* @var integer
*
* @ORM\Column(name="max_adults", type="integer", nullable=true)
*/
private $maxAdults;
/**
* @var integer
*
* @ORM\Column(name="max_children", type="integer", nullable=true)
*/
private $maxChildren;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Set name
*
* @param string $name
*
* @return TravelPeriodPriceType
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set internalName
*
* @param string $internalName
*
* @return TravelPeriodPriceType
*/
public function setInternalName($internalName)
{
$this->internalName = $internalName;
return $this;
}
/**
* Get internalName
*
* @return string
*/
public function getInternalName()
{
return $this->internalName;
}
/**
* Set short
*
* @param string $short
*
* @return TravelPeriodPriceType
*/
public function setShort($short)
{
$this->short = $short;
return $this;
}
/**
* Get short
*
* @return string
*/
public function getShort()
{
return $this->short;
}
/**
* Set max
*
* @param integer $max
*
* @return TravelPeriodPriceType
*/
public function setMax($max)
{
$this->max = $max;
return $this;
}
/**
* Get max
*
* @return integer
*/
public function getMax()
{
return $this->max;
}
/**
* Set minAdults
*
* @param integer $minAdults
*
* @return TravelPeriodPriceType
*/
public function setMinAdults($minAdults)
{
$this->minAdults = $minAdults;
return $this;
}
/**
* Get minAdults
*
* @return integer
*/
public function getMinAdults()
{
return $this->minAdults;
}
/**
* Set maxAdults
*
* @param integer $maxAdults
*
* @return TravelPeriodPriceType
*/
public function setMaxAdults($maxAdults)
{
$this->maxAdults = $maxAdults;
return $this;
}
/**
* Get maxAdults
*
* @return integer
*/
public function getMaxAdults()
{
return $this->maxAdults;
}
/**
* Set maxChildren
*
* @param integer $maxChildren
*
* @return TravelPeriodPriceType
*/
public function setMaxChildren($maxChildren)
{
$this->maxChildren = $maxChildren;
return $this;
}
/**
* Get maxChildren
*
* @return integer
*/
public function getMaxChildren()
{
return $this->maxChildren;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
}

View file

@ -0,0 +1,20 @@
<?php
namespace AppBundle\Entity;
/**
* TravelPeriodPriceTypeRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class TravelPeriodPriceTypeRepository extends \Doctrine\ORM\EntityRepository
{
/**
* @return TravelPeriodPriceType[]
*/
public function findAllIndexedById()
{
return $this->createQueryBuilder('p', 'p.id')->select('p')->getQuery()->execute();
}
}

View file

@ -0,0 +1,514 @@
<?php
namespace AppBundle\Entity;
use AppBundle\Util;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\PersistentCollection;
use Doctrine\ORM\Query\Expr;
class TravelPeriodRepository extends \Doctrine\ORM\EntityRepository
{
private $departureRepository;
function __construct(EntityManager $em, ClassMetadata $class)
{
parent::__construct($em, $class);
$this->departureRepository = $this->getEntityManager()->getRepository('AppBundle:TravelDeparturePoint');
}
/**
* @param \DateTime $startDate
* @param \DateTime $endDate
* @param null $destinationIds
* @param bool $combi
*
* @return TravelProgram[]|array
* @throws \Exception
* @internal param null $destination
*/
public function getTravelProgramsWithTravelDatesForTimePeriod($startDate, $endDate, $destinationIds = null,
$combi = false)
{
// Idea for natural sort problem:
// Add new column sortable_name
$now = new \DateTime();
if ($startDate < $now)
{
$startDate = $now;
}
$startDateStr = $startDate->format('Y-m-d');
if ($endDate)
{
$endDateStr = $endDate->format('Y-m-d');
}
$qb = $this->getEntityManager()->createQueryBuilder()
->from('AppBundle:TravelProgram', 'tp', 'tp.id')
->addSelect('tp')
->where('tp.status > 0');
// Limit time period for seasons and travel dates
$qb->innerJoin('tp.periods', 'p');
$qb->addSelect('p');
$qb->innerJoin('p.dates', 'd');
$qb->addSelect('d');
$qb->andWhere("((p.isSeason = 0 AND d.startDate >= '$startDateStr' AND d.endDate <= '$endDateStr') OR".
" (p.isSeason = 1 AND d.endDate >= '$startDateStr' AND".
" DATE_ADD(d.startDate, tp.programDuration, 'DAY') <= '$endDateStr' AND p.status > 0))");
// Prices
// Instead of a single join to prices we add one join per price type. This reduces the execution time by
// 150ms on the development system
$priceTypes = $this->getEntityManager()->getRepository('AppBundle:TravelPeriodPriceType')->findAll();
foreach ($priceTypes as $priceType)
{
$priceTypeKey = 'price_'. $priceType->getId();
$qb->leftJoin('p.prices', $priceTypeKey, Expr\Join::WITH,
$priceTypeKey .'.priceType = '. $priceType->getId(), $priceTypeKey .'.priceTypeId');
$qb->addSelect($priceTypeKey);
}
$qb->leftJoin('p.discounts', 'discount');
$qb->addSelect('discount');
$qb->leftJoin('p.departures', 'p_dep', Expr\Join::WITH, 'tp.programType = '.
TravelProgram::MEDIATED_PROGRAM_TYPE);
$qb->addSelect('p_dep');
// Destinations
if (!empty($destinationIds) && is_array($destinationIds))
{
//$qb->innerJoin('AppBundle:TravelProgramCountry', 'tpc', Expr\Join::WITH,
// 'tpc.program = tp AND IDENTITY(tpc.country) IN ('. implode(', ', $destinationIds) .')');
$qb->innerJoin('tp.countries', 'tc', Expr\Join::WITH,
'tc.id IN ('. implode(', ', $destinationIds) .')');
if ($combi)
{
//$qb->having('COUNT(DISTINCT tpc.country) = '. count($destinationIds));
$qb->having('COUNT(DISTINCT tc) = '. count($destinationIds));
}
}
// TODO $qb->groupBy('p.id, p_dep.id, d.id');
// $qb->groupBy('p.id');
// Travel class
$qb->innerJoin('p.class', 'cls', Expr\Join::WITH, 'cls.standard = 1');
// Image
$qb->leftJoin('tp.images', 'tp_image', Expr\Join::WITH, 'tp_image.type = 2')
->addSelect('tp_image');
// Sort travel programs
// $qb->addSelect('COALESCE(tp.position, 0) as HIDDEN position_sort_key');
// $qb->orderBy('position_sort_key');
//$qb->addOrderBy('LENGTH(tp.title)'); // Emulate natural sort
$qb->addOrderBy('tp.title');
$qb->addOrderBy('tp.id');
// Sort: Real travel dates have higher priority than virtual travel dates. Sort travel programs
$qb->addOrderBy('p.isSeason, p.id');
/** @var TravelProgram[]|array $travelPrograms */
$travelPrograms = $qb->getQuery()->getResult();
if (empty($travelPrograms))
{
return $travelPrograms;
}
// Collect arrival point IDs for non mediated travel programs
$isUsedArrivalPointById = [];
foreach ($travelPrograms as $travelProgram)
{
$isUsedTravelProgramById[$travelProgram->getId()] = true;
if (!$travelProgram->getIsMediated())
{
$isUsedArrivalPointById[$travelProgram->getTravelArrivalPoint()->getId()] = true;
}
}
$usedArrivalPointIds = array_keys($isUsedArrivalPointById);
// Find flight periods and related departures
$flightPeriods = empty($isUsedArrivalPointById) ? []
: $this->getEntityManager()->getRepository('AppBundle:FlightPeriod')
->getIndexedFlightPeriodsForTimePeriod($startDate, $endDate, $usedArrivalPointIds);
// Find default departures and classify by-program or by-arrival-point
// We could've simply left joined them to get an equal result. But we're reducing the number of rows returned
// in the first travel program query above drastically with this solution. This doesn't hurt performance.
// Of course, we have to link departures of travel programs manually later.
$defDepsByArrivalPointId = [];
$qb = $this->getEntityManager()->createQueryBuilder()
->from('AppBundle:TravelDeparturePoint', 'dep')
->addSelect('dep')
->where($qb->expr()->in('IDENTITY(dep.program)', array_keys($travelPrograms)));
if (!empty($isUsedArrivalPointById))
{
$qb->orWhere($qb->expr()->in('IDENTITY(dep.travelArrivalPoint)', $usedArrivalPointIds));
}
/** @var TravelDeparturePoint[]|array $defaultDepartures */
$defaultDepartures = $qb->getQuery()->execute();
foreach ($defaultDepartures as $defaultDeparture)
{
if ($defaultDeparture->getProgram())
{
$travelProgram = $travelPrograms[$defaultDeparture->getProgram()->getId()];
if ($travelProgram->getDepartures() instanceof PersistentCollection)
{
Util::reAttachRelatedCollection($travelProgram, 'departures', $travelProgram->getDepartures()->unwrap());
}
$travelProgram->addDeparture($defaultDeparture);
}
elseif ($defaultDeparture->getTravelArrivalPoint())
{
if (!isset($defDepsByArrivalPointId[$defaultDeparture->getTravelArrivalPoint()->getId()]))
{
$defDepsByArrivalPointId[$defaultDeparture->getTravelArrivalPoint()->getId()] = [];
}
$defDepsByArrivalPointId[$defaultDeparture->getTravelArrivalPoint()->getId()][] = $defaultDeparture;
}
}
foreach ($travelPrograms as $k => $travelProgram)
{
$flightPeriod = null;
if (!$travelProgram->getIsMediated())
{
$arrivalPointId = $travelProgram->getTravelArrivalPoint()->getId();
// Manually link separately fetched default departures
$travelProgram->getTravelArrivalPoint()->__setDepartures(
isset($defDepsByArrivalPointId[$arrivalPointId])
? $defDepsByArrivalPointId[$arrivalPointId]
: []
);
}
$this->addTravelDatesToProgram($travelProgram, $travelProgram->getPeriods(), $flightPeriods,
$startDate, $endDate);
if (!$travelProgram->hasTravelDates())
{
unset($travelPrograms[$k]);
}
}
return $travelPrograms;
}
private function createTravelDateKey(\DateTime $startDate, \DateTime $endDate)
{
return $startDate->format('Y-m-d') . $endDate->format('Y-m-d');
}
const TD_QUERY_NON_VIRTUAL = 0x1;
const TD_QUERY_VIRTUAL = 0x2;
const TD_QUERY_INACTIVE = 0x4;
const TD_QUERY_OUTDATED = 0x8;
const TD_QUERY_ACP = self::TD_QUERY_INACTIVE | self::TD_QUERY_OUTDATED;
const TD_QUERY_VIRTUAL_AND_NON_VIRTUAL = self::TD_QUERY_VIRTUAL | self::TD_QUERY_NON_VIRTUAL;
/**
* @param TravelProgram $program
* @param bool $class
* @param int $flags
*
* @return TravelDate[]|array
* @todo Find a more appropriate name for this method
*/
public function getTrueTravelPeriods(TravelProgram $program, $class = false, $flags =
self::TD_QUERY_VIRTUAL_AND_NON_VIRTUAL)
{
if (!($flags & self::TD_QUERY_VIRTUAL_AND_NON_VIRTUAL))
{
return [];
}
$doQueryVirtualAndNonVirtual = $flags & self::TD_QUERY_VIRTUAL_AND_NON_VIRTUAL ==
self::TD_QUERY_VIRTUAL_AND_NON_VIRTUAL;
/** @var TravelPeriod[] $periods */
$qb = $this->createQueryBuilder('p');
$qb
//->from('AppBundle:TravelPeriod', 'tpp', 'key')
->leftJoin('p.dates', 'd')->addSelect('d')
->leftJoin('p.prices', 'price', null, null, 'price.priceTypeId')
//->innerJoin('price.priceType', 'price_type_')
->addSelect('price')
->leftJoin('p.discounts', 'discount', Expr\Join::WITH,
'discount.start <= CURRENT_TIMESTAMP() AND discount.end >= CURRENT_TIMESTAMP()')->addSelect('discount')
->where('IDENTITY(p.program) = '. $program->getId())
;
if ($program->getIsMediated())
{
// Only mediated travel programs define departures in travelPeriods
$qb->leftJoin('p.departures', 'p_dep')->addSelect('p_dep');
}
elseif (!($flags & self::TD_QUERY_VIRTUAL))
{
// Retrieving all flight periods by join is only possible, if virtual entries are excluded
$qb->leftJoin('AppBundle:FlightPeriod', 'fp', Expr\Join::WITH, 'IDENTITY(fp.travelArrivalPoint) = '.
':travelArrivalPointId AND d.startDate = fp.startDate AND d.endDate = fp.endDate');
$qb->setParameter('travelArrivalPointId', $program->getTravelArrivalPoint()->getId());
$qb->addSelect('fp');
$qb->leftJoin('fp.departures', 'fp_dep')->addSelect('fp_dep');
}
$startDate = null;
if (!($flags & self::TD_QUERY_OUTDATED))
{
$startDate = new \DateTime('tomorrow');
}
if ($class)
{
$qb->andWhere($qb->expr()->eq('IDENTITY(tpp.class)', $class));
}
if ($doQueryVirtualAndNonVirtual)
{
$qb->addOrderBy('p.isSeason');
}
else
{
$qb->andWhere($qb->expr()->eq('p.isSeason', $flags & self::TD_QUERY_VIRTUAL));
if(!($flags & self::TD_QUERY_INACTIVE))
{
// If both, non virtual and virtual entries are selected, we cannot exclude inactive entries, because
// there may be a non virtual travel date with inactive status and a matching virtual travel date with
// active status. In this case, the inactive status would get lost and the virtual travel date would
// wrongly be included in the result. Therefore we are removing inactive travel dates later in the
// TD_QUERY_VIRTUAL_AND_NON_VIRTUAL case.
$qb->andWhere($qb->expr()->gt('tpp.status', 0));
}
}
$qb
->addOrderBy('p.order', 'ASC')
->addOrderBy('d.startDate', 'ASC')
->addOrderBy('p.name', 'ASC')
;
$entities = $qb->getQuery()->execute();
$flightPeriodByKey = null;
if (!$program->getIsMediated())
{
if (!$program->getTravelArrivalPoint())
{
return [];
}
if ($flags & self::TD_QUERY_VIRTUAL)
{
// If virtual entries are included, we have to fetch all flight periods, because we don't know
// the actual dates yet
$flightPeriodByKey = $this->getEntityManager()->getRepository('AppBundle:FlightPeriod')
->getIndexedFlightPeriodsForTimePeriod($startDate, null, $program->getTravelArrivalPoint()->getId());
}
foreach ($entities as $key => $entity)
{
if ($entity == null)
{
unset($entities[$key]);
}
else if ($entity instanceof FlightPeriod)
{
// We are joining to flight period with multiple keys. Doctrine cannot handle this and returns a
// mixed list containing both, travel and flight periods at the same level. We fix that here.
$flightPeriodByKey[$entity->getStartDate()->format('Y-m-d') .'_'.
$entity->getEndDate()->format('Y-m-d')] = $entity;
unset($entities[$key]);
}
}
/** @var TravelPeriod $period */
foreach ($entities as &$period)
{
foreach ($period->getDates() as &$date)
{
$fpKey = $date->getStartDate()->format('Y-m-d') . $date->getEndDate()->format('Y-m-d') .
$program->getTravelArrivalPoint()->getId();
if (isset($flightPeriodByKey[$fpKey]))
{
// #TODO Does this cause performance problems?
$date->setFlightPeriod($flightPeriodByKey[$fpKey]);
}
}
}
}
$this->addTravelDatesToProgram($program, $entities, $flightPeriodByKey, $startDate, null);
return $program->getTravelDates();
}
private $currencyFactor = null;
public function getCurrencyFactor()
{
if ($this->currencyFactor == null)
{
// #TODO Enable doctrine 2nd level cache instead of implementing own caching mechanism
$dollar = $this->getEntityManager()->getRepository('AppBundle:TravelSetting')->findOneBy(['key' => 'dollar']);
if (!$dollar)
{
throw new \Exception('Missing currency factor setting "dollar" in table travel_setting');
}
$this->currencyFactor = $dollar->getValue() ?? 1;
}
return $this->currencyFactor;
}
/**
* @param TravelProgram $travelProgram
* @param array|TravelPeriod[] $travelPeriods Represent seasons and travel dates
* @param array|FlightPeriod[] $flightPeriods For performance reasons, $flightPeriods must be pre-fetched
* @param \DateTime|null $startDate If not null, only add travel dates later than this value
* @param \DateTime|null $endDate If not null, only add travel dates earlier than this value
*
* @throws \Exception
*/
public function addTravelDatesToProgram(TravelProgram &$travelProgram, $travelPeriods, $flightPeriods,
\DateTime $startDate = null, \DateTime $endDate = null)
{
$currencyFactor = $travelProgram->getNettoPricesInEuro() ? 1 : $this->getCurrencyFactor();
$counters = array();
// #TODO Consider adding travelPeriods to travelProgram in the search algorithm
//foreach ($travelProgram->getPeriods() as $travelPeriod)
foreach ($travelPeriods as $travelPeriod)
{
if ($travelPeriod->getIsSeason())
{
foreach ($travelPeriod->getDates() as $travelPeriodDate)
{
$cn = $travelPeriodDate->getId().$travelPeriod->getName();
if(empty($counters[$cn])){
$counters[$cn] = 1;
}
$seasonEndDate = clone $travelPeriodDate->getEndDate();
$seasonEndDate->modify('+'.$travelProgram->getProgramDuration().' day');
if ($endDate != null && $seasonEndDate > $endDate)
{
// Limit end date to requested latest travel end date
$seasonEndDate = clone $endDate;
}
// Subtract temporarily added days which were added above. (Also subtract if date was limited!)
// Add one day to include season end date in $dates array below (would be excluded otherwise)
$seasonEndDate->modify('-'. ($travelProgram->getProgramDuration() - 1) .' day');
$dates = new \DatePeriod($travelPeriodDate->getStartDate(),
\DateInterval::createFromDateString('1 day'), $seasonEndDate);
$doTestStartDate = $startDate != null;
/** @var \DateTime $date */
foreach ($dates as $date)
{
$isPossibleDate = $travelProgram->getIsAvailWeekday($date->format('w'));
// $doTestStartDate helps to improve performance by avoiding unnecessary (more expensive)
// "$date < $startDate" checks: As soon as $date >= $startDate the first time, it will stay
// this way until the foreach iteration has finished.
if (!($doTestStartDate && $date < $startDate))
{
$doTestStartDate = false;
if ($isPossibleDate)
{
// #TODO Do we need the travel date key?
$travelDateEnd = (clone $date)->modify('+'.$travelProgram->getProgramDuration().' day');
$travelDateKey = $this->createTravelDateKey($date, $travelDateEnd);
if (!$travelProgram->hasTravelDate($travelDateKey))
{
$flightPeriod = null;
if (!$travelProgram->getIsMediated())
{
$flightPeriodKey = $travelDateKey .
$travelProgram->getTravelArrivalPoint()->getId();
$flightPeriod = $flightPeriods[$flightPeriodKey] ?? null;
}
$travelProgram->addTravelDateFromSeasonTravelPeriod(
$travelDateKey,
$travelPeriod,
$travelPeriodDate->getId() . $travelPeriod->getName() . $counters[$cn],
$date,
$travelDateEnd,
$flightPeriod,
$currencyFactor
);
}
}
}
// Also increment $i if the date is theoretically possible but excluded from the search request
if ($isPossibleDate)
{
++ $counters[$cn];
}
}
}
}
elseif (count($travelPeriod->getDates()) && $travelProgram->getIsPossibleStartDate($travelPeriod->getStartDate()))
{
$travelDateKey = $this->createTravelDateKey($travelPeriod->getStartDate(), $travelPeriod->getEndDate());
$flightPeriod = null;
if (!$travelProgram->getIsMediated())
{
$flightPeriod = $flightPeriods[$travelDateKey . $travelProgram->getTravelArrivalPoint()->getId()]
?? null;
}
// #TODO There is an error in the old backend which causes duplicates
if ($travelProgram->hasTravelDate($travelDateKey) &&
$travelProgram->getTravelDate($travelDateKey)->__getTravelPeriod()->getId() != $travelPeriod->getId())
{
global $kernel;
if($kernel instanceOf \AppCache) $kernel = $kernel->getKernel();
$kernel->getContainer()->get('logger')->warn('Duplicate travel period found with name "'.
$travelPeriod->getName() .'"');
}
else
{
$TravelDate = $travelProgram->addTravelDateFromNonSeasonTravelPeriod($travelDateKey, $travelPeriod, $flightPeriod,
$currencyFactor);
}
}
}
}
/**
* "Default departures" are taken if a travel period date has no departure itself. For mediated travel programs
* default departures are defined at travel program level. For self-organized travel programs they are defined
* at travel-arrival-point (airport) level.
*
* @param TravelProgram $program
* @param bool $acp
*
* @return TravelDeparturePoint[]|array|\Doctrine\Common\Collections\Collection|mixed
*/
public function getDefaultDeparturesByProgram(TravelProgram $program, $acp = false)
{
if ($program->getIsMediated())
{
return $program->getDepartures();
}
if ($program->getTravelArrivalPoint() == null)
{
return [];
}
$defaultDepartures = $program->getTravelArrivalPoint()->getDepartures();
if (!$acp)
{
$defaultDepartures = $this->departureRepository->limitIndividualArrivalPriceInDepartures(
$defaultDepartures, $program->getDefaultFlightPrice());
}
return $defaultDepartures;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,103 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelProgramDrafts
*
* @ORM\Table(name="travel_program_drafts", indexes={@ORM\Index(name="travel_program_drafts_ibfk_1", columns={"travel_program_id"})})
* @ORM\Entity
*/
class TravelProgramDrafts
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="weekdays", type="string", length=255, nullable=true)
*/
private $weekdays;
/**
* @var \AppBundle\Entity\TravelProgram
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelProgram", inversedBy="drafts")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="travel_program_id", referencedColumnName="id")
* })
*/
private $program;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set program
*
* @param \AppBundle\Entity\TravelProgram $program
*
* @return TravelProgramDrafts
*/
public function setProgram(\AppBundle\Entity\TravelProgram $program = null)
{
$this->program = $program;
return $this;
}
/**
* Get program
*
* @return \AppBundle\Entity\TravelProgram
*/
public function getProgram()
{
return $this->program;
}
/**
* Set weekdays
*
* @param string TravelProgramDrafts
*
* @return TravelProgramDrafts
*/
public function setWeekdays($weekdays)
{
$this->weekdays = $weekdays;
return $this;
}
/**
* Get weekdays
*
* @return string
*/
public function getWeekdays()
{
return $this->weekdays;
}
}

View file

@ -0,0 +1,235 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelProgramImage
*
* @ORM\Table(name="travel_program_image", indexes={@ORM\Index(name="FK_travel_program_image_travel_program", columns={"program_id"})})
* @ORM\Entity
*/
class TravelProgramImage
{
/**
* @var string
*
* @ORM\Column(name="file_name", type="string", length=255, nullable=true)
*/
private $fileName;
/**
* @var string
*
* @ORM\Column(name="extension", type="string", length=255, nullable=true)
*/
private $extension;
/**
* @var string
*
* @ORM\Column(name="description", type="string", length=255, nullable=true)
*/
private $description;
/**
* @var boolean
*
* @ORM\Column(name="type", type="boolean", nullable=true)
*/
private $type;
/**
* @var string
*
* @ORM\Column(name="position", type="string", length=10, nullable=true)
*/
private $position;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \AppBundle\Entity\TravelProgram
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelProgram", inversedBy="images")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="program_id", referencedColumnName="id")
* })
*/
private $program;
/**
* Set fileName
*
* @param string $fileName
*
* @return TravelProgramImage
*/
public function setFileName($fileName)
{
$this->fileName = $fileName;
return $this;
}
/**
* Get fileName
*
* @return string
*/
public function getFileName()
{
return $this->fileName;
}
/**
* Set extension
*
* @param string $extension
*
* @return TravelProgramImage
*/
public function setExtension($extension)
{
$this->extension = $extension;
return $this;
}
/**
* Get extension
*
* @return string
*/
public function getExtension()
{
return $this->extension;
}
/**
* Set description
*
* @param string $description
*
* @return TravelProgramImage
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set type
*
* @param boolean $type
*
* @return TravelProgramImage
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Get type
*
* @return boolean
*/
public function getType()
{
return $this->type;
}
/**
* Set type
*
* @param string $position
*
* @return TravelProgramImage
*/
public function setPosition($position)
{
$this->position = $position;
return $this;
}
/**
* Get position
*
* @return string
*/
public function getPosition()
{
if(!$this->position){
return 'bottom';
}
return $this->position;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set program
*
* @param \AppBundle\Entity\TravelProgram $program
*
* @return TravelProgramImage
*/
public function setProgram(\AppBundle\Entity\TravelProgram $program = null)
{
$this->program = $program;
return $this;
}
/**
* Get program
*
* @return \AppBundle\Entity\TravelProgram
*/
public function getProgram()
{
return $this->program;
}
public function getFileNameWithExtension()
{
return $this->getFileName() . $this->getExtension();
}
}

View file

@ -0,0 +1,37 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Query\Expr;
/**
* TravelProgramRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class TravelProgramRepository extends \Doctrine\ORM\EntityRepository
{
/**
* @return TravelProgram[]
*/
public function getProgramsToExport()
{
return $this->createQueryBuilder('tp')
->innerJoin('tp.page', 'page')
->addSelect('page')
->leftJoin('tp.countries', 'country')
->addSelect('country')
->leftJoin('country.destinations', 'destination')
->addSelect('destination')
->leftJoin('tp.options', 'option')
->addSelect('option')
->leftJoin('tp.images', 'image', Expr\Join::WITH, 'image.type = 1')
->addSelect('image')
->where('tp.status = 1')
->andWhere('tp.programType = '. TravelProgram::ORGANIZED_PROGRAM_TYPE)
->getQuery()
->execute()
;
}
}

View file

@ -0,0 +1,97 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TravelSetting
*
* @ORM\Table(name="travel_setting")
* @ORM\Entity(repositoryClass="AppBundle\Entity\TravelSettingRepository")
*/
class TravelSetting
{
/**
* @var string
*
* @ORM\Column(name="key", type="string", length=255, nullable=false)
*/
private $key;
/**
* @var string
*
* @ORM\Column(name="value", type="string", length=255, nullable=false)
*/
private $value;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Set key
*
* @param string $key
*
* @return TravelSetting
*/
public function setKey($key)
{
$this->key = $key;
return $this;
}
/**
* Get key
*
* @return string
*/
public function getKey()
{
return $this->key;
}
/**
* Set value
*
* @param string $value
*
* @return TravelSetting
*/
public function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* Get value
*
* @return string
*/
public function getValue()
{
return $this->value;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
}

View file

@ -0,0 +1,13 @@
<?php
namespace AppBundle\Entity;
/**
* TravelSettingRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class TravelSettingRepository extends \Doctrine\ORM\EntityRepository
{
}

View file

@ -0,0 +1,212 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 02/10/2017
*/
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
class Traveler
{
// Used in SternToursCrmBookingExports, expected to be equivalent to salutation (as defined in BookingRequest)
const MALE = 1;
const FEMALE = 2;
private $NATIONALITIES = [];
/**
* @Assert\NotNull
* @Assert\Choice(choices={1,2})
*/
private $sex;
/**
* @Assert\NotBlank()
*/
private $firstName;
/**
* @Assert\NotBlank()
*/
private $lastName;
/**
* @Assert\NotBlank()
*/
private $birthDate;
/**
* @Assert\NotBlank()
*/
private $nationality;
/**
* @Assert\IsTrue()
*/
private $acceptEntryRequirements = false;
/**
* @Assert\IsTrue()
*/
private $child = false;
/**
* Constructor
*/
function __construct()
{
$this->nationalities = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* @return int
*/
public function getSex()
{
return $this->sex;
}
/**
* @param int $sex
*/
public function setSex($sex)
{
$this->sex = $sex;
}
/**
* @return string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* @param string $firstName
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
}
/**
* @return string
*/
public function getLastName()
{
return $this->lastName;
}
/**
* @param string $lastName
*/
public function setLastName($lastName)
{
$this->lastName = $lastName;
}
/**
* @return string
*/
public function getBirthDate()
{
if($this->birthDate != null && $this->birthDate != ""){
if(!is_object($this->birthDate) && !strtotime($this->birthDate)){
return '01.01.1900';
}
}
return $this->birthDate;
}
/**
* @param string $birthDate
*/
public function setBirthDate($birthDate)
{
$this->birthDate = $birthDate;
}
/**
* @return int
*/
public function getNationality()
{
return $this->nationality;
}
/**
* @param int $nationality
*/
public function setNationality($nationality)
{
$this->nationality = $nationality;
}
/**
* @return int
*/
public function getNationalityName($nat)
{
if(!count($this->NATIONALITIES)){
foreach ($nat as $na){
$this->NATIONALITIES[$na['id']] = $na['name'];
}
}
if(isset($this->NATIONALITIES[$this->nationality])){
return $this->NATIONALITIES[$this->nationality];
}
/*
if(isset($this->NATIONALITIES[$this->nationality])){
return $this->NATIONALITIES[$this->nationality];
}*/
return $this->nationality;
}
/**
* @return mixed
*/
public function isAcceptEntryRequirements()
{
return $this->acceptEntryRequirements;
}
/**
* @param mixed $acceptEntryRequirements
*/
public function setAcceptEntryRequirements($acceptEntryRequirements)
{
$this->acceptEntryRequirements = $acceptEntryRequirements;
}
/**
* @return mixed
*/
public function isChild()
{
return $this->child;
}
/**
* @param mixed $child
*/
public function setChild($child)
{
$this->child = $child;
}
}

View file

@ -0,0 +1,97 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* WikiPage
*
* @ORM\Table(name="wiki_page")
* @ORM\Entity
*/
class WikiPage
{
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255, nullable=true)
*/
private $title;
/**
* @var string
*
* @ORM\Column(name="content", type="text", nullable=true)
*/
private $content;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Set title
*
* @param string $title
*
* @return WikiPage
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set content
*
* @param string $content
*
* @return WikiPage
*/
public function setContent($content)
{
$this->content = $content;
return $this;
}
/**
* Get content
*
* @return string
*/
public function getContent()
{
return $this->content;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
}

View file

@ -0,0 +1,476 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 02/13/2017
*/
namespace AppBundle\Export;
use AppBundle\Entity\BookingRequest;
use AppBundle\Entity\TravelDate;
use AppBundle\Entity\Traveler;
use AppBundle\Util;
use Monolog\Logger;
class BookingSternToursCrmExporter extends SternToursCrmExporter
{
public function __construct(Logger $logger)
{
parent::__construct($logger);
}
public function process(BookingRequest $bookingRequest, TravelDate $travelDate, $bookingPriceInfo)
{
$tp = $travelDate->getTravelProgram();
$startDateStr = $travelDate->getStart()->format('Y-m-d');
if(count($tp->getDrafts()) > 0){
$newDrafts = true;
}else{
$newDrafts = false;
}
$lead = $this->createLead($bookingRequest, $travelDate);
if ($lead === null)
{
$this->warn('Failed creating lead in CRM Lead', $bookingRequest, $travelDate, Logger::ERROR);
return false;
}
$bookingUrl = $this->createBooking($bookingRequest, $travelDate, $bookingPriceInfo, $lead['customer_id'], $lead['id'], $newDrafts);
if ($bookingUrl === false)
{
$this->warn('Failed creating booking in CRM Booking', $bookingRequest, $travelDate, Logger::ERROR);
return false;
}
for ($i = 1; $i < ($bookingRequest->getTravelerCount() + $bookingRequest->getChildrenCount()); ++$i)
{
if (!$this->createTraveler($bookingUrl, $bookingRequest->getTravelers()[$i]))
{
$this->warn('Failed creating traveler with index '. $i .' in CRM.', $bookingRequest, $travelDate);
}
}
if ($tp->getIsMediated())
{
$serviceItemDefaults = [
'travel_company_id' => $tp->getOrganizer()->getCmsId(),
'travel_date' => $startDateStr,
'commission' => 0,
];
foreach ($bookingPriceInfo['rooms'] as $room)
{
$this->createServiceItem($bookingUrl, $serviceItemDefaults + [
'service_price' => $room['price_total'],
'name' => $room['name'],
]);
}
$this->createServiceItem($bookingUrl, $serviceItemDefaults + [
'service_price' => $bookingRequest->getTravelerCount() * $bookingPriceInfo['departure']->getExtraCharge(),
'name' => $bookingRequest->getTravelerCount() .' x '. $bookingPriceInfo['departure']->getName()
]);
foreach ($bookingRequest->getTravelOptions() as $option)
{
$this->createServiceItem($bookingUrl, $serviceItemDefaults + [
'service_price' => $option->getPrice() * $bookingRequest->getTravelerCount(),
'name' => $bookingRequest->getTravelerCount() .' x '. $option->getName()
]);
}
// Actually: extra_category
foreach ($bookingPriceInfo['classOptions'] as $classOption)
{
$this->createServiceItem($bookingUrl, $serviceItemDefaults + [
'service_price' => $classOption['count'] * $classOption['price'],
'name' => $classOption['count'] .' x '. $classOption['name']
]);
}
}
else {
//has drafts - get the new Drafts from the CRM v3
if($newDrafts){
$this->createNewDrafts($bookingUrl, $bookingRequest, $tp, $travelDate, $bookingPriceInfo, $startDateStr);
}else{
//no new Drafts - create the old Arrangements
$this->createOldArrangement($bookingUrl, $bookingRequest, $tp, $travelDate, $bookingPriceInfo, $startDateStr);
}
foreach ($bookingPriceInfo['insurances'] as $insuranceInfo) {
$this->createServiceItem($bookingUrl, [
'travel_company_id' => 30,
'service_price' => $insuranceInfo['count'] * $insuranceInfo['insurancePriceValue'],
'name' => $insuranceInfo['count'] . 'x ' . $insuranceInfo['insurance']->getName() . ' (' .
$insuranceInfo['insurancePrice']->getCode() . ')',
'commission' => round(($insuranceInfo['count'] * $insuranceInfo['insurancePriceValue']) * 20 / 100, 2),
'travel_date' => $startDateStr,
]);
//child
if ($insuranceInfo['countChild'] > 0) {
$this->createServiceItem($bookingUrl, [
'travel_company_id' => 30,
'service_price' => $insuranceInfo['countChild'] * $insuranceInfo['insuranceChildPriceValue'],
'name' => $insuranceInfo['countChild'] . 'x ' . $insuranceInfo['insurance']->getName() . ' (' .
$insuranceInfo['insuranceChildPrice']->getCode() . ')',
'commission' => round(($insuranceInfo['countChild'] * $insuranceInfo['insuranceChildPriceValue']) * 20 / 100, 2),
'travel_date' => $startDateStr,
]);
}
}
}
return $bookingUrl;
}
private function createNewDrafts($bookingUrl, $bookingRequest, $tp, $travelDate, $bookingPriceInfo, $startDateStr){
//make an request omn the new API
$endDateStr = $travelDate->getEnd()->format('Y-m-d');
$rooms = [];
$i = 0;
foreach ($bookingPriceInfo['rooms'] as $room)
{
$rooms[$i] = [
'name' => $room['name'],
'price_adult' => $room['price'],
'adult' => $room['adults'],
'children' => 0,
'price_children' => 0,
'price_children_full' => 0,
'price_adult_full' => $room['price_full'],
];
if($room['children'] > 0){
$rooms[$i]['children'] = $room['children'];
$rooms[$i]['price_children'] = $room['price_children'];
$rooms[$i]['price_children_full'] = $room['price_children_full'];
}
$i++;
}
$class_options = [];
// Actually: extra_category
foreach ($bookingPriceInfo['classOptions'] as $classOption)
{
$class_options[] = [
'name' => $classOption['name'],
'price' => $classOption['price'],
'count' => $classOption['count'],
];
}
$travel_options = [];
$i = 0;
foreach ($bookingRequest->getTravelOptions() as $option)
{
$travel_options[$i] = [
'name' => $option->getName(),
'price_adult' => $option->getPrice(),
'adult' => $bookingRequest->getTravelerCount(),
'children' => 0,
'price_children' => 0,
];
if($bookingRequest->getChildrenCount() > 0){
$travel_options[$i]['children'] = $bookingRequest->getChildrenCount();
$travel_options[$i]['price_children'] = $option->getPriceChildren();
}
$i++;
}
$dis = [];
$i = 0;
foreach ($bookingPriceInfo['discount'] as $discount)
{
$dis[$i] = [
'count' => $discount['count'],
'value' => $discount['value'],
'price' => $discount['price_discount']
];
$i++;
}
$resp = $this->httpPostAPIv3('draft/create_drafts_from_booking', [
'travel_program_id' => $tp->getId(),
'comfort' => $bookingRequest->getComfort(),
'booking_before' => $bookingPriceInfo['booking_before'],
'booking_after' => $bookingPriceInfo['booking_after'],
'booking_id' => array_values(array_slice(explode("/", $bookingUrl), -1))[0],
'request_date' => (new \DateTime())->format('Y-m-d'),
'startDateStr' => $startDateStr,
'endDateStr' => $endDateStr,
'departure' => $bookingPriceInfo['departure']->getName(),
'departure_extra_charge' => $bookingPriceInfo['departure']->getExtraCharge(),
'traveler' => ($bookingRequest->getTravelerCount() + $bookingRequest->getChildrenCount()),
'title' => $tp->getTitle(),
'number' => $travelDate->getName(),
'rooms' => $rooms,
'class_options' => $class_options,
'travel_options' => $travel_options,
'discount' => $dis,
]);
if (count($resp) == 0)
{
$this->warn('Failed retrieving newly created lead object', $bookingRequest, $travelDate);
}
return $resp;
}
private function createOldArrangement($bookingUrl, $bookingRequest, $tp, $travelDate, $bookingPriceInfo, $startDateStr){
$viewPosition = 100;
$viewPositionPrice = 50;
$endDateStr = $travelDate->getEnd()->format('Y-m-d');
$arrangementDefaults = [
'state' => (new \DateTime())->format('Y-m-d'),
'in_pdf' => 1
];
$this->createArrangement($bookingUrl, $arrangementDefaults + [
'type_id' => 4, // Flug
'type_s' => 'Flug',
'begin' => $startDateStr,
'view_position' => --$viewPosition,
'data_s' => ['Hinflug' => 'von '. $bookingPriceInfo['departure']->getName()],
]);
$this->createArrangement($bookingUrl, $arrangementDefaults + [
'type_id' => 26, // Preisinformation
'type_s' => 'Preisinformation',
'view_position' => --$viewPositionPrice,
'data_s' => [
'Name' => 'Abfahrts-/Abflugort '. $bookingPriceInfo['departure']->getName(),
'Preis' => $bookingPriceInfo['departure']->getExtraCharge(),
'Teilnehmer' => ($bookingRequest->getTravelerCount() + $bookingRequest->getChildrenCount()),
],
]);
$this->createArrangement($bookingUrl, $arrangementDefaults + [
'type_id' => 24, // Rundreise
'type_s' => 'Rundreise', // Rundreise
'begin' => $startDateStr,
'end' => $endDateStr,
'view_position' => --$viewPosition,
'data_s' => ['Name' => $tp->getTitle() .' ('. $travelDate->getName() .')'],
]);
$roomStrs = [];
foreach ($bookingPriceInfo['rooms'] as $room)
{
$roomStrs[] = '1x '. $room['name'];
$child = array();
if($room['children'] > 0){
$child = [
'Kind' => $room['children'],
'KindPreis' => $room['price_children'],
];
}
$data = [
'Name' => 'pro Person im \''. $room['name'] .'\'',
'Preis' => $room['price'],
'Teilnehmer' => $room['adults'],
];
$data = array_merge($data, $child);
$this->createArrangement($bookingUrl, $arrangementDefaults + [
'type_id' => 26, // Preisinformation
'type_s' => 'Preisinformation',
'view_position' => --$viewPositionPrice,
'data_s' => $data,
]);
}
$this->createArrangement($bookingUrl, $arrangementDefaults + [
'type_id' => 5, // Hotel
'type_s' => 'Hotel',
'begin' => $startDateStr,
'end' => $endDateStr,
'view_position' => --$viewPosition,
'data_s' => ['Zimmer' => implode(', ', $roomStrs)],
]);
// Actually: extra_category
foreach ($bookingPriceInfo['classOptions'] as $classOption)
{
$this->createArrangement($bookingUrl, $arrangementDefaults + [
'type_id' => 26, // Preisinformation
'type_s' => 'Preisinformation',
'view_position' => --$viewPositionPrice,
'data_s' => [
'Name' => $classOption['name'],
'Preis' => $classOption['price'],
'Teilnehmer' => $classOption['count'],
],
]);
}
$this->createArrangement($bookingUrl, $arrangementDefaults + [
'type_id' => 4, // Flug
'type_s' => 'Flug',
'begin' => $endDateStr,
'view_position' => --$viewPosition,
'data_s' => ['Rückflug' => $bookingRequest->getDeparture()->getName()],
]);
foreach ($bookingRequest->getTravelOptions() as $option)
{
$child = array();
if($option->getPriceChildren() > 0){
$child = [
'Kind' => $bookingRequest->getChildrenCount(),
'KindPreis' => $option->getPriceChildren(),
];
}
$data = [
'Name' => $option->getName(),
'Preis' => $option->getPrice(),
'Teilnehmer' => $bookingRequest->getTravelerCount(),
];
$data = array_merge($data, $child);
$this->createArrangement($bookingUrl, $arrangementDefaults + [
'type_id' => 26, // Preisinformation
'type_s' => 'Preisinformation',
'view_position' => --$viewPositionPrice,
'data_s' => $data
]);
}
}
private function createLead(BookingRequest $bookingRequest, TravelDate $travelDate)
{
$resp = $this->httpPost('lead', ['lead' => [
'customerForm' => [
'salutation_id' => $bookingRequest->getSalutation(),
'name' => $bookingRequest->getLastName(),
'firstname' => $bookingRequest->getFirstName(),
'street' => $bookingRequest->getStreetAddress(),
'zip' => $bookingRequest->getZipCode(),
'city' => $bookingRequest->getCity(),
'country_id' => $bookingRequest->getNation(),
'phone' => $bookingRequest->getPhone(),
'phonemobile' => $bookingRequest->getMobile(),
'email' => $bookingRequest->getEmail()
],
'request_date' => (new \DateTime())->format('Y-m-d'),
'sf_guard_user_id' => self::API_USER_ID,
'status_id' => 7, // 'gebucht'
'travelperiod_start' => $travelDate->getStart()->format('Y-m-d'),
'travelperiod_end' => $travelDate->getEnd()->format('Y-m-d'),
//'travelcategory_id'
'is_closed' => 1,
'website_id' => self::WEBSITE_ID,
'initialcontacttype_id' => 14,
// 'travelperiod_length
'remarks' => $bookingRequest->getNotes()
]]);
if ($resp['success'])
{
$ret = $this->httpGet($resp['location']);
if ($ret == null)
{
$this->warn('Failed retrieving newly created lead object', $bookingRequest, $travelDate);
}
return $ret;
}
return null;
}
private function createBooking(BookingRequest $bookingRequest, TravelDate $travelDate, $bookingPriceInfo,
$customerId, $leadId, $newDrafts = false)
{
$tp = $travelDate->getTravelProgram();
$resp = $this->httpPost('booking', ['booking' => [
'booking_date' => (new \DateTime())->format('Y-m-d'),
'customer_id' => $customerId,
'lead_id' => $leadId,
'travel_country_id' => $tp->getTravelCountry(),
'travel_category_id' => $tp->getTravelCategory(),
'travelagenda_id' => $tp->getTravelAgenda(),
'sf_guard_user_id' => self::API_USER_ID,
'branch_id' => 4,
'website_id' => self::WEBSITE_ID,
'title' => $tp->getTitle(),
'start_date' => $travelDate->getStart()->format('Y-m-d'),
'end_date' => $travelDate->getEnd()->format('Y-m-d'),
'pax' => $bookingRequest->getTravelerCount(),
'travel_number' => $travelDate->getName(),
'price' => $bookingPriceInfo['totalWithoutInsurance'],
'price_total' => $bookingPriceInfo['total'],
'deposit_total' => $bookingPriceInfo['deposit_total'],
'final_payment' => $bookingPriceInfo['final_payment'],
'final_payment_date' => date("Y-m-d",strtotime($bookingPriceInfo['final_payment_date'])),
'participant_salutation_id' => $bookingRequest->getTravelers()[0]->getSex(),
'participant_name' => $bookingRequest->getTravelers()[0]->getLastName(),
'participant_firstname' => $bookingRequest->getTravelers()[0]->getFirstName(),
'participant_birthdate' => $bookingRequest->getTravelers()[0]->getBirthDate(),
'new_drafts' => $newDrafts,
]]);
if (!$resp['success'])
{
return false;
}
return $resp['location'];
}
private function createTraveler($bookingUrl, Traveler $traveler)
{
$resp = $this->httpPost($bookingUrl .'/participant.json', ['participant' => [
'participant_salutation_id' => $traveler->getSex(),
'participant_name' => $traveler->getLastName(),
'participant_firstname' => $traveler->getFirstName(),
'participant_birthdate' => $traveler->getBirthDate(),
'participant_child' => $traveler->isChild(),
]], true);
return $resp['success'];
}
private function createServiceItem($bookingUrl, $serviceItemData)
{
$resp = $this->httpPost($bookingUrl .'/serviceitem.json', ['booking_service_item' => $serviceItemData], true);
if (!$resp['success'])
{
$this->warn('Failed creating service item '. $serviceItemData['name'] .' for booking '. $bookingUrl);
}
return $resp['success'];
}
private function createArrangement($bookingUrl, $arrangementData)
{
if (isset($arrangementData['data_s']) && is_array($arrangementData['data_s']))
{
$tmp = [];
foreach ($arrangementData['data_s'] as $k => $v)
{
$tmp[] .= $k .': '. $v;
}
$arrangementData['data_s'] = implode("\n", $tmp);
}
$resp = $this->httpPost($bookingUrl .'/arrangement.json', ['arrangement' => $arrangementData], true);
if (!$resp['success'])
{
$this->warn('Failed creating arrangement item '. $arrangementData['type_s'] .' for booking '. $bookingUrl);
}
return $resp['success'];
}
private function warn($msg, BookingRequest $bookingRequest = null, TravelDate $travelDate = null,
$level = Logger::WARNING)
{
$this->logger->log($level, 'SternToursCrmBookingExporter: '. $msg);
$this->logger->log($level, '*** Date: '. (new \DateTime())->format('d.m.Y'));
if ($travelDate !== null)
{
$this->logger->log($level, '*** Travel date: '. $travelDate->getName() .'('. $travelDate->getStart()->format('d.m.Y') .
' - '. $travelDate->getEnd()->format('d.m.Y') .')');
//$this->logger->warn('*** Travel program ID: '. $travelDate->)
}
if ($bookingRequest !== null)
{
$this->logger->log($level, '*** User name: '. $bookingRequest->getFirstName() .' '. $bookingRequest->getLastName());
}
}
}

View file

@ -0,0 +1,63 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 02/21/2017
*/
namespace AppBundle\Export;
use AppBundle\Entity\ContactRequest;
use Monolog\Logger;
class ContactSternToursCrmExporter extends SternToursCrmExporter
{
public function __construct(Logger $logger)
{
parent::__construct($logger);
}
public function process(ContactRequest $contactRequest)
{
$data = ['lead' => [
'customerForm' => [
'salutation_id' => $contactRequest->getSalutation(),
'name' => $contactRequest->getLastName(),
'firstname' => $contactRequest->getFirstName(),
'street' => $contactRequest->getStreetAddress(),
'zip' => $contactRequest->getZipCode(),
'city' => $contactRequest->getCity(),
'country_id' => $contactRequest->getNation(),
'phone' => $contactRequest->getPhone(),
'phonemobile' => $contactRequest->getMobilePhone(),
'email' => $contactRequest->getEmail()
],
'request_date' => (new \DateTime())->format('Y-m-d'),
'sf_guard_user_id' => self::API_USER_ID,
'status_id' => 10, // 'Angebot erstellen'
'travelperiod_start' => $contactRequest->getStart(),
'travelperiod_end' => $contactRequest->getEnd(),
//'travelcategory_id'
'is_closed' => 0,
'website_id' => self::WEBSITE_ID,
'initialcontacttype_id' => 1,
'travelperiod_length' => $contactRequest->getDuration(),
'remarks' => $contactRequest->getNotes(),
'pax' => $contactRequest->getTravelerCount(),
]];
$resp = $this->httpPost('lead', $data);
if (!$resp['success'])
{
$this->logger->error(get_class($this). ': Failed submitting contact request to CRM');
$this->logger->error('*** Submitted data: '. json_encode($data));
//var_dump($resp['content']);
//die();
//$this->logger->error('*** Server response: '. $resp['content']);
}
return $resp['location'] ?? null;
}
}

View file

@ -0,0 +1,141 @@
<?php
namespace AppBundle\Export;
use AppBundle\Entity\BookingRequest;
use AppBundle\Entity\FewoBookingRequest;
use AppBundle\Entity\FewoLodging;
use AppBundle\Entity\FewoPrice;
use AppBundle\Entity\TravelDate;
use AppBundle\Entity\Traveler;
use AppBundle\Util;
use Monolog\Logger;
class FewoBookingSternToursCrmExporter extends SternToursCrmExporter
{
public function __construct(Logger $logger)
{
parent::__construct($logger);
}
public function process(FewoBookingRequest $fewoBookingRequest, FewoLodging $fewoLodging, FewoPrice $fewoPrice, $priceResult, $reservationId)
{
$lead = $this->createLead($fewoBookingRequest);
if ($lead === null)
{
$this->warn('Failed creating lead in CRM', $fewoBookingRequest, Logger::ERROR);
return false;
}
$booking = $this->createBooking($fewoBookingRequest, $fewoLodging, $fewoPrice, $priceResult, $lead->travel_user_id, $reservationId);
if ($booking === null)
{
$this->warn('Failed creating booking in CRM', $fewoBookingRequest, Logger::ERROR);
return false;
}
// is out $this->createNewDrafts($booking['crm_url'], $fewoBookingRequest, $fewoLodging, $fewoPrice, $priceResult);
return $booking->crm_url;
}
/* private function createNewDrafts($bookingUrl, $fewoBookingRequest, $fewoLodging, $fewoPrice, $priceResult){
//make an request omn the new API
$resp = $this->httpPostAPIv3('draft/create_drafts_from_fewo', [
'booking_id' => array_values(array_slice(explode("/", $bookingUrl), -1))[0],
'fewo_lodging_id' => $fewoLodging->getId(),
'request_date' => (new \DateTime())->format('Y-m-d'), // required
'priceResult' => $priceResult,
'startDateStr' => $fewoBookingRequest->getFromDate()->format('Y-m-d'),
'endDateStr' => $fewoBookingRequest->getToDate()->format('Y-m-d'),
]);
if (count($resp) == 0)
{
$this->warn('Failed retrieving newly created new draft object', $fewoBookingRequest);
return null;
}
return $resp;
} */
private function createLead(FewoBookingRequest $fewoBookingRequest)
{
$resp = $this->httpPostAPIv3('fewo/create_travel_users',
['travel_user' => [
'salutation_id' => $fewoBookingRequest->getSalutation(),
'first_name' => $fewoBookingRequest->getFirstName(),
'last_name' => $fewoBookingRequest->getLastName(),
'street' => $fewoBookingRequest->getStreetAddress(),
'zipcode' => $fewoBookingRequest->getZipCode(),
'city' => $fewoBookingRequest->getCity(),
'travel_nationality_id' => $fewoBookingRequest->getNation(),
'phone' => $fewoBookingRequest->getPhone(),
'mobile' => $fewoBookingRequest->getMobile(),
'email' => $fewoBookingRequest->getEmail()
],
]
);
if (count($resp) == 0)
{
$this->warn('Failed retrieving newly created new draft object', $fewoBookingRequest);
return null;
}
return $resp;
}
private function createBooking(FewoBookingRequest $fewoBookingRequest, FewoLodging $lodging, FewoPrice $price, $priceResult, $travel_user_id, $reservationId)
{
$resp = $this->httpPostAPIv3('fewo/create_fewo_booking',
['travel_user_booking_fewo' => [
'travel_user_id' => $travel_user_id,
'fewo_lodging_id' => $lodging->getId(),
'fewo_reservation_id' => $reservationId,
'invoice_number' => '',
'persons' => $fewoBookingRequest->getTravelerCount(),
'adults' => $fewoBookingRequest->getTravelerCountAdult(),
'children' => $fewoBookingRequest->getTravelerCountChild(),
// 'booking_date' => now(),
'from_date' => $fewoBookingRequest->getFromDate()->format('Y-m-d'),
'to_date' => $fewoBookingRequest->getToDate()->format('Y-m-d'),
'daily_prices' => $priceResult['season'],
'price_travel' => $priceResult['total'],
'price_deposit' => $priceResult['deposit'],
'price_service' => $priceResult['flatPrice'],
'price_total' => $priceResult['total_price'],
'notice' => $fewoBookingRequest->getNotes(),
'travel_booking_fewo_channel_id' => 7,
'is_calendar_fewo_direct' => false,
'is_calendar_hrs' => false,
'is_calendar_stern_tours' => true,
'status' => false,
'status_text' => "",
]]);
if (count($resp) == 0)
{
$this->warn('Failed retrieving newly created new draft object', $fewoBookingRequest);
return null;
}
return $resp;
}
private function warn($msg, FewoBookingRequest $fewoBookingRequest = null, $level = Logger::WARNING)
{
$this->logger->log($level, 'SternToursCrmBookingExporter: '. $msg);
$this->logger->log($level, '*** Date: '. (new \DateTime())->format('d.m.Y'));
if ($fewoBookingRequest !== null)
{
$this->logger->log($level, '*** Booking date: '. $fewoBookingRequest->getFromDate()->format('d.m.Y') .
' - '. $fewoBookingRequest->getToDate()->format('d.m.Y') .')');
$this->logger->log($level, '*** User name: '. $fewoBookingRequest->getFirstName() .' '. $fewoBookingRequest->getLastName());
}
}
}

View file

@ -0,0 +1,123 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 02/21/2017
*/
namespace AppBundle\Export;
use AppBundle\Util;
use Monolog\Logger;
abstract class SternToursCrmExporter
{
//auto
const API_URL_LOCAL = 'http://cms-stern-tours.local/api';
const API_v3_URL_LOCAL = 'http://mein.sterntours.test/';
const API_URL = 'https://cms.stern-tours.net/api';
const API_v3_URL = 'https://mein.sterntours.de/';
const API_KEY = 'f6077389c9ce710e554763a5de02c8ec';
const API_USER_ID = 15; // 'apiuser'
const WEBSITE_ID = 1; // 'sterntours.de'
const API_v3_MAIL = 'info@mein.sterntours.de';
const API_v3_PASS = '6m9j,v2GE8px<bt75w';
protected $logger;
public function __construct(Logger $logger)
{
$this->logger = $logger;
}
protected final function httpGet($url)
{
$auth = base64_encode("star:4w28baV8xEZa0SR4");
$resp = Util::httpGet($url, ['X-ApiKey: '. self::API_KEY, 'Authorization: Basic '.$auth]);
$ret = json_decode($resp['content'], true);
if ($ret === null)
{
$this->logger->warn(get_class($this) .': Invalid server response: '. $resp['content']);
$this->logger->warn('*** Date: '. (new \DateTime())->format('d.m.Y'));
}
return $ret;
}
protected final function httpPost($context, $postData = [], $isContextFullUrl = false)
{
$baseUrl = self::API_URL;
if($_SERVER['HTTP_HOST'] == 'sterntours.test') {
$baseUrl = self::API_URL_LOCAL;
}
$url = $isContextFullUrl ? $context : $baseUrl.'/'. $context .'.json';
$auth = base64_encode("star:4w28baV8xEZa0SR4");
$resp = Util::httpPost($url, $postData, ['X-ApiKey: '. self::API_KEY, 'Authorization: Basic '.$auth], true);
return [
'content' => json_decode($resp['content']),
'location' => isset($resp['response_headers']['location'])
? $resp['response_headers']['location']
: null,
'success' => $resp['success'] && ($resp['status_code'] == 201)
];
}
protected final function httpPostAPIv3($action, $postData = [])
{
return self::loadFromApi($action, $postData);
}
protected final function loadFromApi($action, $postData){
//first - login and get token
$baseUrl = self::API_v3_URL.'api/';
if($_SERVER['HTTP_HOST'] == 'sterntours.test') {
$baseUrl = self::API_v3_URL_LOCAL.'api/';
}
$data = array(
'email' => self::API_v3_MAIL,
'password' => self::API_v3_PASS,
);
$ret = [];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $baseUrl.'login');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_POST, count($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$result = curl_exec($ch);
$r = json_decode($result);
if($r->success) {
//api URL
$data = json_encode($postData);
//var_dump($data);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $r->success->token, 'Accept:application/json', 'Content-Type:application/json']);
curl_setopt($ch, CURLOPT_URL, $baseUrl.$action);
$result = curl_exec($ch);
$r = json_decode($result);
//var_dump($r);
curl_close($ch);
if(isset($r->success)) {
return $r->success;
}
if(isset($r->error)) {
$this->logger->warn('*** v3 Error: '.$r->error);
return $r->error;
}
}
return $ret;
}
}

View file

@ -0,0 +1,476 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 02/13/2017
*/
namespace AppBundle\Export;
use AppBundle\Entity\BookingRequest;
use AppBundle\Entity\TravelDate;
use AppBundle\Entity\Traveler;
use AppBundle\Util;
use Monolog\Logger;
class BookingSternToursCrmExporter extends SternToursCrmExporter
{
public function __construct(Logger $logger)
{
parent::__construct($logger);
}
public function process(BookingRequest $bookingRequest, TravelDate $travelDate, $bookingPriceInfo)
{
$tp = $travelDate->getTravelProgram();
$startDateStr = $travelDate->getStart()->format('Y-m-d');
if(count($tp->getDrafts()) > 0){
$newDrafts = true;
}else{
$newDrafts = false;
}
$lead = $this->createLead($bookingRequest, $travelDate);
if ($lead === null)
{
$this->warn('Failed creating lead in CRM Lead', $bookingRequest, $travelDate, Logger::ERROR);
return false;
}
$bookingUrl = $this->createBooking($bookingRequest, $travelDate, $bookingPriceInfo, $lead['customer_id'], $lead['id'], $newDrafts);
if ($bookingUrl === false)
{
$this->warn('Failed creating booking in CRM Booking', $bookingRequest, $travelDate, Logger::ERROR);
return false;
}
for ($i = 1; $i < ($bookingRequest->getTravelerCount() + $bookingRequest->getChildrenCount()); ++$i)
{
if (!$this->createTraveler($bookingUrl, $bookingRequest->getTravelers()[$i]))
{
$this->warn('Failed creating traveler with index '. $i .' in CRM.', $bookingRequest, $travelDate);
}
}
if ($tp->getIsMediated())
{
$serviceItemDefaults = [
'travel_company_id' => $tp->getOrganizer()->getCmsId(),
'travel_date' => $startDateStr,
'commission' => 0,
];
foreach ($bookingPriceInfo['rooms'] as $room)
{
$this->createServiceItem($bookingUrl, $serviceItemDefaults + [
'service_price' => $room['price_total'],
'name' => $room['name'],
]);
}
$this->createServiceItem($bookingUrl, $serviceItemDefaults + [
'service_price' => $bookingRequest->getTravelerCount() * $bookingPriceInfo['departure']->getExtraCharge(),
'name' => $bookingRequest->getTravelerCount() .' x '. $bookingPriceInfo['departure']->getName()
]);
foreach ($bookingRequest->getTravelOptions() as $option)
{
$this->createServiceItem($bookingUrl, $serviceItemDefaults + [
'service_price' => $option->getPrice() * $bookingRequest->getTravelerCount(),
'name' => $bookingRequest->getTravelerCount() .' x '. $option->getName()
]);
}
// Actually: extra_category
foreach ($bookingPriceInfo['classOptions'] as $classOption)
{
$this->createServiceItem($bookingUrl, $serviceItemDefaults + [
'service_price' => $classOption['count'] * $classOption['price'],
'name' => $classOption['count'] .' x '. $classOption['name']
]);
}
}
else {
//has drafts - get the new Drafts from the CRM v3
if($newDrafts){
$this->createNewDrafts($bookingUrl, $bookingRequest, $tp, $travelDate, $bookingPriceInfo, $startDateStr);
}else{
//no new Drafts - create the old Arrangements
$this->createOldArrangement($bookingUrl, $bookingRequest, $tp, $travelDate, $bookingPriceInfo, $startDateStr);
}
foreach ($bookingPriceInfo['insurances'] as $insuranceInfo) {
$this->createServiceItem($bookingUrl, [
'travel_company_id' => 30,
'service_price' => $insuranceInfo['count'] * $insuranceInfo['insurancePriceValue'],
'name' => $insuranceInfo['count'] . 'x ' . $insuranceInfo['insurance']->getName() . ' (' .
$insuranceInfo['insurancePrice']->getCode() . ')',
'commission' => round(($insuranceInfo['count'] * $insuranceInfo['insurancePriceValue']) * 20 / 100, 2),
'travel_date' => $startDateStr,
]);
//child
if ($insuranceInfo['countChild'] > 0) {
$this->createServiceItem($bookingUrl, [
'travel_company_id' => 30,
'service_price' => $insuranceInfo['countChild'] * $insuranceInfo['insuranceChildPriceValue'],
'name' => $insuranceInfo['countChild'] . 'x ' . $insuranceInfo['insurance']->getName() . ' (' .
$insuranceInfo['insuranceChildPrice']->getCode() . ')',
'commission' => round(($insuranceInfo['countChild'] * $insuranceInfo['insuranceChildPriceValue']) * 20 / 100, 2),
'travel_date' => $startDateStr,
]);
}
}
}
return $bookingUrl;
}
private function createNewDrafts($bookingUrl, $bookingRequest, $tp, $travelDate, $bookingPriceInfo, $startDateStr){
//make an request omn the new API
$endDateStr = $travelDate->getEnd()->format('Y-m-d');
$rooms = [];
$i = 0;
foreach ($bookingPriceInfo['rooms'] as $room)
{
$rooms[$i] = [
'name' => $room['name'],
'price_adult' => $room['price'],
'adult' => $room['adults'],
'children' => 0,
'price_children' => 0,
'price_children_full' => 0,
'price_adult_full' => $room['price_full'],
];
if($room['children'] > 0){
$rooms[$i]['children'] = $room['children'];
$rooms[$i]['price_children'] = $room['price_children'];
$rooms[$i]['price_children_full'] = $room['price_children_full'];
}
$i++;
}
$class_options = [];
// Actually: extra_category
foreach ($bookingPriceInfo['classOptions'] as $classOption)
{
$class_options[] = [
'name' => $classOption['name'],
'price' => $classOption['price'],
'count' => $classOption['count'],
];
}
$travel_options = [];
$i = 0;
foreach ($bookingRequest->getTravelOptions() as $option)
{
$travel_options[$i] = [
'name' => $option->getName(),
'price_adult' => $option->getPrice(),
'adult' => $bookingRequest->getTravelerCount(),
'children' => 0,
'price_children' => 0,
];
if($bookingRequest->getChildrenCount() > 0){
$travel_options[$i]['children'] = $bookingRequest->getChildrenCount();
$travel_options[$i]['price_children'] = $option->getPriceChildren();
}
$i++;
}
$dis = [];
$i = 0;
foreach ($bookingPriceInfo['discount'] as $discount)
{
$dis[$i] = [
'count' => $discount['count'],
'value' => $discount['value'],
'price' => $discount['price_discount']
];
$i++;
}
$resp = $this->httpPostAPIv3('draft/create_drafts_from_booking', [
'travel_program_id' => $tp->getId(),
'comfort' => $bookingRequest->getComfort(),
'booking_before' => $bookingPriceInfo['booking_before'],
'booking_after' => $bookingPriceInfo['booking_after'],
'booking_id' => array_values(array_slice(explode("/", $bookingUrl), -1))[0],
'request_date' => (new \DateTime())->format('Y-m-d'),
'startDateStr' => $startDateStr,
'endDateStr' => $endDateStr,
'departure' => $bookingPriceInfo['departure']->getName(),
'departure_extra_charge' => $bookingPriceInfo['departure']->getExtraCharge(),
'traveler' => ($bookingRequest->getTravelerCount() + $bookingRequest->getChildrenCount()),
'title' => $tp->getTitle(),
'number' => $travelDate->getName(),
'rooms' => $rooms,
'class_options' => $class_options,
'travel_options' => $travel_options,
'discount' => $dis,
]);
if (count($resp) == 0)
{
$this->warn('Failed retrieving newly created lead object', $bookingRequest, $travelDate);
}
return $resp;
}
private function createOldArrangement($bookingUrl, $bookingRequest, $tp, $travelDate, $bookingPriceInfo, $startDateStr){
$viewPosition = 100;
$viewPositionPrice = 50;
$endDateStr = $travelDate->getEnd()->format('Y-m-d');
$arrangementDefaults = [
'state' => (new \DateTime())->format('Y-m-d'),
'in_pdf' => 1
];
$this->createArrangement($bookingUrl, $arrangementDefaults + [
'type_id' => 4, // Flug
'type_s' => 'Flug',
'begin' => $startDateStr,
'view_position' => --$viewPosition,
'data_s' => ['Hinflug' => 'von '. $bookingPriceInfo['departure']->getName()],
]);
$this->createArrangement($bookingUrl, $arrangementDefaults + [
'type_id' => 26, // Preisinformation
'type_s' => 'Preisinformation',
'view_position' => --$viewPositionPrice,
'data_s' => [
'Name' => 'Abfahrts-/Abflugort '. $bookingPriceInfo['departure']->getName(),
'Preis' => $bookingPriceInfo['departure']->getExtraCharge(),
'Teilnehmer' => ($bookingRequest->getTravelerCount() + $bookingRequest->getChildrenCount()),
],
]);
$this->createArrangement($bookingUrl, $arrangementDefaults + [
'type_id' => 24, // Rundreise
'type_s' => 'Rundreise', // Rundreise
'begin' => $startDateStr,
'end' => $endDateStr,
'view_position' => --$viewPosition,
'data_s' => ['Name' => $tp->getTitle() .' ('. $travelDate->getName() .')'],
]);
$roomStrs = [];
foreach ($bookingPriceInfo['rooms'] as $room)
{
$roomStrs[] = '1x '. $room['name'];
$child = array();
if($room['children'] > 0){
$child = [
'Kind' => $room['children'],
'KindPreis' => $room['price_children'],
];
}
$data = [
'Name' => 'pro Person im \''. $room['name'] .'\'',
'Preis' => $room['price'],
'Teilnehmer' => $room['adults'],
];
$data = array_merge($data, $child);
$this->createArrangement($bookingUrl, $arrangementDefaults + [
'type_id' => 26, // Preisinformation
'type_s' => 'Preisinformation',
'view_position' => --$viewPositionPrice,
'data_s' => $data,
]);
}
$this->createArrangement($bookingUrl, $arrangementDefaults + [
'type_id' => 5, // Hotel
'type_s' => 'Hotel',
'begin' => $startDateStr,
'end' => $endDateStr,
'view_position' => --$viewPosition,
'data_s' => ['Zimmer' => implode(', ', $roomStrs)],
]);
// Actually: extra_category
foreach ($bookingPriceInfo['classOptions'] as $classOption)
{
$this->createArrangement($bookingUrl, $arrangementDefaults + [
'type_id' => 26, // Preisinformation
'type_s' => 'Preisinformation',
'view_position' => --$viewPositionPrice,
'data_s' => [
'Name' => $classOption['name'],
'Preis' => $classOption['price'],
'Teilnehmer' => $classOption['count'],
],
]);
}
$this->createArrangement($bookingUrl, $arrangementDefaults + [
'type_id' => 4, // Flug
'type_s' => 'Flug',
'begin' => $endDateStr,
'view_position' => --$viewPosition,
'data_s' => ['Rückflug' => $bookingRequest->getDeparture()->getName()],
]);
foreach ($bookingRequest->getTravelOptions() as $option)
{
$child = array();
if($option->getPriceChildren() > 0){
$child = [
'Kind' => $bookingRequest->getChildrenCount(),
'KindPreis' => $option->getPriceChildren(),
];
}
$data = [
'Name' => $option->getName(),
'Preis' => $option->getPrice(),
'Teilnehmer' => $bookingRequest->getTravelerCount(),
];
$data = array_merge($data, $child);
$this->createArrangement($bookingUrl, $arrangementDefaults + [
'type_id' => 26, // Preisinformation
'type_s' => 'Preisinformation',
'view_position' => --$viewPositionPrice,
'data_s' => $data
]);
}
}
private function createLead(BookingRequest $bookingRequest, TravelDate $travelDate)
{
$resp = $this->httpPost('lead', ['lead' => [
'customerForm' => [
'salutation_id' => $bookingRequest->getSalutation(),
'name' => $bookingRequest->getLastName(),
'firstname' => $bookingRequest->getFirstName(),
'street' => $bookingRequest->getStreetAddress(),
'zip' => $bookingRequest->getZipCode(),
'city' => $bookingRequest->getCity(),
'country_id' => $bookingRequest->getNation(),
'phone' => $bookingRequest->getPhone(),
'phonemobile' => $bookingRequest->getMobile(),
'email' => $bookingRequest->getEmail()
],
'request_date' => (new \DateTime())->format('Y-m-d'),
'sf_guard_user_id' => self::API_USER_ID,
'status_id' => 7, // 'gebucht'
'travelperiod_start' => $travelDate->getStart()->format('Y-m-d'),
'travelperiod_end' => $travelDate->getEnd()->format('Y-m-d'),
//'travelcategory_id'
'is_closed' => 1,
'website_id' => self::WEBSITE_ID,
'initialcontacttype_id' => 14,
// 'travelperiod_length
'remarks' => $bookingRequest->getNotes()
]]);
if ($resp['success'])
{
$ret = $this->httpGet($resp['location']);
if ($ret == null)
{
$this->warn('Failed retrieving newly created lead object', $bookingRequest, $travelDate);
}
return $ret;
}
return null;
}
private function createBooking(BookingRequest $bookingRequest, TravelDate $travelDate, $bookingPriceInfo,
$customerId, $leadId, $newDrafts = false)
{
$tp = $travelDate->getTravelProgram();
$resp = $this->httpPost('booking', ['booking' => [
'booking_date' => (new \DateTime())->format('Y-m-d'),
'customer_id' => $customerId,
'lead_id' => $leadId,
'travel_country_id' => $tp->getTravelCountry(),
'travel_category_id' => $tp->getTravelCategory(),
'travelagenda_id' => $tp->getTravelAgenda(),
'sf_guard_user_id' => self::API_USER_ID,
'branch_id' => 4,
'website_id' => self::WEBSITE_ID,
'title' => $tp->getTitle(),
'start_date' => $travelDate->getStart()->format('Y-m-d'),
'end_date' => $travelDate->getEnd()->format('Y-m-d'),
'pax' => $bookingRequest->getTravelerCount(),
'travel_number' => $travelDate->getName(),
'price' => $bookingPriceInfo['totalWithoutInsurance'],
'price_total' => $bookingPriceInfo['total'],
'deposit_total' => $bookingPriceInfo['deposit_total'],
'final_payment' => $bookingPriceInfo['final_payment'],
'final_payment_date' => date("Y-m-d",strtotime($bookingPriceInfo['final_payment_date'])),
'participant_salutation_id' => $bookingRequest->getTravelers()[0]->getSex(),
'participant_name' => $bookingRequest->getTravelers()[0]->getLastName(),
'participant_firstname' => $bookingRequest->getTravelers()[0]->getFirstName(),
'participant_birthdate' => $bookingRequest->getTravelers()[0]->getBirthDate(),
'new_drafts' => $newDrafts,
]]);
if (!$resp['success'])
{
return false;
}
return $resp['location'];
}
private function createTraveler($bookingUrl, Traveler $traveler)
{
$resp = $this->httpPost($bookingUrl .'/participant.json', ['participant' => [
'participant_salutation_id' => $traveler->getSex(),
'participant_name' => $traveler->getLastName(),
'participant_firstname' => $traveler->getFirstName(),
'participant_birthdate' => $traveler->getBirthDate(),
'participant_child' => $traveler->isChild(),
]], true);
return $resp['success'];
}
private function createServiceItem($bookingUrl, $serviceItemData)
{
$resp = $this->httpPost($bookingUrl .'/serviceitem.json', ['booking_service_item' => $serviceItemData], true);
if (!$resp['success'])
{
$this->warn('Failed creating service item '. $serviceItemData['name'] .' for booking '. $bookingUrl);
}
return $resp['success'];
}
private function createArrangement($bookingUrl, $arrangementData)
{
if (isset($arrangementData['data_s']) && is_array($arrangementData['data_s']))
{
$tmp = [];
foreach ($arrangementData['data_s'] as $k => $v)
{
$tmp[] .= $k .': '. $v;
}
$arrangementData['data_s'] = implode("\n", $tmp);
}
$resp = $this->httpPost($bookingUrl .'/arrangement.json', ['arrangement' => $arrangementData], true);
if (!$resp['success'])
{
$this->warn('Failed creating arrangement item '. $arrangementData['type_s'] .' for booking '. $bookingUrl);
}
return $resp['success'];
}
private function warn($msg, BookingRequest $bookingRequest = null, TravelDate $travelDate = null,
$level = Logger::WARNING)
{
$this->logger->log($level, 'SternToursCrmBookingExporter: '. $msg);
$this->logger->log($level, '*** Date: '. (new \DateTime())->format('d.m.Y'));
if ($travelDate !== null)
{
$this->logger->log($level, '*** Travel date: '. $travelDate->getName() .'('. $travelDate->getStart()->format('d.m.Y') .
' - '. $travelDate->getEnd()->format('d.m.Y') .')');
//$this->logger->warn('*** Travel program ID: '. $travelDate->)
}
if ($bookingRequest !== null)
{
$this->logger->log($level, '*** User name: '. $bookingRequest->getFirstName() .' '. $bookingRequest->getLastName());
}
}
}

View file

@ -0,0 +1,123 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 02/21/2017
*/
namespace AppBundle\Export;
use AppBundle\Util;
use Monolog\Logger;
abstract class SternToursCrmExporter
{
//auto
const API_URL_LOCAL = 'http://cms-stern-tours.local/api';
const API_v3_URL_LOCAL = 'http://mein.sterntours.test/';
const API_URL = 'https://cms.stern-tours.net/api';
const API_v3_URL = 'https://mein.sterntours.de/';
const API_KEY = 'f6077389c9ce710e554763a5de02c8ec';
const API_USER_ID = 15; // 'apiuser'
const WEBSITE_ID = 1; // 'sterntours.de'
const API_v3_MAIL = 'info@mein.sterntours.de';
const API_v3_PASS = '6m9j,v2GE8px<bt75w';
protected $logger;
public function __construct(Logger $logger)
{
$this->logger = $logger;
}
protected final function httpGet($url)
{
$auth = base64_encode("star:4w28baV8xEZa0SR4");
$resp = Util::httpGet($url, ['X-ApiKey: '. self::API_KEY, 'Authorization: Basic '.$auth]);
$ret = json_decode($resp['content'], true);
if ($ret === null)
{
$this->logger->warn(get_class($this) .': Invalid server response: '. $resp['content']);
$this->logger->warn('*** Date: '. (new \DateTime())->format('d.m.Y'));
}
return $ret;
}
protected final function httpPost($context, $postData = [], $isContextFullUrl = false)
{
$baseUrl = self::API_URL;
if($_SERVER['HTTP_HOST'] == 'sterntours.test') {
$baseUrl = self::API_URL_LOCAL;
}
$url = $isContextFullUrl ? $context : $baseUrl.'/'. $context .'.json';
$auth = base64_encode("star:4w28baV8xEZa0SR4");
$resp = Util::httpPost($url, $postData, ['X-ApiKey: '. self::API_KEY, 'Authorization: Basic '.$auth], true);
return [
'content' => json_decode($resp['content']),
'location' => isset($resp['response_headers']['location'])
? $resp['response_headers']['location']
: null,
'success' => $resp['success'] && ($resp['status_code'] == 201)
];
}
protected final function httpPostAPIv3($action, $postData = [])
{
return self::loadFromApi($action, $postData);
}
protected final function loadFromApi($action, $postData){
//first - login and get token
$baseUrl = self::API_v3_URL.'api/';
if($_SERVER['HTTP_HOST'] == 'sterntours.test') {
$baseUrl = self::API_v3_URL_LOCAL.'api/';
}
$data = array(
'email' => self::API_v3_MAIL,
'password' => self::API_v3_PASS,
);
$ret = [];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $baseUrl.'login');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_POST, count($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$result = curl_exec($ch);
$r = json_decode($result);
if($r->success) {
//api URL
$data = json_encode($postData);
//var_dump($data);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $r->success->token, 'Accept:application/json', 'Content-Type:application/json']);
curl_setopt($ch, CURLOPT_URL, $baseUrl.$action);
$result = curl_exec($ch);
$r = json_decode($result);
//var_dump($r);
curl_close($ch);
if(isset($r->success)) {
return $r->success;
}
if(isset($r->error)) {
$this->logger->warn('*** v3 Error: '.$r->error);
return $r->error;
}
}
return $ret;
}
}

View file

@ -0,0 +1,318 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 12/16/2016
*/
namespace AppBundle\Form;
use AppBundle\Entity\BookingRequest;
use AppBundle\Entity\TravelDate;
use AppBundle\Entity\Traveler;
use AppBundle\Entity\TravelProgram;
use AppBundle\Util;
use Doctrine\Common\Collections\Collection;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotBlank;
class BookingRequestType extends AbstractType
{
public static $SINGLE_ROOM_COUNT_CHOICES = [
'0 Einzelzimmer' => 0,
'1 Einzelzimmer' => 1,
'2 Einzelzimmer' => 2,
'3 Einzelzimmer' => 3,
'4 Einzelzimmer' => 4,
];
public static $EXTRA_BOOKING_DAYS = [
'Keine Reiseverlängerung' => 0,
'1 Tag' => 1,
'2 Tage' => 2,
'3 Tage' => 3,
'4 Tage' => 4,
'5 Tage' => 5,
'6 Tage' => 6,
'7 Tage' => 7,
];
public static $SINGLE_ROOM_CHILD_COUNT_CHOICES = [
'0 Einzelzimmer [1 Erwachsener + 1 Kind (bis einschl. 11 Jahren)]' => 0,
'1 Einzelzimmer [1 Erwachsener + 1 Kind (bis einschl. 11 Jahren)]' => 1,
'2 Einzelzimmer [1 Erwachsener + 1 Kind (bis einschl. 11 Jahren)]' => 2,
'3 Einzelzimmer [1 Erwachsener + 1 Kind (bis einschl. 11 Jahren)]' => 3,
'4 Einzelzimmer [1 Erwachsener + 1 Kind (bis einschl. 11 Jahren)]' => 4,
];
public static $DOUBLE_ROOM_COUNT_CHOICES = [
'0 Doppelzimmer' => 0,
'1 Doppelzimmer' => 1,
'2 Doppelzimmer' => 2,
'3 Doppelzimmer' => 3,
];
public static $DOUBLE_ROOM_CHILD_COUNT_CHOICES = [
'0 Doppelzimmer [2 Erwachsene + 1 Kind (bis einschl. 11 Jahren)]' => 0,
'1 Doppelzimmer [2 Erwachsene + 1 Kind (bis einschl. 11 Jahren)]' => 1,
'2 Doppelzimmer [2 Erwachsene + 1 Kind (bis einschl. 11 Jahren)]' => 2,
'3 Doppelzimmer [2 Erwachsene + 1 Kind (bis einschl. 11 Jahren)]' => 3,
];
public static $TRIPLE_ROOM_COUNT_CHOICES = [
'0 Dreibettzimmer' => 0,
'1 Dreibettzimmer' => 1,
'2 Dreibettzimmer' => 2,
];
public static $TRIPLE_ROOM_CHILD_COUNT_CHOICES = [
'0 Dreibettzimmer [3 Erwachsene + 1 Kind (bis einschl. 11 Jahren)]' => 0,
'1 Dreibettzimmer [3 Erwachsene + 1 Kind (bis einschl. 11 Jahren)]' => 1,
'2 Dreibettzimmer [3 Erwachsene + 1 Kind (bis einschl. 11 Jahren)]' => 2,
];
public static $NATION_CHOICES = [
'Deutschland' => 27,
'Österreich' => 34,
'Schweiz' => 181,
'Niederlande' => 196,
'Sonstiges' => 197,
];
public static $SALUTATION_CHOICES = [
'Herr' => BookingRequest::MR,
'Frau' => BookingRequest::MRS
];
/*
//**
* {@inheritdoc}
* /
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['travel_date'] = $options['travel_date'];
$view->vars['travel_program'] = $options['travel_program'];
}
*/
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'travel_date' => null,
'travel_program' => null,
'nationalities' => null,
'data_class' => 'AppBundle\Entity\BookingRequest',
]);
$resolver->setAllowedTypes('travel_date', ['AppBundle\Entity\TravelDate']);
$resolver->setAllowedTypes('travel_program', ['AppBundle\Entity\TravelProgram']);
}
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
/* @var TravelDate $travelDate */
$travelDate = $options['travel_date'];
/* @var TravelProgram $travelProgram */
$travelProgram = $options['travel_program'];
$nationalities = $options['nationalities'];
$builder
->add('salutation', ChoiceType::class, [
//'placeholder' => 'Anrede (Bitte wählen) *',
'choices' => self::$SALUTATION_CHOICES,
'constraints' => [
new NotNull(),
new Choice(['choices' => self::$SALUTATION_CHOICES])
]
])
->add('firstName')
->add('lastName')
->add('streetAddress')
->add('zipCode')
->add('city')
->add('nation', ChoiceType::class, [
'choices' => self::$NATION_CHOICES,
'constraints' => [
new NotNull(),
new Choice(['choices' => self::$NATION_CHOICES])
]
])
->add('phone')
->add('mobile')
->add('email',
EmailType::class, [
'constraints' =>[
new Email([
'message'=>'Dies ist nicht das richtige E-Mail-Format, bitte korrigieren.'
]),
new NotBlank([
'message' => 'Das Feld E-Mail darf nicht leer sein.'
])
]
])
->add('rooms', CollectionType::class, [
'entry_type' => RoomType::class,
'entry_options' => array(
'nationalities' =>$nationalities,
),
'by_reference' => false,
])
->add('notes', TextareaType::class, ['required' => false])
->add('acceptTerms', CheckboxType::class, ['required' => true])
->add('acceptPrivacy', CheckboxType::class, ['required' => true])
->add('acceptLegalRights', CheckboxType::class, ['required' => true])
;
$builder->add('departure', EntityType::class, [
'placeholder' => 'Abflugort (Bitte wählen) *',
'class' => 'AppBundle\Entity\TravelDeparturePoint',
'choices' => $travelDate->getDepartures(),
'constraints' => [
new NotNull(),
new Choice([
'choices' => $travelDate->getDepartures()
]
)]
]);
$builder->add('singleRoomCount', ChoiceType::class, [
'choices' => self::$SINGLE_ROOM_COUNT_CHOICES,
'constraints' => [
new Choice(['choices' => self::$SINGLE_ROOM_COUNT_CHOICES]
)]
]);
$builder->add('singleRoomChildCount', ChoiceType::class, [
'choices' => self::$SINGLE_ROOM_CHILD_COUNT_CHOICES,
'constraints' => [
new Choice(['choices' => self::$SINGLE_ROOM_CHILD_COUNT_CHOICES]
)]
]);
$builder->add('doubleRoomCount', ChoiceType::class, [
'choices' => self::$DOUBLE_ROOM_COUNT_CHOICES,
'constraints' => [
new Choice(['choices' => self::$DOUBLE_ROOM_COUNT_CHOICES]
)]
]);
$builder->add('doubleRoomChildCount', ChoiceType::class, [
'choices' => self::$DOUBLE_ROOM_CHILD_COUNT_CHOICES,
'constraints' => [
new Choice(['choices' => self::$DOUBLE_ROOM_CHILD_COUNT_CHOICES]
)]
]);
$builder->add('tripleRoomCount', ChoiceType::class, [
'choices' => self::$TRIPLE_ROOM_COUNT_CHOICES,
'constraints' => [
new Choice(['choices' => self::$TRIPLE_ROOM_COUNT_CHOICES]
)]
]);
$builder->add('tripleRoomChildCount', ChoiceType::class, [
'choices' => self::$TRIPLE_ROOM_CHILD_COUNT_CHOICES,
'constraints' => [
new Choice(['choices' => self::$TRIPLE_ROOM_CHILD_COUNT_CHOICES]
)]
]);
$builder->add('extraBookingDaysBefore', ChoiceType::class, [
'choices' => self::$EXTRA_BOOKING_DAYS,
'constraints' => [
new Choice(['choices' => self::$EXTRA_BOOKING_DAYS]
)]
]);
$builder->add('extraBookingDaysAfter', ChoiceType::class, [
'choices' => self::$EXTRA_BOOKING_DAYS,
'constraints' => [
new Choice(['choices' => self::$EXTRA_BOOKING_DAYS]
)]
]);
$insuranceChoices = [];
if ($travelProgram->getInsurance1())
{
$insuranceChoices[$travelProgram->getInsurance1()->getName()] = $travelProgram->getInsurance1();
}
if ($travelProgram->getInsurance2())
{
$insuranceChoices[$travelProgram->getInsurance2()->getName()] = $travelProgram->getInsurance2();
}
if ($travelProgram->getInsurance3())
{
$insuranceChoices[$travelProgram->getInsurance3()->getName()] = $travelProgram->getInsurance3();
}
if ($travelProgram->getInsurance4())
{
$insuranceChoices[$travelProgram->getInsurance4()->getName()] = $travelProgram->getInsurance4();
}
if (!empty($insuranceChoices))
{
$builder->add('insurance', EntityType::class, [
'class' => 'AppBundle\Entity\TravelInsurance',
'placeholder' => 'keine Reiseversicherung',
'choices' => $insuranceChoices,
'expanded' => true,
'constraints' => [
new Choice(['choices' => $insuranceChoices])
]
]);
}
//$travelDate->getPrices()[0]->getPriceType()
if ($travelDate->hasComfortCategory())
{
$builder->add('comfort', CheckboxType::class, ['required' => false]);
}
$travelOptions = $travelProgram->getOptions();
if ($travelOptions instanceof Collection)
{
$travelOptions = $travelOptions->toArray();
}
if (!empty($travelOptions))
{
$builder->add('travelOptions', ChoiceType::class, [
'choices' => $travelOptions,
'expanded' => true,
'multiple' => true,
'constraints' => [
new Choice([
'choices' => $travelOptions,
'multiple' => true
])
]
]);
}
}
}

View file

@ -0,0 +1,90 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 02/21/2017
*/
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\NotNull;
class ContactRequestType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => 'AppBundle\Entity\ContactRequest',
]);
}
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$travelerCountChoices = [];
for ($i = 1; $i <= 20; ++$i)
{
$travelerCountChoices[$i] = $i;
}
$builder
->add('salutation', ChoiceType::class, [
'placeholder' => 'Anrede (Bitte wählen) *',
'choices' => BookingRequestType::$SALUTATION_CHOICES,
'constraints' => [
new Choice(['choices' => BookingRequestType::$SALUTATION_CHOICES])
],
'required' => false,
])
->add('firstName', TextType::class, ['required' => false])
->add('lastName', TextType::class, ['required' => true])
->add('streetAddress')
->add('zipCode')
->add('city')
->add('nation', ChoiceType::class, [
'placeholder' => 'Land (Bitte wählen)',
'choices' => BookingRequestType::$NATION_CHOICES,
'constraints' => [
new NotNull(),
new Choice(['choices' => BookingRequestType::$NATION_CHOICES])
],
'data' => BookingRequestType::$NATION_CHOICES['Deutschland'],
])
->add('phone', TextType::class, ['required' => false])
->add('mobilePhone')
->add('email', EmailType::class, ['required' => true])
->add('travelerCount', ChoiceType::class, [
'placeholder' => 'Anzahl der Reisenden (Bitte wählen)',
'choices' => $travelerCountChoices,
'constraints' => [
new Choice(['choices' => $travelerCountChoices])
],
'required' => false,
])
->add('notes', TextareaType::class, ['required' => false, 'attr' => ['max_length' => 100]])
->add('departure0')
->add('departure1')
->add('departure2')
->add('start', StDateType::class, ['required' => false])
->add('end', StDateType::class, ['required' => false])
->add('duration')
->add('acceptPrivacy', CheckboxType::class, ['required' => true])
->add('acceptProcessing', CheckboxType::class, ['required' => true])
;
}
}

View file

@ -0,0 +1,37 @@
<?php
/**
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
* @date 02/20/2017
*/
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
class DatalistType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setRequired(['choices']);
}
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['choices'] = $options['choices'];
}
public function getName()
{
return 'datalist';
}
public function getParent()
{
return TextType::class;
}
}

View file

@ -0,0 +1,207 @@
<?php
namespace AppBundle\Form;
//TODO bereinigen
use AppBundle\Entity\BookingRequest;
use AppBundle\Entity\TravelDate;
use AppBundle\Entity\Traveler;
use AppBundle\Entity\TravelProgram;
use AppBundle\Util;
use Doctrine\Common\Collections\Collection;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use AppBundle\Form\StPlainDateType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\RangeType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotBlank;
use AppBundle\Entity\TravelNationality;
class FewoBookingRequestType extends AbstractType
{
public static $SALUTATION_CHOICES = [
'Herr' => 1,
'Frau' => 2
];
public static $NATIONALITY_CHOICES = [];
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'lodging' => null,
'maxPersons' => null,
'maxAdults' => null,
'maxChilds' => null,
'nationalities' => null,
'toDate' => null,
'fromDate' => null,
'data_class' => 'AppBundle\Entity\FewoBookingRequest',
]);
$resolver->setAllowedTypes('lodging', ['AppBundle\Entity\FewoLodging']);
$resolver->setAllowedTypes('toDate', ['string', 'NULL']);
$resolver->setAllowedTypes('fromDate', ['string', 'NULL']);
}
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$maxPersons = $options['maxPersons'];
$maxAdults = $options['maxAdults'];
$maxChilds = $options['maxChilds'];
$fromDate= $options['fromDate'];
$toDate = $options['toDate'];
$fromDateDateTime = new \DateTime($fromDate);
$toDateDateTime = new \DateTime($toDate);
$TRAVELERS_CHOICES = [
'1' => 1,
];
$TRAVELERS_ADULTS = [
'1' => 1,
];
$TRAVELERS_CHILDS = [
'0' => 0,
];
if($maxPersons > 1)
{
for($i = 2; $i <= $maxPersons; $i++)
{
$TRAVELERS_CHOICES[] = $i;
}
}
if($maxAdults > 1)
{
for($i = 2; $i <= $maxAdults; $i++)
{
$TRAVELERS_ADULTS[] = $i;
}
}
if($maxChilds > 1)
{
for($i = 1; $i <= $maxChilds; $i++)
{
$TRAVELERS_CHILDS[] = $i;
}
}
if(!count(self::$NATIONALITY_CHOICES)){
$nationalities = $options['nationalities'];
if($nationalities){
foreach ($nationalities as $nationality){
self::$NATIONALITY_CHOICES[$nationality['name']] = $nationality['id'];
}
}
}
$builder
->add('fromDate', StDateType::class, [
//options
"attr" => array(
"class" => "form-control",
'placeholder' => 'StartDatum',
'data-range' => 1,
),
'data' => $fromDateDateTime
])
->add('toDate', StDateType::class, [
"attr" => array(
"class" => "form-control",
'placeholder' => 'EndDatum',
'data-range' => 1,
),
'data' => $toDateDateTime
])
->add('travelerCount', ChoiceType::class, [
'choices' => $TRAVELERS_CHOICES,
'constraints' => [
// new NotNull(),
new Choice(['choices' => $TRAVELERS_CHOICES])
]
])
->add('travelerCountAdult', ChoiceType::class, [
'choices' => $TRAVELERS_ADULTS,
'constraints' => [
new NotNull(),
new Choice(['choices' => $TRAVELERS_ADULTS])
]
])
->add('travelerCountChild', ChoiceType::class, [
'choices' => $TRAVELERS_CHILDS,
'constraints' => [
new NotNull(),
new Choice(['choices' => $TRAVELERS_CHILDS])
]
])
->add('salutation', ChoiceType::class,[
'choices' => self::$SALUTATION_CHOICES,
'constraints' => [
new NotNull(),
new Choice(['choices' => self::$SALUTATION_CHOICES])
]
])
->add('firstName')
->add('lastName')
->add('nation', ChoiceType::class, [
'choices' => self::$NATIONALITY_CHOICES,
'constraints' => [
new NotNull(),
new Choice(['choices' => self::$NATIONALITY_CHOICES])
]
])
->add('streetAddress')
->add('zipCode')
->add('city')
->add('phone')
->add('mobile')
->add('email',
EmailType::class, [
'constraints' =>[
new Email([
'message'=>'Dies ist nicht das richtige E-Mail-Format, bitte korrigieren.'
]),
new NotBlank([
'message' => 'Das Feld E-Mail darf nicht leer sein.'
])
]
])
->add('notes', TextareaType::class, ['required' => false])
//->add('acceptTerms', CheckboxType::class, ['required' => true])
->add('acceptPrivacy', CheckboxType::class, ['required' => true])
->add('acceptRentalConditions', CheckboxType::class, ['required' => true])
//->add('acceptProcessing', CheckboxType::class, ['required' => true])
;
}
}

View file

@ -0,0 +1,49 @@
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
class FewoLodgingGroupImageType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('file', FileType::class, [
'data_class' => null
])
->add('pos')
->add('comp', HiddenType::class, ['required' => false])
->add('fileName')
->add('description')
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\FewoLodgingGroupImage'
));
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'appbundle_fewolodginggroupimage';
}
}

View file

@ -0,0 +1,47 @@
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class FewoLodgingImageType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('file', FileType::class, [
'data_class' => null
])
->add('pos')
->add('fileName')
->add('description')
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\FewoLodgingImage'
));
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'appbundle_fewolodgingimage';
}
}

View file

@ -0,0 +1,103 @@
<?php
namespace AppBundle\Form;
use Doctrine\Common\Collections\Collection;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\NotNull;
use AppBundle\Entity\FewoSeason;
class FewoLodgingType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', null, [
'required' => true,
])
->add('description', null, [
'required' => true,
'attr' => array('rows' => '7')
])
->add('equipment', null, [
'required' => true,
'attr' => array('rows' => '7')
])
->add('adress1', null, [
'required' => true,
])
->add('adress2')
->add('zipCode', null, [
'required' => true,
])
->add('city', null, [
'required' => true,
])
->add('maximumPersons', TextType::class, [
'required' => true,
])
->add('maximumAdults', TextType::class, [
'required' => true,
])
->add('maximumChilds', TextType::class, [
'required' => true,
])
->add('deposit', null, [
'required' => true,
])
//->add('calendarVisible')
->add('group', EntityType::class, [
'placeholder' => '(Bitte wählen) *',
'class' => 'AppBundle\Entity\FewoLodgingGroup',
'constraints' => [
new NotNull()
]
])
->add('type', EntityType::class, [
'placeholder' => '(Bitte wählen) *',
'class' => 'AppBundle\Entity\FewoLodgingType',
'constraints' => [
new NotNull()
]
])
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\FewoLodging'
));
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'appbundle_fewolodging';
}
}

View file

@ -0,0 +1,57 @@
<?php
namespace AppBundle\Form;
use Doctrine\Common\Collections\Collection;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\NotNull;
use AppBundle\Entity\FewoSeason;
class FewoLodgingTypeGroup extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', null, [
'required' => true,
])
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\FewoLodgingGroup'
));
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'appbundle_fewolodgingtypegroup';
}
}

View file

@ -0,0 +1,60 @@
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\NotNull;
class FewoPriceType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$lodging = $options['lodging'];
$builder
->add('perNight')
->add('flatPrice')
->add('season', EntityType::class, [
'placeholder' => 'Bitte wählen',
'class' => 'AppBundle\Entity\FewoSeason',
'choices' => $lodging->getChoosableSeasons(),
'constraints' => [
new NotNull(),
new Choice([
'choices' => $lodging->getChoosableSeasons()
]
)]
])
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'lodging' => null,
'data_class' => 'AppBundle\Entity\FewoPrice'
));
$resolver->setAllowedTypes('lodging', ['AppBundle\Entity\FewoLodging']);
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'appbundle_fewoprice';
}
}

View file

@ -0,0 +1,112 @@
<?php
namespace AppBundle\Form;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use AppBundle\Form\StDateType;
class FewoReservationType extends AbstractType
{
public static $STATUS_CHOICES = [
'Belegt' => 0,
'Nicht verfügbar' => 1,
];
public static $TYPE_CHOICES = [
'Buchung' => 0,
'Händisch' => 1
];
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$lodging = $options['lodging'];
$fromDate = $options['fromDate'];
$toDate = $options['toDate'];
$fromDateDateTime = new \DateTime($fromDate);
$toDateDateTime = new \DateTime($toDate);
$lodgingArr[] = $lodging;
$builder
->add('lodging', EntityType::class, [
'class' => 'AppBundle\Entity\FewoLodging',
'choices' => $lodgingArr,
'constraints' => [
new Choice(['choices' => $lodgingArr])
],
'required'=> true
])
->add('fromDate', StDateType::class, [
//options
"attr" => array(
"class" => "form-control",
'placeholder' => 'StartDatum',
'data-range' => 1,
),
'data' => $fromDateDateTime
])
->add('toDate', StDateType::class, [
"attr" => array(
"class" => "form-control",
'placeholder' => 'EndDatum',
'data-range' => 1,
),
'data' => $toDateDateTime
])
->add('status', ChoiceType::class, [
'placeholder' => 'Status (Bitte wählen) *',
'choices' => self::$STATUS_CHOICES,
'constraints' => [
new Choice(['choices' => self::$STATUS_CHOICES])
],
'required' => true,
])
/*
->add('type', ChoiceType::class, [
'placeholder' => 'Buchungstyp (Bitte wählen) *',
'choices' => self::$TYPE_CHOICES,
'constraints' => [
new Choice(['choices' => self::$TYPE_CHOICES])
],
'required' => true,
])
*/
//->add('lodging') // wird händisch gesetzt
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'lodging' => null,
'fromDate' => null,
'toDate' => null,
'data_class' => 'AppBundle\Entity\FewoReservation'
));
$resolver->setAllowedTypes('lodging', ['AppBundle\Entity\FewoLodging']);
$resolver->setAllowedTypes('fromDate', ['string', 'NULL']);
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'appbundle_feworeservation';
}
}

View file

@ -0,0 +1,80 @@
<?php
namespace AppBundle\Form;
use Doctrine\Common\Collections\Collection;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use AppBundle\Form\StDateType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\NotNull;
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}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name')
->add('fromDate', StDateType::class, [
//options
])
->add('toDate', StDateType::class, [
//options
])
->add('minimumStay', TextType::class, [
])
->add('description')
->add('onlyWeekday', ChoiceType::class, [
'choices' => self::$WEEKDAY_CHOICES,
'constraints' => [
new Choice(['choices' => self::$WEEKDAY_CHOICES])
]
])
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\FewoSeason'
));
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'appbundle_fewoseason';
}
}

View file

@ -0,0 +1,53 @@
<?php
namespace AppBundle\Form;
//use AppBundle\Entity\Traveler;
use AppBundle\Entity\Room;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\NotNull;
class RoomType extends AbstractType
{
public static $TYPE_CHOICES = [
'Einzelzimmer' => Room::SINGLE,
'Doppelzimmer' => Room::DOUBLE,
'Dreibettzimmer' => Room::TRIPLE
];
/**
* @param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'nationalities' => null,
'data_class' => 'AppBundle\Entity\Room'
));
}
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$nationalities = $options['nationalities'];
$builder
->add('travelers', CollectionType::class, [
'entry_type' => TravelerType::class,
'entry_options' => array(
'nationalities' =>$nationalities,
),
]);
}
}

Some files were not shown because too many files have changed in this diff Show more