WIP Impelement more stuff
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin\Teamer;
|
||||
|
||||
use App\Entity\Teamer;
|
||||
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 AvailabilityController extends AbstractController
|
||||
{
|
||||
#[Route('/admin/teamer/availability/{uuid}', name: 'app_admin_teamer_availability')]
|
||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||
public function index(Teamer $teamer): Response
|
||||
{
|
||||
return $this->render('admin/teamer/availability.html.twig', [
|
||||
'teamer' => $teamer,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin\Teamer;
|
||||
|
||||
use App\Entity\Teamer;
|
||||
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 CrmSelectionsController extends AbstractController
|
||||
{
|
||||
#[Route('/admin/teamer/crm-selections/{uuid}', name: 'app_admin_teamer_crm_selections')]
|
||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||
public function index(Teamer $teamer): Response
|
||||
{
|
||||
return $this->render('admin/teamer/crm_selections.html.twig', [
|
||||
'teamer' => $teamer,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin\Teamer;
|
||||
|
||||
use App\Entity\Teamer;
|
||||
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 ProfileController extends AbstractController
|
||||
{
|
||||
#[Route('/admin/teamer/profile/{uuid}', name: 'app_admin_teamer_profile')]
|
||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||
public function index(Teamer $teamer): Response
|
||||
{
|
||||
return $this->render('admin/teamer/profile.html.twig', [
|
||||
'teamer' => $teamer,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin\Teamer;
|
||||
|
||||
use App\Entity\Teamer;
|
||||
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 RecentAssignmentsController extends AbstractController
|
||||
{
|
||||
#[Route('/admin/teamer/recent-assignments/{uuid}', name: 'app_admin_teamer_recent_assignments')]
|
||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||
public function index(Teamer $teamer): Response
|
||||
{
|
||||
return $this->render('admin/teamer/recent_assignments.html.twig', [
|
||||
'teamer' => $teamer,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin\Teamer;
|
||||
|
||||
use App\Entity\Teamer;
|
||||
use App\Repository\TrainingRepository;
|
||||
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 SkillsController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly TrainingRepository $trainingRepository)
|
||||
{}
|
||||
|
||||
#[Route('/admin/teamer/skills/{uuid}', name: 'app_admin_teamer_skills')]
|
||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||
public function index(Teamer $teamer): Response
|
||||
{
|
||||
$trainings = $this->trainingRepository->getList();
|
||||
|
||||
return $this->render('admin/teamer/skills.html.twig', [
|
||||
'teamer' => $teamer,
|
||||
'trainings' => $trainings,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin\Teamer\TrainingAttendance;
|
||||
|
||||
use App\Entity\Teamer;
|
||||
use App\Entity\Training;
|
||||
use App\Entity\TrainingAttendance;
|
||||
use App\Form\AbbreviatedDateType;
|
||||
use App\Form\FeeType;
|
||||
use App\Model\AjaxModalResponseDto;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
|
||||
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/teamer/skills/training-attendance/create/{training_id}/{teamer_id}', name: 'app_admin_teamer_skills_training_attendance_create')]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function index(
|
||||
#[MapEntity(mapping: ['training_id' => 'id'])]
|
||||
Training $training,
|
||||
#[MapEntity(mapping: ['teamer_id' => 'id'])]
|
||||
Teamer $teamer,
|
||||
Request $request
|
||||
): JsonResponse {
|
||||
$response = new AjaxModalResponseDto();
|
||||
$action = $this->generateUrl('app_admin_teamer_skills_training_attendance_create', [
|
||||
'training_id' => $training->getId(),
|
||||
'teamer_id' => $teamer->getId(),
|
||||
]);
|
||||
|
||||
$attendance = new TrainingAttendance();
|
||||
$attendance
|
||||
->setTeamer($teamer)
|
||||
->setTraining($training)
|
||||
;
|
||||
|
||||
$form = $this
|
||||
->createFormBuilder($attendance, ['action' => $action, 'ajax_submit' => true])
|
||||
->add('date', AbbreviatedDateType::class, [
|
||||
'label' => 'Datum',
|
||||
])
|
||||
->getForm()
|
||||
;
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->persist($attendance);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Die Teilnahme wurde hinzugefügt');
|
||||
$this->logger->info('Create training attendance', [
|
||||
'teamer' => $teamer->getUuid(),
|
||||
'training' => $training->getName(),
|
||||
]);
|
||||
|
||||
$redirectUrl = $this->generateUrl('app_admin_teamer_skills', ['uuid' => $teamer->getUuid()]);
|
||||
$response->setCloseAndRedirect($redirectUrl);
|
||||
} else {
|
||||
$content = $this->renderView('admin/teamer/training_attendance/create.html.twig', [
|
||||
'form' => $form
|
||||
]);
|
||||
$response->setContent($content);
|
||||
}
|
||||
|
||||
return $this->json($response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin\Teamer\TrainingAttendance;
|
||||
|
||||
use App\Entity\TrainingAttendance;
|
||||
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/teamer/skills/training-attendance/delete/{uuid}', name: 'app_admin_teamer_skills_training_attendance_delete', methods: ['POST'])]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function index(TrainingAttendance $attendance): Response
|
||||
{
|
||||
$teamer = $attendance->getTeamer();
|
||||
|
||||
$this->entityManager->remove($attendance);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Die Teilnahme an der Fortbilundg wurde gelöscht');
|
||||
$this->logger->info('Delete training attendance', [
|
||||
'teamer' => $teamer->getUuid(),
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_admin_teamer_skills', ['uuid' => $teamer->getUuid()]);
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,31 @@
|
||||
|
||||
namespace App\Controller\Teamer;
|
||||
|
||||
use App\Entity\User;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
class IndexController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly ValidatorInterface $validator)
|
||||
{}
|
||||
|
||||
#[Route('/teamer', name: 'app_teamer_index')]
|
||||
#[IsGranted('ROLE_TEAMER')]
|
||||
public function index(): Response
|
||||
{
|
||||
return $this->render('teamer/index.html.twig');
|
||||
/** @var User $user */
|
||||
$user = $this->getUser();
|
||||
$teamer = $user->getTeamer();
|
||||
|
||||
// Validate teamer data to show missing data right away
|
||||
$errors = $this->validator->validate($teamer, null, ['profile_preflight']);
|
||||
|
||||
return $this->render('teamer/index.html.twig', [
|
||||
'errors' => $errors,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -35,11 +35,11 @@ class SkillsController extends AbstractController
|
||||
|
||||
foreach ($jobProfiles as $profile) {
|
||||
$selectableJobProfiles[$profile->getId()] = true;
|
||||
if (null !== $profile->getRequiredTraining() && false === $teamer->hasTraining($profile->getRequiredTraining())) {
|
||||
if (null !== $profile->getRequiredTraining() && null === $teamer->getTrainingAttendance($profile->getRequiredTraining())) {
|
||||
$selectableJobProfiles[$profile->getId()] = false;
|
||||
}
|
||||
foreach ($profile->getRequiredLicenses() as $license) {
|
||||
if (false === $teamer->hasLicenseOfType($license)) {
|
||||
if (null === $teamer->getLicenseOfType($license)) {
|
||||
$selectableJobProfiles[$profile->getId()] = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user