Feat: Implement availabilities
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin\System\Availability;
|
||||
|
||||
use App\Entity\Availability;
|
||||
use App\Form\AvailabilityType;
|
||||
use App\Model\AjaxModalResponseDto;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class CreateController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly LoggerInterface $logger
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/admin/system/availability/create', name: 'app_admin_system_availability_create')]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$response = new AjaxModalResponseDto();
|
||||
$action = $this->generateUrl('app_admin_system_availability_create');
|
||||
|
||||
$availability = new Availability();
|
||||
$form = $this->createForm(AvailabilityType::class, $availability, ['action' => $action, 'ajax_submit' => true]);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->persist($availability);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Der Zeitraum wurde hinzugefügt.');
|
||||
$this->logger->info('Add availability', [
|
||||
'availability' => $availability,
|
||||
]);
|
||||
|
||||
$redirectUrl = $this->generateUrl('app_admin_system_availability_index');
|
||||
$response->setCloseAndRedirect($redirectUrl);
|
||||
} else {
|
||||
$content = $this->renderView('admin/system/availability/create.html.twig', [
|
||||
'form' => $form,
|
||||
]);
|
||||
$response->setContent($content);
|
||||
}
|
||||
|
||||
return $this->json($response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin\System\Availability;
|
||||
|
||||
use App\Entity\Availability;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class DeleteController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly LoggerInterface $logger
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/admin/system/availability/delete/{id}', name: 'app_admin_system_availability_delete', methods: ['POST'])]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function index(Availability $availability): Response
|
||||
{
|
||||
$this->entityManager->remove($availability);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Die Verfügbarkeit wurde gelöscht');
|
||||
$this->logger->info('Delete availability', [
|
||||
'availability' => $availability,
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_admin_system_availability_index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin\System\Availability;
|
||||
|
||||
use App\Repository\AvailabilityRepository;
|
||||
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\Annotation\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class IndexController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly AvailabilityRepository $availabilityRepository,
|
||||
private readonly PaginatorInterface $paginator
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/admin/system/availability', name: 'app_admin_system_availability_index')]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$query = $this
|
||||
->availabilityRepository
|
||||
->getListQuery()
|
||||
;
|
||||
|
||||
$pagination = $this->paginator->paginate(
|
||||
$query,
|
||||
$request->query->getInt('page', 1),
|
||||
10,
|
||||
[
|
||||
'defaultSortFieldName' => 'availability.dateFrom',
|
||||
'defaultSortDirection' => 'asc',
|
||||
]
|
||||
);
|
||||
|
||||
return $this->render('admin/system/availability/index.html.twig', [
|
||||
'pagination' => $pagination,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,12 @@ namespace App\Controller\Admin\System\Fee;
|
||||
|
||||
use App\Entity\Fee;
|
||||
use App\Form\FeeType;
|
||||
use App\Model\AjaxModalResponseDto;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
@@ -22,10 +23,13 @@ class CreateController extends AbstractController
|
||||
|
||||
#[Route('/admin/system/fee/create', name: 'app_admin_system_fee_create')]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function index(Request $request): Response
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$response = new AjaxModalResponseDto();
|
||||
$action = $this->generateUrl('app_admin_system_fee_create');
|
||||
|
||||
$fee = new Fee();
|
||||
$form = $this->createForm(FeeType::class, $fee);
|
||||
$form = $this->createForm(FeeType::class, $fee, ['action' => $action, 'ajax_submit' => true]);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
@@ -37,11 +41,15 @@ class CreateController extends AbstractController
|
||||
'fee' => $fee->getName(),
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_admin_system_fee_index');
|
||||
$redirectUrl = $this->generateUrl('app_admin_system_fee_index');
|
||||
$response->setCloseAndRedirect($redirectUrl);
|
||||
} else {
|
||||
$content = $this->renderView('admin/system/fee/create.html.twig', [
|
||||
'form' => $form
|
||||
]);
|
||||
$response->setContent($content);
|
||||
}
|
||||
|
||||
return $this->render('admin/system/fee/create.html.twig', [
|
||||
'form' => $form
|
||||
]);
|
||||
return $this->json($response);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin\System\Fee;
|
||||
|
||||
use App\Entity\Fee;
|
||||
use App\Form\FeeType;
|
||||
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\Annotation\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class EditController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly LoggerInterface $logger
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/admin/system/fee/edit/{id}', name: 'app_admin_system_fee_edit')]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function index(Fee $fee, Request $request): Response
|
||||
{
|
||||
$form = $this->createForm(FeeType::class, $fee);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->persist($fee);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Das Honorar wurde aktualisiert');
|
||||
$this->logger->info('Edit fee', [
|
||||
'fee' => $fee->getName(),
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_admin_system_fee_index');
|
||||
}
|
||||
|
||||
return $this->render('admin/system/fee/edit.html.twig', [
|
||||
'form' => $form
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,12 @@ namespace App\Controller\Admin\System\Training;
|
||||
|
||||
use App\Entity\Training;
|
||||
use App\Form\TrainingType;
|
||||
use App\Model\AjaxModalResponseDto;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
@@ -22,10 +23,13 @@ class CreateController extends AbstractController
|
||||
|
||||
#[Route('/admin/system/training/create', name: 'app_admin_system_training_create')]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function index(Request $request): Response
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$response = new AjaxModalResponseDto();
|
||||
$action = $this->generateUrl('app_admin_system_training_create');
|
||||
|
||||
$training = new Training();
|
||||
$form = $this->createForm(TrainingType::class, $training);
|
||||
$form = $this->createForm(TrainingType::class, $training, ['action' => $action, 'ajax_submit' => true]);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
@@ -37,11 +41,15 @@ class CreateController extends AbstractController
|
||||
'training' => $training->getName(),
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_admin_system_training_index');
|
||||
$redirectUrl = $this->generateUrl('app_admin_system_training_index');
|
||||
$response->setCloseAndRedirect($redirectUrl);
|
||||
} else {
|
||||
$content = $this->renderView('admin/system/training/create.html.twig', [
|
||||
'form' => $form
|
||||
]);
|
||||
$response->setContent($content);
|
||||
}
|
||||
|
||||
return $this->render('admin/system/training/create.html.twig', [
|
||||
'form' => $form
|
||||
]);
|
||||
return $this->json($response);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin\System\Training;
|
||||
|
||||
use App\Entity\Training;
|
||||
use App\Form\TrainingType;
|
||||
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\Annotation\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class EditController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly LoggerInterface $logger
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/admin/system/training/edit/{id}', name: 'app_admin_system_training_edit')]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function index(Training $training, Request $request): Response
|
||||
{
|
||||
$form = $this->createForm(TrainingType::class, $training);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Die Fortbildung wurde aktualisiert');
|
||||
$this->logger->info('Edit training', [
|
||||
'training' => $training->getName(),
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_admin_system_training_index');
|
||||
}
|
||||
|
||||
return $this->render('admin/system/training/edit.html.twig', [
|
||||
'form' => $form
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user