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(),
|
||||
Reference in New Issue
Block a user