From 7c7addf5313277852d076bc84997c92a6a351fee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Wed, 14 Feb 2024 14:59:47 +0100 Subject: [PATCH] wip: functionality for new role 'management' --- migrations/Version20240214134047.php | 31 +++++++ src/Controller/Admin/IndexController.php | 2 +- .../Admin/Teamer/CrmSelectionsController.php | 2 +- .../Admin/Teamer/InfoController.php | 2 + .../Admin/Teamer/SkillsController.php | 2 +- .../Feedback/IndexController.php | 42 ++++++++++ .../Teamer/IndexController.php | 6 +- .../Teamer/ProfileController.php | 6 +- .../Teamer/RecentAssignmentsController.php | 6 +- src/Entity/Feedback.php | 83 +++++++++++++++++-- src/Menu/AdminMenuBuilder.php | 21 ++++- src/Menu/ManagerMenuBuilder.php | 63 ++++++-------- src/Repository/FeedbackRepository.php | 12 +++ .../administrative/feedback/index.html.twig | 78 +++++++++++++++++ .../teamer/index.html.twig | 8 +- .../teamer/profile.html.twig | 8 +- .../teamer/recent_assignments.html.twig | 8 +- 17 files changed, 312 insertions(+), 68 deletions(-) create mode 100644 migrations/Version20240214134047.php create mode 100644 src/Controller/Administrative/Feedback/IndexController.php rename src/Controller/{Admin => Administrative}/Teamer/IndexController.php (86%) rename src/Controller/{Admin => Administrative}/Teamer/ProfileController.php (67%) rename src/Controller/{Admin => Administrative}/Teamer/RecentAssignmentsController.php (83%) create mode 100644 templates/administrative/feedback/index.html.twig rename templates/{admin => administrative}/teamer/index.html.twig (91%) rename templates/{admin => administrative}/teamer/profile.html.twig (96%) rename templates/{admin => administrative}/teamer/recent_assignments.html.twig (91%) diff --git a/migrations/Version20240214134047.php b/migrations/Version20240214134047.php new file mode 100644 index 0000000..443a0b3 --- /dev/null +++ b/migrations/Version20240214134047.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE feedback ADD hotel VARCHAR(255) DEFAULT NULL, ADD hotel_code VARCHAR(32) DEFAULT NULL, ADD hotel_bus_pro_id INT DEFAULT NULL, ADD assignment_date_to DATE DEFAULT NULL COMMENT \'(DC2Type:date_immutable)\', CHANGE assignment_date assignment_date_from DATE DEFAULT NULL COMMENT \'(DC2Type:date_immutable)\''); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE feedback ADD assignment_date DATE DEFAULT NULL COMMENT \'(DC2Type:date_immutable)\', DROP hotel, DROP hotel_code, DROP hotel_bus_pro_id, DROP assignment_date_from, DROP assignment_date_to'); + } +} diff --git a/src/Controller/Admin/IndexController.php b/src/Controller/Admin/IndexController.php index f697626..6adbecf 100644 --- a/src/Controller/Admin/IndexController.php +++ b/src/Controller/Admin/IndexController.php @@ -27,7 +27,7 @@ class IndexController extends AbstractController } #[Route('/admin', name: 'app_admin_index')] - #[IsGranted('ROLE_ADMINISTRATIVE')] + #[IsGranted('ROLE_ADMIN')] public function index(): Response { $applications = $this->applicationRepository->getNew(); diff --git a/src/Controller/Admin/Teamer/CrmSelectionsController.php b/src/Controller/Admin/Teamer/CrmSelectionsController.php index 4940d87..4dcfa29 100644 --- a/src/Controller/Admin/Teamer/CrmSelectionsController.php +++ b/src/Controller/Admin/Teamer/CrmSelectionsController.php @@ -11,7 +11,7 @@ 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')] + #[IsGranted('ROLE_ADMIN')] public function index(Teamer $teamer): Response { return $this->render('admin/teamer/crm_selections.html.twig', [ diff --git a/src/Controller/Admin/Teamer/InfoController.php b/src/Controller/Admin/Teamer/InfoController.php index b1c88ad..d183524 100644 --- a/src/Controller/Admin/Teamer/InfoController.php +++ b/src/Controller/Admin/Teamer/InfoController.php @@ -7,6 +7,7 @@ use App\Repository\DispositionRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; +use Symfony\Component\Security\Http\Attribute\IsGranted; class InfoController extends AbstractController { @@ -14,6 +15,7 @@ class InfoController extends AbstractController {} #[Route('/admin/teamer/info/{uuid}', name: 'app_admin_teamer_info')] + #[IsGranted('ROLE_ADMIN')] public function index(Teamer $teamer): Response { $recentDispositions = $this->dispositionRepository->findRecentDispositionsByTeamer($teamer); diff --git a/src/Controller/Admin/Teamer/SkillsController.php b/src/Controller/Admin/Teamer/SkillsController.php index 5faee6b..ecf342d 100644 --- a/src/Controller/Admin/Teamer/SkillsController.php +++ b/src/Controller/Admin/Teamer/SkillsController.php @@ -15,7 +15,7 @@ class SkillsController extends AbstractController {} #[Route('/admin/teamer/skills/{uuid}', name: 'app_admin_teamer_skills')] - #[IsGranted('ROLE_ADMINISTRATIVE')] + #[IsGranted('ROLE_ADMIN')] public function index(Teamer $teamer): Response { $trainings = $this->trainingRepository->getList(); diff --git a/src/Controller/Administrative/Feedback/IndexController.php b/src/Controller/Administrative/Feedback/IndexController.php new file mode 100644 index 0000000..3fb1c66 --- /dev/null +++ b/src/Controller/Administrative/Feedback/IndexController.php @@ -0,0 +1,42 @@ +feedbackRepository + ->getListQuery() + ; + + $pagination = $this->paginator->paginate( + $query, + $request->query->getInt('page', 1), + 10, + [ + 'defaultSortFieldName' => 'feedback.createdAt', + 'defaultSortDirection' => 'desc', + ] + ); + + return $this->render('administrative/feedback/index.html.twig', [ + 'pagination' => $pagination, + ]); + } +} \ No newline at end of file diff --git a/src/Controller/Admin/Teamer/IndexController.php b/src/Controller/Administrative/Teamer/IndexController.php similarity index 86% rename from src/Controller/Admin/Teamer/IndexController.php rename to src/Controller/Administrative/Teamer/IndexController.php index 88363aa..6002dd3 100644 --- a/src/Controller/Admin/Teamer/IndexController.php +++ b/src/Controller/Administrative/Teamer/IndexController.php @@ -1,6 +1,6 @@ render('admin/teamer/index.html.twig', [ + return $this->render('administrative/teamer/index.html.twig', [ 'pagination' => $pagination, 'filterDto' => $filterDto, ]); diff --git a/src/Controller/Admin/Teamer/ProfileController.php b/src/Controller/Administrative/Teamer/ProfileController.php similarity index 67% rename from src/Controller/Admin/Teamer/ProfileController.php rename to src/Controller/Administrative/Teamer/ProfileController.php index 1be26f6..94b4951 100644 --- a/src/Controller/Admin/Teamer/ProfileController.php +++ b/src/Controller/Administrative/Teamer/ProfileController.php @@ -1,6 +1,6 @@ render('admin/teamer/profile.html.twig', [ + return $this->render('administrative/teamer/profile.html.twig', [ 'teamer' => $teamer, ]); } diff --git a/src/Controller/Admin/Teamer/RecentAssignmentsController.php b/src/Controller/Administrative/Teamer/RecentAssignmentsController.php similarity index 83% rename from src/Controller/Admin/Teamer/RecentAssignmentsController.php rename to src/Controller/Administrative/Teamer/RecentAssignmentsController.php index ba0aa68..a0c3e0f 100644 --- a/src/Controller/Admin/Teamer/RecentAssignmentsController.php +++ b/src/Controller/Administrative/Teamer/RecentAssignmentsController.php @@ -1,6 +1,6 @@ render('admin/teamer/recent_assignments.html.twig', [ + return $this->render('administrative/teamer/recent_assignments.html.twig', [ 'teamer' => $teamer, 'pagination' => $pagination, ]); diff --git a/src/Entity/Feedback.php b/src/Entity/Feedback.php index fe52191..fb2f201 100644 --- a/src/Entity/Feedback.php +++ b/src/Entity/Feedback.php @@ -40,8 +40,20 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface #[ORM\Column(length: 255, nullable: true)] private ?string $jobProfileName = null; + #[ORM\Column(length: 255, nullable: true)] + private ?string $hotel = null; + + #[ORM\Column(length: 32, nullable: true)] + private ?string $hotelCode = null; + + #[ORM\Column(nullable: true)] + private ?int $hotelBusProId = null; + #[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)] - private ?\DateTimeImmutable $assignmentDate = null; + private ?\DateTimeImmutable $assignmentDateFrom = null; + + #[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)] + private ?\DateTimeImmutable $assignmentDateTo = null; #[ORM\Column] #[Assert\Count(min: 1, minMessage: 'Bitte gib eine Bewertung ab')] @@ -69,10 +81,17 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface { $instance = new static($user); + $destination = $assignment->getDestination(); + $jobProfile = $assignment->getJobProfile(); + $instance - ->setDestinationName($assignment->getDestination()->getProduct()) - ->setAssignmentDate($assignment->getEffectiveDateFrom()) - ->setJobProfileName($assignment->getJobProfile()->getName()) + ->setAssignmentDateFrom($assignment->getEffectiveDateFrom()) + ->setAssignmentDateTo($assignment->getEffectiveDateTo()) + ->setDestinationName($destination->getProduct()) + ->setHotel($destination->getHotel()) + ->setHotelCode($destination->getHotelCode()) + ->setHotelBusProId($destination->getHotelBusProId()) + ->setJobProfileName($jobProfile->getName()) ; return $instance; @@ -124,14 +143,26 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface return $this; } - public function getAssignmentDate(): ?\DateTimeImmutable + public function getAssignmentDateFrom(): ?\DateTimeImmutable { - return $this->assignmentDate; + return $this->assignmentDateFrom; } - public function setAssignmentDate(\DateTimeImmutable $assignmentDate): static + public function setAssignmentDateFrom(\DateTimeImmutable $assignmentDateFrom): static { - $this->assignmentDate = $assignmentDate; + $this->assignmentDateFrom = $assignmentDateFrom; + + return $this; + } + + public function getAssignmentDateTo(): ?\DateTimeImmutable + { + return $this->assignmentDateTo; + } + + public function setAssignmentDateTo(?\DateTimeImmutable $assignmentDateTo): static + { + $this->assignmentDateTo = $assignmentDateTo; return $this; } @@ -148,6 +179,42 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface return $this; } + public function getHotel(): ?string + { + return $this->hotel; + } + + public function setHotel(?string $hotel): static + { + $this->hotel = $hotel; + + return $this; + } + + public function getHotelCode(): ?string + { + return $this->hotelCode; + } + + public function setHotelCode(?string $hotelCode): static + { + $this->hotelCode = $hotelCode; + + return $this; + } + + public function getHotelBusProId(): ?int + { + return $this->hotelBusProId; + } + + public function setHotelBusProId(?int $hotelBusProId): static + { + $this->hotelBusProId = $hotelBusProId; + + return $this; + } + public function getRatings(): array { return $this->ratings; diff --git a/src/Menu/AdminMenuBuilder.php b/src/Menu/AdminMenuBuilder.php index 53810f2..07c43fa 100644 --- a/src/Menu/AdminMenuBuilder.php +++ b/src/Menu/AdminMenuBuilder.php @@ -49,14 +49,27 @@ class AdminMenuBuilder extends AbstractMenuBuilder 'icon' => 'document', ], ]); + $menu->addChild('Feedbackübersicht', [ + 'route' => 'app_administrative_feedback_index', + 'linkAttributes' => [ + 'title' => 'Feedbackübersicht', + ], + 'extras' => [ + 'icon' => 'feedback', + 'routes' => [ + ['pattern' => '/^app_administrative_feedback_/'] + ], + ], + ]); $menu->addChild('Teamübersicht', [ - 'route' => 'app_admin_teamer_index', + 'route' => 'app_administrative_teamer_index', 'linkAttributes' => [ 'title' => 'Teamübersicht', ], 'extras' => [ 'icon' => 'users', 'routes' => [ + ['pattern' => '/^app_administrative_teamer_/'], ['pattern' => '/^app_admin_teamer_/'] ], ], @@ -181,7 +194,7 @@ class AdminMenuBuilder extends AbstractMenuBuilder $menu = $this->createRootElement(); $menu->addChild('Stammdaten & Foto', [ - 'route' => 'app_admin_teamer_profile', + 'route' => 'app_administrative_teamer_profile', 'routeParameters' => $this->getDefaultRouteParameters('uuid'), 'linkAttributes' => [ 'title' => 'Stammdaten & Foto', @@ -209,7 +222,7 @@ class AdminMenuBuilder extends AbstractMenuBuilder ], ]); $menu->addChild('Vergangene Einsätze', [ - 'route' => 'app_admin_teamer_recent_assignments', + 'route' => 'app_administrative_teamer_recent_assignments', 'routeParameters' => $this->getDefaultRouteParameters('uuid'), 'linkAttributes' => [ 'title' => 'Vergangene Einsätze', @@ -219,7 +232,7 @@ class AdminMenuBuilder extends AbstractMenuBuilder $this->addDivider($menu); $menu->addChild('zurück zur Übersicht', [ - 'route' => 'app_admin_teamer_index', + 'route' => 'app_administrative_teamer_index', 'extras' => [ 'icon' => 'arrow-left', ], diff --git a/src/Menu/ManagerMenuBuilder.php b/src/Menu/ManagerMenuBuilder.php index d15ba80..d8d562d 100644 --- a/src/Menu/ManagerMenuBuilder.php +++ b/src/Menu/ManagerMenuBuilder.php @@ -40,18 +40,30 @@ class ManagerMenuBuilder extends AbstractMenuBuilder 'icon' => 'document', ], ]); -// $menu->addChild('Teamübersicht', [ -// 'route' => 'app_admin_teamer_index', -// 'linkAttributes' => [ -// 'title' => 'Teamübersicht', -// ], -// 'extras' => [ -// 'icon' => 'users', -// 'routes' => [ -// ['pattern' => '/^app_admin_teamer_/'] -// ], -// ], -// ]); + $menu->addChild('Teamübersicht', [ + 'route' => 'app_administrative_teamer_index', + 'linkAttributes' => [ + 'title' => 'Teamübersicht', + ], + 'extras' => [ + 'icon' => 'users', + 'routes' => [ + ['pattern' => '/^app_administrative_teamer_/'] + ], + ], + ]); + $menu->addChild('Feedbackübersicht', [ + 'route' => 'app_administrative_feedback_index', + 'linkAttributes' => [ + 'title' => 'Feedbackübersicht', + ], + 'extras' => [ + 'icon' => 'feedback', + 'routes' => [ + ['pattern' => '/^app_administrative_feedback_/'] + ], + ], + ]); $settingsMenu = $menu->addChild('Einstellungen', [ 'linkAttributes' => [ 'title' => 'Einstellungen', @@ -96,35 +108,14 @@ class ManagerMenuBuilder extends AbstractMenuBuilder $menu = $this->createRootElement(); $menu->addChild('Stammdaten & Foto', [ - 'route' => 'app_admin_teamer_profile', + 'route' => 'app_administrative_teamer_profile', 'routeParameters' => $this->getDefaultRouteParameters('uuid'), 'linkAttributes' => [ 'title' => 'Stammdaten & Foto', ], ]); - $menu->addChild('Jobprofile & Skills', [ - 'route' => 'app_admin_teamer_skills', - 'routeParameters' => $this->getDefaultRouteParameters('uuid'), - 'linkAttributes' => [ - 'title' => 'Jobprofile & Skills', - ], - ]); - $menu->addChild('Verfügbarkeit', [ - 'route' => 'app_admin_teamer_availability', - 'routeParameters' => $this->getDefaultRouteParameters('uuid'), - 'linkAttributes' => [ - 'title' => 'Verfügbarkeit', - ], - ]); - $menu->addChild('Selektionsmerkmale', [ - 'route' => 'app_admin_teamer_crm_selections', - 'routeParameters' => $this->getDefaultRouteParameters('uuid'), - 'linkAttributes' => [ - 'title' => 'Selektionsmerkmale', - ], - ]); $menu->addChild('Vergangene Einsätze', [ - 'route' => 'app_admin_teamer_recent_assignments', + 'route' => 'app_administrative_teamer_recent_assignments', 'routeParameters' => $this->getDefaultRouteParameters('uuid'), 'linkAttributes' => [ 'title' => 'Vergangene Einsätze', @@ -134,7 +125,7 @@ class ManagerMenuBuilder extends AbstractMenuBuilder $this->addDivider($menu); $menu->addChild('zurück zur Übersicht', [ - 'route' => 'app_admin_teamer_index', + 'route' => 'app_administrative_teamer_index', 'extras' => [ 'icon' => 'arrow-left', ], diff --git a/src/Repository/FeedbackRepository.php b/src/Repository/FeedbackRepository.php index 3f97db0..462feba 100644 --- a/src/Repository/FeedbackRepository.php +++ b/src/Repository/FeedbackRepository.php @@ -5,6 +5,7 @@ namespace App\Repository; use App\Entity\Feedback; use App\Entity\Teamer; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; +use Doctrine\ORM\Query; use Doctrine\Persistence\ManagerRegistry; /** @@ -22,6 +23,17 @@ class FeedbackRepository extends ServiceEntityRepository parent::__construct($registry, Feedback::class); } + public function getListQuery(): Query + { + $qb = $this->createQueryBuilder('feedback'); + + return $qb + ->select('feedback', 'teamer') + ->innerJoin('feedback.teamer', 'teamer') + ->getQuery() + ; + } + public function getNew(int $limit = 5): array { $qb = $this->createQueryBuilder('feedback'); diff --git a/templates/administrative/feedback/index.html.twig b/templates/administrative/feedback/index.html.twig new file mode 100644 index 0000000..afc3ff7 --- /dev/null +++ b/templates/administrative/feedback/index.html.twig @@ -0,0 +1,78 @@ +{% extends 'administrative/layout.html.twig' %} + +{% block title %}Feedbackübersicht{% endblock %} + +{% block content %} +
+

+ Feedbackübersicht +

+
+ +
+
+ + + + + + + + + + + + + {% for feedback in pagination %} + + + + + + + + + {% else %} + + + + {% endfor %} + +
+ {{ knp_pagination_sortable(pagination, 'Name', 'teamer.lastName') }} + + {{ knp_pagination_sortable(pagination, 'Vorname', 'teamer.firstName') }} + + {{ knp_pagination_sortable(pagination, 'Einsatzzeitraum', 'feedback.assignmentDateFrom') }} + + {{ knp_pagination_sortable(pagination, 'Haus', 'feedback.hotel') }} + + {{ knp_pagination_sortable(pagination, 'Note', 'feedback.averageRating') }} +
+ {{ feedback.teamer.lastName }} + + {{ feedback.teamer.firstName }} + + {% if feedback.assignmentDateFrom and feedback.assignmentDateTo %} + {{ feedback.assignmentDateFrom|date('d.m.Y') }}- +
+ {{ feedback.assignmentDateTo|date('d.m.Y') }} + {% else %} + - + {% endif %} +
+ {{ feedback.hotel|default('-') }} + + {% if feedback.averageRating %} + {{ feedback.averageRating|format_rating }} + {% else %} + - + {% endif %} + +
+ Keine Daten... +
+ {{ knp_pagination_render(pagination) }} +
+
+{% endblock %} \ No newline at end of file diff --git a/templates/admin/teamer/index.html.twig b/templates/administrative/teamer/index.html.twig similarity index 91% rename from templates/admin/teamer/index.html.twig rename to templates/administrative/teamer/index.html.twig index 157cb79..31becd1 100644 --- a/templates/admin/teamer/index.html.twig +++ b/templates/administrative/teamer/index.html.twig @@ -1,4 +1,4 @@ -{% extends 'admin/layout.html.twig' %} +{% extends 'administrative/layout.html.twig' %} {% block title %}Teamübersicht{% endblock %} @@ -70,12 +70,12 @@ - + {{ teamer.lastName }} - + {{ teamer.firstName }} @@ -94,7 +94,7 @@
- + {{ icon('user') }}
diff --git a/templates/admin/teamer/profile.html.twig b/templates/administrative/teamer/profile.html.twig similarity index 96% rename from templates/admin/teamer/profile.html.twig rename to templates/administrative/teamer/profile.html.twig index 17b85e0..15c912a 100644 --- a/templates/admin/teamer/profile.html.twig +++ b/templates/administrative/teamer/profile.html.twig @@ -1,11 +1,15 @@ -{% extends 'admin/layout.html.twig' %} +{% extends 'administrative/layout.html.twig' %} {% block title %}Stammdaten und Foto {{ teamer }}{% endblock %} {% block content %}
- {{ knp_menu_render(knp_menu_get('admin_teamer')) }} + {% if is_granted('ROLE_MANAGER') %} + {{ knp_menu_render(knp_menu_get('manager_teamer')) }} + {% elseif is_granted('ROLE_ADMIN') %} + {{ knp_menu_render(knp_menu_get('admin_teamer')) }} + {% endif %}

diff --git a/templates/admin/teamer/recent_assignments.html.twig b/templates/administrative/teamer/recent_assignments.html.twig similarity index 91% rename from templates/admin/teamer/recent_assignments.html.twig rename to templates/administrative/teamer/recent_assignments.html.twig index ae365c1..1d4ed0e 100644 --- a/templates/admin/teamer/recent_assignments.html.twig +++ b/templates/administrative/teamer/recent_assignments.html.twig @@ -1,11 +1,15 @@ -{% extends 'admin/layout.html.twig' %} +{% extends 'administrative/layout.html.twig' %} {% block title %}Vergangene Einsätze & Feeback {{ teamer }}{% endblock %} {% block content %}
- {{ knp_menu_render(knp_menu_get('admin_teamer')) }} + {% if is_granted('ROLE_MANAGER') %} + {{ knp_menu_render(knp_menu_get('manager_teamer')) }} + {% elseif is_granted('ROLE_ADMIN') %} + {{ knp_menu_render(knp_menu_get('admin_teamer')) }} + {% endif %}