<?php
namespace App\Entity;
use App\Repository\CabeceraRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use App\Validator as BcAssert;
/**
* @ORM\Entity(repositoryClass=CabeceraRepository::class)
* @ORM\HasLifecycleCallbacks()
* @BcAssert\BcGreaterThanOrEqual
*/
class Cabecera
{
public const PAY_METHOD = array(
'EFECTIVO' => 1,
// 'TARJETAS BIGPASS' => 10,
// 'TARJETA LA FRAGATA' => 11,
// 'VALE SODEXO' => 12,
// 'VALE BIGPASS' => 13,
// 'CREDITO CLIENTES' => 14,
// 'CORTESIAS' => 15,
// 'INVITACIONES' => 16,
// 'MENU EMPLEADO' => 17,
// 'CAPACITACIONES' => 18,
// 'GASTOS REPRESENTACION' => 19,
'TARJETAS' => 2,
'BONOS CREPES' => 20,
// 'CUPON ARKADIA' => 21,
// 'LINK PAGOS E-COMMERCE' => 22,
// 'RTE FUENTE' => 23,
// 'I FOOD' => 24,
// 'ECOMMERCE PREPAGADA' => 25,
// 'ECOMMERCE CONTRAENTREGA' => 26,
// 'ONLINE RAPPI' => 3,
// 'ONLINE UBER' => 4,
// 'ONLINE DOMI.COM' => 5,
'LINK DE PAGOS WOMPI' => 6,
// 'TARJETA TUYA' => 7,
// 'TARJETA FALABELLA' => 8,
// 'TARJETAS SODEXO' => 9,
'CALL CENTER PREPAGADA' => 30
);
public const SERVICE_TYPE = array(
'DOMICILIO' => 4,
'RECOGER' => 16,
'PROGRAMAR' => 100,
);
use Timestamp;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $nombrecliente;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $nombres;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $apellidos;
/**
* @ORM\Column(type="string", length=8, nullable=true)
*/
private $codpostalcliente;
/**
* @ORM\Column(type="string", length=255)
*/
private $direccioncliente;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $poblacioncliente;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $provinciacliente;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $paiscliente;
/**
* @ORM\Column(type="string", length=15)
*/
private $telefonocliente;
/**
* @ORM\Column(type="string", length=15, nullable=true)
*/
private $telefono2cliente;
/**
* @ORM\Column(type="string", length=15, nullable=true)
*/
private $movilcliente;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $emailcliente;
/**
* @ORM\Column(type="integer", nullable=true, nullable=true)
*/
private $codmonedaminuta;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private $nifcliente;
/**
* @ORM\Column(type="string", length=2, nullable=true)
*/
private $zona;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $fechareserva;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $codcliente;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $direccion2cliente;
/**
* @ORM\OneToMany(targetEntity=Lineas::class, mappedBy="cabecera", cascade={"persist", "remove"})
* @ORM\OrderBy({"root" = "ASC","lft" = "ASC"})
*/
private $lineas;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="cabeceras")
*/
private $user;
/**
* @ORM\Column(type="decimal", precision=10, scale=0, nullable=true)
*/
private $total;
/**
* @ORM\Column(type="decimal", precision=10, scale=0, nullable=true)
*/
private $totalsiniva;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private $sucursal;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $comentario;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isFinalizada;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private $metododepago;
/**
* @ORM\Column(type="integer")
*/
private $Tipodeservicio = 4;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $is_enviado = false;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $filename;
/**
* @ORM\OneToMany(targetEntity=CabeceraStatus::class, mappedBy="Cabecera")
*/
private $CabeceraStatus;
/**
* @ORM\Column(type="string", length=255)
*/
private $estado;
/**
* @ORM\OneToMany(targetEntity=Domicilios::class, mappedBy="cabecera", cascade={"remove"}, fetch="LAZY")
*/
private $domicilios;
/**
* @ORM\Column(type="decimal", precision=10, scale=0, nullable=true)
*/
private $propinatotal;
/**
* @ORM\Column(type="decimal", precision=10, scale=0, nullable=true)
*/
private $propinaporcentaje;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $linkdepago;
/**
* @ORM\OneToMany(targetEntity=CabeceraLinkdepago::class, mappedBy="Cabecera", cascade={"persist", "remove"})
*/
private $CabeceraLinkdepago;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $facturaelectronica = false;
// nuevos campos de clientescamposlibres
/**
* @var string|null
*
* @ORM\Column(name="DIRECCION_2", type="string", length=50, nullable=true, options={"default"="NULL"})
*/
private $direccion_2 = 'NULL';
/**
* @var string|null
*
* @ORM\Column(name="NOMBRE_1", type="string", length=50, nullable=true, options={"default"="NULL"})
*/
private $nombre_1 = 'NULL';
/**
* @var string|null
*
* @ORM\Column(name="OTROS_NOMBRES", type="string", length=50, nullable=true, options={"default"="NULL"})
*/
private $otros_nombres = 'NULL';
/**
* @var string|null
*
* @ORM\Column(name="APELLIDO_1", type="string", length=50, nullable=true, options={"default"="NULL"})
*/
private $apellido_1 = 'NULL';
/**
* @var string|null
*
* @ORM\Column(name="APELLIDO_2", type="string", length=50, nullable=true, options={"default"="NULL"})
*/
private $apellido_2 = 'NULL';
/**
* @var string|null
*
* @ORM\Column(name="FE_MUNICIPIO", type="string", length=10, nullable=true, options={"default"="NULL"})
*/
private $fe_municipio = 'NULL';
/**
* @var string|null
*
* @ORM\Column(name="FE_RESPONSABILIDADES", type="string", length=255, nullable=true, options={"default"="NULL"})
*/
private $fe_responsabilidades = 'NULL';
/**
* @var string|null
*
* @ORM\Column(name="TIPO_DE_DOCUMENTO", type="string", length=100, nullable=true, options={"default"="NULL"})
*/
private $tipo_de_documento = 'NULL';
/**
* @var string|null
*
* @ORM\Column(name="TIPOPERSONA", type="string", length=50, nullable=true, options={"default"="NULL"})
*/
private $tipopersona = 'NULL';
/**
* @var string|null
*
* @ORM\Column(name="FE_REGIMEN", type="string", length=50, nullable=true, options={"default"="NULL"})
*/
private $fe_regimen = 'NULL';
/**
* @var string|null
*
* @ORM\Column(name="FE_DET_TRIBUTARIO", type="string", length=100, nullable=true, options={"default"="NULL"})
*/
private $fe_det_tributario = 'NULL';
/**
* @var string|null
*
* @ORM\Column(name="CUENTA_ALIMENTACION", type="string", length=50, nullable=true, options={"default"="NULL"})
*/
private $cuenta_alimentacion = 'NULL';
/**
* @var string|null
*
* @ORM\Column(name="CENTRO_COSTOS", type="string", length=50, nullable=true, options={"default"="NULL"})
*/
private $centro_costos = 'NULL';
/**
* @var string|null
*
* @ORM\Column(name="CENTRO_OPERACION", type="string", length=50, nullable=true, options={"default"="NULL"})
*/
private $centro_operacion = 'NULL';
/**
* @var string|null
*
* @ORM\Column(type="integer", nullable=true)
*/
private $alias = 0;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email_linkdepago;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $nombre_receptor;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $telefono_receptor;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $observaciones_receptor;
public function __construct()
{
$this->lineas = new ArrayCollection();
$this->CabeceraStatus = new ArrayCollection();
// $this->domicilios = new ArrayCollection();
$this->CabeceraLinkdepago = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNombrecliente(): ?string
{
return $this->nombrecliente;
}
// public function setNombrecliente(string $nombrecliente): self
public function setNombrecliente(): self
{
// $this->nombrecliente = $nombrecliente;
// return $this;
$nombreCompleto = $this->nombres;
if ($this->apellidos) {
$nombreCompleto .= ' ' . $this->apellidos;
}
$this->nombrecliente = $nombreCompleto;
return $this;
}
public function getNombres(): ?string
{
return $this->nombres;
}
public function setNombres(string $nombres): self
{
$this->nombres = $nombres;
$this->setNombrecliente();
return $this;
}
public function getApellidos(): ?string
{
return $this->apellidos;
}
public function setApellidos(?string $apellidos): self
{
$this->apellidos = $apellidos;
$this->setNombrecliente();
return $this;
}
public function getCodpostalcliente(): ?string
{
return $this->codpostalcliente;
}
public function setCodpostalcliente(?string $codpostalcliente): self
{
$this->codpostalcliente = $codpostalcliente;
return $this;
}
public function getDireccioncliente(): ?string
{
return $this->direccioncliente;
}
public function setDireccioncliente(string $direccioncliente): self
{
$this->direccioncliente = $direccioncliente;
return $this;
}
public function getPoblacioncliente(): ?string
{
return $this->poblacioncliente;
}
public function setPoblacioncliente(string $poblacioncliente): self
{
$this->poblacioncliente = $poblacioncliente;
return $this;
}
public function getProvinciacliente(): ?string
{
return $this->provinciacliente;
}
public function setProvinciacliente(string $provinciacliente): self
{
$this->provinciacliente = $provinciacliente;
return $this;
}
public function getPaiscliente(): ?string
{
return $this->paiscliente;
}
public function setPaiscliente(string $paiscliente): self
{
$this->paiscliente = $paiscliente;
return $this;
}
public function getTelefonocliente(): ?string
{
return $this->telefonocliente;
}
public function setTelefonocliente(string $telefonocliente): self
{
$this->telefonocliente = $telefonocliente;
return $this;
}
public function getTelefono2cliente(): ?string
{
return $this->telefono2cliente;
}
public function setTelefono2cliente(?string $telefono2cliente): self
{
$this->telefono2cliente = $telefono2cliente;
return $this;
}
public function getMovilcliente(): ?string
{
return $this->movilcliente;
}
public function setMovilcliente(?string $movilcliente): self
{
$this->movilcliente = $movilcliente;
return $this;
}
public function getEmailcliente(): ?string
{
return $this->emailcliente;
}
public function setEmailcliente(?string $emailcliente): self
{
$this->emailcliente = $emailcliente;
return $this;
}
public function getCodmonedaminuta(): ?int
{
return $this->codmonedaminuta;
}
public function setCodmonedaminuta(?int $codmonedaminuta): self
{
$this->codmonedaminuta = $codmonedaminuta;
return $this;
}
public function getNifcliente(): ?string
{
return $this->nifcliente;
}
public function setNifcliente(?string $nifcliente): self
{
$this->nifcliente = $nifcliente;
return $this;
}
// /**
// * @ORM\PrePersist
// */
// public function setNifclienteValue(): void
// {
// if ($this->nifcliente == '') {
// $datetime = new \DateTime('now');
// // $this->nifcliente = 'BC' . $datetime->format('ymdGisv');
// $dayOfYear = sprintf('%03d', $datetime->format('z'));
// $miliseconds = sprintf('%03d', $datetime->format('v'));
// $this->nifcliente = 'BC' . $datetime->format('y') . $dayOfYear . $datetime->format('His') . $miliseconds;
// }
// }
public function getZona(): ?string
{
return $this->zona;
}
public function setZona(?string $zona): self
{
$this->zona = $zona;
return $this;
}
public function getFechareserva(): ?\DateTimeInterface
{
return $this->fechareserva;
}
public function setFechareserva(?\DateTimeInterface $fechareserva): self
{
$this->fechareserva = $fechareserva;
return $this;
}
public function getCodcliente(): ?int
{
return $this->codcliente;
}
public function setCodcliente(?int $codcliente): self
{
$this->codcliente = $codcliente;
return $this;
}
public function getDireccion2cliente(): ?string
{
return $this->direccion2cliente;
}
public function setDireccion2cliente(?string $direccion2cliente): self
{
$this->direccion2cliente = $direccion2cliente;
return $this;
}
/**
* @return Collection|Lineas[]
*/
public function getLineas(): Collection
{
return $this->lineas;
}
public function addLinea(Lineas $linea): self
{
if (!$this->lineas->contains($linea)) {
$this->lineas[] = $linea;
$linea->setCabecera($this);
}
return $this;
}
public function removeLinea(Lineas $linea): self
{
if ($this->lineas->removeElement($linea)) {
// set the owning side to null (unless already changed)
if ($linea->getCabecera() === $this) {
$linea->setCabecera(null);
}
}
return $this;
}
public function getUser(): ?user
{
return $this->user;
}
public function setUser(?user $user): self
{
$this->user = $user;
return $this;
}
public function getTotal(): ?string
{
return $this->total;
}
public function setTotal(?string $total): self
{
$this->total = $total;
return $this;
}
public function getTotalsiniva(): ?string
{
return $this->totalsiniva;
}
public function setTotalsiniva(?string $totalsiniva): self
{
$this->totalsiniva = $totalsiniva;
return $this;
}
public function getSucursal(): ?string
{
return $this->sucursal;
}
public function setSucursal(?string $sucursal): self
{
$this->sucursal = $sucursal;
return $this;
}
public function getComentario(): ?string
{
return $this->comentario;
}
public function setComentario(?string $comentario): self
{
$this->comentario = $comentario;
return $this;
}
public function getIsFinalizada(): ?bool
{
return $this->isFinalizada;
}
public function setIsFinalizada(?bool $isFinalizada): self
{
$this->isFinalizada = $isFinalizada;
return $this;
}
public function getMetododepago(): ?string
{
return $this->metododepago;
}
public function setMetododepago(?string $metododepago): self
{
$this->metododepago = $metododepago;
return $this;
}
public function getTipodeservicio(): ?int
{
return $this->Tipodeservicio;
}
public function setTipodeservicio(int $Tipodeservicio): self
{
$this->Tipodeservicio = $Tipodeservicio;
return $this;
}
public function getIsEnviado(): ?bool
{
return $this->is_enviado;
}
public function setIsEnviado(?bool $is_enviado): self
{
$this->is_enviado = $is_enviado;
return $this;
}
public function getFilename(): ?string
{
return $this->filename;
}
public function setFilename(?string $filename): self
{
$this->filename = $filename;
return $this;
}
/**
* @return Collection|CabeceraStatus[]
*/
public function getCabeceraStatus(): Collection
{
return $this->CabeceraStatus;
}
public function addCabeceraStatus(CabeceraStatus $cabeceraStatus): self
{
if (!$this->CabeceraStatus->contains($cabeceraStatus)) {
$this->CabeceraStatus[] = $cabeceraStatus;
$cabeceraStatus->setCabecera($this);
}
return $this;
}
public function removeCabeceraStatus(CabeceraStatus $cabeceraStatus): self
{
if ($this->CabeceraStatus->removeElement($cabeceraStatus)) {
// set the owning side to null (unless already changed)
if ($cabeceraStatus->getCabecera() === $this) {
$cabeceraStatus->setCabecera(null);
}
}
return $this;
}
public function getEstado(): ?string
{
return $this->estado;
}
public function setEstado(string $estado): self
{
$this->estado = $estado;
return $this;
}
public function getDomicilios(): ?Domicilios
{
return $this->domicilios;
}
public function setDomicilios(Domicilios $domicilios): self
{
// set the owning side of the relation if necessary
if ($domicilios->getCabecera() !== $this) {
$domicilios->setCabecera($this);
}
$this->domicilios = $domicilios;
return $this;
}
public function getPropinatotal(): ?string
{
return $this->propinatotal;
}
public function setPropinatotal(?string $propinatotal): self
{
$this->propinatotal = $propinatotal;
return $this;
}
public function getPropinaporcentaje(): ?string
{
return $this->propinaporcentaje;
}
public function setPropinaporcentaje(?string $propinaporcentaje): self
{
$this->propinaporcentaje = $propinaporcentaje;
return $this;
}
public function getLinkdepago(): ?string
{
return $this->linkdepago;
}
public function setLinkdepago(?string $linkdepago): self
{
$this->linkdepago = $linkdepago;
return $this;
}
public function getFacturaelectronica(): ?bool
{
return $this->facturaelectronica;
}
public function setFacturaelectronica(?bool $facturaelectronica): self
{
$this->facturaelectronica = $facturaelectronica;
return $this;
}
public function __toString(): string
{
return '(#' . $this->getid() . ') ' . $this->getDireccioncliente() . ' - ' . $this->getNombrecliente();
}
public function isIsFinalizada(): ?bool
{
return $this->isFinalizada;
}
public function isIsEnviado(): ?bool
{
return $this->is_enviado;
}
public function isFacturaelectronica(): ?bool
{
return $this->facturaelectronica;
}
public function getDireccion2(): ?string
{
return $this->direccion_2;
}
public function setDireccion2(?string $direccion_2): static
{
$this->direccion_2 = $direccion_2;
return $this;
}
public function getNombre1(): ?string
{
return $this->nombre_1;
}
public function setNombre1(?string $nombre_1): static
{
$this->nombre_1 = $nombre_1;
return $this;
}
public function getOtrosNombres(): ?string
{
return $this->otros_nombres;
}
public function setOtrosNombres(?string $otros_nombres): static
{
$this->otros_nombres = $otros_nombres;
return $this;
}
public function getApellido1(): ?string
{
return $this->apellido_1;
}
public function setApellido1(?string $apellido_1): static
{
$this->apellido_1 = $apellido_1;
return $this;
}
public function getApellido2(): ?string
{
return $this->apellido_2;
}
public function setApellido2(?string $apellido_2): static
{
$this->apellido_2 = $apellido_2;
return $this;
}
public function getFeMunicipio(): ?string
{
return $this->fe_municipio;
}
public function setFeMunicipio(?string $fe_municipio): static
{
$this->fe_municipio = $fe_municipio;
return $this;
}
public function getFeResponsabilidades(): ?string
{
return $this->fe_responsabilidades;
}
public function setFeResponsabilidades(?string $fe_responsabilidades): static
{
$this->fe_responsabilidades = $fe_responsabilidades;
return $this;
}
public function getTipoDeDocumento(): ?string
{
return $this->tipo_de_documento;
}
public function setTipoDeDocumento(?string $tipo_de_documento): static
{
$this->tipo_de_documento = $tipo_de_documento;
return $this;
}
public function getTipopersona(): ?string
{
return $this->tipopersona;
}
public function setTipopersona(?string $tipopersona): static
{
$this->tipopersona = $tipopersona;
return $this;
}
public function getFeRegimen(): ?string
{
return $this->fe_regimen;
}
public function setFeRegimen(?string $fe_regimen): static
{
$this->fe_regimen = $fe_regimen;
return $this;
}
public function getFeDetTributario(): ?string
{
return $this->fe_det_tributario;
}
public function setFeDetTributario(?string $fe_det_tributario): static
{
$this->fe_det_tributario = $fe_det_tributario;
return $this;
}
public function getCuentaAlimentacion(): ?string
{
return $this->cuenta_alimentacion;
}
public function setCuentaAlimentacion(?string $cuenta_alimentacion): static
{
$this->cuenta_alimentacion = $cuenta_alimentacion;
return $this;
}
public function getCentroCostos(): ?string
{
return $this->centro_costos;
}
public function setCentroCostos(?string $centro_costos): static
{
$this->centro_costos = $centro_costos;
return $this;
}
public function getCentroOperacion(): ?string
{
return $this->centro_operacion;
}
public function setCentroOperacion(?string $centro_operacion): static
{
$this->centro_operacion = $centro_operacion;
return $this;
}
public function getAlias(): ?string
{
return $this->alias;
}
public function setAlias(?string $alias): static
{
$this->alias = $alias;
return $this;
}
public function getEmailLinkdepago(): ?string
{
return $this->email_linkdepago;
}
public function setEmailLinkdepago(?string $email_linkdepago): self
{
$this->email_linkdepago = $email_linkdepago;
return $this;
}
// public function addDomicilio(Domicilios $domicilio): static
// {
// if (!$this->domicilios->contains($domicilio)) {
// $this->domicilios->add($domicilio);
// $domicilio->setCabecera($this);
// }
// return $this;
// }
// public function removeDomicilio(Domicilios $domicilio): static
// {
// if ($this->domicilios->removeElement($domicilio)) {
// // set the owning side to null (unless already changed)
// if ($domicilio->getCabecera() === $this) {
// $domicilio->setCabecera(null);
// }
// }
// return $this;
// }
/**
* @return Collection<int, CabeceraLinkdepago>
*/
public function getCabeceraLinkdepago(): Collection
{
return $this->CabeceraLinkdepago;
}
public function addCabeceraLinkdepago(CabeceraLinkdepago $cabeceraLinkdepago): static
{
if (!$this->CabeceraLinkdepago->contains($cabeceraLinkdepago)) {
$this->CabeceraLinkdepago->add($cabeceraLinkdepago);
$cabeceraLinkdepago->setCabecera($this);
}
return $this;
}
public function removeCabeceraLinkdepago(CabeceraLinkdepago $cabeceraLinkdepago): static
{
if ($this->CabeceraLinkdepago->removeElement($cabeceraLinkdepago)) {
// set the owning side to null (unless already changed)
if ($cabeceraLinkdepago->getCabecera() === $this) {
$cabeceraLinkdepago->setCabecera(null);
}
}
return $this;
}
public function getNombreReceptor(): ?string
{
return $this->nombre_receptor;
}
public function setNombreReceptor(string $nombre_receptor): self
{
$this->nombre_receptor = $nombre_receptor;
return $this;
}
public function getTelefonoReceptor(): ?string
{
return $this->telefono_receptor;
}
public function setTelefonoReceptor(string $telefono_receptor): self
{
$this->telefono_receptor = $telefono_receptor;
return $this;
}
public function getObservacionesReceptor(): ?string
{
return $this->observaciones_receptor;
}
public function setObservacionesReceptor(string $observaciones_receptor): self
{
$this->observaciones_receptor = $observaciones_receptor;
return $this;
}
/**
* Devuelve el último CabeceraLinkdepago asociado.
*/
public function getUltimoLinkdepago(): ?string
{
if ($this->metododepago != 30) {
return null;
}
$linkdepagos = $this->getCabeceraLinkdepago();
if ($linkdepagos->isEmpty()) {
return 0;
}
// Verificar si alguno de los linkdepagos tiene el estado 1
foreach ($linkdepagos as $linkdepago) {
if ($linkdepago->getGlobalpayStatus() == 1) {
return $linkdepago->getGlobalpayStatus();
}
}
// Devolver el último linkdepago si no se cumple la condición anterior
$linkdepagos = $linkdepagos->last();
return $linkdepagos->getGlobalpayStatus();
}
}