Include pax data
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ php_version: "7.3"
|
|||||||
webserver_type: apache-cgi
|
webserver_type: apache-cgi
|
||||||
router_http_port: "80"
|
router_http_port: "80"
|
||||||
router_https_port: "443"
|
router_https_port: "443"
|
||||||
xdebug_enabled: false
|
xdebug_enabled: true
|
||||||
additional_hostnames:
|
additional_hostnames:
|
||||||
- ep-events
|
- ep-events
|
||||||
- ski-boarderweek
|
- ski-boarderweek
|
||||||
|
|||||||
@@ -342,4 +342,12 @@ class Contingent extends AbstractEntity implements EventInterface
|
|||||||
{
|
{
|
||||||
return $this->getBegin() >= $period->getBegin() && $this->getEnd() < $period->getEnd();
|
return $this->getBegin() >= $period->getBegin() && $this->getEnd() < $period->getEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getOccupancy()
|
||||||
|
{
|
||||||
|
return $this->getPax() - $this->getAvailable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
|
|||||||
$qb
|
$qb
|
||||||
->select('c.date as date', 'c.min_nights as minNights')
|
->select('c.date as date', 'c.min_nights as minNights')
|
||||||
->addSelectLiteral('SUM(c.available) as total')
|
->addSelectLiteral('SUM(c.available) as total')
|
||||||
|
->addSelectLiteral('SUM(c.pax) as capacity')
|
||||||
->from('tx_epproducts_domain_model_contingent', 'c')
|
->from('tx_epproducts_domain_model_contingent', 'c')
|
||||||
->innerJoin('c', 'tx_epproducts_domain_model_date', 'd', 'c.date = d.date_start AND c.hotel_code = d.hotel_code')
|
->innerJoin('c', 'tx_epproducts_domain_model_date', 'd', 'c.date = d.date_start AND c.hotel_code = d.hotel_code')
|
||||||
->where('c.hotel = :hotelUid')
|
->where('c.hotel = :hotelUid')
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ class ContingentDataService
|
|||||||
'date' => $row['date'],
|
'date' => $row['date'],
|
||||||
'minNights' => $row['minNights'],
|
'minNights' => $row['minNights'],
|
||||||
'total' => $row['total'],
|
'total' => $row['total'],
|
||||||
|
'capacity' => $row['capacity'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ class ContingentImportService implements SingletonInterface
|
|||||||
protected function parseContingent(\SimpleXMLElement $xmlContingent)
|
protected function parseContingent(\SimpleXMLElement $xmlContingent)
|
||||||
{
|
{
|
||||||
$hotelCode = (string) $xmlContingent['code'];
|
$hotelCode = (string) $xmlContingent['code'];
|
||||||
$sql = 'SELECT h.uid uid, h.groupsch_id groupsch_id
|
$sql = 'SELECT h.uid uid
|
||||||
FROM tx_epproducts_domain_model_hotel h
|
FROM tx_epproducts_domain_model_hotel h
|
||||||
LEFT JOIN tx_epproducts_domain_model_matchcode m ON (h.uid = m.entity AND m.entity_type = "hotel")
|
LEFT JOIN tx_epproducts_domain_model_matchcode m ON (h.uid = m.entity AND m.entity_type = "hotel")
|
||||||
WHERE h.deleted = 0 AND h.hidden = 0 AND h.code = :code OR m.code = :code
|
WHERE h.deleted = 0 AND h.hidden = 0 AND h.code = :code OR m.code = :code
|
||||||
@@ -241,12 +241,12 @@ class ContingentImportService implements SingletonInterface
|
|||||||
$status = Contingent::STATUS_BLOCKED;
|
$status = Contingent::STATUS_BLOCKED;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$pax = $roomType['pax'] * (int) $xmlRoom['kontingent'];
|
$capacity = (int) $xmlRoom['kontingent'] * $roomType['pax'];
|
||||||
$availableRooms = (int) $xmlRoom['frei'] > 0 ? (int) $xmlRoom['frei'] : 0;
|
$availableRooms = (int) $xmlRoom['frei'] > 0 ? (int) $xmlRoom['frei'] : 0;
|
||||||
$availablePax = $availableRooms * $roomType['pax'];
|
$availablePax = $availableRooms * $roomType['pax'];
|
||||||
}
|
}
|
||||||
if ($availablePax === 0 && $roomType['ctrl'] === false) {
|
if ($availablePax === 0 && $roomType['ctrl'] === false) {
|
||||||
continue;
|
//continue;
|
||||||
}
|
}
|
||||||
$minPrice = (int) $xmlRoom['abpreis'];
|
$minPrice = (int) $xmlRoom['abpreis'];
|
||||||
$minNights = (int) $xmlRoom['abpreis_naechte'];
|
$minNights = (int) $xmlRoom['abpreis_naechte'];
|
||||||
@@ -262,8 +262,7 @@ class ContingentImportService implements SingletonInterface
|
|||||||
'hotel_bus_pro_id' => $hotelData['busProId'],
|
'hotel_bus_pro_id' => $hotelData['busProId'],
|
||||||
'room_code' => $roomCode,
|
'room_code' => $roomCode,
|
||||||
'room_label' => $roomLabel,
|
'room_label' => $roomLabel,
|
||||||
'groupsch_id' => $hotelData['groupsch_id'],
|
'pax' => $capacity,
|
||||||
'pax' => $pax,
|
|
||||||
'available' => $availablePax,
|
'available' => $availablePax,
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
'date' => $date->format('Y-m-d'),
|
'date' => $date->format('Y-m-d'),
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace EP\EpProducts\Service;
|
|||||||
*
|
*
|
||||||
* Copyright notice
|
* Copyright notice
|
||||||
*
|
*
|
||||||
* (c) 2019 Björn Fromme <[email protected]>, dreipunktnull
|
* (c) 2020 Björn Fromme <[email protected]>, dreipunktnull
|
||||||
*
|
*
|
||||||
* All rights reserved
|
* All rights reserved
|
||||||
*
|
*
|
||||||
@@ -36,13 +36,16 @@ use TYPO3\CMS\Core\SingletonInterface;
|
|||||||
|
|
||||||
class IcalService implements SingletonInterface
|
class IcalService implements SingletonInterface
|
||||||
{
|
{
|
||||||
const THRESHOLD = 75;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ContingentRepository
|
* @var ContingentRepository
|
||||||
*/
|
*/
|
||||||
protected $contingentRepository;
|
protected $contingentRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Vcalendar
|
||||||
|
*/
|
||||||
|
protected $vcalendar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ContingentRepository $contingentRepository
|
* @param ContingentRepository $contingentRepository
|
||||||
*/
|
*/
|
||||||
@@ -69,43 +72,13 @@ class IcalService implements SingletonInterface
|
|||||||
$events = [];
|
$events = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$vcalendar = $this->createCalendarInstance();
|
$this->createCalendarInstance();
|
||||||
|
|
||||||
$paxOccupiedCurrent = $dateStart = $dateEnd = null;
|
$this->generateOccupancyItems($events);
|
||||||
|
$this->generateBlockedItems($events);
|
||||||
foreach ($events as $event) {
|
|
||||||
/** @var Contingent $event */
|
|
||||||
$paxTotal = $event->getPax();
|
|
||||||
$paxAvailable = $event->getAvailable();
|
|
||||||
|
|
||||||
if (Contingent::STATUS_BLOCKED === $event->getStatus()) {
|
|
||||||
$paxOccupied = $paxTotal;
|
|
||||||
} else {
|
|
||||||
$paxOccupied = $paxTotal - $paxAvailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($paxOccupied !== $paxOccupiedCurrent) {
|
|
||||||
if (null === $dateStart) {
|
|
||||||
$dateStart = $event->getBegin();
|
|
||||||
} else {
|
|
||||||
$dateEnd = $event->getEnd();
|
|
||||||
if ($paxOccupiedCurrent > 0) {
|
|
||||||
$this->addCalendarItem(
|
|
||||||
$vcalendar,
|
|
||||||
$dateStart,
|
|
||||||
$dateEnd,
|
|
||||||
$paxOccupiedCurrent
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$dateStart = $dateEnd = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$paxOccupiedCurrent = $paxOccupied;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$feed = $vcalendar->vtimezonePopulate()->createCalendar();
|
$feed = $this->vcalendar->vtimezonePopulate()->createCalendar();
|
||||||
}
|
}
|
||||||
catch (\Exception $e) {
|
catch (\Exception $e) {
|
||||||
$feed = '';
|
$feed = '';
|
||||||
@@ -115,19 +88,69 @@ class IcalService implements SingletonInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Vcalendar $vcalendar
|
* @param array $events
|
||||||
* @param \DateTime $dateStart
|
|
||||||
* @param \DateTime $dateEnd
|
|
||||||
* @param int $pax
|
|
||||||
*/
|
*/
|
||||||
protected function addCalendarItem(Vcalendar $vcalendar, \DateTime $dateStart, \DateTime $dateEnd, int $pax): void
|
protected function generateOccupancyItems(array $events): void
|
||||||
|
{
|
||||||
|
$occupancy = null;
|
||||||
|
|
||||||
|
foreach ($events as $event) {
|
||||||
|
/** @var Contingent $event */
|
||||||
|
if (null === $occupancy) {
|
||||||
|
$item = [
|
||||||
|
'from' => $event->getBegin(),
|
||||||
|
'occupancy' => $event->getOccupancy(),
|
||||||
|
];
|
||||||
|
} elseif ($occupancy !== $event->getOccupancy()) {
|
||||||
|
$item['to'] = $event->getEnd();
|
||||||
|
$this->addOccupancyItem($item);
|
||||||
|
$item = [
|
||||||
|
'from' => $event->getBegin(),
|
||||||
|
'occupancy' => $event->getOccupancy(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$occupancy = $event->getOccupancy();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($item['to'])) {
|
||||||
|
$item['to'] = $event->getEnd();
|
||||||
|
$this->addOccupancyItem($item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $events
|
||||||
|
*/
|
||||||
|
protected function generateBlockedItems(array $events): void
|
||||||
|
{
|
||||||
|
$item = null;
|
||||||
|
|
||||||
|
foreach ($events as $event) {
|
||||||
|
/** @var Contingent $event */
|
||||||
|
if (null === $item && Contingent::STATUS_BLOCKED === $event->getStatus()) {
|
||||||
|
$item = [
|
||||||
|
'from' => $event->getBegin(),
|
||||||
|
];
|
||||||
|
} elseif (true === is_array($item) && Contingent::STATUS_OK === $event->getStatus()) {
|
||||||
|
$item['to'] = $event->getEnd();
|
||||||
|
$this->addBlockedItem($item);
|
||||||
|
$item = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $item
|
||||||
|
*/
|
||||||
|
protected function addBlockedItem(array $item): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$vcalendar
|
$this->vcalendar
|
||||||
->newVevent()
|
->newVevent()
|
||||||
->setDtstart($dateStart)
|
->setDtstart($item['from'])
|
||||||
->setDtend($dateEnd)
|
->setDtend($item['to'])
|
||||||
->setDescription(sprintf('Part-occupied:%d', $pax))
|
->setSummary('Unavailable')
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
catch (\Exception $e) {
|
catch (\Exception $e) {
|
||||||
@@ -135,16 +158,30 @@ class IcalService implements SingletonInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Vcalendar
|
* @param array $item
|
||||||
*/
|
*/
|
||||||
protected function createCalendarInstance(): Vcalendar
|
protected function addOccupancyItem( array $item): void
|
||||||
{
|
{
|
||||||
$vcalendar = Vcalendar::factory([ Vcalendar::UNIQUE_ID => 'www.ep-reisen.de' ]);
|
$summary = sprintf('Part-occupied:%d', $item['occupancy']);
|
||||||
$vcalendar->setXprop(
|
|
||||||
|
try {
|
||||||
|
$this->vcalendar
|
||||||
|
->newVevent()
|
||||||
|
->setDtstart($item['from'])
|
||||||
|
->setDtend($item['to'])
|
||||||
|
->setSummary($summary)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
catch (\Exception $e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createCalendarInstance(): void
|
||||||
|
{
|
||||||
|
$this->vcalendar = Vcalendar::factory([ Vcalendar::UNIQUE_ID => 'www.ep-reisen.de' ]);
|
||||||
|
$this->vcalendar->setXprop(
|
||||||
Vcalendar::X_WR_TIMEZONE,
|
Vcalendar::X_WR_TIMEZONE,
|
||||||
'Europe/Berlin'
|
'Europe/Berlin'
|
||||||
);
|
);
|
||||||
|
|
||||||
return $vcalendar;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-10
@@ -42,7 +42,7 @@ return [
|
|||||||
],
|
],
|
||||||
'palettes' => [
|
'palettes' => [
|
||||||
'top' => ['showitem' => 'hidden,earlybird,new,low_contingent,show_as_teaser,
|
'top' => ['showitem' => 'hidden,earlybird,new,low_contingent,show_as_teaser,
|
||||||
--linebreak--,code,groupsch_id,detail_page,--linebreak--,external_link,path_segment'],
|
--linebreak--,code,detail_page,--linebreak--,external_link,path_segment'],
|
||||||
'geolocation' => ['showitem' => 'address, longitude, latitude'],
|
'geolocation' => ['showitem' => 'address, longitude, latitude'],
|
||||||
'destinations' => ['showitem' => 'country,region,city'],
|
'destinations' => ['showitem' => 'country,region,city'],
|
||||||
'name' => ['showitem' => 'name,short_name,--linebreak--,header_title,header_subtitle,--linebreak--,headline'],
|
'name' => ['showitem' => 'name,short_name,--linebreak--,header_title,header_subtitle,--linebreak--,headline'],
|
||||||
@@ -446,15 +446,6 @@ return [
|
|||||||
'eval' => 'trim'
|
'eval' => 'trim'
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'groupsch_id' => [
|
|
||||||
'exclude' => 0,
|
|
||||||
'label' => 'groups.ch ID',
|
|
||||||
'config' => [
|
|
||||||
'type' => 'input',
|
|
||||||
'size' => 8,
|
|
||||||
'eval' => 'trim,int'
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'external_link' => [
|
'external_link' => [
|
||||||
'exclude' => 0,
|
'exclude' => 0,
|
||||||
'label' => 'Externer Link (Google MyBusiness)',
|
'label' => 'Externer Link (Google MyBusiness)',
|
||||||
|
|||||||
@@ -222,7 +222,6 @@ CREATE TABLE tx_epproducts_domain_model_hotel
|
|||||||
images int(11) unsigned NOT NULL default '0',
|
images int(11) unsigned NOT NULL default '0',
|
||||||
reseller_images int(11) unsigned NOT NULL default '0',
|
reseller_images int(11) unsigned NOT NULL default '0',
|
||||||
code varchar(255) DEFAULT '' NOT NULL,
|
code varchar(255) DEFAULT '' NOT NULL,
|
||||||
groupsch_id varchar(8) DEFAULT '' NOT NULL,
|
|
||||||
external_link varchar(255) DEFAULT '' NOT NULL,
|
external_link varchar(255) DEFAULT '' NOT NULL,
|
||||||
path_segment varchar(255) DEFAULT '' NOT NULL,
|
path_segment varchar(255) DEFAULT '' NOT NULL,
|
||||||
type varchar(255) DEFAULT '' NOT NULL,
|
type varchar(255) DEFAULT '' NOT NULL,
|
||||||
|
|||||||
Reference in New Issue
Block a user