initial commit

This commit is contained in:
2024-07-25 10:54:27 +02:00
parent 3a922fd5bc
commit d2ae809b98
113 changed files with 19295 additions and 2522 deletions
+197
View File
@@ -0,0 +1,197 @@
<?php
namespace App\Entity;
use App\Enum\ReportStatus;
use App\Enum\ReportTodoEnum;
use App\Repository\ReportsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ReportsRepository::class)]
class Reports
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(referencedColumnName: "id", nullable: false)]
private ?Clients $client = null;
#[ORM\Column(type: Types::DATE_MUTABLE)]
private ?\DateTimeInterface $dateStart = null;
/**
* @var Collection<int, ReportsTodo>
*/
#[ORM\OneToMany(targetEntity: ReportsTodo::class, mappedBy: 'report', orphanRemoval: true)]
private Collection $reportsTodos;
#[ORM\Column(options: ["default" => "0"])]
private bool $isDelete = false;
private int $numberOfReport = 0;
#[ORM\Column(options: ["default" => "0"])]
private bool $isDone = false;
#[ORM\Column]
private ?int $number = null;
public function __construct()
{
$this->reportsTodos = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDateStart(): ?\DateTimeInterface
{
return $this->dateStart;
}
public function setDateStart(\DateTimeInterface $dateStart): static
{
$this->dateStart = $dateStart;
return $this;
}
public function getClient(): ?Clients
{
return $this->client;
}
public function setClient(?Clients $client): static
{
$this->client = $client;
return $this;
}
/**
* @return Collection<int, ReportsTodo>
*/
public function getReportsTodos(): Collection
{
return $this->reportsTodos;
}
public function addReportsTodo(ReportsTodo $reportsTodo): static
{
if (!$this->reportsTodos->contains($reportsTodo)) {
$this->reportsTodos->add($reportsTodo);
$reportsTodo->setReport($this);
}
return $this;
}
public function removeReportsTodo(ReportsTodo $reportsTodo): static
{
if ($this->reportsTodos->removeElement($reportsTodo)) {
// set the owning side to null (unless already changed)
if ($reportsTodo->getReport() === $this) {
$reportsTodo->setReport(null);
}
}
return $this;
}
public function isReportsTodo(ReportTodoEnum $enum): bool
{
$return = false;
foreach ($this->getReportsTodos() as $reportsTodo) {
if ($reportsTodo->getName() === $enum) {
$return = !$reportsTodo->isDeleted();
}
}
return $return;
}
public function countTodoReports(): int
{
$count = 0;
foreach ($this->getReportsTodos() as $reportsTodo) {
if (!$reportsTodo->isDeleted()) {
$count++;
}
}
return $count;
}
public function takeStatusTodo(): ReportStatus
{
if ($this->countTodoReports() === 0) {
return ReportStatus::INSERT;
}
$status = ReportStatus::WORKING;
foreach ($this->getReportsTodos() as $reportsTodo) {
if ($reportsTodo->isDeleted()) {
continue;
}
if ($reportsTodo->getName() === ReportTodoEnum::COMPLETE) {
$status = ReportStatus::COMPLETE;
break;
}
}
return $status;
}
public function isDelete(): ?bool
{
return $this->isDelete;
}
public function setDelete(bool $isDelete): static
{
$this->isDelete = $isDelete;
return $this;
}
public function getNumberOfReport(): int
{
return $this->numberOfReport;
}
public function setNumberOfReport(int $numberOfReport): void
{
$this->numberOfReport = $numberOfReport;
}
public function isDone(): bool
{
return $this->isDone;
}
public function setDone(bool $isDone): static
{
$this->isDone = $isDone;
return $this;
}
public function getNumber(): ?int
{
return $this->number;
}
public function setNumber(int $number): static
{
$this->number = $number;
return $this;
}
}