WIP: Implement application process

This commit is contained in:
Björn Fromme
2023-10-09 14:42:37 +02:00
parent 8e3499581a
commit abced8c924
26 changed files with 802 additions and 138 deletions
+11 -8
View File
@@ -7,11 +7,10 @@ use App\Entity\Destination;
use App\Entity\Fee;
use App\Entity\JobProfile;
use App\Entity\User;
use App\Model\BenefitsDto;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -22,8 +21,12 @@ class AssignmentType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('available', IntegerType::class, [
'label' => 'Anzahl',
->add('availableDispositions', IntegerType::class, [
'label' => 'zu vergeben',
'required' => false,
])
->add('showAvailableDispositions', CheckboxType::class, [
'label' => 'Anzahl anzeigen',
'required' => false,
])
->add('destination', AutocompleteEntityType::class, [
@@ -56,12 +59,12 @@ class AssignmentType extends AbstractType
'required' => false,
'placeholder' => 'Keine Busbegleitung',
])
->add('benefits', ChoiceType::class, [
->add('benefits', TextareaType::class, [
'label' => 'Benefits',
'required' => false,
'multiple' => true,
'expanded' => true,
'choices' => array_flip(BenefitsDto::$values),
'attr' => [
'rows' => 5,
],
])
->add('fees', EntityType::class, [
'label' => 'Honorar(e)',
+56
View File
@@ -0,0 +1,56 @@
<?php
namespace App\Form;
use App\Entity\Application;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\IsTrue;
class TeamerApplicationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
/** @var Application $application */
$application = $event->getData();
if (null === $application) {
return;
}
$assignment = $application->getAssignment();
if (null === $assignment->getPickup()) {
return;
}
$teamer = $application->getTeamer();
if (in_array($assignment->getPickup(), $teamer->getPickups())) {
return;
}
$event->getForm()->add('confirmPickup', CheckboxType::class, [
'label' => 'Ich bestätige den abweichenden Buszustieg',
'mapped' => false,
'constraints' => [
new IsTrue([
'message' => 'Deine Bestätigung ist erforderlich',
]),
],
]);
});
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Application::class,
]);
}
}