From 794c40003bdce504294ae0a5a4f16c96ace905a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Thu, 7 Dec 2023 15:18:16 +0100 Subject: [PATCH] feat: hotel manager dashboard --- .../HouseManager/IndexController.php | 39 +++++++++++++- src/Repository/DispositionRepository.php | 27 ++++++++++ templates/_partials/_dot.html.twig | 3 ++ templates/house_manager/index.html.twig | 53 +++++++++++++++++++ 4 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 templates/_partials/_dot.html.twig diff --git a/src/Controller/HouseManager/IndexController.php b/src/Controller/HouseManager/IndexController.php index 5942008..003c5e7 100644 --- a/src/Controller/HouseManager/IndexController.php +++ b/src/Controller/HouseManager/IndexController.php @@ -2,15 +2,52 @@ namespace App\Controller\HouseManager; +use App\BusProNet\DataProvider\HotelDataProvider; +use App\BusProNet\Model\Hotel; +use App\Entity\User; +use App\Repository\DispositionRepository; 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 IndexController extends AbstractController { + public function __construct( + private readonly HotelDataProvider $hotelDataProvider, + private readonly DispositionRepository $dispositionRepository + ) { + } + #[Route('/house-manager', name: 'app_house_manager_index')] + #[IsGranted('ROLE_HOUSE_MANAGER')] public function index(): Response { - return $this->render('house_manager/index.html.twig'); + /** @var User $user */ + $user = $this->getUser(); + + $hotels = $this + ->hotelDataProvider + ->findByCode($user->getHotelCode()) + ; + + $hotelBusProIds = array_map(function (Hotel $hotel) { + return $hotel->getBusProId(); + }, $hotels); + + $newDispositions = $this + ->dispositionRepository + ->getNewByHotelBusProIds($hotelBusProIds) + ; + + $pendingFeedbacks = $this + ->dispositionRepository + ->getPendingFeedbackByHotelBusProIds($hotelBusProIds) + ; + + return $this->render('house_manager/index.html.twig', [ + 'newDispositions' => $newDispositions, + 'pendingFeedbacks' => $pendingFeedbacks, + ]); } } \ No newline at end of file diff --git a/src/Repository/DispositionRepository.php b/src/Repository/DispositionRepository.php index 5e2ca15..e582176 100644 --- a/src/Repository/DispositionRepository.php +++ b/src/Repository/DispositionRepository.php @@ -113,6 +113,25 @@ class DispositionRepository extends ServiceEntityRepository ; } + public function getNewByHotelBusProIds(array $hotelBusProIds): array + { + $qb = $this->createQueryBuilder('disposition'); + + return $qb + ->select('disposition', 'assignment', 'destination') + ->innerJoin('disposition.assignment', 'assignment') + ->innerJoin('assignment.destination', 'destination') + ->where($qb->expr()->andX( + $qb->expr()->in('destination.hotelBusProId', ':hotelBusProIds'), + $qb->expr()->lt('destination.dateTo', ':dateTo') + )) + ->setParameter('hotelBusProIds', $hotelBusProIds) + ->setParameter('dateTo', new \DateTimeImmutable()) + ->getQuery() + ->getResult() + ; + } + public function getPendingFeedbackQuery(array $hotelBusProIds = null): Query { $qb = $this->createQueryBuilder('disposition'); @@ -137,4 +156,12 @@ class DispositionRepository extends ServiceEntityRepository return $qb->getQuery(); } + + public function getPendingFeedbackByHotelBusProIds(array $hotelBusProIds): array + { + return $this + ->getPendingFeedbackQuery($hotelBusProIds) + ->getResult() + ; + } } diff --git a/templates/_partials/_dot.html.twig b/templates/_partials/_dot.html.twig new file mode 100644 index 0000000..1053aeb --- /dev/null +++ b/templates/_partials/_dot.html.twig @@ -0,0 +1,3 @@ + + + diff --git a/templates/house_manager/index.html.twig b/templates/house_manager/index.html.twig index 3bec960..edc432c 100644 --- a/templates/house_manager/index.html.twig +++ b/templates/house_manager/index.html.twig @@ -1,4 +1,57 @@ {% extends 'house_manager/layout.html.twig' %} +{% macro dispositionData(disposition) %} + {% set assignment = disposition.assignment %} + {{ disposition.teamer.fullName(true) }} + {% include '_partials/_dot.html.twig' %} + {{ assignment.effectivePeriod.start|date('d.m.y') }} - {{ assignment.effectivePeriod.end|date('d.m.y') }} + {% include '_partials/_dot.html.twig' %} + {{ assignment.destination.hotel }} + {% include '_partials/_dot.html.twig' %} + {{ assignment.jobProfile.name }} +{% endmacro %} + {% block content %} +
+
+

+ Neue Einteilungen +

+ +
+
+

+ Offene Feedbacks +

+ +
+
{% endblock %} \ No newline at end of file