Files
myep-team/src/Controller/Admin/IndexController.php
T
2026-03-02 14:50:51 +01:00

77 lines
3.7 KiB
PHP

<?php
namespace App\Controller\Admin;
use App\Entity\Application;
use App\Entity\Assignment;
use App\Entity\Availability;
use App\Entity\Disposition;
use App\Entity\Feedback;
use App\Entity\Upload;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class IndexController extends AbstractController
{
public function __construct(private readonly EntityManagerInterface $entityManager)
{
}
#[Route('/admin', name: 'app_admin_index')]
#[IsGranted('ROLE_ADMIN')]
public function index(): Response
{
$applicationRepository = $this->entityManager->getRepository(Application::class);
$applications = $applicationRepository->getNew();
$newApplicationsCount = $applicationRepository->getCountByStatus(Application::STATUS_NEW);
$pendingApplicationsCount = $applicationRepository->getCountByStatus(Application::STATUS_PENDING);
$feedbackRepository = $this->entityManager->getRepository(Feedback::class);
$feedbacks = $feedbackRepository->getNew();
$pendingFeedbacksCount = $feedbackRepository->getCountByStatus(Feedback::STATUS_NEW);
$assignments = $this->entityManager->getRepository(Assignment::class)->getNew();
$availabilities = $this->entityManager->getRepository(Availability::class)->getNew();
$uploadRepository = $this->entityManager->getRepository(Upload::class);
$newContracts = $uploadRepository->getNewByType(Upload::TYPE_CONTRACT);
$newContractsCount = $uploadRepository->getCountByStatusAndType(Upload::STATUS_NEW, Upload::TYPE_CONTRACT);
$pendingContractsCount = $uploadRepository->getCountByStatusAndType(Upload::STATUS_PENDING, Upload::TYPE_CONTRACT);
$newInvoices = $uploadRepository->getNewByType(Upload::TYPE_INVOICE);
$newInvoicesCount = $uploadRepository->getCountByStatusAndType(Upload::STATUS_NEW, Upload::TYPE_INVOICE);
$pendingInvoicesCount = $uploadRepository->getCountByStatusAndType(Upload::STATUS_PENDING, Upload::TYPE_INVOICE);
$newDriverLicenses = $uploadRepository->getNewByType(Upload::TYPE_DRIVER_LICENSE);
$newDriverLicensesCount = $uploadRepository->getCountByStatusAndType(Upload::STATUS_NEW, Upload::TYPE_DRIVER_LICENSE);
$dispositionRepository = $this->entityManager->getRepository(Disposition::class);
$overdueContracts = $dispositionRepository->findOverdueContracts();
$newDispositions = $dispositionRepository->getNew();
$overdueFeedbacks = $dispositionRepository->findDispositionsWithOverdueFeedback(7);
return $this->render('admin/index.html.twig', [
'applications' => $applications,
'newApplicationsCount' => $newApplicationsCount,
'pendingApplicationsCount' => $pendingApplicationsCount,
'feedbacks' => $feedbacks,
'pendingFeedbacksCount' => $pendingFeedbacksCount,
'assignments' => $assignments,
'availabilities' => $availabilities,
'newContracts' => $newContracts,
'newContractsCount' => $newContractsCount,
'pendingContractsCount' => $pendingContractsCount,
'newInvoices' => $newInvoices,
'newInvoicesCount' => $newInvoicesCount,
'pendingInvoicesCount' => $pendingInvoicesCount,
'newDriverLicenses' => $newDriverLicenses,
'newDriverLicensesCount' => $newDriverLicensesCount,
'overdueContracts' => $overdueContracts,
'newDispositions' => $newDispositions,
'overdueFeedbacks' => $overdueFeedbacks,
]);
}
}