*/ #[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 */ 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 isDone(): bool { return $this->isReportsTodo(ReportTodoEnum::COMPLETE); } 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 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; } }