feat: feedback per destination
addresses #869bgty87
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Administrative\Statistics;
|
||||
|
||||
use App\Form\StatisticsFilterType;
|
||||
use App\Repository\DispositionRepository;
|
||||
use App\Service\Common\StatisticsFilterHandler;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class FeedbackByDestinationController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly StatisticsFilterHandler $filterHandler,
|
||||
private readonly DispositionRepository $dispositionRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/administrative/statistics/feedback-by-destination', name: 'app_administrative_statistics_feedback_by_destination')]
|
||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$filterDto = $this->filterHandler->getFilterSettings();
|
||||
|
||||
$form = $this->createForm(StatisticsFilterType::class, $filterDto);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$filterDto = $this->filterHandler->handleRequest($form);
|
||||
}
|
||||
|
||||
$statistics = $this->dispositionRepository->getFeedbackStatisticsByNormalizedHotelCode(
|
||||
$filterDto->getDateFrom(),
|
||||
$filterDto->getDateTo(),
|
||||
);
|
||||
|
||||
return $this->render('administrative/statistics/feedback_by_destination.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'filterDto' => $filterDto,
|
||||
'statistics' => $statistics,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Administrative\Statistics;
|
||||
|
||||
use App\Form\FeedbackStatisticsFilterType;
|
||||
use App\Form\StatisticsFilterType;
|
||||
use App\Repository\FeedbackRepository;
|
||||
use App\Service\Common\FeedbackStatisticsFilterHandler;
|
||||
use App\Service\Common\StatisticsFilterHandler;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -16,7 +16,7 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
class FeedbackRatingsController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly FeedbackStatisticsFilterHandler $filterHandler,
|
||||
private readonly StatisticsFilterHandler $filterHandler,
|
||||
private readonly FeedbackRepository $feedbackRepository,
|
||||
) {
|
||||
}
|
||||
@@ -27,7 +27,7 @@ class FeedbackRatingsController extends AbstractController
|
||||
{
|
||||
$filterDto = $this->filterHandler->getFilterSettings();
|
||||
|
||||
$form = $this->createForm(FeedbackStatisticsFilterType::class, $filterDto);
|
||||
$form = $this->createForm(StatisticsFilterType::class, $filterDto);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
|
||||
@@ -4,13 +4,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Model\FeedbackStatisticsFilterDto;
|
||||
use App\Model\StatisticsFilterDto;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class FeedbackStatisticsFilterType extends AbstractType
|
||||
class StatisticsFilterType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
@@ -36,7 +36,7 @@ class FeedbackStatisticsFilterType extends AbstractType
|
||||
{
|
||||
$resolver
|
||||
->setDefaults([
|
||||
'data_class' => FeedbackStatisticsFilterDto::class,
|
||||
'data_class' => StatisticsFilterDto::class,
|
||||
])
|
||||
;
|
||||
}
|
||||
@@ -118,14 +118,25 @@ class AdminMenuBuilder extends AbstractMenuBuilder
|
||||
'icon' => 'chart',
|
||||
],
|
||||
]);
|
||||
$statisticsMenu->addChild('Feedback-Bewertungen', [
|
||||
$statisticsMenu->addChild('Bewertungen nach Kategorie', [
|
||||
'route' => 'app_administrative_statistics_feedback_ratings',
|
||||
'linkAttributes' => [
|
||||
'title' => 'Feedback-Bewertungen',
|
||||
'title' => 'Bewertungen nach Kategorie',
|
||||
],
|
||||
'extras' => [
|
||||
'routes' => [
|
||||
['pattern' => '/^app_administrative_statistics_/'],
|
||||
['pattern' => '/^app_administrative_statistics_feedback_ratings/'],
|
||||
],
|
||||
],
|
||||
]);
|
||||
$statisticsMenu->addChild('Feedback pro Destination', [
|
||||
'route' => 'app_administrative_statistics_feedback_by_destination',
|
||||
'linkAttributes' => [
|
||||
'title' => 'Feedback pro Destination',
|
||||
],
|
||||
'extras' => [
|
||||
'routes' => [
|
||||
['pattern' => '/^app_administrative_statistics_feedback_by_destination/'],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -99,14 +99,25 @@ class ManagerMenuBuilder extends AbstractMenuBuilder
|
||||
'icon' => 'chart',
|
||||
],
|
||||
]);
|
||||
$statisticsMenu->addChild('Feedback-Bewertungen', [
|
||||
$statisticsMenu->addChild('Bewertungen nach Kategorie', [
|
||||
'route' => 'app_administrative_statistics_feedback_ratings',
|
||||
'linkAttributes' => [
|
||||
'title' => 'Feedback-Bewertungen',
|
||||
'title' => 'Bewertungen nach Kategorie',
|
||||
],
|
||||
'extras' => [
|
||||
'routes' => [
|
||||
['pattern' => '/^app_administrative_statistics_/'],
|
||||
['pattern' => '/^app_administrative_statistics_feedback_ratings/'],
|
||||
],
|
||||
],
|
||||
]);
|
||||
$statisticsMenu->addChild('Feedback pro Destination', [
|
||||
'route' => 'app_administrative_statistics_feedback_by_destination',
|
||||
'linkAttributes' => [
|
||||
'title' => 'Feedback pro Destination',
|
||||
],
|
||||
'extras' => [
|
||||
'routes' => [
|
||||
['pattern' => '/^app_administrative_statistics_feedback_by_destination/'],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
class FeedbackStatisticsFilterDto extends AbstractFilterDto
|
||||
class StatisticsFilterDto extends AbstractFilterDto
|
||||
{
|
||||
protected ?\DateTimeImmutable $dateFrom = null;
|
||||
protected ?\DateTimeImmutable $dateTo = null;
|
||||
@@ -318,7 +318,11 @@ class DispositionRepository extends ServiceEntityRepository
|
||||
->innerJoin('assignment.destination', 'destination')
|
||||
->leftJoin('disposition.feedback', 'feedback')
|
||||
->where($qb->expr()->in('disposition.status', ':statuses'))
|
||||
->setParameter('statuses', [Disposition::STATUS_ENDED, Disposition::STATUS_COMPLETED])
|
||||
->setParameter('statuses', [
|
||||
Disposition::STATUS_ENDED,
|
||||
Disposition::STATUS_PAID,
|
||||
Disposition::STATUS_COMPLETED,
|
||||
])
|
||||
->groupBy('destination.hotelCode', 'destination.hotel')
|
||||
->orderBy('destination.hotel', 'ASC')
|
||||
;
|
||||
@@ -406,7 +410,11 @@ class DispositionRepository extends ServiceEntityRepository
|
||||
->innerJoin('assignment.destination', 'destination')
|
||||
->leftJoin('disposition.feedback', 'feedback')
|
||||
->where($qb->expr()->in('disposition.status', ':statuses'))
|
||||
->setParameter('statuses', [Disposition::STATUS_ENDED, Disposition::STATUS_COMPLETED])
|
||||
->setParameter('statuses', [
|
||||
Disposition::STATUS_ENDED,
|
||||
Disposition::STATUS_PAID,
|
||||
Disposition::STATUS_COMPLETED,
|
||||
])
|
||||
->groupBy('hotelCode')
|
||||
->orderBy('hotelCode', 'ASC')
|
||||
;
|
||||
|
||||
+6
-6
@@ -5,14 +5,14 @@ declare(strict_types=1);
|
||||
namespace App\Service\Common;
|
||||
|
||||
use App\Model\AbstractFilterDto;
|
||||
use App\Model\FeedbackStatisticsFilterDto;
|
||||
use App\Model\StatisticsFilterDto;
|
||||
|
||||
class FeedbackStatisticsFilterHandler extends AbstractFilterHandler
|
||||
class StatisticsFilterHandler extends AbstractFilterHandler
|
||||
{
|
||||
protected string $namespace = 'filter:feedback_statistics';
|
||||
protected string $modelClass = FeedbackStatisticsFilterDto::class;
|
||||
protected string $namespace = 'filter:statistics';
|
||||
protected string $modelClass = StatisticsFilterDto::class;
|
||||
|
||||
public function getFilterSettings(): FeedbackStatisticsFilterDto
|
||||
public function getFilterSettings(): StatisticsFilterDto
|
||||
{
|
||||
$filterDto = new $this->modelClass();
|
||||
|
||||
@@ -32,7 +32,7 @@ class FeedbackStatisticsFilterHandler extends AbstractFilterHandler
|
||||
|
||||
protected function saveFilterSettings(AbstractFilterDto $filterDto): void
|
||||
{
|
||||
/* @var FeedbackStatisticsFilterDto $filterDto */
|
||||
/* @var StatisticsFilterDto $filterDto */
|
||||
$this->getSession()->set($this->namespace, [
|
||||
'date_from' => $filterDto->getDateFrom(),
|
||||
'date_to' => $filterDto->getDateTo(),
|
||||
@@ -0,0 +1,107 @@
|
||||
{% extends 'administrative/layout.html.twig' %}
|
||||
|
||||
{% block title %}Feedback pro Destination{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="flex items-start justify-between pb-4">
|
||||
<h1 class="text-2xl font-bold">
|
||||
Feedback pro Destination
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-lg shadow p-4 mb-8">
|
||||
{{ form_start(form, { attr: { class: 'flex flex-wrap items-end gap-4' } }) }}
|
||||
<div class="flex-1 min-w-[150px]">
|
||||
{{ form_row(form.dateFrom) }}
|
||||
</div>
|
||||
<div class="flex-1 min-w-[150px]">
|
||||
{{ form_row(form.dateTo) }}
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
{{ form_widget(form.apply, { attr: { class: 'btn btn--small' } }) }}
|
||||
{{ form_widget(form.reset, { attr: { class: 'btn btn--small btn--secondary' } }) }}
|
||||
</div>
|
||||
{{ form_end(form) }}
|
||||
</div>
|
||||
|
||||
{% if filterDto.active %}
|
||||
<p class="text-sm text-gray-600 mb-4">
|
||||
Filter aktiv:
|
||||
{% if filterDto.dateFrom %}von {{ filterDto.dateFrom|date('d.m.Y') }}{% endif %}
|
||||
{% if filterDto.dateTo %}bis {{ filterDto.dateTo|date('d.m.Y') }}{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if statistics is empty %}
|
||||
<div class="bg-white rounded-lg shadow p-8 text-center text-gray-500">
|
||||
Keine Daten im ausgewählten Zeitraum vorhanden.
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="bg-white rounded-lg shadow overflow-hidden">
|
||||
<table class="w-full text-sm">
|
||||
<thead>
|
||||
<tr class="bg-gray-50 border-b">
|
||||
<th class="px-4 py-3 text-left font-semibold">Destination</th>
|
||||
<th class="px-4 py-3 text-right font-semibold">Erwartet</th>
|
||||
<th class="px-4 py-3 text-right font-semibold">Abgegeben</th>
|
||||
<th class="px-4 py-3 text-right font-semibold">Fehlend</th>
|
||||
<th class="px-4 py-3 text-right font-semibold">Quote</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for stat in statistics %}
|
||||
<tr class="border-b hover:bg-gray-50">
|
||||
<td class="px-4 py-3 font-medium">{{ stat.hotelCode }}</td>
|
||||
<td class="px-4 py-3 text-right">{{ stat.totalDispositions }}</td>
|
||||
<td class="px-4 py-3 text-right">{{ stat.providedFeedbacks }}</td>
|
||||
<td class="px-4 py-3 text-right">{{ stat.missingFeedbacks }}</td>
|
||||
<td class="px-4 py-3 text-right">
|
||||
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium
|
||||
{% if stat.percentageProvided >= 80 %}
|
||||
bg-green-100 text-green-800
|
||||
{% elseif stat.percentageProvided >= 50 %}
|
||||
bg-yellow-100 text-yellow-800
|
||||
{% else %}
|
||||
bg-red-100 text-red-800
|
||||
{% endif %}
|
||||
">
|
||||
{{ stat.percentageProvided|number_format(1, ',', '.') }}%
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
{% set totalExpected = 0 %}
|
||||
{% set totalProvided = 0 %}
|
||||
{% set totalMissing = 0 %}
|
||||
{% for stat in statistics %}
|
||||
{% set totalExpected = totalExpected + stat.totalDispositions %}
|
||||
{% set totalProvided = totalProvided + stat.providedFeedbacks %}
|
||||
{% set totalMissing = totalMissing + stat.missingFeedbacks %}
|
||||
{% endfor %}
|
||||
{% set totalPercentage = totalExpected > 0 ? (totalProvided / totalExpected * 100) : 0 %}
|
||||
<tr class="bg-gray-100 font-semibold">
|
||||
<td class="px-4 py-3">Gesamt</td>
|
||||
<td class="px-4 py-3 text-right">{{ totalExpected }}</td>
|
||||
<td class="px-4 py-3 text-right">{{ totalProvided }}</td>
|
||||
<td class="px-4 py-3 text-right">{{ totalMissing }}</td>
|
||||
<td class="px-4 py-3 text-right">
|
||||
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium
|
||||
{% if totalPercentage >= 80 %}
|
||||
bg-green-100 text-green-800
|
||||
{% elseif totalPercentage >= 50 %}
|
||||
bg-yellow-100 text-yellow-800
|
||||
{% else %}
|
||||
bg-red-100 text-red-800
|
||||
{% endif %}
|
||||
">
|
||||
{{ totalPercentage|number_format(1, ',', '.') }}%
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user