major fixes

This commit is contained in:
2024-09-25 16:55:03 +02:00
parent e1cb68766e
commit 598acfd77c
12 changed files with 351 additions and 236 deletions
+16 -4
View File
@@ -1,6 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Services;
use App\Entity\Clients;
use App\Entity\Reports;
use Doctrine\ORM\EntityManager;
@@ -8,12 +9,14 @@ class OverdueReports
{
private array $list;
private int $leftCount = 0;
public function __construct(private readonly EntityManager $entity){
$this->list = $this->takeOverdueList();
}
private ?Clients $client = null;
public function __construct(private readonly EntityManager $entity){}
public function getList(): array
{
if(!isset($this->list)){
$this->list = $this->takeOverdueList();
}
return $this->list;
}
@@ -22,6 +25,11 @@ class OverdueReports
$this->leftCount = $leftCount;
}
public function setClient(?Clients $client): void
{
$this->client = $client;
}
public function getLeftCount(): int
{
return $this->leftCount;
@@ -29,7 +37,11 @@ class OverdueReports
private function takeOverdueList() : array
{
$reports = $this->entity->getRepository(Reports::class)->findAllOverdue();
$clientId = 0;
if($this->client){
$clientId = $this->client->getId();
}
$reports = $this->entity->getRepository(Reports::class)->findAllOverdue($clientId);
if (!$reports) {
return [];
}