git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3283 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
parent
75a065758f
commit
7422f06e90
261 changed files with 83347 additions and 0 deletions
71
trunk/src/AppBundle/Controller/BookingController.php
Normal file
71
trunk/src/AppBundle/Controller/BookingController.php
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
|
||||
* @date 12/08/2016
|
||||
*/
|
||||
|
||||
namespace AppBundle\Controller;
|
||||
|
||||
|
||||
use AppBundle\Entity\BookingRequest;
|
||||
use AppBundle\Entity\BreadcrumbEntry;
|
||||
use AppBundle\Entity\Page;
|
||||
use AppBundle\Form\BookingRequestType;
|
||||
use AppBundle\Util;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class BookingController extends Controller
|
||||
{
|
||||
public function indexAction(Page $travelProgramPage, Request $request)
|
||||
{
|
||||
$travelProgram = $travelProgramPage->getTravelProgram();
|
||||
if (!$request->query->has('nr'))
|
||||
{
|
||||
return $this->redirect($travelProgramPage->getUrlPath());
|
||||
}
|
||||
$this->getDoctrine()->getRepository('AppBundle:TravelPeriod')->getTrueTravelPeriods($travelProgram);
|
||||
|
||||
// #TODO Consider changing key of travel dates
|
||||
foreach ($travelProgram->getTravelDates() as $curTravelDate)
|
||||
{
|
||||
if ($curTravelDate->getName() == $request->query->get('nr'))
|
||||
{
|
||||
$travelDate = $curTravelDate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isset($travelDate))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
$form = $this->createForm(BookingRequestType::class, null, [
|
||||
'travel_date' => $travelDate,
|
||||
'travel_program' => $travelProgram
|
||||
]);
|
||||
//$form->submit([]);
|
||||
|
||||
$priceTypeById = $this->getDoctrine()->getRepository('AppBundle:TravelPeriodPriceType')->findAllIndexedById();
|
||||
|
||||
$breadcrumbEntries = Util::createBreadcrumb($travelProgramPage);
|
||||
$breadcrumbEntries[] = new BreadcrumbEntry('Buchen', $travelProgramPage->getUrlPath() .'/buchen');
|
||||
|
||||
return $this->render('default/pages/booking.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'page' => $travelProgramPage,
|
||||
'travel_program' => $travelProgram,
|
||||
'travel_date' => $travelDate,
|
||||
'form' => $form->createView(),
|
||||
'price_type_by_id' => $priceTypeById,
|
||||
'breadcrumb_entries' => $breadcrumbEntries,
|
||||
]);
|
||||
}
|
||||
|
||||
public function calculatePrice()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
210
trunk/src/AppBundle/Controller/DefaultController.php
Normal file
210
trunk/src/AppBundle/Controller/DefaultController.php
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
<?php
|
||||
|
||||
namespace AppBundle\Controller;
|
||||
|
||||
use AppBundle\Entity\Page;
|
||||
use AppBundle\Entity\TravelProgram;
|
||||
use AppBundle\Util;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\Query\Expr;
|
||||
use Gedmo\Tree\TreeListener;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Stopwatch\Stopwatch;
|
||||
|
||||
class DefaultController extends Controller
|
||||
{
|
||||
/**
|
||||
* @return EntityManager
|
||||
*/
|
||||
public function getEntityManager()
|
||||
{
|
||||
return $this->getDoctrine()->getManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(path="/{req}", requirements={"req": ".+"})
|
||||
*/
|
||||
public function defaultAction(Request $request)
|
||||
{
|
||||
die ("caught");
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/")
|
||||
*/
|
||||
public function homeAction()
|
||||
{
|
||||
return $this->render('default/pages/home.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
]);
|
||||
}
|
||||
|
||||
public function cmsDefaultAction(Page $page)
|
||||
{
|
||||
return $this->render('default/pages/default.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'page' => $page
|
||||
]);
|
||||
}
|
||||
|
||||
public function cmsOverviewAction(Page $page)
|
||||
{
|
||||
return $this->render('default/pages/overview.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'page' => $page
|
||||
]);
|
||||
}
|
||||
|
||||
public function cmsTravelProgramOverviewAction(Page $page)
|
||||
{
|
||||
$childPages =
|
||||
$this->getEntityManager()->getRepository('AppBundle:Page')->getChildrenWithTravelProgramsAndDates($page);
|
||||
|
||||
return $this->render('default/pages/travelProgramOverview.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'page' => $page,
|
||||
'child_pages' => $childPages
|
||||
]);
|
||||
}
|
||||
|
||||
public function cmsTravelProgramAction(Page $page)
|
||||
{
|
||||
$this->getDoctrine()->getRepository('AppBundle:TravelPeriod')->getTrueTravelPeriods($page->getTravelProgram());
|
||||
|
||||
// replace this example code with whatever you need
|
||||
return $this->render('default/pages/travelProgram.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'page' => $page,
|
||||
'travel_program' => $page->getTravelProgram()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/suche")
|
||||
*/
|
||||
public function searchAction()
|
||||
{
|
||||
$stopwatch = $this->get('debug.stopwatch');
|
||||
|
||||
$stopwatch->start('search');
|
||||
$r = $this->getDoctrine()->getRepository('AppBundle:TravelPeriod')->getTravelProgramsWithTravelDatesForTimePeriod(
|
||||
//new \DateTime('2014-01-01'), new \DateTime('2017-01-01'), null, true);
|
||||
new \DateTime(), new \DateTime('2016-12-12'), null, true);
|
||||
$stopwatch->stop('search');
|
||||
|
||||
return $this->render('default/pages/search.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'travel_programs' => $r
|
||||
]);
|
||||
}
|
||||
|
||||
public function headerAction()
|
||||
{
|
||||
$qb = $this->getEntityManager()->createQueryBuilder();
|
||||
$navPages = $qb
|
||||
->from('AppBundle:Page', 'page')
|
||||
->select('page')
|
||||
->leftJoin('page.children', 'childPage', Expr\Join::WITH, 'childPage.status > 0')
|
||||
->addSelect('childPage')
|
||||
->where('page.status > 0')
|
||||
->andWhere('page.template = \'overview\'')
|
||||
->andWhere('page.lvl = 0')
|
||||
->orderBy('page.title,childPage.title')
|
||||
->getQuery()
|
||||
->execute()
|
||||
;
|
||||
return $this->render('default/components/header.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'nav_pages' => $navPages
|
||||
]);
|
||||
}
|
||||
|
||||
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)
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
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();
|
||||
|
||||
foreach ($em->getEventManager()->getListeners() as $event => $listeners) {
|
||||
foreach ($listeners as $hash => $listener) {
|
||||
if ($listener instanceof TreeListener)
|
||||
{
|
||||
$em->getEventManager()->removeEventListener($event, $listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$em->beginTransaction();
|
||||
$lft = 0;
|
||||
$this->createTree(0, $lft, 0);
|
||||
$em->commit();
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
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.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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue