<?php
namespace App\Entity\Request;
use App\Entity\TemplateEmail\Template;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\Request\RequestStatusRepository;
use Gedmo\Timestampable\Traits\TimestampableEntity;
#[ORM\Entity(repositoryClass: RequestStatusRepository::class)]
class RequestStatus
{
use TimestampableEntity;
const TYPE_REQUEST_STATUS_TO_DO = "to_do";
const TYPE_REQUEST_STATUS_IN_PROGRESS = "in_progress";
const TYPE_REQUEST_STATUS_COMPLETED = "completed";
const TYPE_REQUEST_STATUS_REJECT = "reject";
const LIST_TYPE = [
self::TYPE_REQUEST_STATUS_TO_DO => self::TYPE_REQUEST_STATUS_TO_DO,
//self::TYPE_REQUEST_STATUS_IN_PROGRESS => self::TYPE_REQUEST_STATUS_IN_PROGRESS,
self::TYPE_REQUEST_STATUS_COMPLETED => self::TYPE_REQUEST_STATUS_COMPLETED,
//self::TYPE_REQUEST_STATUS_REJECT => self::TYPE_REQUEST_STATUS_REJECT,
];
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $type = null;
#[ORM\Column(nullable: true)]
private ?bool $isEnable = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $deletedAt = null;
#[ORM\OneToMany(mappedBy: 'requestStatus', targetEntity: RequestForm::class, orphanRemoval: true)]
private Collection $requestForms;
#[ORM\OneToMany(mappedBy: 'requestStatus', targetEntity: RequestHistory::class, orphanRemoval: true)]
private Collection $requestHistories;
#[ORM\Column(length: 50, nullable: true)]
private ?string $bgColor = null;
#[ORM\Column(length: 50, nullable: true)]
private ?string $textColor = null;
#[ORM\OneToMany(mappedBy: 'requestStatus', targetEntity: Template::class)]
private Collection $templates;
public function __construct()
{
$this->createdAt = new \DateTime();
$this->updatedAt = new \DateTime();
$this->requestForms = new ArrayCollection();
$this->requestHistories = new ArrayCollection();
$this->templates = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function isIsEnable(): ?bool
{
return $this->isEnable;
}
public function setIsEnable(?bool $isEnable): self
{
$this->isEnable = $isEnable;
return $this;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTimeInterface $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* @return Collection<int, RequestForm>
*/
public function getRequestForms(): Collection
{
return $this->requestForms;
}
public function addRequestForm(RequestForm $requestForm): self
{
if (!$this->requestForms->contains($requestForm)) {
$this->requestForms->add($requestForm);
$requestForm->setRequestStatus($this);
}
return $this;
}
public function removeRequestForm(RequestForm $requestForm): self
{
if ($this->requestForms->removeElement($requestForm)) {
// set the owning side to null (unless already changed)
if ($requestForm->getRequestStatus() === $this) {
$requestForm->setRequestStatus(null);
}
}
return $this;
}
/**
* @return Collection<int, RequestHistory>
*/
public function getRequestHistories(): Collection
{
return $this->requestHistories;
}
public function addRequestHistory(RequestHistory $requestHistory): self
{
if (!$this->requestHistories->contains($requestHistory)) {
$this->requestHistories->add($requestHistory);
$requestHistory->setRequestStatus($this);
}
return $this;
}
public function removeRequestHistory(RequestHistory $requestHistory): self
{
if ($this->requestHistories->removeElement($requestHistory)) {
// set the owning side to null (unless already changed)
if ($requestHistory->getRequestStatus() === $this) {
$requestHistory->setRequestStatus(null);
}
}
return $this;
}
public function getBgColor(): ?string
{
return $this->bgColor;
}
public function setBgColor(?string $bgColor): self
{
$this->bgColor = $bgColor;
return $this;
}
public function getTextColor(): ?string
{
return $this->textColor;
}
public function setTextColor(?string $textColor): self
{
$this->textColor = $textColor;
return $this;
}
/**
* @return Collection<int, Template>
*/
public function getTemplates(): Collection
{
return $this->templates;
}
public function addTemplate(Template $template): self
{
if (!$this->templates->contains($template)) {
$this->templates->add($template);
$template->setRequestStatus($this);
}
return $this;
}
public function removeTemplate(Template $template): self
{
if ($this->templates->removeElement($template)) {
// set the owning side to null (unless already changed)
if ($template->getRequestStatus() === $this) {
$template->setRequestStatus(null);
}
}
return $this;
}
}