50 lines
1.8 KiB
PHP
50 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Controller\Administrative\Statistics;
|
|
|
|
use App\Form\StatisticsFilterType;
|
|
use App\Repository\FeedbackRepository;
|
|
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 FeedbackRatingsByDestinationController extends AbstractController
|
|
{
|
|
public function __construct(
|
|
private readonly StatisticsFilterHandler $filterHandler,
|
|
private readonly FeedbackRepository $feedbackRepository,
|
|
) {
|
|
}
|
|
|
|
#[Route('/administrative/statistics/feedback-ratings-by-destination', name: 'app_administrative_statistics_feedback_ratings_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->feedbackRepository->getAverageRatingsByDestinationAndFeedbackSet(
|
|
$filterDto->getEffectiveDateFrom(),
|
|
$filterDto->getEffectiveDateTo(),
|
|
);
|
|
|
|
return $this->render('administrative/statistics/feedback_ratings_by_destination.html.twig', [
|
|
'form' => $form->createView(),
|
|
'filterDto' => $filterDto,
|
|
'destinations' => $statistics['destinations'],
|
|
'feedbackSets' => $statistics['feedbackSets'],
|
|
]);
|
|
}
|
|
}
|