<?php
namespace App\Entity;
use App\Repository\ContractRepository;
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: ContractRepository::class)]
class Contract
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: 'uuid', unique: true)]
private ?string $uuid;
#[ORM\ManyToOne(targetEntity: Customer::class)]
#[ORM\JoinColumn(name: 'fk_customer')]
private ?Customer $customer = null;
#[ORM\OneToMany(
mappedBy: 'contract',
targetEntity: CustomerAdvertisingArea::class,
cascade: ['persist', 'remove']
)]
private ?Collection $areas;
#[ORM\ManyToOne(targetEntity: Sponsor::class, inversedBy: 'contracts')]
#[ORM\JoinColumn(name: 'fk_sponsor')]
private ?Sponsor $sponsor = null;
#[ORM\OneToMany(
mappedBy: 'contract',
targetEntity: Invoice::class,
cascade: ['persist', 'remove']
)]
private ?Collection $invoices;
#[ORM\Column]
private ?\DateTime $startAt = null;
#[ORM\Column]
private ?\DateTime $endAt = null;
#[ORM\Column(nullable: true)]
private ?\DateTime $createdAt = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTime $dateNextInvoice = null;
#[ORM\Column]
private ?string $state = null;
#[ORM\Column(nullable: true)]
private ?string $file;
#[ORM\Column(nullable: true)]
private ?\DateTime $notifyCancellable = null;
#[ORM\Column(nullable: true)]
private ?string $number = null;
#[ORM\Column(nullable: true)]
private ?int $duration = null;
#[ORM\Column]
private bool $existingContract = false;
#[ORM\Column]
private ?bool $contributionActive = false;
#[ORM\Column]
private ?float $contributionPrice = 0;
#[ORM\ManyToOne(targetEntity: InvoiceInterval::class)]
#[ORM\JoinColumn(name: 'fk_invoice_interval')]
private InvoiceInterval|null $invoiceInterval = null;
#[ORM\OneToMany(mappedBy: 'contract', targetEntity: ContractFeedback::class, cascade: ['persist', 'remove'])]
private Collection $feedback;
#[ORM\OneToOne(mappedBy: 'contract', cascade: ['persist', 'remove'])]
private ?ContractAgreement $agreement = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $signature = null;
#[ORM\Column]
private ?int $extendingPeriodInMonth = null;
#[ORM\Column]
private ?int $cancelingPeriodInMonth = null;
public function __construct()
{
$this->areas = new ArrayCollection();
$this->invoices = new ArrayCollection();
$this->feedback = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getStartAt(): ?\DateTime
{
return $this->startAt;
}
public function setStartAt(\DateTime $startAt): self
{
$this->startAt = $startAt;
return $this;
}
public function getEndAt(): ?\DateTime
{
return $this->endAt;
}
public function setEndAt(\DateTime $endAt): self
{
$this->endAt = $endAt;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getDateNextInvoice(): ?\DateTimeInterface
{
return $this->dateNextInvoice;
}
public function setDateNextInvoice(?\DateTimeInterface $dateNextInvoice): self
{
$this->dateNextInvoice = $dateNextInvoice;
return $this;
}
public function getState(): ?string
{
return $this->state;
}
public function setState(string $state): self
{
$this->state = $state;
return $this;
}
public function getFile(): ?string
{
return $this->file;
}
public function setFile(?string $file): self
{
$this->file = $file;
return $this;
}
public function getNotifyCancellable(): ?\DateTime
{
return $this->notifyCancellable;
}
public function setNotifyCancellable(?\DateTime $notifyCancellable): self
{
$this->notifyCancellable = $notifyCancellable;
return $this;
}
public function getNumber(): ?string
{
return $this->number;
}
public function setNumber(?string $number): self
{
$this->number = $number;
return $this;
}
public function getDuration(): ?int
{
return $this->duration;
}
public function setDuration(?int $duration): self
{
$this->duration = $duration;
return $this;
}
public function isExistingContract(): ?bool
{
return $this->existingContract;
}
public function setExistingContract(bool $existingContract): self
{
$this->existingContract = $existingContract;
return $this;
}
public function getCustomer(): ?Customer
{
return $this->customer;
}
public function setCustomer(?Customer $customer): self
{
$this->customer = $customer;
return $this;
}
/**
* @return Collection<int, CustomerAdvertisingArea>
*/
public function getAreas(): Collection
{
return $this->areas;
}
public function addArea(CustomerAdvertisingArea $area): self
{
if (!$this->areas->contains($area)) {
$this->areas->add($area);
$area->setContract($this);
}
return $this;
}
public function removeArea(CustomerAdvertisingArea $area): self
{
if ($this->areas->removeElement($area)) {
// set the owning side to null (unless already changed)
if ($area->getContract() === $this) {
$area->setContract(null);
}
}
return $this;
}
public function getSponsor(): ?Sponsor
{
return $this->sponsor;
}
public function setSponsor(?Sponsor $sponsor): self
{
$this->sponsor = $sponsor;
return $this;
}
/**
* @return Collection<int, Invoice>
*/
public function getInvoices(): Collection
{
return $this->invoices;
}
public function addInvoice(Invoice $invoice): self
{
if (!$this->invoices->contains($invoice)) {
$this->invoices->add($invoice);
$invoice->setContract($this);
}
return $this;
}
public function removeInvoice(Invoice $invoice): self
{
if ($this->invoices->removeElement($invoice)) {
// set the owning side to null (unless already changed)
if ($invoice->getContract() === $this) {
$invoice->setContract(null);
}
}
return $this;
}
public function getUuid(): ?string
{
return $this->uuid;
}
public function setUuid(Uuid $uuid): self
{
$this->uuid = $uuid;
return $this;
}
public function isContributionActive(): ?bool
{
return $this->contributionActive;
}
public function setContributionActive(bool $contributionActive): self
{
$this->contributionActive = $contributionActive;
return $this;
}
public function getContributionPrice(): ?float
{
return $this->contributionPrice;
}
public function setContributionPrice(float $contributionPrice): self
{
$this->contributionPrice = $contributionPrice;
return $this;
}
public function getInvoiceInterval(): ?InvoiceInterval
{
return $this->invoiceInterval;
}
public function setInvoiceInterval(?InvoiceInterval $invoiceInterval): self
{
$this->invoiceInterval = $invoiceInterval;
return $this;
}
/**
* @return Collection<int, ContractFeedback>
*/
public function getFeedback(): Collection
{
return $this->feedback;
}
public function addFeedback(ContractFeedback $feedback): self
{
if (!$this->feedback->contains($feedback)) {
$this->feedback->add($feedback);
$feedback->setContract($this);
}
return $this;
}
public function removeFeedback(ContractFeedback $feedback): self
{
if ($this->feedback->removeElement($feedback)) {
// set the owning side to null (unless already changed)
if ($feedback->getContract() === $this) {
$feedback->setContract(null);
}
}
return $this;
}
public function getSignature(): ?string
{
return $this->signature;
}
public function setSignature(string $signature): self
{
$this->signature = $signature;
return $this;
}
public function getAgreement(): ?ContractAgreement
{
return $this->agreement;
}
public function setAgreement(?ContractAgreement $agreement): self
{
// unset the owning side of the relation if necessary
if ($agreement === null && $this->agreement !== null) {
$this->agreement->setContract(null);
}
// set the owning side of the relation if necessary
if ($agreement !== null && $agreement->getContract() !== $this) {
$agreement->setContract($this);
}
$this->agreement = $agreement;
return $this;
}
public function getExtendingPeriodInMonth(): ?int
{
return $this->extendingPeriodInMonth;
}
public function setExtendingPeriodInMonth(int $extendingPeriodInMonth): self
{
$this->extendingPeriodInMonth = $extendingPeriodInMonth;
return $this;
}
public function getCancelingPeriodInMonth(): ?int
{
return $this->cancelingPeriodInMonth;
}
public function setCancelingPeriodInMonth(int $cancelingPeriodInMonth): self
{
$this->cancelingPeriodInMonth = $cancelingPeriodInMonth;
return $this;
}
}