* Suchformular auf Startseite funktioniert nun
* Neueste Design-Änderungen aufgenommen * Sortierung auf Reiseübersichtsseiten * Fehler bei Suche behoben git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3285 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
parent
99c6715712
commit
23b2c7a7e8
12 changed files with 217 additions and 119 deletions
|
|
@ -15,83 +15,6 @@ use Symfony\Component\Stopwatch\Stopwatch;
|
|||
|
||||
class DefaultController extends Controller
|
||||
{
|
||||
|
||||
/*
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EntityManager
|
||||
*/
|
||||
|
|
@ -100,11 +23,9 @@ Für jeden Kindknoten
|
|||
return $this->getDoctrine()->getManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(path="/{req}", requirements={"req": ".+"})
|
||||
*/
|
||||
public function defaultAction(Request $request)
|
||||
{
|
||||
// #TODO 404
|
||||
die ("caught");
|
||||
}
|
||||
|
||||
|
|
@ -113,8 +34,14 @@ Für jeden Kindknoten
|
|||
*/
|
||||
public function homeAction()
|
||||
{
|
||||
//$departures = $this->getEntityManager()->getRepository('AppBundle:TravelDeparturePoint')->findAll();
|
||||
$destinations = $this->getEntityManager()->getRepository('AppBundle:TravelCountry')->findAll();
|
||||
|
||||
return $this->render('default/pages/home.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'destinations' => $destinations,
|
||||
'startDate' => new \DateTime('+5 day'),
|
||||
'endDate' => new \DateTime('+19 day')
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -161,14 +88,25 @@ Für jeden Kindknoten
|
|||
/**
|
||||
* @Route("/suche")
|
||||
*/
|
||||
public function searchAction()
|
||||
public function searchAction(Request $request)
|
||||
{
|
||||
$stopwatch = $this->get('debug.stopwatch');
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$destinationsIds = [6,7];
|
||||
$destination = $em->getRepository('AppBundle:TravelCountry')->find($request->query->get('c'));
|
||||
if ($destination)
|
||||
{
|
||||
$destinationsIds = [$destination->getId()];
|
||||
}
|
||||
$startDate = $request->query->has('b')
|
||||
? \DateTime::createFromFormat('d.m.Y', $request->query->get('b'))
|
||||
: new \DateTime();
|
||||
$endDate = \DateTime::createFromFormat('d.m.Y', $request->query->get('e'));
|
||||
|
||||
$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);
|
||||
$startDate, $endDate, $destinationsIds, true);
|
||||
$stopwatch->stop('search');
|
||||
|
||||
return $this->render('default/pages/search.html.twig', [
|
||||
|
|
@ -206,8 +144,84 @@ Für jeden Kindknoten
|
|||
]);
|
||||
}
|
||||
|
||||
/*
|
||||
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();
|
||||
$lft = 0;
|
||||
$this->createTree(0, $lft, 0);
|
||||
$em->commit();
|
||||
$em->flush();
|
||||
|
||||
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.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,12 +20,15 @@ class PageRepository extends NestedTreeRepository
|
|||
public function getChildrenWithTravelProgramsAndDates(Page $page)
|
||||
{
|
||||
$pages = $this->getChildrenQueryBuilder($page)
|
||||
->leftJoin('node.travelProgram', 'tp')
|
||||
->addSelect('tp')
|
||||
->andWhere('tp.status > 0')
|
||||
->andWhere('node.status > 0')
|
||||
->getQuery()
|
||||
->execute();
|
||||
->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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@ class TravelCountry
|
|||
*/
|
||||
private $feedbackPage;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\TravelProgram", mappedBy="countries")
|
||||
*/
|
||||
private $programs;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ final class TravelDate
|
|||
$lowest = -1;
|
||||
foreach ($this->getPrices() as $price)
|
||||
{
|
||||
if ($price->getPriceType() == 3)
|
||||
if ($price->getPriceTypeId() == 3)
|
||||
{
|
||||
// Use double room if available (#1076)
|
||||
return /*$price->getEffectiveDiscountPrice() ??*/ $price->getEffectivePrice();
|
||||
|
|
|
|||
|
|
@ -40,7 +40,10 @@ class TravelPeriodRepository extends \Doctrine\ORM\EntityRepository
|
|||
$startDate = $now;
|
||||
}
|
||||
$startDateStr = $startDate->format('Y-m-d');
|
||||
$endDateStr = $endDate->format('Y-m-d');
|
||||
if ($endDate)
|
||||
{
|
||||
$endDateStr = $endDate->format('Y-m-d');
|
||||
}
|
||||
|
||||
$qb = $this->getEntityManager()->createQueryBuilder()
|
||||
->from('AppBundle:TravelProgram', 'tp', 'tp.id')
|
||||
|
|
@ -64,7 +67,7 @@ class TravelPeriodRepository extends \Doctrine\ORM\EntityRepository
|
|||
{
|
||||
$priceTypeKey = 'price_'. $priceType->getId();
|
||||
$qb->leftJoin('p.prices', $priceTypeKey, Expr\Join::WITH,
|
||||
$priceTypeKey .'.priceType = '. $priceType->getId(), null, $priceTypeKey .'.priceType');
|
||||
$priceTypeKey .'.priceType = '. $priceType->getId(), $priceTypeKey .'.priceTypeId');
|
||||
$qb->addSelect($priceTypeKey);
|
||||
}
|
||||
$qb->leftJoin('p.discounts', 'discount');
|
||||
|
|
@ -77,11 +80,14 @@ class TravelPeriodRepository extends \Doctrine\ORM\EntityRepository
|
|||
// 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('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 tpc.country) = '. count($destinationIds));
|
||||
$qb->having('COUNT(DISTINCT tc) = '. count($destinationIds));
|
||||
}
|
||||
}
|
||||
$qb->groupBy('p.id, p_dep.id, d.id');
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ class TravelProgram
|
|||
private $departures;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\TravelCountry")
|
||||
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\TravelCountry", inversedBy="programs")
|
||||
* @ORM\JoinTable(name="travel_program_country",
|
||||
* joinColumns={@ORM\JoinColumn(name="program_id", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="country_id", referencedColumnName="id")}
|
||||
|
|
@ -1501,4 +1501,16 @@ class TravelProgram
|
|||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
public function getPreviewImage()
|
||||
{
|
||||
foreach ($this->getImages() as $image)
|
||||
{
|
||||
if ($image->getType() == 2)
|
||||
{
|
||||
return $image;
|
||||
}
|
||||
}
|
||||
return $this->getImages()[0];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -756,6 +756,55 @@ a,
|
|||
.travel-wrapper .item > a.item-button.dobble_line {
|
||||
height: 3.6em;
|
||||
}
|
||||
.travel-wrapper .lb {
|
||||
position: relative;
|
||||
}
|
||||
.travel-wrapper .lb .cstar_right {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
background: url(../images/star.png) no-repeat scroll center center / cover rgba(0, 0, 0, 0);
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
padding-top: 20px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
right: 4px;
|
||||
top: 6px;
|
||||
color: #1a457c;
|
||||
}
|
||||
.travel-wrapper .lb .cstar_left {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
background: url(../images/star.png) no-repeat scroll center center / cover rgba(0, 0, 0, 0);
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
padding-top: 20px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
left: 4px;
|
||||
top: 6px;
|
||||
color: #1a457c;
|
||||
}
|
||||
.travel-wrapper .lb .cprice {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
left: 0;
|
||||
top: 140px;
|
||||
background-color: #648859;
|
||||
color: #fff;
|
||||
padding: 4px 6px 4px 12px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.travel-wrapper .lb .cdiscount {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
right: 0;
|
||||
top: 23px;
|
||||
background-color: #ffc926;
|
||||
color: #1a457c;
|
||||
padding: 4px 12px 4px 6px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.travel-wrapper .item .hl5 {
|
||||
text-overflow: ellipsis;
|
||||
word-wrap: break-word;
|
||||
|
|
|
|||
BIN
trunk/src/AppBundle/Resources/public/images/star.png
Normal file
BIN
trunk/src/AppBundle/Resources/public/images/star.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
Loading…
Add table
Add a link
Reference in a new issue