wip: functionality for new role 'management'
This commit is contained in:
1 parent
f80e600310
commit
e95310c3a1
50 files changed
+350
-129
No files matched your search
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Administrative\Assignment;
|
||||
|
||||
use App\Entity\Assignment;
|
||||
use App\Form\AssignmentType;
|
||||
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 LoggerInterface $logger
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/administrative/assignment/duplicate/{uuid}', name: 'app_administrative_assignment_duplicate')]
|
||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||
public function index(Assignment $assignment, Request $request): Response
|
||||
{
|
||||
$copy = Assignment::duplicate($assignment);
|
||||
|
||||
$form = $this->createForm(
|
||||
AssignmentType::class,
|
||||
$copy,
|
||||
[
|
||||
'pickup_form_url' => $this->generateUrl('app_administrative_assignment_pickup_form'),
|
||||
]
|
||||
);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->persist($copy);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Der Einsatz wurde dupliziert');
|
||||
|
||||
$this->logger->info('Duplicate assignment', [
|
||||
'original_id' => $assignment->getId(),
|
||||
'duplicate_id' => $copy->getId(),
|
||||
'destination' => (string) $assignment->getDestination(),
|
||||
'job_profile' => $assignment->getJobProfile()->getName(),
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_administrative_assignment_edit', [
|
||||
'uuid' => $copy->getUuid(),
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->render('administrative/assignment/duplicate.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user