feat: additional attribute for synced with bpn status including filtering by
closes #869anf53g
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Administrative\Disposition;
|
||||
|
||||
use App\Entity\Disposition;
|
||||
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 BusProNetSyncToggleController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/administrative/disposition/bpn-sync-toggle/{uuid}', name: 'app_administrative_disposition_bpn_sync_toggle', methods: ['POST'])]
|
||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||
public function index(Disposition $disposition, Request $request): Response
|
||||
{
|
||||
$isSynced = $disposition->isSyncedWithBusProNet();
|
||||
$disposition->setSyncedWithBusProNet(!$isSynced);
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'BusProNet Status aktualisiert');
|
||||
|
||||
$this->logger->info('Edit toggle BusProNet sync', [
|
||||
'disposition' => $disposition->getUuid(),
|
||||
'synced' => $disposition->isSyncedWithBusProNet(),
|
||||
]);
|
||||
|
||||
return new HxRedirectResponse($this->generateUrl('app_administrative_assignment_detail', [
|
||||
'uuid' => $disposition->getAssignment()->getUuid(),
|
||||
]));
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,9 @@ class Disposition implements BlameableEntityInterface, TimestampableEntityInterf
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $calledOffReason = null;
|
||||
|
||||
#[ORM\Column(type: Types::BOOLEAN)]
|
||||
private bool $syncedWithBusProNet = false;
|
||||
|
||||
public function __construct(Application $application)
|
||||
{
|
||||
$this->uuid = Uuid::v4();
|
||||
@@ -277,4 +280,16 @@ class Disposition implements BlameableEntityInterface, TimestampableEntityInterf
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isSyncedWithBusProNet(): bool
|
||||
{
|
||||
return $this->syncedWithBusProNet;
|
||||
}
|
||||
|
||||
public function setSyncedWithBusProNet(bool $syncedWithBusProNet): static
|
||||
{
|
||||
$this->syncedWithBusProNet = $syncedWithBusProNet;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,10 @@ class AssignmentFilterType extends AbstractType
|
||||
'label' => 'vergangene Einsätze anzeigen',
|
||||
'required' => false,
|
||||
])
|
||||
->add('syncedWithBusProNet', CheckboxType::class, [
|
||||
'label' => 'in BusProNet hinterlegt',
|
||||
'required' => false,
|
||||
])
|
||||
->add('country', ChoiceType::class, [
|
||||
'label' => 'Land',
|
||||
'required' => false,
|
||||
|
||||
@@ -18,6 +18,7 @@ class AssignmentFilterDto extends AbstractFilterDto
|
||||
protected array $status = [];
|
||||
protected bool $includePast = false;
|
||||
protected ?string $country = null;
|
||||
protected bool $syncedWithBusProNet = false;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
@@ -126,4 +127,16 @@ class AssignmentFilterDto extends AbstractFilterDto
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isSyncedWithBusProNet(): bool
|
||||
{
|
||||
return $this->syncedWithBusProNet;
|
||||
}
|
||||
|
||||
public function setSyncedWithBusProNet(bool $syncedWithBusProNet): static
|
||||
{
|
||||
$this->syncedWithBusProNet = $syncedWithBusProNet;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,6 +185,13 @@ class AssignmentRepository extends ServiceEntityRepository
|
||||
->setParameter('country', $country)
|
||||
;
|
||||
}
|
||||
|
||||
if (true === $filterDto->isSyncedWithBusProNet()) {
|
||||
$qb
|
||||
->andWhere($qb->expr()->eq('disposition.syncedWithBusProNet', ':syncedWithBusProNet'))
|
||||
->setParameter('syncedWithBusProNet', true)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function getBookmarkQueryForTeamer(Teamer $teamer): Query
|
||||
|
||||
@@ -51,6 +51,9 @@ class AssignmentFilterHandler extends AbstractFilterHandler
|
||||
if (isset($data['country'])) {
|
||||
$filterDto->setCountry($data['country']);
|
||||
}
|
||||
if (isset($data['synced_with_bus_pro_net'])) {
|
||||
$filterDto->setSyncedWithBusProNet((bool) $data['synced_with_bus_pro_net']);
|
||||
}
|
||||
|
||||
return $filterDto;
|
||||
}
|
||||
@@ -70,6 +73,7 @@ class AssignmentFilterHandler extends AbstractFilterHandler
|
||||
'status' => $filterDto->getStatus(),
|
||||
'include_past' => $filterDto->isIncludePast(),
|
||||
'country' => $filterDto->getCountry(),
|
||||
'synced_with_bus_pro_net' => $filterDto->isSyncedWithBusProNet(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user