Refactor configurator defaults config, add more defaults
This commit is contained in:
@@ -30,6 +30,7 @@ namespace EP\EpEvents\Controller;
|
||||
use EP\EpEvents\Domain\Model\Inquiry;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
||||
use TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility;
|
||||
|
||||
class FormController extends ActionController
|
||||
{
|
||||
@@ -62,6 +63,7 @@ class FormController extends ActionController
|
||||
} else {
|
||||
$inquiry = $this->getInquiryFromContext();
|
||||
}
|
||||
$this->view->assign('configuratorConfig', $this->getConfiguratorConfig());
|
||||
$this->view->assign('inquiry', $inquiry);
|
||||
}
|
||||
|
||||
@@ -76,9 +78,11 @@ class FormController extends ActionController
|
||||
$offer = $content['offer'];
|
||||
$inquiry = Inquiry::fromOffer($offer, $defaults);
|
||||
} elseif (isset($content['travelType'])) {
|
||||
$config = $this->getConfiguratorConfig();
|
||||
/** @var \EP\EpEvents\Domain\Model\Traveltype $travelType */
|
||||
$travelType = $content['travelType'];
|
||||
$inquiryName = $this->settings['configurator']['options']['travelType'][$travelType->getConfiguratorType()];
|
||||
$configuratorType = $travelType->getConfiguratorType();
|
||||
$inquiryName = $config['travelTypeOptions'][$configuratorType];
|
||||
$inquiry = Inquiry::fromTraveltype($travelType, $inquiryName, $defaults);
|
||||
} elseif (isset($content['activityType'])) {
|
||||
$inquiry = new Inquiry($defaults);
|
||||
@@ -108,4 +112,42 @@ class FormController extends ActionController
|
||||
->build()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getConfiguratorConfig()
|
||||
{
|
||||
/** @var ConfigurationUtility $configUtility */
|
||||
$configUtility = $this->objectManager->get(ConfigurationUtility::class);
|
||||
$extensionConfig = $configUtility->getCurrentConfiguration('ep_events');
|
||||
|
||||
return [
|
||||
'budgetOptions' => $this->parseConfigItem($extensionConfig, 'configuratorBudgetOptions'),
|
||||
'paxOptions' => $this->parseConfigItem($extensionConfig, 'configuratorPaxOptions'),
|
||||
'periodOptions' => $this->parseConfigItem($extensionConfig, 'configuratorPeriodOptions'),
|
||||
'travelTypeOptions' => $this->parseConfigItem($extensionConfig, 'configuratorTravelTypeOptions'),
|
||||
'locationTypeOptions' => $this->parseConfigItem($extensionConfig, 'configuratorLocationTypeOptions'),
|
||||
'accommodationTypeOptions' => $this->parseConfigItem($extensionConfig, 'configuratorAccommodationTypeOptions'),
|
||||
'programmeTypeOptions' => $this->parseConfigItem($extensionConfig, 'configuratorProgrammeTypeOptions'),
|
||||
'distanceOptions' => $this->parseConfigItem($extensionConfig, 'configuratorDistanceOptions'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $configArray
|
||||
* @param string $itemName
|
||||
* @return array
|
||||
*/
|
||||
protected function parseConfigItem($configArray, $itemName)
|
||||
{
|
||||
$config = [];
|
||||
foreach (explode(';', $configArray[$itemName]['value']) as $item)
|
||||
{
|
||||
list ($value, $label) = explode(':', $item);
|
||||
$config[$value] = $label;
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,6 +151,15 @@ class Inquiry extends AbstractValueObject
|
||||
if ($offer->getLocation()->getConfiguratorDistance()) {
|
||||
$inquiry->setDistance($offer->getLocation()->getConfiguratorDistance());
|
||||
}
|
||||
if ($offer->getConfiguratorBudget()) {
|
||||
$inquiry->setBudget($offer->getConfiguratorBudget());
|
||||
}
|
||||
if ($offer->getConfiguratorPax()) {
|
||||
$inquiry->setPax($offer->getConfiguratorPax());
|
||||
}
|
||||
if ($offer->getConfiguratorPeriod()) {
|
||||
$inquiry->setPeriod($offer->getConfiguratorPeriod());
|
||||
}
|
||||
$activities = [];
|
||||
/** @var \EP\EpEvents\Domain\Model\Activity $activity */
|
||||
foreach ($offer->getActivities() as $activity)
|
||||
|
||||
@@ -157,6 +157,27 @@ class Offer extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
|
||||
*/
|
||||
protected $configuratorType = 0;
|
||||
|
||||
/**
|
||||
* configuratorBudget
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $configuratorBudget = 0;
|
||||
|
||||
/**
|
||||
* configuratorPax
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $configuratorPax = 0;
|
||||
|
||||
/**
|
||||
* configuratorPeriod
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $configuratorPeriod = 0;
|
||||
|
||||
/**
|
||||
* contact
|
||||
*
|
||||
@@ -626,6 +647,54 @@ class Offer extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
|
||||
$this->configuratorType = $configuratorType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getConfiguratorBudget()
|
||||
{
|
||||
return $this->configuratorBudget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $configuratorBudget
|
||||
*/
|
||||
public function setConfiguratorBudget($configuratorBudget)
|
||||
{
|
||||
$this->configuratorBudget = $configuratorBudget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getConfiguratorPax()
|
||||
{
|
||||
return $this->configuratorPax;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $configuratorPax
|
||||
*/
|
||||
public function setConfiguratorPax($configuratorPax)
|
||||
{
|
||||
$this->configuratorPax = $configuratorPax;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getConfiguratorPeriod()
|
||||
{
|
||||
return $this->configuratorPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $configuratorPeriod
|
||||
*/
|
||||
public function setConfiguratorPeriod($configuratorPeriod)
|
||||
{
|
||||
$this->configuratorPeriod = $configuratorPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
defined('TYPO3_MODE') or die();
|
||||
|
||||
call_user_func(function() {
|
||||
|
||||
$budgetItems = $paxItems = $periodItems = [
|
||||
['keine Auswahl', 0]
|
||||
];
|
||||
|
||||
if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['ep_events'])) {
|
||||
$extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['ep_events']);
|
||||
|
||||
$budgetItemsConfig = explode(';', $extensionConfiguration['configuratorBudgetOptions']);
|
||||
foreach ($budgetItemsConfig as $item)
|
||||
{
|
||||
list ($value, $label) = explode(':', $item);
|
||||
$budgetItems[] = [$label, $value];
|
||||
}
|
||||
$GLOBALS['TCA']['tx_epevents_domain_model_offer']['columns']['configurator_budget']['config']['items'] = $budgetItems;
|
||||
|
||||
$paxItemsConfig = explode(';', $extensionConfiguration['configuratorPaxOptions']);
|
||||
foreach ($paxItemsConfig as $item)
|
||||
{
|
||||
list ($value, $label) = explode(':', $item);
|
||||
$paxItems[] = [$label, $value];
|
||||
}
|
||||
$GLOBALS['TCA']['tx_epevents_domain_model_offer']['columns']['configurator_pax']['config']['items'] = $paxItems;
|
||||
|
||||
$periodItemsConfig = explode(';', $extensionConfiguration['configuratorPeriodOptions']);
|
||||
foreach ($periodItemsConfig as $item)
|
||||
{
|
||||
list ($value, $label) = explode(':', $item);
|
||||
$periodItems[] = [$label, $value];
|
||||
}
|
||||
$GLOBALS['TCA']['tx_epevents_domain_model_offer']['columns']['configurator_period']['config']['items'] = $periodItems;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -27,8 +27,9 @@ return [
|
||||
'interface' => [
|
||||
'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, type, name, name_internal,
|
||||
groupname, price, headline, header, arrival, schedule, services, guidelines, image_teaser,
|
||||
image_teaser_mobile, image_header, booking_form, configurator_type, contact, hotel, location, activities,
|
||||
detail_page, url, url_rendered',
|
||||
image_teaser_mobile, image_header, booking_form, configurator_type, configurator_budget,
|
||||
configurator_pax, configurator_period, contact, hotel, location, activities, detail_page, url,
|
||||
url_rendered',
|
||||
],
|
||||
'types' => [
|
||||
'1' => [
|
||||
@@ -71,7 +72,7 @@ return [
|
||||
],
|
||||
],
|
||||
'palettes' => [
|
||||
'general' => ['showitem' => 'type, configurator_type, detail_page'],
|
||||
'general' => ['showitem' => 'type, configurator_type, configurator_pax, configurator_budget, configurator_period, detail_page'],
|
||||
'general_ext' => ['showitem' => 'type, configurator_type, price'],
|
||||
'naming' => ['showitem' => 'name, name_internal'],
|
||||
'url' => ['showitem' => 'url, url_rendered'],
|
||||
@@ -385,7 +386,45 @@ return [
|
||||
'size' => 1,
|
||||
'minitems' => 1,
|
||||
'maxitems' => 1,
|
||||
'eval' => ''
|
||||
],
|
||||
],
|
||||
'configurator_budget' => [
|
||||
'exclude' => 0,
|
||||
'label' => 'Konfigurator Budget',
|
||||
'config' => [
|
||||
'type' => 'select',
|
||||
'renderType' => 'selectSingle',
|
||||
'items' => [],
|
||||
'default' => 1,
|
||||
'size' => 1,
|
||||
'minitems' => 0,
|
||||
'maxitems' => 1,
|
||||
],
|
||||
],
|
||||
'configurator_pax' => [
|
||||
'exclude' => 0,
|
||||
'label' => 'Teilnehmerzahl',
|
||||
'config' => [
|
||||
'type' => 'select',
|
||||
'renderType' => 'selectSingle',
|
||||
'items' => [],
|
||||
'default' => 1,
|
||||
'size' => 1,
|
||||
'minitems' => 0,
|
||||
'maxitems' => 1,
|
||||
],
|
||||
],
|
||||
'configurator_period' => [
|
||||
'exclude' => 0,
|
||||
'label' => 'Reisezeitraum',
|
||||
'config' => [
|
||||
'type' => 'select',
|
||||
'renderType' => 'selectSingle',
|
||||
'items' => [],
|
||||
'default' => 1,
|
||||
'size' => 1,
|
||||
'minitems' => 0,
|
||||
'maxitems' => 1,
|
||||
],
|
||||
],
|
||||
'contact' => [
|
||||
|
||||
@@ -52,70 +52,6 @@ plugin.tx_epevents {
|
||||
contactFormAutoreplySubject = {$plugin.tx_epevents.settings.contactFormAutoreplySubject}
|
||||
businessHours = {$plugin.tx_epevents.settings.businessHours}
|
||||
configurator {
|
||||
options {
|
||||
travelType {
|
||||
1 = Incentive
|
||||
2 = Teambuilding
|
||||
3 = Meeting
|
||||
4 = Corporate Event
|
||||
}
|
||||
locationType {
|
||||
1 = Meer
|
||||
2 = Berge
|
||||
3 = Städte
|
||||
4 = Spezial
|
||||
}
|
||||
accommodationType {
|
||||
1 = 3-Sterne
|
||||
2 = 4-Sterne
|
||||
3 = 5-Sterne
|
||||
4 = Spezial
|
||||
}
|
||||
programmeType {
|
||||
1 = Outdoor & Action
|
||||
2 = Event-Gastronomie
|
||||
3 = Sightseeing
|
||||
4 = Spezial
|
||||
}
|
||||
distance {
|
||||
1 = Deutschland
|
||||
2 = Europa
|
||||
3 = Welt
|
||||
}
|
||||
pax {
|
||||
1 = 20 - 40
|
||||
2 = 40 - 60
|
||||
3 = 60 - 80
|
||||
4 = 80 - 100
|
||||
5 = 100 - 150
|
||||
6 = 150 - 200
|
||||
7 = 200 - 250
|
||||
8 = 250 - 300
|
||||
9 = 350 - 400
|
||||
10 = 400 - 450
|
||||
11 = 450 - 500
|
||||
12 = 500+
|
||||
}
|
||||
budget {
|
||||
1 = nicht festgelegt
|
||||
2 = 400 - 600 €
|
||||
3 = 600 - 800 €
|
||||
4 = 800 - 1000 €
|
||||
5 = 1000 - 1500 €
|
||||
6 = 1500 - 2000 €
|
||||
7 = 2500 - 3000 €
|
||||
}
|
||||
period {
|
||||
1 = Tagesevent
|
||||
2 = 1 Nacht
|
||||
3 = 2 Nächte
|
||||
4 = 3 Nächte
|
||||
5 = 4 Nächte
|
||||
6 = 5 Nächte
|
||||
7 = 6 Nächte
|
||||
8 = 7 Nächte
|
||||
}
|
||||
}
|
||||
defaults {
|
||||
budget = 4
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
contextAccommodation: { type: String, default: '' },
|
||||
contextProgramme: { type: String, default: '' },
|
||||
contextDistance: { type: String, default: '0' },
|
||||
contextBudget: { type: String, default: '0' },
|
||||
contextPeriod: { type: String, default: '0' },
|
||||
contextPax: { type: String, default: '0' },
|
||||
imagesType: { type: Object, required: true },
|
||||
optionsType: { type: Object, required: true },
|
||||
imagesDestination: { type: Object, required: true },
|
||||
@@ -245,6 +248,9 @@
|
||||
this.formData.accommodation = this.contextAccommodation ? this.contextAccommodation.split(',') : [];
|
||||
this.formData.programme = this.contextProgramme ? this.contextProgramme.split(',') : [];
|
||||
this.formData.distance = this.contextDistance ? this.contextDistance : '';
|
||||
this.formData.budget = this.contextBudget ? this.contextBudget : this.defaultValues.budget;
|
||||
this.formData.pax = this.contextPax ? this.contextPax : '';
|
||||
this.formData.period = this.contextPeriod ? this.contextPeriod : '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,11 @@
|
||||
</div>
|
||||
<configurator
|
||||
context-type='{inquiry.travelType}'
|
||||
context-pax='{inquiry.pax}'
|
||||
context-budget='{inquiry.budget}'
|
||||
context-period='{inquiry.period}'
|
||||
:default-values='{settings.configurator.defaults -> v:format.json.encode()}'
|
||||
:options-type='{settings.configurator.options.travelType -> v:format.json.encode()}'
|
||||
:options-type='{configuratorConfig.travelTypeOptions -> v:format.json.encode()}'
|
||||
:images-type='{<f:format.raw>
|
||||
1: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_type_incentive.jpg', width: '450')}",
|
||||
2: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_type_team-building.jpg', width: '450')}",
|
||||
@@ -24,7 +27,7 @@
|
||||
4: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_type_corporate-event.jpg', width: '450')}"
|
||||
</f:format.raw>}'
|
||||
context-destination='{inquiry.locationType}'
|
||||
:options-destination='{settings.configurator.options.locationType -> v:format.json.encode()}'
|
||||
:options-destination='{configuratorConfig.locationTypeOptions -> v:format.json.encode()}'
|
||||
:images-destination='{<f:format.raw>
|
||||
1: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_destination_sea.jpg', width: '450')}",
|
||||
2: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_destination_mountains_skiing.jpg', width: '450')}",
|
||||
@@ -32,7 +35,7 @@
|
||||
4: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_destination_special.jpg', width: '450')}"
|
||||
</f:format.raw>}'
|
||||
context-accommodation='{inquiry.hotelType}'
|
||||
:options-accommodation='{settings.configurator.options.accommodationType -> v:format.json.encode()}'
|
||||
:options-accommodation='{configuratorConfig.accommodationTypeOptions -> v:format.json.encode()}'
|
||||
:images-accommodation='{<f:format.raw>
|
||||
1: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_hotel_3-stars.jpg', width: '450')}",
|
||||
2: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_hotel_4-stars.jpg', width: '450')}",
|
||||
@@ -40,7 +43,7 @@
|
||||
4: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_hotel_special.jpg', width: '450')}"
|
||||
</f:format.raw>}'
|
||||
context-programme='{inquiry.activityType}'
|
||||
:options-programme='{settings.configurator.options.programmeType -> v:format.json.encode()}'
|
||||
:options-programme='{configuratorConfig.programmeTypeOptions -> v:format.json.encode()}'
|
||||
:images-programme='{<f:format.raw>
|
||||
1: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_programme_outdoor-action.jpg', width: '450')}",
|
||||
2: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_programme_event-gastro.jpg', width: '450')}",
|
||||
@@ -48,10 +51,10 @@
|
||||
4: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_programme_special.jpg', width: '450')}"
|
||||
</f:format.raw>}'
|
||||
context-distance="{inquiry.distance}"
|
||||
:options-distance='{settings.configurator.options.distance -> v:format.json.encode()}'
|
||||
:options-pax='{settings.configurator.options.pax -> v:format.json.encode()}'
|
||||
:options-budget='{settings.configurator.options.budget -> v:format.json.encode()}'
|
||||
:options-period='{settings.configurator.options.period -> v:format.json.encode()}'
|
||||
:options-distance='{configuratorConfig.distanceOptions -> v:format.json.encode()}'
|
||||
:options-pax='{configuratorConfig.paxOptions -> v:format.json.encode()}'
|
||||
:options-budget='{configuratorConfig.budgetOptions -> v:format.json.encode()}'
|
||||
:options-period='{configuratorConfig.periodOptions -> v:format.json.encode()}'
|
||||
inline-template>
|
||||
<f:form id="configuratorform" object="{inquiry}" name="inquiry" noCacheHash="1"
|
||||
action="processConfiguratorForm" controller="AjaxForm" pluginName="Ajax" pageType="1703"
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
# cat=basic/100/010; type=string; label=Budget options
|
||||
configuratorBudgetOptions = 1:nicht festgelegt;2:400 - 600 €;3:600 - 800 €;4:800 - 1000 €;5:1000 - 1500 €;6:1500 - 2000 €;7:2500 - 3000 €
|
||||
# cat=basic/100/020; type=string; label=Pax options
|
||||
configuratorPaxOptions = 1:20 - 40;2:40 - 60;3:60 - 80;4:80 - 100;5:100 - 150;6:150 - 200;7:200 - 250;8:250 - 300;9:350 - 400;10:400 - 450;11:450 - 500;12:500+
|
||||
# cat=basic/100/030; type=string; label=Period options
|
||||
configuratorPeriodOptions = 1:Tagesevent;2:1 Nacht;3:2 Nächte;4:3 Nächte;5:4 Nächte;6:5 Nächte;7:6 Nächte;8:7 Nächte
|
||||
# cat=basic/100/040; type=string; label=Travel type options
|
||||
configuratorTravelTypeOptions = 1:Incentive;2:Teambuilding;3:Meeting;4:Corporate Event
|
||||
# cat=basic/100/050; type=string; label=Location type options
|
||||
configuratorLocationTypeOptions = 1:Meer;2:Berge;3:Städte;4:Spezial
|
||||
# cat=basic/100/060; type=string; label=Accommodation type options
|
||||
configuratorAccommodationTypeOptions = 1:3-Sterne;2:4-Sterne;3:5-Sterne;4:Spezial
|
||||
# cat=basic/100/070; type=string; label=Programme type options
|
||||
configuratorProgrammeTypeOptions = 1:Outdoor & Action;2:Event-Gastronomie;3:Sightseeing;4:Spezial
|
||||
# cat=basic/100/080; type=string; label=Distance options
|
||||
configuratorDistanceOptions = 1:Deutschland;2:Europa;3:Welt
|
||||
@@ -72,6 +72,9 @@ CREATE TABLE tx_epevents_domain_model_offer (
|
||||
image_teaser_mobile int(11) unsigned NOT NULL default '0',
|
||||
booking_form int(11) unsigned NOT NULL default '0',
|
||||
configurator_type int(11) DEFAULT '0' NOT NULL,
|
||||
configurator_budget int(11) DEFAULT '0' NOT NULL,
|
||||
configurator_pax int(11) DEFAULT '0' NOT NULL,
|
||||
configurator_period int(11) DEFAULT '0' NOT NULL,
|
||||
contact int(11) unsigned DEFAULT '0',
|
||||
hotel int(11) unsigned DEFAULT '0',
|
||||
location int(11) unsigned DEFAULT '0',
|
||||
|
||||
Reference in New Issue
Block a user