This commit is contained in:
Björn Fromme
2025-02-27 19:21:12 +01:00
parent f5d3619c4a
commit ac498f9040
15 changed files with 311 additions and 185 deletions
@@ -78,6 +78,13 @@ class BookingDataProcessor
$bookingData->participants[$participant->index]->communication->mobile = $participant->mobile;
}
// Update applicant's data with personal data of first participant
if (false !== $firstParticipant = reset($bookingData->participants)) {
$bookingData->applicant->height = $firstParticipant->height;
$bookingData->applicant->weight = $firstParticipant->weight;
$bookingData->applicant->shoeSize = $firstParticipant->shoeSize;
}
$payload = [
'idbuchung' => $bookingData->id,
'status' => $bookingData->status,
@@ -153,4 +160,4 @@ class BookingDataProcessor
return $payload;
}
}
}
+5 -1
View File
@@ -20,6 +20,10 @@ class Service
public const TOKEN_BOARD = 'VPF';
public const TOKEN_RENTALS = ['VER', 'VE2', 'VE3', 'VE4', 'VE5', 'VE6', 'VE7', 'VE8'];
public const STATUS_AVAILABLE = 'Frei';
public const STATUS_BLOCKED = 'Buchungsstop';
public const STATUS_ON_REQUEST = 'Anfrage';
#[Groups(['api:single', 'api:list'])]
public ?int $id = null;
@@ -69,4 +73,4 @@ class Service
#[Groups(['api:single', 'api:list'])]
public ?string $direction = null;
}
}
+1 -8
View File
@@ -24,20 +24,13 @@ class ParticipantData
public ?string $title = null;
public ?string $gender = null;
public ?string $nationality = null;
#[Assert\Range(notInRangeMessage: 'Bitte einen Wert im Bereich {{ min }}-{{ max }}cm angeben', min: 150, max: 210)]
public ?string $height = null;
#[Assert\Range(notInRangeMessage: 'Bitte einen Wert im Bereich {{ min }}-{{ max }} angeben', min: 37, max: 49)]
public ?string $shoeSize = null;
#[Assert\Range(notInRangeMessage: 'Bitte einen Wert im Bereich {{ min }}-{{ max }}kg angeben', min: 40, max: 130)]
public ?string $weight = null;
#[Assert\NotNull(message: 'Bitte angeben')]
public ?\DateTimeImmutable $dateOfBirth = null;
#[Assert\NotBlank(message: 'Bitte angeben')]
#[Assert\Email(message: 'Bitte eine gültige E-Mail Adresse angeben', mode: 'strict')]
public ?string $email = null;
@@ -112,4 +105,4 @@ class ParticipantData
return $instance;
}
}
}
+43 -7
View File
@@ -10,7 +10,6 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\BirthdayType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
@@ -77,6 +76,7 @@ class ParticipantType extends AbstractType
])
->add('email', EmailType::class, [
'label' => 'E-Mail',
'required' => false,
'attr' => [
'readonly' => false === $personalDataMutable,
]
@@ -87,17 +87,43 @@ class ParticipantType extends AbstractType
'readonly' => false === $personalDataMutable,
]
])
->add('height', IntegerType::class, [
'label' => 'Körpergröße [cm]',
->add('height', ChoiceType::class, [
'label' => 'Körpergröße',
'required' => false,
'expanded' => false,
'multiple' => false,
'placeholder' => 'Keine Angabe',
'choices' => [
'bis 148cm' => '-148',
'149 - 157cm' => '149-157',
'158 - 166cm' => '158-166',
'167 - 178cm' => '167-178',
'179 - 194cm' => '179-197',
'195cm oder mehr' => '195cm+',
],
])
->add('shoeSize', IntegerType::class, [
->add('shoeSize', ChoiceType::class, [
'label' => 'Schuhgröße',
'required' => false,
'expanded' => false,
'multiple' => false,
'placeholder' => 'Keine Angabe',
'choices' => array_combine(range(36, 48), range(36, 48)),
])
->add('weight', IntegerType::class, [
'label' => 'Gewicht [kg]',
->add('weight', ChoiceType::class, [
'label' => 'Gewicht',
'required' => false,
'expanded' => false,
'multiple' => false,
'placeholder' => 'Keine Angabe',
'choices' => [
'42 - 48kg' => '42-48',
'49 - 57kg' => '49-57',
'58 - 66kg' => '58-66',
'67 - 78kg' => '67-78',
'79 - 94kg' => '79-94',
'95kg oder mehr' => '95k+',
],
])
;
@@ -130,11 +156,21 @@ class ParticipantType extends AbstractType
if (true === $service->mandatory) {
$attributes['checked'] = true;
$attributes['disabled'] = true;
$attributes['class'] = 'text-pink';
$attributes['tooltip'] = 'Diese Leistung ist nicht abwählbar';
}
// disable selection of services only available in booking data
if (Service::SOURCE_BOOKING === $service->source) {
$attributes['disabled'] = true;
$attributes['class'] = 'text-pink';
}
// disable selection of services that are unavailable according to their status
if (Service::STATUS_BLOCKED === $service->status) {
$attributes['checked'] = false;
$attributes['disabled'] = true;
$attributes['tooltip'] = 'Diese Leistung ist derzeit leider nicht buchbar';
}
return $attributes;
@@ -297,4 +333,4 @@ class ParticipantType extends AbstractType
'anti_xss' => true,
]);
}
}
}
+1 -26
View File
@@ -16,31 +16,6 @@ class PersonalDataType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('gender', ChoiceType::class, [
'label' => 'Gender',
'choices' => [
'männlich' => 'M',
'weiblich' => 'W',
'divers' => 'D',
],
])
->add('firstName', TextType::class, [
'label' => 'Name',
])
->add('name', TextType::class, [
'label' => 'Nachname',
])
->add('dateOfBirth', BirthdayType::class, [
'label' => 'Geburtsdatum',
'html5' => true,
'widget' => 'single_text',
'input' => 'datetime_immutable',
])
->add('nationality', CountryType::class, [
'label' => 'Nationalität',
'property' => 'nationality',
'preferred_choices' => ['D', 'A', 'CH'],
])
->add('street', TextType::class, [
'label' => 'Straße',
'property_path' => 'address.street',
@@ -78,4 +53,4 @@ class PersonalDataType extends AbstractType
'anti_xss' => true,
]);
}
}
}
+3
View File
@@ -14,7 +14,10 @@ class AppExtension extends AbstractExtension
new TwigFilter('file_size', [AppRuntime::class, 'formatBytes']),
new TwigFilter('file_icon', [AppRuntime::class, 'fileIconFilter'], ['is_safe' => ['html']]),
new TwigFilter('format_money', [AppRuntime::class, 'formatMoney']),
new TwigFilter('map_gender', [AppRuntime::class, 'mapGender']),
new TwigFilter('map_status', [AppRuntime::class, 'mapStatus']),
new TwigFilter('map_country', [AppRuntime::class, 'mapCountry']),
new TwigFilter('map_nationality', [AppRuntime::class, 'mapNationality']),
];
}
+37 -2
View File
@@ -2,14 +2,17 @@
namespace App\Twig;
use App\BusProNet\DataProvider\CountryDataProvider;
use Twig\Environment;
use Twig\Extension\RuntimeExtensionInterface;
use Twig\Extra\Intl\IntlExtension;
class AppRuntime implements RuntimeExtensionInterface
{
public function __construct(private readonly IntlExtension $intlExtension)
{
public function __construct(
private readonly IntlExtension $intlExtension,
private readonly CountryDataProvider $countryDataProvider,
) {
}
public function fileIconFilter(Environment $environment, string $mimeType, ?string $classes = 'w-4 h-4'): string
@@ -50,6 +53,8 @@ class AppRuntime implements RuntimeExtensionInterface
public function mapStatus(string $status): string
{
$status = strtoupper($status);
return match ($status) {
'F', 'F/S' => 'Festbuchung',
'S' => 'Stornierung',
@@ -58,4 +63,34 @@ class AppRuntime implements RuntimeExtensionInterface
default => '',
};
}
public function mapGender(string $gender): string
{
$gender = strtoupper($gender);
return match ($gender) {
'M' => 'männlich',
'F' => 'weiblich',
'D' => 'divers',
default => '',
};
}
public function mapCountry(?string $country): ?string
{
if (null === $country) {
return null;
}
return $this->countryDataProvider->get($country)?->name;
}
public function mapNationality(?string $nationality): ?string
{
if (null === $nationality) {
return null;
}
return $this->countryDataProvider->get($nationality)?->nationality;
}
}