<?php
namespace App\Entity;
use App\Repository\LicenseRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Table]
#[ORM\Index(name: 'idx_lic_uniqueNumber', columns: ['unique_number'])]
#[ORM\Index(name: 'idx_lic_uniqueNumber_createdAt', columns: ['unique_number', 'created_at'])]
#[ORM\Entity(repositoryClass: LicenseRepository::class)]
class License
{
public function __construct(){
$this->uuid = Uuid::v4();
$this->createdAt = new \DateTimeImmutable();
$this->updatedAt = new \DateTimeImmutable();
$this->valid = true;
$this->validityPeriod = 12;
$this->oneDayCert = false;
}
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer', unique: true)]
private $id;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'uuid')]
private $uuid;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'datetime_immutable')]
private $createdAt;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'datetime_immutable')]
private $updatedAt;
#[ORM\ManyToOne(targetEntity: Client::class, inversedBy: 'licenses')]
#[ORM\JoinColumn(nullable: false)]
private $client;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'string', length: 10)]
private $nip;
#[Groups(['show_license'])]
#[ORM\OneToOne(targetEntity: Fiscalization::class, inversedBy: 'license', cascade: ['persist', 'remove'])]
private $fiscalization;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'boolean')]
private $valid;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $gmina;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $kod;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $kraj;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $krajKod;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $miejscowosc;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $numBudynku;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $numLokalu;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $poczta;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $powiat;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $wojewodztwo;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $ulica;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $name;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $regon;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $deviceId;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'string', length: 30, nullable: true)]
private $uniqueNumber;
#[ORM\ManyToOne(targetEntity: DeviceActivationRequest::class, inversedBy: 'licenses')]
private $activationRequest;
#[ORM\ManyToOne(targetEntity: App::class, inversedBy: 'licenses')]
private $app;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\ManyToOne(targetEntity: LicenseType::class, inversedBy: 'licenses')]
private $licenseType;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'date', nullable: true)]
private $validUntil;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'date', nullable: true)]
private $validFrom;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\Column(type: 'integer')]
private $validityPeriod;
#[Groups(['show_fiscalization','show_license'])]
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'licenses')]
private $user;
#[ORM\Column(type: 'boolean')]
private $oneDayCert;
private $qrcode;
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = (string)$id;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getClient(): ?Client
{
return $this->client;
}
public function setClient(?Client $client): self
{
$this->client = $client;
return $this;
}
public function getNip(): ?string
{
return $this->nip;
}
public function setNip(string $nip): self
{
$this->nip = $nip;
return $this;
}
public function getFiscalization(): ?Fiscalization
{
return $this->fiscalization;
}
public function setFiscalization(?Fiscalization $fiscalization): self
{
$this->fiscalization = $fiscalization;
return $this;
}
public function getValid(): ?bool
{
return $this->valid;
}
public function setValid(bool $valid): self
{
$this->valid = $valid;
return $this;
}
public function getGmina(): ?string
{
return $this->gmina;
}
public function setGmina(?string $gmina): self
{
$this->gmina = $gmina;
return $this;
}
public function getKod(): ?string
{
return $this->kod;
}
public function setKod(?string $kod): self
{
$this->kod = $kod;
return $this;
}
public function getKraj(): ?string
{
return $this->kraj;
}
public function setKraj(?string $kraj): self
{
$this->kraj = $kraj;
return $this;
}
public function getKrajKod(): ?string
{
return $this->krajKod;
}
public function setKrajKod(?string $krajKod): self
{
$this->krajKod = $krajKod;
return $this;
}
public function getMiejscowosc(): ?string
{
return $this->miejscowosc;
}
public function setMiejscowosc(?string $miejscowosc): self
{
$this->miejscowosc = $miejscowosc;
return $this;
}
public function getNumBudynku(): ?string
{
return $this->numBudynku;
}
public function setNumBudynku(?string $numBudynku): self
{
$this->numBudynku = $numBudynku;
return $this;
}
public function getNumLokalu(): ?string
{
return $this->numLokalu;
}
public function setNumLokalu(?string $numLokalu): self
{
$this->numLokalu = $numLokalu;
return $this;
}
public function getPoczta(): ?string
{
return $this->poczta;
}
public function setPoczta(?string $poczta): self
{
$this->poczta = $poczta;
return $this;
}
public function getPowiat(): ?string
{
return $this->powiat;
}
public function setPowiat(?string $powiat): self
{
$this->powiat = $powiat;
return $this;
}
public function getUlica(): ?string
{
return $this->ulica;
}
public function setUlica(?string $ulica): self
{
$this->ulica = $ulica;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getRegon(): ?string
{
return $this->regon;
}
public function setRegon(?string $regon): self
{
$this->regon = $regon;
return $this;
}
/**
* Get the value of wojewodztwo
*/
public function getWojewodztwo()
{
return $this->wojewodztwo;
}
/**
* Set the value of wojewodztwo
*
* @return self
*/
public function setWojewodztwo($wojewodztwo)
{
$this->wojewodztwo = $wojewodztwo;
return $this;
}
public function getDeviceId(): ?string
{
return $this->deviceId;
}
public function setDeviceId(?string $deviceId): self
{
$this->deviceId = $deviceId;
return $this;
}
public function getActivationRequest(): ?DeviceActivationRequest
{
return $this->activationRequest;
}
public function setActivationRequest(?DeviceActivationRequest $activationRequest): self
{
$this->activationRequest = $activationRequest;
return $this;
}
public function getUniqueNumber(): ?string
{
return $this->uniqueNumber;
}
public function setUniqueNumber(string $uniqueNumber): self
{
$this->uniqueNumber = $uniqueNumber;
return $this;
}
public function isValid(): ?bool
{
return $this->valid;
}
public function getApp(): ?App
{
return $this->app;
}
public function setApp(?App $app): self
{
$this->app = $app;
return $this;
}
public function getLicenseType(): ?LicenseType
{
return $this->licenseType;
}
public function setLicenseType(?LicenseType $licenseType): self
{
$this->licenseType = $licenseType;
return $this;
}
public function getValidUntil(): ?\DateTimeInterface
{
return $this->validUntil;
}
public function setValidUntil(?\DateTimeInterface $validUntil): self
{
$this->validUntil = $validUntil;
return $this;
}
public function getValidFrom(): ?\DateTimeInterface
{
return $this->validFrom;
}
public function setValidFrom(?\DateTimeInterface $validFrom): self
{
$this->validFrom = $validFrom;
return $this;
}
public function getUuid(){
return $this->uuid;
}
public function setUuid($uuid){
$this->uuid = $uuid;
return $this;
}
public function getValidityPeriod(): ?int
{
return $this->validityPeriod;
}
public function setValidityPeriod(int $validityPeriod): self
{
$this->validityPeriod = $validityPeriod;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function isOneDayCert(): ?bool
{
return $this->oneDayCert;
}
public function setOneDayCert(bool $oneDayCert): self
{
$this->oneDayCert = $oneDayCert;
return $this;
}
/**
* Get the value of qrcode
*/
public function getQrcode()
{
return 'https://system.abspos.pl/api/qr-code/'.$this->uuid.'.png?size=300';
}
}