feat: hotel manager dashboard

This commit is contained in:
Björn Fromme
2023-12-07 15:18:16 +01:00
parent 77924b6a31
commit 794c40003b
4 changed files with 121 additions and 1 deletions
@@ -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,
]);
}
}
+27
View File
@@ -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()
;
}
}
+3
View File
@@ -0,0 +1,3 @@
<svg viewBox="0 0 2 2" class="h-1 w-1 fill-current shrink-0">
<circle cx="1" cy="1" r="1" />
</svg>

After

Width:  |  Height:  |  Size: 104 B

+53
View File
@@ -1,4 +1,57 @@
{% extends 'house_manager/layout.html.twig' %}
{% macro dispositionData(disposition) %}
{% set assignment = disposition.assignment %}
<span class="whitespace-nowrap">{{ disposition.teamer.fullName(true) }}</span>
{% include '_partials/_dot.html.twig' %}
<span class="whitespace-nowrap">{{ assignment.effectivePeriod.start|date('d.m.y') }} - {{ assignment.effectivePeriod.end|date('d.m.y') }}</span>
{% include '_partials/_dot.html.twig' %}
<span class="whitespace-nowrap">{{ assignment.destination.hotel }}</span>
{% include '_partials/_dot.html.twig' %}
<span class="whitespace-nowrap">{{ assignment.jobProfile.name }}</span>
{% endmacro %}
{% block content %}
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
<div class="bg-gray-100 border border-gray-200 rounded-md px-4 py-2">
<h2 class="font-bold text-lg">
Neue Einteilungen
</h2>
<ul class="divide-y divide-gray-200">
{% for disposition in newDispositions %}
{% set assignment = disposition.assignment %}
<li class="py-2 first:pt-0 last:pb-0">
<a href="#" class="flex items-center space-x-1 truncate">
{{ icon('hand', 'w-4 h-4 shrink-0') }}
{{ _self.dispositionData(disposition) }}
</a>
</li>
{% else %}
<li class="py-2 first:pt-0 last:pb-0">
-
</li>
{% endfor %}
</ul>
</div>
<div class="bg-gray-100 border border-gray-200 rounded-md px-4 py-2">
<h2 class="font-bold text-lg pb-2">
Offene Feedbacks
</h2>
<ul class="divide-y divide-gray-200">
{% for disposition in pendingFeedbacks %}
{% set assignment = disposition.assignment %}
<li class="py-2 first:pt-0 last:pb-0">
<a href="{{ path('app_house_manager_feedback_provide', { 'uuid': disposition.uuid, 'r': return_url() }) }}" class="flex items-center space-x-1 truncate">
{{ icon('feedback', 'w-4 h-4 shrink-0') }}
{{ _self.dispositionData(disposition) }}
</a>
</li>
{% else %}
<li class="py-2 first:pt-0 last:pb-0">
-
</li>
{% endfor %}
</ul>
</div>
</div>
{% endblock %}