175 lines
4.1 KiB
PHP
175 lines
4.1 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Entity\Traits\BlameableEntity;
|
|
use App\Entity\Traits\SoftDeletableEntity;
|
|
use App\Entity\Traits\TimestampableEntity;
|
|
use App\Repository\DispositionRepository;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\DBAL\Types\Types;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Uid\Uuid;
|
|
|
|
#[ORM\Entity(repositoryClass: DispositionRepository::class)]
|
|
class Disposition implements BlameableEntityInterface, TimestampableEntityInterface
|
|
{
|
|
use BlameableEntity;
|
|
use TimestampableEntity;
|
|
|
|
public const STATUS_NEW = 'new';
|
|
public const STATUS_CHECKING_CONTRACT = 'checking_contract';
|
|
public const STATUS_CONFIRMED = 'confirmed';
|
|
public const STATUS_CHECKING_INVOICE = 'checking_invoice';
|
|
public const STATUS_PAID = 'paid';
|
|
public const STATUS_COMPLETED = 'completed';
|
|
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(type: 'string', length: 36, unique: true)]
|
|
private string $uuid;
|
|
|
|
#[ORM\Column(length: 64)]
|
|
private ?string $status;
|
|
|
|
#[ORM\ManyToOne(inversedBy: 'dispositions')]
|
|
private ?Assignment $assignment;
|
|
|
|
#[ORM\ManyToOne(inversedBy: 'dispositions')]
|
|
private ?Teamer $teamer;
|
|
|
|
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
|
private ?string $remarks;
|
|
|
|
#[ORM\OneToMany(mappedBy: 'disposition', targetEntity: Upload::class, cascade: ['persist', 'remove'])]
|
|
private Collection $documents;
|
|
|
|
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
|
|
#[ORM\JoinColumn(onDelete: 'SET NULL')]
|
|
private ?Feedback $feedback = null;
|
|
|
|
public function __construct(Application $application)
|
|
{
|
|
$this->uuid = Uuid::v4();
|
|
$this->status = static::STATUS_NEW;
|
|
$this->assignment = $application->getAssignment();
|
|
$this->teamer = $application->getTeamer();
|
|
$this->documents = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getUuid(): string
|
|
{
|
|
return $this->uuid;
|
|
}
|
|
|
|
public function getStatus(): ?string
|
|
{
|
|
return $this->status;
|
|
}
|
|
|
|
public function setStatus(string $status): static
|
|
{
|
|
$this->status = $status;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getAssignment(): ?Assignment
|
|
{
|
|
return $this->assignment;
|
|
}
|
|
|
|
public function setAssignment(?Assignment $assignment): static
|
|
{
|
|
$this->assignment = $assignment;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getTeamer(): ?Teamer
|
|
{
|
|
return $this->teamer;
|
|
}
|
|
|
|
public function setTeamer(?Teamer $teamer): static
|
|
{
|
|
$this->teamer = $teamer;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getRemarks(): ?string
|
|
{
|
|
return $this->remarks;
|
|
}
|
|
|
|
public function setRemarks(?string $remarks): static
|
|
{
|
|
$this->remarks = $remarks;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, Upload>
|
|
*/
|
|
public function getDocuments(): Collection
|
|
{
|
|
return $this->documents;
|
|
}
|
|
|
|
public function getDocumentByType(string $type): ?Upload
|
|
{
|
|
foreach ($this->getDocuments() as $upload) {
|
|
if ($type === $upload->getType()) {
|
|
return $upload;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public function addDocument(Upload $document): static
|
|
{
|
|
if (!$this->documents->contains($document)) {
|
|
$this->documents->add($document);
|
|
$document->setDisposition($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeDocument(Upload $document): static
|
|
{
|
|
if ($this->documents->removeElement($document)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($document->getDisposition() === $this) {
|
|
$document->setDisposition(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getFeedback(): ?Feedback
|
|
{
|
|
return $this->feedback;
|
|
}
|
|
|
|
public function setFeedback(?Feedback $feedback): static
|
|
{
|
|
$this->feedback = $feedback;
|
|
|
|
return $this;
|
|
}
|
|
}
|