<?php
namespace App\Entity;
use App\Entity\Person\Referrer;
use App\Entity\Special\VotingInfo;
use App\Repository\PersonRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=PersonRepository::class)
*/
class Person
{
const COORDINATOR = 'coordinator';
const OPERATOR = 'operator';
const PROMOTER = 'promoter';
const PROMOTED = 'promoted';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $fullName;
/**
* @ORM\Column(type="string", length=1024)
*/
private $address;
/**
* @ORM\Column(type="string", length=255, unique=true, name="person_key")
*/
private $key;
/**
* @ORM\Column(type="string", length=255)
*/
private $number;
/**
* @ORM\Column(type="string", length=255)
*/
private $cellPhone;
/**
* @ORM\ManyToMany(targetEntity=HelpProgram::class, mappedBy="persons")
*/
private $helpPrograms;
/**
* @ORM\OneToMany(targetEntity=PersonLog::class, mappedBy="person")
*/
private $personLogs;
/**
* @ORM\Column(type="string", length=255)
*/
private $classification;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $observations;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="persons")
* @ORM\JoinColumn(nullable=false)
*/
private $captureUser;
/**
* @ORM\ManyToOne(targetEntity=Section::class, inversedBy="persons")
* @ORM\JoinColumn(nullable=false)
*/
private $section;
/**
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="people")
*/
private $parent;
/**
* @ORM\OneToMany(targetEntity=Person::class, mappedBy="parent")
*/
private $people;
/**
* @ORM\ManyToOne(targetEntity=ExternalDataBase::class, inversedBy="people")
*/
private $externalDB;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $committedPeople;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $votingBooth;
/**
* @ORM\ManyToOne(targetEntity=Suburb::class, inversedBy="people")
*/
private $subUrb;
/**
* @ORM\ManyToOne(targetEntity=VotingBooth::class, inversedBy="persons")
*/
private $vBooth;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="coordinators")
*/
private $specialUser;
/**
* @ORM\ManyToOne(targetEntity=CuttingSchedule::class, inversedBy="persons")
*/
private $cuttingSchedule;
/**
* @ORM\OneToMany(targetEntity=VotingInfo::class, mappedBy="person")
*/
private $votingInfos;
/**
* @ORM\Column(type="boolean")
*/
private $verified;
/**
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="linkPeople")
*/
private $parentLink;
/**
* @ORM\OneToMany(targetEntity=Person::class, mappedBy="parentLink")
*/
private $linkPeople;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $personVoted;
/**
* @ORM\ManyToOne(targetEntity=Referrer::class, inversedBy="referrals")
*/
private $referrer;
public function __construct()
{
$this->helpPrograms = new ArrayCollection();
$this->personLogs = new ArrayCollection();
$this->people = new ArrayCollection();
$this->votingInfos = new ArrayCollection();
$this->linkPeople = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getFullName(): ?string
{
return $this->fullName;
}
public function setFullName(string $fullName): self
{
$this->fullName = $fullName;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(string $address): self
{
$this->address = $address;
return $this;
}
public function getKey(): ?string
{
return $this->key;
}
public function setKey(string $key): self
{
$this->key = $key;
return $this;
}
public function getNumber(): ?string
{
return $this->number;
}
public function setNumber(string $number): self
{
$this->number = $number;
return $this;
}
public function getCellPhone(): ?string
{
return $this->cellPhone;
}
public function setCellPhone(string $cellPhone): self
{
$this->cellPhone = $cellPhone;
return $this;
}
/**
* @return Collection<int, HelpProgram>
*/
public function getHelpPrograms(): Collection
{
return $this->helpPrograms;
}
public function addHelpProgram(HelpProgram $helpProgram): self
{
if (!$this->helpPrograms->contains($helpProgram)) {
$this->helpPrograms[] = $helpProgram;
$helpProgram->addPerson($this);
}
return $this;
}
public function removeHelpProgram(HelpProgram $helpProgram): self
{
if ($this->helpPrograms->removeElement($helpProgram)) {
$helpProgram->removePerson($this);
}
return $this;
}
/**
* @return Collection<int, PersonLog>
*/
public function getPersonLogs(): Collection
{
return $this->personLogs;
}
public function addPersonLog(PersonLog $personLog): self
{
if (!$this->personLogs->contains($personLog)) {
$this->personLogs[] = $personLog;
$personLog->setPerson($this);
}
return $this;
}
public function removePersonLog(PersonLog $personLog): self
{
if ($this->personLogs->removeElement($personLog)) {
// set the owning side to null (unless already changed)
if ($personLog->getPerson() === $this) {
$personLog->setPerson(null);
}
}
return $this;
}
public function getClassification(): ?string
{
return $this->classification;
}
public function setClassification(string $classification): self
{
$this->classification = $classification;
return $this;
}
public function getObservations(): ?string
{
return $this->observations;
}
public function setObservations(?string $observations): self
{
$this->observations = $observations;
return $this;
}
public function getCaptureUser(): ?User
{
return $this->captureUser;
}
public function setCaptureUser(?User $captureUser): self
{
$this->captureUser = $captureUser;
return $this;
}
public function getSection(): ?Section
{
return $this->section;
}
public function setSection(?Section $section): self
{
$this->section = $section;
return $this;
}
public function getParent(): ?self
{
return $this->parent;
}
public function getParentText(): string
{
$result = '';
if ($this->getParent()) {
if ($this->classification == self::OPERATOR) {
$result = 'Coordinador: ' . $this->getParent()->getFullName();
} elseif ($this->classification == self::PROMOTER) {
$result = 'Operador: ' . $this->getParent()->getFullName();
} elseif ($this->classification == self::PROMOTED) {
$result = 'Promotor: ' . $this->getParent()->getFullName();
}
}
return $result;
}
public function setParent(?self $parent): self
{
$this->parent = $parent;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getPeople(): Collection
{
return $this->people;
}
public function addPerson(self $person): self
{
if (!$this->people->contains($person)) {
$this->people[] = $person;
$person->setParent($this);
}
return $this;
}
public function removePerson(self $person): self
{
if ($this->people->removeElement($person)) {
// set the owning side to null (unless already changed)
if ($person->getParent() === $this) {
$person->setParent(null);
}
}
return $this;
}
public function getExternalDB(): ?ExternalDataBase
{
return $this->externalDB;
}
public function setExternalDB(?ExternalDataBase $externalDB): self
{
$this->externalDB = $externalDB;
return $this;
}
public function getCommittedPeople(): ?int
{
return $this->committedPeople;
}
public function setCommittedPeople(?int $committedPeople): self
{
$this->committedPeople = $committedPeople;
return $this;
}
public function getVotingBooth(): ?string
{
return $this->votingBooth;
}
public function setVotingBooth(?string $votingBooth): self
{
$this->votingBooth = $votingBooth;
return $this;
}
public function getSubUrb(): ?Suburb
{
return $this->subUrb;
}
public function setSubUrb(?Suburb $subUrb): self
{
$this->subUrb = $subUrb;
return $this;
}
public function getVBooth(): ?VotingBooth
{
return $this->vBooth;
}
public function setVBooth(?VotingBooth $vBooth): self
{
$this->vBooth = $vBooth;
return $this;
}
public function getSpecialUser(): ?User
{
return $this->specialUser;
}
public function setSpecialUser(?User $specialUser): self
{
$this->specialUser = $specialUser;
return $this;
}
public function getCuttingSchedule(): ?CuttingSchedule
{
return $this->cuttingSchedule;
}
public function setCuttingSchedule(?CuttingSchedule $cuttingSchedule): self
{
$this->cuttingSchedule = $cuttingSchedule;
return $this;
}
/**
* @return Collection<int, VotingInfo>
*/
public function getVotingInfos(): Collection
{
return $this->votingInfos;
}
public function addVotingInfo(VotingInfo $votingInfo): self
{
if (!$this->votingInfos->contains($votingInfo)) {
$this->votingInfos[] = $votingInfo;
$votingInfo->setPerson($this);
}
return $this;
}
public function removeVotingInfo(VotingInfo $votingInfo): self
{
if ($this->votingInfos->removeElement($votingInfo)) {
// set the owning side to null (unless already changed)
if ($votingInfo->getPerson() === $this) {
$votingInfo->setPerson(null);
}
}
return $this;
}
public function isVerified(): ?bool
{
return $this->verified;
}
public function setVerified(bool $verified): self
{
$this->verified = $verified;
return $this;
}
public function getParentLink(): ?self
{
return $this->parentLink;
}
public function setParentLink(?self $parentLink): self
{
$this->parentLink = $parentLink;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getLinkPeople(): Collection
{
return $this->linkPeople;
}
public function addLinkPerson(self $linkPerson): self
{
if (!$this->linkPeople->contains($linkPerson)) {
$this->linkPeople[] = $linkPerson;
$linkPerson->setParentLink($this);
}
return $this;
}
public function removeLinkPerson(self $linkPerson): self
{
if ($this->linkPeople->removeElement($linkPerson)) {
// set the owning side to null (unless already changed)
if ($linkPerson->getParentLink() === $this) {
$linkPerson->setParentLink(null);
}
}
return $this;
}
public function isPersonVoted(): ?bool
{
return $this->personVoted;
}
public function setPersonVoted(?bool $personVoted): self
{
$this->personVoted = $personVoted;
return $this;
}
public function getReferrer(): ?Referrer
{
return $this->referrer;
}
public function setReferrer(?Referrer $referrer): self
{
$this->referrer = $referrer;
return $this;
}
}