<?php
namespace App\Entity;
use App\Repository\ConductorRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=ConductorRepository::class)
* @Vich\Uploadable
*/
class Conductor
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $nombre;
/**
* @ORM\Column(type="string", length=255)
*/
private $rut;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $telefono;
/**
* @ORM\Column(type="boolean")
*/
private $activo;
/**
* @ORM\ManyToMany(targetEntity=LicenciaConducir::class)
*/
private $licenciaConducir;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $fechaVencimientoLicencia;
/**
* @ORM\OneToMany(targetEntity=Ruta::class, mappedBy="conductor")
*/
private $rutas;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $fechaActualizacion;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $documentoName;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
* @Assert\File(
* maxSize = "200Mi",
* mimeTypes={ "image/*" }
* )
* @Vich\UploadableField(mapping="conductores_foto", fileNameProperty="documentoName")
* @var File
*/
private $documentoFile;
/**
* @ORM\OneToMany(targetEntity=Vehiculo::class, mappedBy="conductor")
*/
private $vehiculos;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $observaciones;
/**
* @ORM\OneToMany(targetEntity=DocumentoConductor::class, mappedBy="conductor")
*/
private $documentoConductors;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $telefonoContactoAnexo;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $contactoEmergencia;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $examenFisico;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $examenFisicoVencimiento;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $testDrogas;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $testDrogasVencimiento;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $fechaNotificacionLicencia;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $fechaNotificacionExamenFisico;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $fechaNotificacionTestDrogas;
public function getDocumentoNameOriginal()
{
$docName = $this->getDocumentoName();
if($docName)
{
$posName = strrpos($docName, '-');
$posExt = strrpos($docName, '.');
if($posName && $posExt)
{
$name = substr($docName, 0, $posName);
$ext = substr($docName, $posExt);
return $name.$ext;
}
}
return $docName;
}
/**
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance
* of 'UploadedFile' is injected into this setter to trigger the update. If this
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
* must be able to accept an instance of 'File' as the bundle will inject one here
* during Doctrine hydration.
*
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $documento
*
* @return Product
*/
public function setDocumentoFile(?File $documento = null): void
{
$this->documentoFile = $documento;
if ($documento) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->fechaActualizacion = new \DateTimeImmutable(null);
}
}
/**
* @return File|null
*/
public function getDocumentoFile(): ?File
{
return $this->documentoFile;
}
public function getDocumentoName(): ?string
{
return $this->documentoName;
}
public function setDocumentoName(?string $documentoName = ""): self
{
$this->documentoName = $documentoName;
return $this;
}
public function __construct()
{
$this->licenciaConducir = new ArrayCollection();
$this->rutas = new ArrayCollection();
$this->vehiculos = new ArrayCollection();
$this->documentoConductors = new ArrayCollection();
}
public function __toString()
{
return $this->nombre;
}
public function getId(): ?int
{
return $this->id;
}
public function getNombre(): ?string
{
return $this->nombre;
}
public function setNombre(string $nombre): self
{
$this->nombre = $nombre;
return $this;
}
public function getRut(): ?string
{
return $this->rut;
}
public function setRut(string $rut): self
{
$this->rut = $rut;
return $this;
}
public function getTelefono(): ?string
{
return $this->telefono;
}
public function setTelefono(?string $telefono): self
{
$this->telefono = $telefono;
return $this;
}
public function getActivo(): ?bool
{
return $this->activo;
}
public function setActivo(bool $activo): self
{
$this->activo = $activo;
return $this;
}
/**
* @return Collection|LicenciaConducir[]
*/
public function getLicenciaConducir(): Collection
{
return $this->licenciaConducir;
}
public function addLicenciaConducir(LicenciaConducir $licenciaConducir): self
{
if (!$this->licenciaConducir->contains($licenciaConducir)) {
$this->licenciaConducir[] = $licenciaConducir;
}
return $this;
}
public function removeLicenciaConducir(LicenciaConducir $licenciaConducir): self
{
if ($this->licenciaConducir->contains($licenciaConducir)) {
$this->licenciaConducir->removeElement($licenciaConducir);
}
return $this;
}
public function getFechaVencimientoLicencia(): ?\DateTimeInterface
{
return $this->fechaVencimientoLicencia;
}
public function setFechaVencimientoLicencia(?\DateTimeInterface $fechaVencimientoLicencia): self
{
$this->fechaVencimientoLicencia = $fechaVencimientoLicencia;
return $this;
}
/**
* @return Collection|Ruta[]
*/
public function getRutas(): Collection
{
return $this->rutas;
}
public function addRuta(Ruta $ruta): self
{
if (!$this->rutas->contains($ruta)) {
$this->rutas[] = $ruta;
$ruta->setConductor($this);
}
return $this;
}
public function removeRuta(Ruta $ruta): self
{
if ($this->rutas->contains($ruta)) {
$this->rutas->removeElement($ruta);
// set the owning side to null (unless already changed)
if ($ruta->getConductor() === $this) {
$ruta->setConductor(null);
}
}
return $this;
}
public function getVehiculo(): ?Vehiculo
{
return $this->vehiculo;
}
public function setVehiculo(?Vehiculo $vehiculo): self
{
$this->vehiculo = $vehiculo;
// set (or unset) the owning side of the relation if necessary
$newConductor = null === $vehiculo ? null : $this;
if ($vehiculo->getConductor() !== $newConductor) {
$vehiculo->setConductor($newConductor);
}
return $this;
}
/**
* @return Collection|Vehiculo[]
*/
public function getVehiculos(): Collection
{
return $this->vehiculos;
}
public function addVehiculo(Vehiculo $vehiculo): self
{
if (!$this->vehiculos->contains($vehiculo)) {
$this->vehiculos[] = $vehiculo;
$vehiculo->setConductor($this);
}
return $this;
}
public function removeVehiculo(Vehiculo $vehiculo): self
{
if ($this->vehiculos->contains($vehiculo)) {
$this->vehiculos->removeElement($vehiculo);
// set the owning side to null (unless already changed)
if ($vehiculo->getConductor() === $this) {
$vehiculo->setConductor(null);
}
}
return $this;
}
public function getObservaciones(): ?string
{
return $this->observaciones;
}
public function setObservaciones(?string $observaciones): self
{
$this->observaciones = $observaciones;
return $this;
}
/**
* @return Collection|DocumentoConductor[]
*/
public function getDocumentoConductors(): Collection
{
return $this->documentoConductors;
}
public function addDocumentoConductor(DocumentoConductor $documentoConductor): self
{
if (!$this->documentoConductors->contains($documentoConductor)) {
$this->documentoConductors[] = $documentoConductor;
$documentoConductor->setConductor($this);
}
return $this;
}
public function removeDocumentoConductor(DocumentoConductor $documentoConductor): self
{
if ($this->documentoConductors->contains($documentoConductor)) {
$this->documentoConductors->removeElement($documentoConductor);
// set the owning side to null (unless already changed)
if ($documentoConductor->getConductor() === $this) {
$documentoConductor->setConductor(null);
}
}
return $this;
}
public function getTelefonoContactoAnexo(): ?int
{
return $this->telefonoContactoAnexo;
}
public function setTelefonoContactoAnexo(?int $telefonoContactoAnexo): self
{
$this->telefonoContactoAnexo = $telefonoContactoAnexo;
return $this;
}
public function getContactoEmergencia(): ?string
{
return $this->contactoEmergencia;
}
public function setContactoEmergencia(?string $contactoEmergencia): self
{
$this->contactoEmergencia = $contactoEmergencia;
return $this;
}
public function getExamenFisico(): ?bool
{
return $this->examenFisico;
}
public function setExamenFisico(?bool $examenFisico): self
{
$this->examenFisico = $examenFisico;
return $this;
}
public function getExamenFisicoVencimiento(): ?\DateTimeInterface
{
return $this->examenFisicoVencimiento;
}
public function setExamenFisicoVencimiento(?\DateTimeInterface $examenFisicoVencimiento): self
{
$this->examenFisicoVencimiento = $examenFisicoVencimiento;
return $this;
}
public function getTestDrogas(): ?bool
{
return $this->testDrogas;
}
public function setTestDrogas(?bool $testDrogas): self
{
$this->testDrogas = $testDrogas;
return $this;
}
public function getTestDrogasVencimiento(): ?\DateTimeInterface
{
return $this->testDrogasVencimiento;
}
public function setTestDrogasVencimiento(?\DateTimeInterface $testDrogasVencimiento): self
{
$this->testDrogasVencimiento = $testDrogasVencimiento;
return $this;
}
public function getFechaNotificacionLicencia(): ?\DateTimeInterface
{
return $this->fechaNotificacionLicencia;
}
public function setFechaNotificacionLicencia(?\DateTimeInterface $fechaNotificacionLicencia): self
{
$this->fechaNotificacionLicencia = $fechaNotificacionLicencia;
return $this;
}
public function getFechaNotificacionExamenFisico(): ?\DateTimeInterface
{
return $this->fechaNotificacionExamenFisico;
}
public function setFechaNotificacionExamenFisico(?\DateTimeInterface $fechaNotificacionExamenFisico): self
{
$this->fechaNotificacionExamenFisico = $fechaNotificacionExamenFisico;
return $this;
}
public function getFechaNotificacionTestDrogas(): ?\DateTimeInterface
{
return $this->fechaNotificacionTestDrogas;
}
public function setFechaNotificacionTestDrogas(?\DateTimeInterface $fechaNotificacionTestDrogas): self
{
$this->fechaNotificacionTestDrogas = $fechaNotificacionTestDrogas;
return $this;
}
}