#1342 #1343 #1345 #1346 #1349 git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3340 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
parent
27d2713283
commit
652eeb16cb
27 changed files with 994 additions and 204 deletions
|
|
@ -26,7 +26,13 @@ class BookingRequest
|
|||
*/
|
||||
private $departure;
|
||||
|
||||
private $travelerCount;
|
||||
private $singleRoomCount;
|
||||
|
||||
private $doubleRoomCount;
|
||||
|
||||
private $tripleRoomCount;
|
||||
|
||||
private $roomCount;
|
||||
|
||||
/**
|
||||
* @var TravelInsurance $insurance
|
||||
|
|
@ -80,6 +86,10 @@ class BookingRequest
|
|||
|
||||
private $travelers = [];
|
||||
|
||||
private $singleRooms = [];
|
||||
private $doubleRooms = [];
|
||||
private $tripleRooms = [];
|
||||
|
||||
private $notes;
|
||||
|
||||
/**
|
||||
|
|
@ -92,9 +102,11 @@ class BookingRequest
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
for ($i = 0; $i < 4; ++$i)
|
||||
for($i = 0; $i < 5; ++$i)
|
||||
{
|
||||
$this->travelers[] = new Traveler();
|
||||
$this->singleRooms[] = new Room(1);
|
||||
$this->doubleRooms[] = new Room(2);
|
||||
$this->tripleRooms[] = new Room(3);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +131,23 @@ class BookingRequest
|
|||
*/
|
||||
public function getTravelerCount()
|
||||
{
|
||||
return $this->travelerCount;
|
||||
$allUsedTravelersCount = 0;
|
||||
for($i = 0; $i < $this->singleRoomCount; ++$i)
|
||||
{
|
||||
$allUsedTravelersCount += $this->singleRooms[$i]->getTravelerCount();
|
||||
}
|
||||
|
||||
for($i = 0; $i < $this->doubleRoomCount; ++$i)
|
||||
{
|
||||
$allUsedTravelersCount += $this->doubleRooms[$i]->getTravelerCount();
|
||||
}
|
||||
|
||||
for($i = 0; $i < $this->tripleRoomCount; ++$i)
|
||||
{
|
||||
$allUsedTravelersCount += $this->tripleRooms[$i]->getTravelerCount();
|
||||
}
|
||||
|
||||
return $allUsedTravelersCount;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -130,6 +158,89 @@ class BookingRequest
|
|||
$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 TravelInsurance
|
||||
*/
|
||||
|
|
@ -338,12 +449,33 @@ class BookingRequest
|
|||
$this->email = $email;
|
||||
}
|
||||
|
||||
// get und set der Travelers liegt jetzt in Room; sollte so nicht mehr verwendet werden!
|
||||
/**
|
||||
* @return Traveler[]
|
||||
*/
|
||||
public function getTravelers()
|
||||
{
|
||||
return $this->travelers;
|
||||
$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->doubleRoomCount; ++$i)
|
||||
{
|
||||
$allUsedTravelers = array_merge($allUsedTravelers, $this->doubleRooms[$i]->getTravelers());
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $this->tripleRoomCount; ++$i)
|
||||
{
|
||||
$allUsedTravelers = array_merge($allUsedTravelers, $this->tripleRooms[$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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -354,6 +486,76 @@ class BookingRequest
|
|||
$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 getRooms()
|
||||
{
|
||||
$allRooms = [];
|
||||
$allRooms = array_merge($allRooms, $this->singleRooms);
|
||||
$allRooms = array_merge($allRooms, $this->doubleRooms);
|
||||
$allRooms = array_merge($allRooms, $this->tripleRooms);
|
||||
|
||||
return $allRooms;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Room[] $tripleRooms
|
||||
*/
|
||||
public function setRooms($rooms)
|
||||
{
|
||||
// falls man es braucht, nachziehen und oder umstrukturieren (booking.html.twig)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public function addTraveler(Traveler $traveler)
|
||||
{
|
||||
|
|
|
|||
87
trunk/src/AppBundle/Entity/Room.php
Normal file
87
trunk/src/AppBundle/Entity/Room.php
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* @Assert\NotNull
|
||||
* @Assert\Choice(choices={1,2,3})
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @Assert\Valid
|
||||
*/
|
||||
private $travelers = [];
|
||||
|
||||
private $travelerCount;
|
||||
|
||||
public function __construct($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
for($i = 0; $i < $this->type; $i++)
|
||||
{
|
||||
$this->travelers[] = new Traveler();
|
||||
}
|
||||
|
||||
$this->travelerCount = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $type
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -59,7 +59,8 @@ class TravelBookingRepository extends \Doctrine\ORM\EntityRepository
|
|||
}
|
||||
$ret->setInsurances($insurances);
|
||||
}
|
||||
$ret->setParticipants(array_slice($bookingRequest->getTravelers(), 0, $bookingRequest->getTravelerCount()));
|
||||
|
||||
$ret->setParticipants($bookingRequest->getTravelers());
|
||||
$ret->setParticipantsTotal($bookingRequest->getTravelerCount());
|
||||
$ret->setRooms($bookingPriceInfo['rooms']);
|
||||
$ret->setPriceTotal($bookingPriceInfo['total']);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue