fix change template mode; fix schedule view; minor fixes
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Services;
|
||||
use App\Entity\Reports;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
class OverdueReports
|
||||
{
|
||||
private array $list;
|
||||
private int $leftCount = 0;
|
||||
public function __construct(private readonly EntityManager $entity){
|
||||
$this->list = $this->takeOverdueList();
|
||||
}
|
||||
|
||||
public function getList(): array
|
||||
{
|
||||
return $this->list;
|
||||
}
|
||||
|
||||
public function setLeftCount(int $leftCount): void
|
||||
{
|
||||
$this->leftCount = $leftCount;
|
||||
}
|
||||
|
||||
public function getLeftCount(): int
|
||||
{
|
||||
return $this->leftCount;
|
||||
}
|
||||
|
||||
private function takeOverdueList() : array
|
||||
{
|
||||
$reports = $this->entity->getRepository(Reports::class)->findAllOverdue();
|
||||
if (!$reports) {
|
||||
return [];
|
||||
}
|
||||
$toReturn = [];
|
||||
/** @var Reports $report */
|
||||
foreach ($reports as $report) {
|
||||
$date = $report->getDateStart()->format('Y-m');
|
||||
if (!array_key_exists($date, $toReturn)) {
|
||||
$toReturn[$date] = 1;
|
||||
} else {
|
||||
$toReturn[$date]++;
|
||||
}
|
||||
}
|
||||
|
||||
return $toReturn;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user