<?php
namespace App\Entity;
use App\Validator as PerseoAssert;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Intl\Countries;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Table(name="cliente", schema="perseo")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
* @ORM\Entity(repositoryClass="App\Repository\ClienteRepository")
* @Vich\Uploadable
* @UniqueEntity("identificacion")
* @PerseoAssert\ContraintsValidarEntidadCp()
*/
class Cliente
{
/**
* @ORM\Id
* @ORM\Column(type="bigint", options={"unsigned":true})
* @ORM\GeneratedValue(strategy="AUTO")
*/
public $id;
/**
* @ORM\Column(type="string", nullable=true, name="razon_social")
*/
protected $razonSocial;
/**
* @ORM\Column(type="string", nullable=true, name="alias")
*/
protected $alias;
/**
* @ORM\Column(type="string", nullable=true, options={"comment":"DNI, Pasaporte, Licencia de Condución"})
*/
protected $identificacionTipo;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $identificacion;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $direccion;
/**
* @ORM\Column(type="string", length=12, nullable=true)
* @Assert\Length(min = 5, max = 12)
*/
protected $cp;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $region;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $ciudad;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $telefono;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $email;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $identificacionFrontal;
/**
* @Vich\UploadableField(mapping="cliente", fileNameProperty="identificacionFrontal")
* @Assert\File(
* maxSize = "15M",
* mimeTypes = {
* "image/jpeg",
* "image/png",
* "image/gif",
* "image/webp",
* "application/pdf"
* },
* mimeTypesMessage = "Solo se permiten imágenes (JPEG, PNG, GIF, WEBP) o archivos PDF."
* )
* @var File
*/
protected $identificacionFrontalFile;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $identificacionTrasera;
/**
* @Vich\UploadableField(mapping="cliente", fileNameProperty="identificacionTrasera")
* @Assert\File(
* maxSize = "15M",
* mimeTypes = {
* "image/jpeg",
* "image/png",
* "image/gif",
* "image/webp",
* "application/pdf"
* },
* mimeTypesMessage = "Solo se permiten imágenes (JPEG, PNG, GIF, WEBP) o archivos PDF."
* )
* @var File
*/
protected $identificacionTraseraFile;
/**
* @ORM\Column(type="string", length=2, nullable=true)
*/
protected $idioma;
/**
* @ORM\Column(type="string", nullable=true, name="entidad_bancaria")
*/
protected $entidadBancaria;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $iban;
/**
* @ORM\Column(type="text", nullable=true)
*/
protected $observaciones;
/**
* @ORM\Column(type="datetime", nullable=true, name="deleted_at")
*/
protected $deletedAt;
/**
* @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
* @Gedmo\Timestampable(on="update")
*/
protected $updatedAt;
/**
* @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
* @Gedmo\Timestampable(on="create")
*/
protected $createdAt;
/**
* @ORM\Column(type="string", length=2, nullable=true, name="pais")
*/
protected $pais;
/**
* @ORM\OneToOne(targetEntity="App\Entity\User", mappedBy="cliente")
*/
protected $user;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Valoracion", mappedBy="cliente")
*/
protected $valoraciones;
/**
* @ORM\OneToMany(targetEntity=\App\Entity\ActividadAbstract::class, mappedBy="cliente")
*/
private $actividades;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Operacion", mappedBy="cliente")
*/
protected $operaciones;
/*
* @ORM\ManyToOne(targetEntity="App\Entity\Ciudad", inversedBy="clientes")
* @ORM\JoinColumn(name="ciudad_id", referencedColumnName="id")
*/
//protected $ciudad;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\CCAA", inversedBy="clientes")
* @ORM\JoinColumn(name="ccaa_id", referencedColumnName="id")
*/
protected $ccaa;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Provincia", inversedBy="clientes")
* @ORM\JoinColumn(name="provincia_id", referencedColumnName="id")
*/
protected $provincia;
public function __construct()
{
$this->valoraciones = new ArrayCollection();
$this->operaciones = new ArrayCollection();
$this->actividades = new ArrayCollection();
}
public function __toString(): string
{
return $this->getRazonSocial() ? $this->getRazonSocial() : ($this->getUser() ? $this->getUser()?->getNombreCompleto() : '---');
}
public function getId(): ?string
{
return $this->id;
}
public function getRazonSocial(): ?string
{
return $this->razonSocial;
}
public function setRazonSocial(?string $razonSocial): self
{
$this->razonSocial = $razonSocial;
return $this;
}
public function getAlias(): ?string
{
return $this->alias;
}
public function setAlias(?string $alias): self
{
$this->alias = $alias;
return $this;
}
public function getIdentificacionTipo(): ?string
{
return $this->identificacionTipo;
}
public function setIdentificacionTipo(?string $identificacionTipo): self
{
$this->identificacionTipo = $identificacionTipo;
return $this;
}
public function getIdentificacion(): ?string
{
return $this->identificacion;
}
public function setIdentificacion(?string $identificacion): self
{
$this->identificacion = $identificacion;
return $this;
}
public function getIdentificacionFrontal(): ?string
{
return $this->identificacionFrontal;
}
public function setIdentificacionFrontal(?string $identificacionFrontal): self
{
$this->identificacionFrontal = $identificacionFrontal;
return $this;
}
public function getIdentificacionFrontalFile(): ?File
{
return $this->identificacionFrontalFile;
}
public function setIdentificacionFrontalFile(?File $identificacionFrontalFile): self
{
$this->identificacionFrontalFile = $identificacionFrontalFile;
if ($identificacionFrontalFile) {
// if 'updatedAt' is not defined in your entity, use another property
$this->setUpdatedAt(new \DateTime('now'));
}
return $this;
}
public function getIdentificacionTrasera(): ?string
{
return $this->identificacionTrasera;
}
public function setIdentificacionTrasera(?string $identificacionTrasera): self
{
$this->identificacionTrasera = $identificacionTrasera;
return $this;
}
public function getIdentificacionTraseraFile(): ?File
{
return $this->identificacionTraseraFile;
}
public function setIdentificacionTraseraFile(?File $identificacionTraseraFile): self
{
$this->identificacionTraseraFile = $identificacionTraseraFile;
if ($identificacionTraseraFile) {
// if 'updatedAt' is not defined in your entity, use another property
$this->setUpdatedAt(new \DateTime('now'));
}
return $this;
}
public function getIdioma(): ?string
{
return $this->idioma;
}
public function setIdioma(?string $idioma): self
{
$this->idioma = $idioma;
return $this;
}
public function getEntidadBancaria(): ?string
{
return $this->entidadBancaria;
}
public function setEntidadBancaria(?string $entidadBancaria): self
{
$this->entidadBancaria = $entidadBancaria;
return $this;
}
public function getIban(): ?string
{
return $this->iban;
}
public function setIban(?string $iban): self
{
$this->iban = $iban;
return $this;
}
public function getObservaciones(): ?string
{
return $this->observaciones;
}
public function setObservaciones(?string $observaciones): self
{
$this->observaciones = $observaciones;
return $this;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTimeInterface $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
// unset the owning side of the relation if necessary
if ($user === null && $this->user !== null) {
$this->user->setCliente(null);
}
// set the owning side of the relation if necessary
if ($user !== null && $user->getCliente() !== $this) {
$user->setCliente($this);
}
$this->user = $user;
return $this;
}
/**
* @return Collection|Valoracion[]
*/
public function getValoraciones(): Collection
{
return $this->valoraciones;
}
public function addValoracione(Valoracion $valoracione): self
{
if (!$this->valoraciones->contains($valoracione)) {
$this->valoraciones[] = $valoracione;
$valoracione->setCliente($this);
}
return $this;
}
public function removeValoracione(Valoracion $valoracione): self
{
if ($this->valoraciones->removeElement($valoracione)) {
// set the owning side to null (unless already changed)
if ($valoracione->getCliente() === $this) {
$valoracione->setCliente(null);
}
}
return $this;
}
/**
* @return Collection|Operacion[]
*/
public function getOperaciones(): Collection
{
return $this->operaciones;
}
public function addOperacione(Operacion $operacione): self
{
if (!$this->operaciones->contains($operacione)) {
$this->operaciones[] = $operacione;
$operacione->setCliente($this);
}
return $this;
}
public function removeOperacione(Operacion $operacione): self
{
if ($this->operaciones->removeElement($operacione)) {
// set the owning side to null (unless already changed)
if ($operacione->getCliente() === $this) {
$operacione->setCliente(null);
}
}
return $this;
}
public function getTelefono(): ?string
{
return $this->telefono;
}
public function setTelefono(?string $telefono): self
{
$this->telefono = $telefono;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getDireccion(): ?string
{
return $this->direccion;
}
public function setDireccion(?string $direccion): self
{
$this->direccion = $direccion;
return $this;
}
public function getCp(): ?string
{
return $this->cp;
}
public function setCp(?string $cp): self
{
$this->cp = $cp;
return $this;
}
public function getCiudad(): ?string
{
return $this->ciudad;
}
public function setCiudad(?string $ciudad): self
{
$this->ciudad = $ciudad;
return $this;
}
public function getCcaa(): ?CCAA
{
return $this->ccaa;
}
public function setCcaa(?CCAA $ccaa): self
{
$this->ccaa = $ccaa;
return $this;
}
public function getPais(): ?string
{
return $this->pais;
}
public function setPais(?string $pais): self
{
$this->pais = $pais;
return $this;
}
public function getProvincia(): ?Provincia
{
return $this->provincia;
}
public function setProvincia(?Provincia $provincia): self
{
$this->provincia = $provincia;
return $this;
}
/**
* @return Collection<int, ActividadAbstract>
*/
public function getActividades(): Collection
{
return $this->actividades;
}
public function addActividade(ActividadAbstract $actividade): static
{
if (!$this->actividades->contains($actividade)) {
$this->actividades->add($actividade);
$actividade->setCliente($this);
}
return $this;
}
public function removeActividade(ActividadAbstract $actividade): static
{
if ($this->actividades->removeElement($actividade)) {
// set the owning side to null (unless already changed)
if ($actividade->getCliente() === $this) {
$actividade->setCliente(null);
}
}
return $this;
}
public function getRegion(): ?string
{
return $this->region;
}
public function setRegion(?string $region): static
{
$this->region = $region;
return $this;
}
public function getExportPais(): ?string
{
return $this->getPais() ? Countries::getName($this->getPais()) : null;
}
}