feat: custom destinations

This commit is contained in:
Björn Fromme
2024-05-15 17:32:07 +02:00
parent 57e1082f2f
commit efc4b58077
27 changed files with 826 additions and 40 deletions
+31
View File
@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240515131333 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE destination ADD created_by VARCHAR(255) DEFAULT NULL, ADD updated_by VARCHAR(255) DEFAULT NULL, CHANGE bus_pro_id bus_pro_id INT DEFAULT NULL, CHANGE code code VARCHAR(32) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE destination DROP created_by, DROP updated_by, CHANGE bus_pro_id bus_pro_id INT NOT NULL, CHANGE code code VARCHAR(32) NOT NULL');
}
}
@@ -0,0 +1,50 @@
<?php
namespace App\Controller\Admin\Autocomplete;
use App\BusProNet\DataProvider\HotelDataProvider;
use App\BusProNet\Model\Hotel;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class HotelController extends AbstractController
{
public function __construct(private readonly HotelDataProvider $hotelDataProvider)
{}
#[Route('/admin/autocomplete/hotel', name: 'app_admin_autocomplete_hotel')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Request $request): JsonResponse
{
try {
$query = json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR);
$queryString = $query['search'];
} catch (\JsonException $e) {
throw $this->createNotFoundException();
}
/** @var Hotel[] $hotels */
$hotels = $this->hotelDataProvider->getAll();
$data = [
[
'value' => '',
'text' => '...',
],
];
foreach ($hotels as $hotel) {
if (false !== stripos($hotel->getName(), $queryString)) {
$data[] = [
'value' => $hotel->getBusProId(),
'text' => sprintf('%s (%s)', $hotel->getName(), $hotel->getCode()),
];
}
}
return $this->json($data);
}
}
@@ -0,0 +1,60 @@
<?php
namespace App\Controller\Administrative\System\Destination;
use App\BusProNet\DataProvider\HotelDataProvider;
use App\BusProNet\DataProvider\PickupDataProvider;
use App\Entity\Destination;
use App\Form\DestinationType;
use App\Model\DestinationDto;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class CreateController extends AbstractController
{
use DestinationTrait;
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly HotelDataProvider $hotelDataProvider,
private readonly PickupDataProvider $pickupDataProvider,
private readonly LoggerInterface $logger
) {
}
#[Route('/administrative/destination/create', name: 'app_administrative_system_destination_create')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Request $request): Response
{
$destinationDto = new DestinationDto();
$form = $this->createForm(DestinationType::class, $destinationDto);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$destination = new Destination();
$this->updateEntity($destination, $destinationDto);
$this->entityManager->persist($destination);
$this->entityManager->flush();
$this->addFlash('success', 'Die Reise wurde angelegt');
$this->logger->info('Create destination', [
'destination_id' => $destination->getId(),
'destination' => (string) $destination,
]);
return $this->redirectToRoute('app_administrative_system_destination_index');
}
return $this->render('administrative/system/destination/create.html.twig', [
'form' => $form->createView(),
]);
}
}
@@ -0,0 +1,45 @@
<?php
namespace App\Controller\Administrative\System\Destination;
use App\Entity\Destination;
use App\Htmx\HxRedirectResponse;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class DeleteController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly LoggerInterface $logger
) {
}
#[Route('/administrative/system/destination/delete/{id}', name: 'app_administrative_system_destination_delete')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Destination $destination, Request $request): Response
{
if (true === $request->isMethod('POST')) {
$destination->setDeleted();
$this->entityManager->flush();
$this->logger->info('Delete destination', [
'destination_id' => $destination->getId(),
'destination' => (string) $destination,
]);
$this->addFlash('success', 'Die Reise wurde gelöscht');
return new HxRedirectResponse($this->generateUrl('app_administrative_system_destination_index'));
}
return $this->render('administrative/system/destination/modal_delete.html.twig', [
'destination' => $destination,
]);
}
}
@@ -0,0 +1,42 @@
<?php
namespace App\Controller\Administrative\System\Destination;
use App\Entity\Destination;
use App\Model\DestinationDto;
trait DestinationTrait
{
private function mapPickups(DestinationDto $destinationDto): array
{
$pickups = [];
foreach ($destinationDto->getPickups() as $pickupId) {
$pickup = $this->pickupDataProvider->get($pickupId);
$pickups[] = [
'busProId' => $pickup->getBusProId(),
'city' => $pickup->getCity(),
'street' => $pickup->getStreet(),
'time' => $pickup->getTime(),
];
}
return $pickups;
}
private function updateEntity(Destination $destination, DestinationDto $destinationDto): void
{
$hotel = $this->hotelDataProvider->get($destinationDto->getHotelBusProId());
$pickups = $this->mapPickups($destinationDto);
$destination
->setProduct($destinationDto->getProduct())
->setDateFrom($destinationDto->getDateFrom())
->setDateTo($destinationDto->getDateTo())
->setHotel($hotel->getName())
->setHotelCode($hotel->getCode())
->setHotelBusProId($hotel->getBusProId())
->setPickups($pickups)
;
}
}
@@ -0,0 +1,68 @@
<?php
namespace App\Controller\Administrative\System\Destination;
use App\BusProNet\DataProvider\HotelDataProvider;
use App\Entity\Destination;
use App\Form\DestinationType;
use App\Model\DestinationDto;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class DuplicateController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly HotelDataProvider $hotelDataProvider,
private readonly LoggerInterface $logger
) {
}
#[Route('/administrative/system/destination/duplicate/{id}', name: 'app_administrative_system_destination_duplicate')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Destination $destination, Request $request): Response
{
$destinationDto = DestinationDto::fromEntity($destination);
$form = $this->createForm(DestinationType::class, $destinationDto);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$hotel = $this->hotelDataProvider->get($destinationDto->getHotelBusProId());
$copy = new Destination();
$copy
->setProduct($destinationDto->getProduct())
->setDateFrom($destinationDto->getDateFrom())
->setDateTo($destinationDto->getDateTo())
->setHotel($hotel->getName())
->setHotelCode($hotel->getCode())
->setHotelBusProId($hotel->getBusProId())
;
$this->entityManager->persist($copy);
$this->entityManager->flush();
$this->addFlash('success', 'Die Reise wurde dupliziert');
$this->logger->info('Duplicate destination', [
'original_id' => $destination->getId(),
'duplicate_id' => $copy->getId(),
'destination' => (string) $destination,
]);
return $this->redirectToRoute('app_administrative_system_destination_edit', [
'id' => $copy->getId(),
]);
}
return $this->render('administrative/system/destination/duplicate.html.twig', [
'form' => $form->createView(),
]);
}
}
@@ -0,0 +1,55 @@
<?php
namespace App\Controller\Administrative\System\Destination;
use App\BusProNet\DataProvider\HotelDataProvider;
use App\BusProNet\DataProvider\PickupDataProvider;
use App\Entity\Destination;
use App\Form\DestinationType;
use App\Model\DestinationDto;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class EditController extends AbstractController
{
use DestinationTrait;
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly HotelDataProvider $hotelDataProvider,
private readonly PickupDataProvider $pickupDataProvider,
private readonly LoggerInterface $logger
) {
}
#[Route('/administrative/destination/edit/{id}', name: 'app_administrative_system_destination_edit')]
public function index(Destination $destination, Request $request): Response
{
$destinationDto = DestinationDto::fromEntity($destination);
$form = $this->createForm(DestinationType::class, $destinationDto);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->updateEntity($destination, $destinationDto);
$this->entityManager->flush();
$this->addFlash('success', 'Die Reise wurde aktualisiert');
$this->logger->info('Edit assignment', [
'destination_id' => $destination->getId(),
'destination' => (string) $destination,
]);
return $this->redirectToRoute('app_administrative_system_destination_index');
}
return $this->render('administrative/system/destination/edit.html.twig', [
'form' => $form->createView(),
]);
}
}
@@ -0,0 +1,44 @@
<?php
namespace App\Controller\Administrative\System\Destination;
use App\Repository\DestinationRepository;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class IndexController extends AbstractController
{
public function __construct(
private readonly DestinationRepository $destinationRepository,
private readonly PaginatorInterface $paginator,
) {
}
#[Route('/administrative/system/destination', name: 'app_administrative_system_destination_index')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Request $request): Response
{
$query = $this
->destinationRepository
->getListQueryForCustom()
;
$pagination = $this->paginator->paginate(
$query,
$request->query->getInt('page', 1),
10,
[
'defaultSortFieldName' => 'destination.dateFrom',
'defaultSortDirection' => 'desc',
]
);
return $this->render('administrative/system/destination/index.html.twig', [
'pagination' => $pagination,
]);
}
}
+10 -7
View File
@@ -3,15 +3,18 @@
namespace App\Entity;
use App\BusProNet\Model\Pickup;
use App\Entity\Traits\BlameableEntity;
use App\Entity\Traits\SoftDeletableEntity;
use App\Entity\Traits\TimestampableEntity;
use App\Repository\DestinationRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: DestinationRepository::class)]
class Destination implements TimestampableEntityInterface, SoftDeletableEntityInterface
class Destination implements TimestampableEntityInterface, SoftDeletableEntityInterface, BlameableEntityInterface
{
use BlameableEntity;
use TimestampableEntity;
use SoftDeletableEntity;
@@ -20,10 +23,10 @@ class Destination implements TimestampableEntityInterface, SoftDeletableEntityIn
#[ORM\Column]
private ?int $id = null;
#[ORM\Column]
#[ORM\Column(nullable: true)]
private ?int $busProId = null;
#[ORM\Column(length: 32)]
#[ORM\Column(length: 32, nullable: true)]
private ?string $code = null;
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
@@ -81,7 +84,7 @@ class Destination implements TimestampableEntityInterface, SoftDeletableEntityIn
return $this->dateFrom;
}
public function setDateFrom(\DateTimeImmutable $dateFrom): static
public function setDateFrom(?\DateTimeImmutable $dateFrom): static
{
$this->dateFrom = $dateFrom;
@@ -93,7 +96,7 @@ class Destination implements TimestampableEntityInterface, SoftDeletableEntityIn
return $this->dateTo;
}
public function setDateTo(\DateTimeImmutable $dateTo): static
public function setDateTo(?\DateTimeImmutable $dateTo): static
{
$this->dateTo = $dateTo;
@@ -117,7 +120,7 @@ class Destination implements TimestampableEntityInterface, SoftDeletableEntityIn
return $this->product;
}
public function setProduct(string $product): static
public function setProduct(?string $product): static
{
$this->product = $product;
@@ -129,7 +132,7 @@ class Destination implements TimestampableEntityInterface, SoftDeletableEntityIn
return $this->hotel;
}
public function setHotel(string $hotel): static
public function setHotel(?string $hotel): static
{
$this->hotel = $hotel;
+4
View File
@@ -181,7 +181,11 @@ class AssignmentType extends AbstractType
$choices = [];
foreach ($destination->getPickups() as $pickup) {
if ($pickup['time']) {
$label = sprintf('%s, %s Uhr', trim($pickup['city']), trim($pickup['time']));
} else {
$label = trim($pickup['city']);
}
$choices[$label] = $pickup['busProId'];
}
+2 -1
View File
@@ -23,6 +23,7 @@ class AutocompleteChoiceType extends AbstractType
'placeholder' => null,
'endpoint_parameters' => [],
'controller_action' => null,
'initial_label' => null,
]);
$resolver->setAllowedTypes('choices', 'array');
@@ -37,7 +38,7 @@ class AutocompleteChoiceType extends AbstractType
}
$view->vars['placeholder'] = $options['placeholder'];
$view->vars['initial_label'] = $form->getData();
$view->vars['initial_label'] = $options['initial_label'] ?? $form->getData();
$view->vars['initial_value'] = $form->getData();
$view->vars['action'] = $options['controller_action'];
}
+2 -2
View File
@@ -3,7 +3,7 @@
namespace App\Form;
use App\BusProNet\DataProvider\PickupDataProvider;
use App\Form\ChoiceLoader\BpnPickupsChoiceLoader;
use App\Form\ChoiceLoader\BpnPickupChoiceLoader;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -21,7 +21,7 @@ class BpnPickupType extends AbstractType
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'choice_loader' => new BpnPickupsChoiceLoader($this->pickups),
'choice_loader' => new BpnPickupChoiceLoader($this->pickups),
'preferred_choices' => [
40, // Köln
18, // Essen
@@ -2,25 +2,26 @@
namespace App\Form\ChoiceLoader;
use App\BusProNet\DataProvider\ProductDataProvider;
use App\BusProNet\Model\Product;
use App\BusProNet\DataProvider\HotelDataProvider;
use App\BusProNet\Model\Hotel;
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
class BpnProductsChoiceLoader implements ChoiceLoaderInterface
class BpnHotelChoiceLoader implements ChoiceLoaderInterface
{
public function __construct(private readonly ProductDataProvider $products)
public function __construct(private readonly HotelDataProvider $dataProvider)
{}
public function loadChoiceList(callable $value = null): ChoiceListInterface
{
$choices = [];
/** @var Product[] $products */
$products = $this->products->getAll();
/** @var Hotel[] $hotels */
$hotels = $this->dataProvider->getAll();
foreach ($products as $product) {
$choices[$product->getName()] = $product->getId();
foreach ($hotels as $hotel) {
$label = sprintf('%s (%s)', $hotel->getName(), $hotel->getCode());
$choices[$label] = $hotel->getBusProId();
}
ksort($choices);
@@ -8,16 +8,16 @@ use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
class BpnPickupsChoiceLoader implements ChoiceLoaderInterface
class BpnPickupChoiceLoader implements ChoiceLoaderInterface
{
public function __construct(private readonly PickupDataProvider $pickups)
public function __construct(private readonly PickupDataProvider $dataProvider)
{}
public function loadChoiceList(callable $value = null): ChoiceListInterface
{
$choices = [];
/** @var Pickup[] $pickups */
$pickups = $this->pickups->getAll();
$pickups = $this->dataProvider->getAll();
foreach ($pickups as $pickup) {
$choices[$pickup->getCity()] = $pickup->getBusProId();
+80
View File
@@ -0,0 +1,80 @@
<?php
namespace App\Form;
use App\BusProNet\DataProvider\HotelDataProvider;
use App\Model\DestinationDto;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class DestinationType extends AbstractType
{
public function __construct(private readonly HotelDataProvider $hotelDataProvider)
{
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('product', TextType::class, [
'label' => 'Bezeichnung',
])
->add('dateFrom', DatepickerType::class, [
'label' => 'Datum von',
])
->add('dateTo', DatepickerType::class, [
'label' => 'Datum bis',
])
->add('pickups', CollectionType::class, [
'label' => 'Zustiege',
'entry_type' => BpnPickupType::class,
'allow_add' => true,
'allow_delete' => true,
])
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$form = $event->getForm();
$data = $event->getData();
$this->addHotelField($form, $data->getHotelBusProId());
})
->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
$form = $event->getForm();
$data = $event->getData();
$this->addHotelField($form, $data['hotelBusProId'] ?? null);
})
;
}
private function addHotelField(FormInterface $form, ?string $hotelBusProId): void
{
$hotelLabel = null;
if (null !== $hotelBusProId) {
$hotel = $this->hotelDataProvider->get($hotelBusProId);
$hotelLabel = sprintf('%s (%s)', $hotel->getName(), $hotel->getCode());
}
$form
->remove('hotelBusProId')
->add('hotelBusProId', AutocompleteChoiceType::class, [
'label' => 'Vertragspartner',
'endpoint_route' => 'app_admin_autocomplete_hotel',
'initial_label' => $hotelLabel,
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => DestinationDto::class,
]);
}
}
+11
View File
@@ -126,6 +126,17 @@ class AdminMenuBuilder extends AbstractMenuBuilder
],
],
]);
$settingsMenu->addChild('Reisen', [
'route' => 'app_administrative_system_destination_index',
'linkAttributes' => [
'title' => 'Reisen',
],
'extras' => [
'routes' => [
['pattern' => '/^app_administrative_system_destination_/']
],
],
]);
$settingsMenu->addChild('Feedbackvorlagen', [
'route' => 'app_admin_system_feedback_set_index',
'linkAttributes' => [
+11
View File
@@ -72,6 +72,17 @@ class ManagerMenuBuilder extends AbstractMenuBuilder
'icon' => 'settings',
],
]);
$settingsMenu->addChild('Reisen', [
'route' => 'app_administrative_system_destination_index',
'linkAttributes' => [
'title' => 'Reisen',
],
'extras' => [
'routes' => [
['pattern' => '/^app_administrative_system_destination_/']
],
],
]);
$settingsMenu->addChild('FAQ', [
'route' => 'app_administrative_system_faq_index',
'linkAttributes' => [
+102
View File
@@ -0,0 +1,102 @@
<?php
namespace App\Model;
use App\Entity\Destination;
use Symfony\Component\Validator\Constraints as Assert;
class DestinationDto
{
#[Assert\NotBlank(message: 'Bitte angeben')]
private ?string $product = null;
#[Assert\NotNull(message: 'Bitte das Beginndatum angeben')]
private ?\DateTimeImmutable $dateFrom = null;
#[Assert\NotNull(message: 'Bitte das Enddatum angeben')]
private ?\DateTimeImmutable $dateTo = null;
#[Assert\NotBlank(message: 'Bitte angeben')]
private ?string $hotelBusProId = null;
private array $pickups = [];
public static function fromEntity(Destination $destination): static
{
$instance = new static();
$pickupIds = array_map(function (array $pickup) {
return $pickup['busProId'];
}, $destination->getPickups());
$instance
->setProduct($destination->getProduct())
->setDateFrom($destination->getDateFrom())
->setDateTo($destination->getDateTo())
->setHotelBusProId($destination->getHotelBusProId())
->setPickups($pickupIds)
;
return $instance;
}
public function getProduct(): ?string
{
return $this->product;
}
public function setProduct(?string $product): static
{
$this->product = $product;
return $this;
}
public function getDateFrom(): ?\DateTimeImmutable
{
return $this->dateFrom;
}
public function setDateFrom(?\DateTimeImmutable $dateFrom): static
{
$this->dateFrom = $dateFrom;
return $this;
}
public function getDateTo(): ?\DateTimeImmutable
{
return $this->dateTo;
}
public function setDateTo(?\DateTimeImmutable $dateTo): static
{
$this->dateTo = $dateTo;
return $this;
}
public function getHotelBusProId(): ?string
{
return $this->hotelBusProId;
}
public function setHotelBusProId(?string $hotelBusProId): static
{
$this->hotelBusProId = $hotelBusProId;
return $this;
}
public function getPickups(): array
{
return $this->pickups;
}
public function setPickups(array $pickups): static
{
$this->pickups = $pickups;
return $this;
}
}
+5 -2
View File
@@ -4,8 +4,11 @@ namespace App\Model;
class EmailAttachmentDto
{
public function __construct(private string $name, private string $content, private string $mimeType)
{
public function __construct(
private readonly string $name,
private readonly string $content,
private readonly string $mimeType
) {
}
public function getName(): string
+5 -16
View File
@@ -4,24 +4,13 @@ namespace App\Model;
class UploadDto
{
private string $uuid;
private string $filename;
private string $originalFilename;
private string $mimeType;
private int $size;
public function __construct(
string $uuid,
string $filename,
string $originalFilename,
string $mimeType,
int $size
private readonly string $uuid,
private readonly string $filename,
private readonly string $originalFilename,
private readonly string $mimeType,
private readonly int $size
) {
$this->uuid = $uuid;
$this->filename = $filename;
$this->originalFilename = $originalFilename;
$this->mimeType = $mimeType;
$this->size = $size;
}
public function getUuid(): string
+15
View File
@@ -5,6 +5,7 @@ namespace App\Repository;
use App\Entity\Destination;
use App\Repository\Traits\QueryHelperTrait;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\Query;
use Doctrine\Persistence\ManagerRegistry;
/**
@@ -24,6 +25,20 @@ class DestinationRepository extends ServiceEntityRepository
parent::__construct($registry, Destination::class);
}
public function getListQueryForCustom(): Query
{
$qb = $this->createQueryBuilder('destination');
return $qb
->where(
$qb->expr()->andX(
$qb->expr()->isNull('destination.deletedAt'),
$qb->expr()->isNull('destination.busProId'))
)
->getQuery()
;
}
public function getAutocompletionData(string $search, bool $upcomingOnly = true): array
{
$qb = $this->createQueryBuilder('destination');
@@ -0,0 +1,45 @@
{% macro collectionRow(form) %}
<div {{ stimulus_target('form-collection', 'field') }}>
<div class="flex items-center space-x-4">
{{ form_widget(form) }}
<button type="button" {{ stimulus_action('form-collection', 'removeItem') }}>
{{ icon('delete', 'w-4 h-4 mt-2 pointer-events-none') }}
</button>
</div>
{{ form_errors(form) }}
</div>
{% endmacro %}
{{ form_start(form) }}
<div class="flex flex-col space-y-4 pb-8">
{{ form_row(form.product) }}
{{ form_row(form.dateFrom) }}
{{ form_row(form.dateTo) }}
{{ form_row(form.hotelBusProId) }}
<div {{ stimulus_controller('form-collection', { 'prototype': _self.collectionRow(form.pickups.vars.prototype)|json_encode }) }}>
<h4 class="font-bold pb-2">
Buszustiege
</h4>
<div {{ stimulus_target('form-collection', 'fields')}} class="flex flex-col space-y-4 mb-4">
{% do form.pickups.setRendered %}
{%- for pickup in form.pickups -%}{{- _self.collectionRow(pickup) -}}{%- endfor -%}
</div>
<div class="flex justify-end">
<button type="button"
{{ stimulus_action('form-collection', 'addItem') }}
title="Zustieg hinzufügen">
{{ icon('plus', 'w-4 h-4 pointer-events-none') }}
</button>
</div>
</div>
</div>
<div class="flex items-center space-x-2">
<button type="submit" class="btn">
Speichern
</button>
<a href="{{ path('app_administrative_system_destination_index') }}" class="btn btn--secondary">
Abbrechen
</a>
</div>
{{ form_rest(form) }}
{{ form_end(form) }}
@@ -0,0 +1,10 @@
{% extends 'administrative/layout.html.twig' %}
{% block title %}Reise anlegen{% endblock %}
{% block content %}
<h1 class="text-2xl font-bold pb-8">
Reise anlegen
</h1>
{% include 'administrative/system/destination/_form.html.twig' %}
{% endblock %}
@@ -0,0 +1,10 @@
{% extends 'administrative/layout.html.twig' %}
{% block title %}Reise duplizieren{% endblock %}
{% block content %}
<h1 class="text-2xl font-bold pb-8">
Reise duplizieren
</h1>
{% include 'administrative/system/destination/_form.html.twig' %}
{% endblock %}
@@ -0,0 +1,10 @@
{% extends 'administrative/layout.html.twig' %}
{% block title %}Reise bearbeiten{% endblock %}
{% block content %}
<h1 class="text-2xl font-bold pb-8">
Reise bearbeiten
</h1>
{% include 'administrative/system/destination/_form.html.twig' %}
{% endblock %}
@@ -0,0 +1,89 @@
{% extends 'administrative/layout.html.twig' %}
{% block title %}Reisen{% endblock %}
{% block content %}
<div class="flex items-start justify-between pb-4">
<h1 class="text-2xl font-bold">
Manuell angelegte Reisen
</h1>
</div>
<div class="data-table-wrapper">
<div class="data-table-wrapper__inner">
<table class="data-table">
<thead>
<tr>
<th>
{{ knp_pagination_sortable(pagination, 'Produkt', 'destination.product') }}
</th>
<th>
{{ knp_pagination_sortable(pagination, 'Vertragspartner', 'destination.hotel') }}
</th>
<th>
{{ knp_pagination_sortable(pagination, 'Zeitraum von', 'destination.dateFrom') }}
</th>
<th>
{{ knp_pagination_sortable(pagination, 'Zeitraum bis', 'destination.dateTo') }}
</th>
<th></th>
</tr>
</thead>
<tbody>
{% for destination in pagination %}
<tr>
<td>
{{ destination.product }}
</td>
<td>
{{ destination.hotel }}{% if destination.hotelCode is not null %} ({{ destination.hotelCode }}){% endif %}
</td>
<td>
{{ destination.dateFrom | date('d.m.Y') }}
</td>
<td>
{{ destination.dateTo | date('d.m.Y') }}
</td>
<td>
<twig:DropDown>
<button type="button"
class="text-red-500 hover:text-primary block px-4 py-2 text-sm w-full text-left"
role="menuitem"
tabindex="-1"
hx-get="{{ path('app_administrative_system_destination_delete', { 'id': destination.id }) }}"
hx-target="body"
hx-swap="beforeend">
löschen
</button>
<a href="{{ path('app_administrative_system_destination_duplicate', { 'id': destination.id }) }}"
class="text-gray-700 hover:text-primary block px-4 py-2 text-sm"
role="menuitem"
tabindex="-1">
duplizieren
</a>
<a href="{{ path('app_administrative_system_destination_edit', { 'id': destination.id }) }}"
class="text-gray-700 hover:text-primary block px-4 py-2 text-sm"
role="menuitem"
tabindex="-1">
bearbeiten
</a>
</twig:DropDown>
</td>
</tr>
{% else %}
<tr>
<td colspan="5">
Keine Daten...
</td>
</tr>
{% endfor %}
</tbody>
</table>
{{ knp_pagination_render(pagination) }}
</div>
</div>
<a href="{{ path('app_administrative_system_destination_create') }}" class="btn">
Neu
</a>
{% endblock %}
@@ -0,0 +1,7 @@
{% extends 'htmx_confirmation_modal.html.twig' %}
{% block content %}
<div>
Möchtest du die Reise <em>{{ destination }}</em> wirklich löschen?
</div>
{% endblock %}