feat: dedicated dashboard widgets for contracts and invoices

This commit is contained in:
Björn Fromme
2025-01-15 16:17:55 +01:00
parent 6af42e5703
commit b62cf18ede
5 changed files with 194 additions and 97 deletions
+12 -6
View File
@@ -38,9 +38,12 @@ class IndexController extends AbstractController
$availabilities = $this->entityManager->getRepository(Availability::class)->getNew();
$uploadRepository = $this->entityManager->getRepository(Upload::class);
$documents = $uploadRepository->getNew();
$newDocumentsCount = $uploadRepository->getCountByStatus(Upload::STATUS_NEW);
$pendingDocumentsCount = $uploadRepository->getCountByStatus(Upload::STATUS_PENDING);
$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);
$dispositionRepository = $this->entityManager->getRepository(Disposition::class);
$overdueContracts = $dispositionRepository->findOverdueContracts();
@@ -55,9 +58,12 @@ class IndexController extends AbstractController
'pendingFeedbacksCount' => $pendingFeedbacksCount,
'assignments' => $assignments,
'availabilities' => $availabilities,
'documents' => $documents,
'newDocumentsCount' => $newDocumentsCount,
'pendingDocumentsCount' => $pendingDocumentsCount,
'newContracts' => $newContracts,
'newContractsCount' => $newContractsCount,
'pendingContractsCount' => $pendingContractsCount,
'newInvoices' => $newInvoices,
'newInvoicesCount' => $newInvoicesCount,
'pendingInvoicesCount' => $pendingInvoicesCount,
'overdueContracts' => $overdueContracts,
'newDispositions' => $newDispositions,
'overdueFeedbacks' => $overdueFeedbacks,
+20 -6
View File
@@ -22,16 +22,30 @@ class IndexController extends AbstractController
{
$dispositions = $this->dispositionRepository->getNew();
$documents = $this->uploadRepository->getNew();
$newDocumentsCount = $this->uploadRepository->getCountByStatus(Upload::STATUS_NEW);
$pendingDocumentsCount = $this->uploadRepository->getCountByStatus(Upload::STATUS_PENDING);
$newContracts = $this->uploadRepository->getNewByType(Upload::TYPE_CONTRACT);
$newContractsCount = $this
->uploadRepository
->getCountByStatusAndType(Upload::STATUS_NEW, Upload::TYPE_CONTRACT);
$pendingContractsCount = $this
->uploadRepository
->getCountByStatusAndType(Upload::STATUS_PENDING, Upload::TYPE_CONTRACT);
$newInvoices = $this->uploadRepository->getNewByType(Upload::TYPE_INVOICE);
$newInvoicesCount = $this
->uploadRepository
->getCountByStatusAndType(Upload::STATUS_NEW, Upload::TYPE_INVOICE);
$pendingInvoicesCount = $this
->uploadRepository
->getCountByStatusAndType(Upload::STATUS_PENDING, Upload::TYPE_INVOICE);
$overdueFeedbacks = $this->dispositionRepository->findDispositionsWithOverdueFeedback(7);
return $this->render('manager/index.html.twig', [
'dispositions' => $dispositions,
'documents' => $documents,
'newDocumentsCount' => $newDocumentsCount,
'pendingDocumentsCount' => $pendingDocumentsCount,
'newContracts' => $newContracts,
'newContractsCount' => $newContractsCount,
'pendingContractsCount' => $pendingContractsCount,
'newInvoices' => $newInvoices,
'newInvoicesCount' => $newInvoicesCount,
'pendingInvoicesCount' => $pendingInvoicesCount,
'overdueFeedbacks' => $overdueFeedbacks,
]);
}
+6 -7
View File
@@ -147,7 +147,7 @@ class UploadRepository extends ServiceEntityRepository
return $qb->getQuery();
}
public function getNew(int $limit = 5): array
public function getNewByType(string $type): array
{
$qb = $this->createQueryBuilder('upload');
@@ -158,29 +158,28 @@ class UploadRepository extends ServiceEntityRepository
->leftJoin('upload.disposition', 'disposition')
->leftJoin('disposition.assignment', 'assignment')
->where($qb->expr()->andX(
$qb->expr()->in('upload.type', ':type'),
$qb->expr()->eq('upload.type', ':type'),
$qb->expr()->in('upload.status', ':status')
))
->orderBy('upload.createdAt', 'DESC')
->setParameter('type', [Upload::TYPE_CONTRACT, Upload::TYPE_INVOICE])
->setParameter('type', $type)
->setParameter('status', [Upload::STATUS_NEW, Upload::STATUS_PENDING])
->setMaxResults($limit)
->getQuery()
->getResult()
;
}
public function getCountByStatus(string $status): ?int
public function getCountByStatusAndType(string $status, string $type): ?int
{
$qb = $this->createQueryBuilder('upload');
return $qb
->select($qb->expr()->count('upload'))
->where($qb->expr()->andX(
$qb->expr()->in('upload.type', ':type'),
$qb->expr()->eq('upload.type', ':type'),
$qb->expr()->eq('upload.status', ':status')
))
->setParameter('type', [Upload::TYPE_CONTRACT, Upload::TYPE_INVOICE])
->setParameter('type', $type)
->setParameter('status', $status)
->getQuery()
->getSingleScalarResult()