<?php
namespace App\Entity;
use App\Repository\ContractsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
#[ORM\Entity(repositoryClass: ContractsRepository::class)]
#[Vich\Uploadable]
/**
* @ORM\Entity(repositoryClass=ContractsRepository::class)
* @Vich\Uploadable
*/
class Contracts
{
public static $statuses = [0=>'Létrehozva',1=>'Elfogadva',2=>'Kiküldve',3=>'Aláírva'];
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\ManyToOne(targetEntity: Customers::class, inversedBy: 'contracts')]
private $customer;
#[ORM\ManyToOne(targetEntity: ContractTemplates::class)]
#[ORM\JoinColumn(name: 'template_id', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
private ?ContractTemplates $template = null;
#[Vich\UploadableField(mapping: 'contracts', fileNameProperty: 'signedContract')]
/**
* @Vich\UploadableField(mapping="contracts", fileNameProperty="signedContract")
* @var File|null
*/
private ?File $signedContractFile = null;
#[ORM\Column(name: 'signed_contract', type: 'string', length: 255, nullable: true)]
private ?string $signedContract = null;
#[ORM\Column(name: 'updated_at', type: 'datetime', nullable: true)]
private ?\DateTimeInterface $updatedAt = null;
#[ORM\Column(type: 'integer', nullable: true)]
private $price_net;
#[ORM\Column(type: 'integer', nullable: true)]
private $price_brt;
#[ORM\Column(type: 'integer', nullable: true)]
private $title;
#[ORM\Column(type: 'text')]
private $contract;
#[ORM\Column(type: 'date')]
private $created;
#[ORM\Column(type: 'integer')]
private $status;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $work_address;
#[ORM\Column(type: 'integer', nullable: true)]
private $production_days;
#[ORM\Column(type: 'date', nullable: true)]
private $production_deadline;
#[ORM\Column(type: 'integer', nullable: true)]
private $deposit_price_br;
#[ORM\OneToMany(targetEntity: PdfFiles::class, mappedBy: 'contracts')]
private $files;
public function __construct()
{
$this->files = new ArrayCollection();
$this->created = new \DateTime();
$this->status = 0;
}
public function getId(): ?int
{
return $this->id;
}
public function getCustomer(): ?Customers
{
return $this->customer;
}
public function setCustomer(?Customers $customer): self
{
$this->customer = $customer;
return $this;
}
public function getPriceNet(): ?int
{
return $this->price_net;
}
public function setPriceNet(?int $price_net): self
{
$this->price_net = $price_net;
$this->setPriceBrt($price_net*1.27);
return $this;
}
public function getPriceBrt(): ?int
{
return $this->price_brt;
}
public function setPriceBrt(?int $price_brt): self
{
$this->price_brt = $price_brt;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getContract(): ?string
{
return $this->contract;
}
public function setContract(string $contract): self
{
$this->contract = $contract;
return $this;
}
public function getTemplate(): ?ContractTemplates
{
return $this->template;
}
public function setTemplate(?ContractTemplates $template): self
{
$this->template = $template;
return $this;
}
public function getSignedContract(): ?string
{
return $this->signedContract;
}
public function setSignedContract(?string $signedContract): self
{
$this->signedContract = $signedContract;
return $this;
}
public function getSignedContractFile(): ?File
{
return $this->signedContractFile;
}
public function setSignedContractFile(?File $signedContractFile = null): self
{
$this->signedContractFile = $signedContractFile;
if ($signedContractFile !== null) {
$this->updatedAt = new \DateTime();
}
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getCreated(): ?\DateTimeInterface
{
return $this->created;
}
public function setCreated(\DateTimeInterface $created): self
{
$this->created = $created;
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
public function getWorkAddress(): ?string
{
return $this->work_address;
}
public function setWorkAddress(?string $work_address): self
{
$this->work_address = $work_address;
return $this;
}
public function getProductionDays(): ?int
{
return $this->production_days;
}
public function setProductionDays(?int $production_days): self
{
$this->production_days = $production_days;
return $this;
}
public function getProductionDeadline(): ?\DateTimeInterface
{
return $this->production_deadline;
}
public function setProductionDeadline(?\DateTimeInterface $production_deadline): self
{
$this->production_deadline = $production_deadline;
return $this;
}
public function getDepositPriceBr(): ?int
{
return $this->deposit_price_br;
}
public function setDepositPriceBr(?int $deposit_price_br): self
{
$this->deposit_price_br = $deposit_price_br;
return $this;
}
/**
* @return Collection|PdfFiles[]
*/
public function getFiles(): Collection
{
return $this->files;
}
public function addFile(PdfFiles $file): self
{
if (!$this->files->contains($file)) {
$this->files[] = $file;
$file->setContracts($this);
}
return $this;
}
public function removeFile(PdfFiles $file): self
{
if ($this->files->removeElement($file)) {
// set the owning side to null (unless already changed)
if ($file->getContracts() === $this) {
$file->setContracts(null);
}
}
return $this;
}
}