Implement ical feed for contingents
This commit is contained in:
@@ -20,7 +20,9 @@
|
||||
"georgringer/news": "^7.2",
|
||||
"gridelementsteam/gridelements": "^9.2",
|
||||
"helhum/typo3-console": "^5.6",
|
||||
"kigkonsult/icalcreator": "^2.29",
|
||||
"league/csv": "^9.2",
|
||||
"league/period": "^4.9",
|
||||
"pixelant/pxa-social-feed": "^2.0",
|
||||
"symfony/http-client": "^4.3",
|
||||
"symfony/options-resolver": "^4.2",
|
||||
|
||||
Generated
+142
-1
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "5ee4c536b0be04461f96a14634b32be3",
|
||||
"content-hash": "bb5a69b6fd8737b6af09a7beaaa27b89",
|
||||
"packages": [
|
||||
{
|
||||
"name": "algo26-matthias/idna-convert",
|
||||
@@ -1266,6 +1266,71 @@
|
||||
],
|
||||
"time": "2018-12-09T12:06:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "kigkonsult/icalcreator",
|
||||
"version": "v2.29.14",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/iCalcreator/iCalcreator.git",
|
||||
"reference": "af69b2c08a871d65d64c486b4b3c1a4ca8ebfa35"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/iCalcreator/iCalcreator/zipball/af69b2c08a871d65d64c486b4b3c1a4ca8ebfa35",
|
||||
"reference": "af69b2c08a871d65d64c486b4b3c1a4ca8ebfa35",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-openssl": "*",
|
||||
"ext-simplexml": "*",
|
||||
"ext-zlib": "*",
|
||||
"php": ">=5.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "6.5.13"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"autoload.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Kigkonsult\\Icalcreator\\": [
|
||||
"src/",
|
||||
"src/Util/",
|
||||
"src/Traits/"
|
||||
]
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-3.0-or-later"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kjell-Inge Gustafsson",
|
||||
"email": "[email protected]"
|
||||
}
|
||||
],
|
||||
"description": "iCalcreator is the PHP implementation of rfc2445/rfc5545, management of calendar information",
|
||||
"keywords": [
|
||||
"calendar",
|
||||
"daylight",
|
||||
"management",
|
||||
"rfc2445",
|
||||
"rfc5545",
|
||||
"rfc6321",
|
||||
"standard",
|
||||
"vCalendar",
|
||||
"valarm",
|
||||
"vevent",
|
||||
"vfreebusy",
|
||||
"vjournal",
|
||||
"vtimezone",
|
||||
"vtodo"
|
||||
],
|
||||
"time": "2019-09-04T00:00:00+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/csv",
|
||||
"version": "9.4.1",
|
||||
@@ -1335,6 +1400,82 @@
|
||||
],
|
||||
"time": "2019-10-17T06:05:32+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/period",
|
||||
"version": "4.9.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thephpleague/period.git",
|
||||
"reference": "b30d2cb474939beaeae8b45ea5aac0edd3ffbf78"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thephpleague/period/zipball/b30d2cb474939beaeae8b45ea5aac0edd3ffbf78",
|
||||
"reference": "b30d2cb474939beaeae8b45ea5aac0edd3ffbf78",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"php": "^7.1.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^2.0",
|
||||
"infection/infection": "^0.13",
|
||||
"phpstan/phpstan": "^0.11",
|
||||
"phpstan/phpstan-phpunit": "^0.11",
|
||||
"phpstan/phpstan-strict-rules": "^0.11",
|
||||
"phpunit/phpunit": "^7.0|^8.0",
|
||||
"symfony/var-dumper": "^4.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"League\\Period\\": "src"
|
||||
},
|
||||
"files": [
|
||||
"src/functions_include.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ignace Nyamagana Butera",
|
||||
"email": "[email protected]",
|
||||
"homepage": "https://github.com/nyamsprod/",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Time range API for PHP",
|
||||
"homepage": "http://period.thephpleague.com",
|
||||
"keywords": [
|
||||
"boundaries",
|
||||
"calendar",
|
||||
"collection",
|
||||
"date",
|
||||
"dateinterval",
|
||||
"dateperiod",
|
||||
"datetime",
|
||||
"gap",
|
||||
"intersections",
|
||||
"interval",
|
||||
"period",
|
||||
"range",
|
||||
"schedule",
|
||||
"sequence",
|
||||
"time",
|
||||
"timeline",
|
||||
"unions"
|
||||
],
|
||||
"time": "2019-09-02T06:27:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nikic/php-parser",
|
||||
"version": "v4.3.0",
|
||||
|
||||
@@ -27,10 +27,13 @@ namespace EP\EpProducts\Controller;
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use EP\EpProducts\Domain\Model\Contingent;
|
||||
use EP\EpProducts\Domain\Model\Hotel;
|
||||
use EP\EpProducts\Domain\Model\Product;
|
||||
use EP\EpProducts\Domain\Repository\ContingentRepository;
|
||||
use EP\EpProducts\Service\ContingentDataService;
|
||||
use Kigkonsult\Icalcreator\Vcalendar;
|
||||
use League\Period\Period;
|
||||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
||||
|
||||
class AjaxContingentController extends ActionController
|
||||
@@ -100,4 +103,52 @@ class AjaxContingentController extends ActionController
|
||||
return \json_encode($rooms);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Hotel $hotel
|
||||
* @param string $year
|
||||
* @param string $month
|
||||
* @param int $months
|
||||
*/
|
||||
public function icalAction(Hotel $hotel)
|
||||
{
|
||||
$range = Period::after(new \DateTime('now'), '1 year');
|
||||
|
||||
$events = $this->contingentRepository->getEvents(
|
||||
\DateTime::createFromImmutable($range->getStartDate()),
|
||||
\DateTime::createFromImmutable($range->getEndDate()),
|
||||
['hotel' => $hotel]
|
||||
);
|
||||
|
||||
$vcalendar = Vcalendar::factory([ Vcalendar::UNIQUE_ID => 'www.ep-reisen.de' ]);
|
||||
|
||||
foreach ($events as $event) {
|
||||
/** @var Contingent $event */
|
||||
$paxTotal = $event->getPax();
|
||||
$paxAvaiable = $event->getAvailable();
|
||||
|
||||
if ($paxTotal > 0) {
|
||||
$percentageBooked = round($paxAvaiable / $paxTotal * 100);
|
||||
} else {
|
||||
$percentageBooked = 100;
|
||||
}
|
||||
|
||||
if ($percentageBooked >= 75) {
|
||||
$dtStart = $event->getBegin();
|
||||
$dtEnd = clone $event->getBegin();
|
||||
$dtEnd->modify('+1 day');
|
||||
$vcalendar
|
||||
->newVevent()
|
||||
->setDtstart($dtStart)
|
||||
->setDtend($dtEnd)
|
||||
->setSummary('Unavailable')
|
||||
->setDescription(sprintf('Unavailable on %s', $dtStart->format('d M Y')))
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $vcalendar->vtimezonePopulate()->createCalendar();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -128,6 +128,7 @@ tx_epproducts_ajax_json {
|
||||
AjaxContingent {
|
||||
1 = list
|
||||
2 = rooms
|
||||
3 = ical
|
||||
}
|
||||
AjaxWatchlist {
|
||||
1 = list
|
||||
@@ -144,6 +145,37 @@ tx_epproducts_ajax_html < tx_epproducts_ajax_json
|
||||
tx_epproducts_ajax_html.typeNum = 1702
|
||||
tx_epproducts_ajax_html.config.additionalHeaders.10.header = Content-type:text/html
|
||||
|
||||
tx_epproducts_ical = PAGE
|
||||
tx_epproducts_ical {
|
||||
typeNum = 1710
|
||||
config {
|
||||
disableAllHeaderCode = 1
|
||||
disablePrefixComment = 1
|
||||
additionalHeaders.1.header = Cache-Control: no-cache, no-store, must-revalidate
|
||||
additionalHeaders.10.header = Content-type: text/calendar
|
||||
additionalHeaders.20.header = Content-disposition: attachment; filename=ep-reisen.ical
|
||||
xhtml_cleaning = 0
|
||||
admPanel = 0
|
||||
debug = 0
|
||||
no_cache = 1
|
||||
}
|
||||
|
||||
10 = USER_INT
|
||||
10 {
|
||||
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
|
||||
extensionName = EpProducts
|
||||
pluginName = ical
|
||||
vendorName = EP
|
||||
controller = AjaxContingent
|
||||
action = ical
|
||||
switchableControllerActions {
|
||||
AjaxContingent {
|
||||
1 = ical
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lib.bookingWidget = USER
|
||||
lib.bookingWidget {
|
||||
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
|
||||
|
||||
@@ -358,6 +358,17 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\EP\EpProducts\T
|
||||
]
|
||||
);
|
||||
|
||||
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
|
||||
'EP.' . $_EXTKEY,
|
||||
'ical',
|
||||
[
|
||||
'AjaxContingent' => 'ical',
|
||||
],
|
||||
[
|
||||
'AjaxContingent' => 'ical',
|
||||
]
|
||||
);
|
||||
|
||||
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']['ep_products'] =
|
||||
\EP\EpProducts\Hook\PageLayoutView::class;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user