<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\Timestampable;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use App\Entity\Client\BillingInfos;
use App\Entity\Client\FamilyMember;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* Client
*
* @ORM\Table(name="client")
* @ORM\Entity
*/
class Client
{
const STATUS_PROSPECT = 'Prospect';
const STATUS_ACTIF = 'Actif';
const STATUS_INACTIF = 'Inactif';
const STATUS_PARTI = 'Parti';
const STATUS_DECES = 'Décès';
const TYPE_TUTEUR_TUTEUR = 'tuteur';
const TYPE_TUTEUR_LEGAL = 'legal';
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var Site
*
* @ORM\ManyToOne(targetEntity="Site")
* @ORM\JoinColumn(name="site_id", referencedColumnName="id")
*/
private $site;
/**
* @var string
*
* @ORM\Column(name="identifier", type="string", length=500, nullable=true)
*/
private $identifier;
/**
* @Groups("rdv")
* @var string
*
* @ORM\Column(name="firstname", type="string", length=500, nullable=true)
*/
private $firstname;
/**
* @Groups("rdv")
* @var string
*
* @ORM\Column(name="numeroClient", type="string", length=500, nullable=true)
*/
private $numClient;
/**
* @var string
*
* @ORM\Column(name="civilite", type="string", nullable=true)
*/
private $civilite;
/**
* @Groups("rdv")
* @var string
*
* @ORM\Column(name="lastname", type="string", length=500, nullable=true)
*/
private $lastname;
/**
* @var string|null
*
* @ORM\Column(name="birthday", type="string", nullable=true)
*/
private $birthday;
/**
* @var string|null
*
* @ORM\Column(name="deathday", type="string", nullable=true)
*/
private $deathday;
/**
* @var string|null
*
* @ORM\Column(name="gender", type="string", length=255, nullable=true)
*/
private $gender;
/**
* @var string|null
*
* @ORM\Column(name="email", type="string", length=255, nullable=true)
*/
private $email;
/**
* @var string|null
*
* @ORM\Column(name="phone", type="string", length=255, nullable=true)
*/
private $phone;
/**
* @var string|null
*
* @ORM\Column(name="comments", type="text", length=0, nullable=true)
*/
private $comments;
/**
* @var string|null
*
* @ORM\Column(name="suivi_client", type="text", length=0, nullable=true)
*/
private $suiviClient;
/**
* @var string|null
* @Groups("rdv")
* @ORM\Column(name="room_number", type="string", length=255, nullable=true)
*/
private $roomNumber;
/**
* @var string|null
*
* @ORM\Column(name="building_room", type="string", length=255, nullable=true)
*/
private $buildingRoom;
/**
* @var string|null
*
* @ORM\Column(name="stairs", type="string", length=255, nullable=true)
*/
private $stairs;
/**
* @var string|null
*
* @ORM\Column(name="nom_tuteur", type="string", nullable=true)
*/
private $nomTuteur;
/**
* @var string|null
*
* @ORM\Column(name="civilite_tuteur", type="string", nullable=true)
*/
private $civiliteTuteur;
/**
* @var string|null
*
* @ORM\Column(name="prenom_tuteur", type="string", nullable=true)
*/
private $prenomTuteur;
/**
* @var string|null
*
* @ORM\Column(name="email_tuteur", type="string", nullable=true)
*/
private $emailTuteur;
/**
* @var string|null
*
* @ORM\Column(name="email_notaire", type="string", nullable=true)
*/
private $emailNotaire;
/**
* @var string|null
*
* @ORM\Column(name="num_tuteur", type="string", nullable=true)
*/
private $numeroTuteur;
/**
* @var string|null
*
* @ORM\Column(name="type_tuteur", type="string", nullable=true)
*/
private $typeTuteur;
/**
* @ORM\Column(type="simple_array", nullable=true)
*/
private $daysOfWeek = [];
/**
* @var string|null
*
* @ORM\Column(name="comment_tuteur", type="string", nullable=true)
*/
private $commentTuteur;
/**
* @var string|null
*
* @ORM\Column(name="consignes_client", type="string", nullable=true)
*/
private $consignesClient;
/**
* @var string|null
*
* @ORM\Column(name="status_prospect", type="string", nullable=true)
*/
private $statusProspect;
/**
* @var string|null
*
* @ORM\Column(name="profil_client", type="string", nullable=true)
*/
private $profilClient;
/**
* @var string|null
*
* @ORM\Column(name="address_tuteur", type="string", nullable=true)
*/
private $addressTuteur;
/**
* @var string|null
*
* @ORM\Column(name="address_tuteur2", type="string", nullable=true)
*/
private $addressTuteur2;
/**
* @var string|null
*
* @ORM\Column(name="city_tuteur", type="string", nullable=true)
*/
private $city;
/**
* @var string|null
*
* @ORM\Column(name="zipcode", type="string", nullable=true)
*/
private $zipcode;
/**
* @var Contract
*
* @ORM\OneToMany(targetEntity="Contract", mappedBy="client", cascade={"persist"})
*/
private $contract;
/**
* @var Contract
*
* @ORM\OneToMany(targetEntity=FamilyMember::class, mappedBy="client", cascade={"persist"})
*/
private $familyMembers;
/**
* @var Contact
*
* @ORM\ManyToOne(targetEntity="Contact", cascade={"persist"})
* @ORM\JoinColumn(name="contact_id", referencedColumnName="id")
*/
private $contact;
/**
* @var BillingInfos
*
* @ORM\ManyToOne(targetEntity=BillingInfos::class, cascade={"persist"})
* @ORM\JoinColumn(name="billing_infos_id", referencedColumnName="id")
*/
private $billingInfos;
/**
* @ORM\ManyToOne(targetEntity=User::class, cascade={"persist"})
* @ORM\JoinColumn(name="creator_id", referencedColumnName="id")
*/
protected $creator;
/**
* @ORM\ManyToOne(targetEntity=User::class, cascade={"persist"})
* @ORM\JoinColumn(name="maj_id", referencedColumnName="id")
*/
protected $maj;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Reglement", mappedBy="client")
*/
private $reglements;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Billing", mappedBy="client")
*/
private $billings;
/**
* @var \DateTime $created
*
* @Gedmo\Timestampable(on="create")
* @ORM\Column(type="datetime", options={"default"="CURRENT_TIMESTAMP"})
*/
private $created;
/**
* @var \DateTime $updated
*
* @Gedmo\Timestampable(on="update")
* @ORM\Column(type="datetime", options={"default"="CURRENT_TIMESTAMP"})
*/
private $updated;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $privacyPolicyAccepted = false;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $emailAgreement = false;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $cgvAccepted = false;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $hasSignedEasyCollect = false;
/**
* @ORM\OneToMany(targetEntity=Recurrence::class, mappedBy="client")
*/
private $recurrences;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $addressFacturation;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $ComplementAdresseFacturation;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $codePostalFacturation;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $villeFacturation;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $nomFacturation;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $prenomFacturation;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $civiliteFacturation;
public function __toString()
{
return strtoupper($this->getLastname()) . " " . ucfirst($this->getFirstname());
}
public function __construct()
{
$this->contract = new ArrayCollection();
$this->familyMembers = new ArrayCollection();
$this->reglements = new ArrayCollection();
$this->billings = new ArrayCollection();
$this->recurrences = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(?string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(?string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function getBirthday(): ?string
{
return $this->birthday;
}
public function setBirthday(?string $birthday): self
{
$this->birthday = $birthday;
return $this;
}
public function getDeathday(): ?string
{
return $this->deathday;
}
public function setDeathday(?string $deathday): self
{
$this->deathday = $deathday;
return $this;
}
public function getGender(): ?string
{
return $this->gender;
}
public function setGender(?string $gender): self
{
$this->gender = $gender;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone($phone): self
{
$this->phone = $phone;
return $this;
}
public function getComments(): ?string
{
return $this->comments;
}
public function setComments(?string $comments): self
{
$this->comments = $comments;
return $this;
}
public function getRoomNumber(): ?string
{
return $this->roomNumber;
}
public function setRoomNumber(?string $roomNumber): self
{
$this->roomNumber = $roomNumber;
return $this;
}
public function getBuildingRoom(): ?string
{
return $this->buildingRoom;
}
public function setBuildingRoom(?string $buildingRoom): self
{
$this->buildingRoom = $buildingRoom;
return $this;
}
public function getStairs(): ?string
{
return $this->stairs;
}
public function setStairs(?string $stairs): self
{
$this->stairs = $stairs;
return $this;
}
public function getContact(): ?Contact
{
return $this->contact;
}
public function setContact(?Contact $contact): self
{
$this->contact = $contact;
return $this;
}
/**
* @return string
*/
public function getCivilite(): ?string
{
return $this->civilite;
}
/**
* @param string $civilite
*/
public function setCivilite($civilite): void
{
$this->civilite = $civilite;
}
/**
* @return string|null
*/
public function getNomTuteur(): ?string
{
return $this->nomTuteur;
}
/**
* @param string|null $nomTuteur
*/
public function setNomTuteur(?string $nomTuteur): void
{
$this->nomTuteur = $nomTuteur;
}
/**
* @return string|null
*/
public function getPrenomTuteur(): ?string
{
return $this->prenomTuteur;
}
/**
* @param string|null $prenomTuteur
*/
public function setPrenomTuteur(?string $prenomTuteur): void
{
$this->prenomTuteur = $prenomTuteur;
}
/**
* @return string|null
*/
public function getEmailTuteur(): ?string
{
return $this->emailTuteur;
}
/**
* @param string|null $emailTuteur
*/
public function setEmailTuteur(?string $emailTuteur): void
{
$this->emailTuteur = $emailTuteur;
}
/**
* @return string|null
*/
public function getEmailNotaire(): ?string
{
return $this->emailNotaire;
}
/**
* @param string|null $emailNotaire
*/
public function setEmailNotaire(?string $emailNotaire): void
{
$this->emailNotaire = $emailNotaire;
}
/**
* @return string|null
*/
public function getNumeroTuteur(): ?string
{
return $this->numeroTuteur;
}
/**
* @param string|null $numeroTuteur
*/
public function setNumeroTuteur(?string $numeroTuteur): void
{
$this->numeroTuteur = $numeroTuteur;
}
/**
* @return string|null
*/
public function getTypeTuteur(): ?string
{
return $this->typeTuteur;
}
/**
* @param string|null $typeTuteur
*/
public function setTypeTuteur(?string $typeTuteur): void
{
$this->typeTuteur = $typeTuteur;
}
/**
* @return string|null
*/
public function getCommentTuteur(): ?string
{
return $this->commentTuteur;
}
/**
* @param string|null $commentTuteur
*/
public function setCommentTuteur(?string $commentTuteur): void
{
$this->commentTuteur = $commentTuteur;
}
/**
* @return Contract
*/
public function getContract(): Collection
{
return $this->contract;
}
/**
* @param Contact $contract
*/
public function setContract($contract): void
{
$this->contract = $contract;
}
/**
* @return Site
*/
public function getSite(): ?Site
{
return $this->site;
}
/**
* @param Contact $site
*/
public function setSite(?Site $site): void
{
$this->site = $site;
}
/*********/
/* ADD */
/********/
public function addContract(Contract $item)
{
$this->contract->add($item);
$item->setClient($this);
}
public function addFamilyMember(FamilyMember $item)
{
$this->familyMembers->add($item);
$item->setClient($this);
}
/*********/
/* REMVOVE */
/********/
public function removeFamilyMember(FamilyMember $item)
{
$this->familyMembers->removeElement($item);
}
/**
* @return BillingInfos|null
*/
public function getBillingInfos(): ?BillingInfos
{
return $this->billingInfos;
}
/**
* @param Contact $billingInfos
*/
public function setBillingInfos(BillingInfos $billingInfos): void
{
$this->billingInfos = $billingInfos;
}
/**
* @return string
*/
public function getNumClient(): ?string
{
return $this->numClient;
}
/**
* @param string $numClient
*/
public function setNumClient(string $numClient): void
{
$this->numClient = $numClient;
}
/**
* @return string
*/
public function getIdentifier(): ?string
{
return $this->identifier;
}
/**
* @param string $identifier
*/
public function setIdentifier(string $identifier): void
{
$this->identifier = $identifier;
}
/**
* @return string|null
*/
public function getAddressTuteur(): ?string
{
return $this->addressTuteur;
}
/**
* @param string|null $addressTuteur
*/
public function setAddressTuteur(?string $addressTuteur): void
{
$this->addressTuteur = $addressTuteur;
}
/**
* @return ArrayCollection
*/
public function getFamilyMembers()
{
return $this->familyMembers;
}
/**
* @param Contract $familyMembers
*/
public function setFamilyMembers($familyMembers): void
{
$this->familyMembers = $familyMembers;
}
/**
* @return string|null
*/
public function getAddressTuteur2(): ?string
{
return $this->addressTuteur2;
}
/**
* @param string|null $addressTuteur2
*/
public function setAddressTuteur2(?string $addressTuteur2): void
{
$this->addressTuteur2 = $addressTuteur2;
}
/**
* @return string|null
*/
public function getCity(): ?string
{
return $this->city;
}
/**
* @param string|null $city
*/
public function setCity(?string $city): void
{
$this->city = $city;
}
/**
* @return string|null
*/
public function getZipcode(): ?string
{
return $this->zipcode;
}
/**
* @param string|null $zipcode
*/
public function setZipcode(?string $zipcode): void
{
$this->zipcode = $zipcode;
}
/**
* @return mixed
*/
public function getCreator()
{
return $this->creator;
}
/**
* @param mixed $creator
*/
public function setCreator($creator): void
{
$this->creator = $creator;
}
/**
* @return mixed
*/
public function getMaj()
{
return $this->maj;
}
/**
* @param mixed $maj
*/
public function setMaj($maj): void
{
$this->maj = $maj;
}
/**
* @return Collection|Reglement[]
*/
public function getReglements(): Collection
{
return $this->reglements;
}
public function addReglement(Reglement $reglement): self
{
if (!$this->reglements->contains($reglement)) {
$this->reglements[] = $reglement;
$reglement->setClient($this);
}
return $this;
}
public function removeReglement(Reglement $reglement): self
{
if ($this->reglements->contains($reglement)) {
$this->reglements->removeElement($reglement);
// set the owning side to null (unless already changed)
if ($reglement->getClient() === $this) {
$reglement->setClient(null);
}
}
return $this;
}
/**
* @return mixed
*/
public function getBillings()
{
return $this->billings;
}
/**
* @param mixed $billings
*/
public function setBillings($billings): void
{
$this->billings = $billings;
}
/**
* @return \DateTime
*/
public function getCreated(): \DateTime
{
return $this->created;
}
/**
* @param \DateTime $created
*/
public function setCreated(\DateTime $created): void
{
$this->created = $created;
}
/**
* @return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* @param \DateTime $updated
*/
public function setUpdated(\DateTime $updated): void
{
$this->updated = $updated;
}
/**
* @return string|null
*/
public function getStatusProspect(): ?string
{
return $this->statusProspect;
}
/**
* @param string|null $statusProspect
*/
public function setStatusProspect(?string $statusProspect): void
{
$this->statusProspect = $statusProspect;
}
/**
* @return string|null
*/
public function getSuiviClient(): ?string
{
return $this->suiviClient;
}
/**
* @param string|null $suiviClient
*/
public function setSuiviClient(?string $suiviClient): void
{
$this->suiviClient = $suiviClient;
}
/**
* @return string|null
*/
public function getCiviliteTuteur(): ?string
{
return $this->civiliteTuteur;
}
/**
* @param string|null $civiliteTuteur
*/
public function setCiviliteTuteur(?string $civiliteTuteur): void
{
$this->civiliteTuteur = $civiliteTuteur;
}
/**
* @return string|null
*/
public function getProfilClient(): ?string
{
return $this->profilClient;
}
/**
* @param string|null $profilClient
*/
public function setProfilClient(?string $profilClient): void
{
$this->profilClient = $profilClient;
}
/**
* @return string|null
*/
public function getSolde(): ?string
{
$total = 0;
/** @var Billing $billing */
foreach ($this->getBillings() as $billing) {
$total += $billing->getSolde();
}
return $total;
}
public function isPrivacyPolicyAccepted(): ?bool
{
return $this->privacyPolicyAccepted;
}
public function setPrivacyPolicyAccepted(?bool $privacyPolicyAccepted): self
{
$this->privacyPolicyAccepted = $privacyPolicyAccepted;
return $this;
}
public function isEmailAgreement(): ?bool
{
return $this->emailAgreement;
}
public function setEmailAgreement(?bool $emailAgreement): self
{
$this->emailAgreement = $emailAgreement;
return $this;
}
public function isCgvAccepted(): ?bool
{
return $this->cgvAccepted;
}
public function setCgvAccepted(?bool $cgvAccepted): self
{
$this->cgvAccepted = $cgvAccepted;
return $this;
}
/**
* @return string|null
*/
public function getConsignesClient(): ?string
{
return $this->consignesClient;
}
/**
* @param string|null $consignesClient
*/
public function setConsignesClient(?string $consignesClient): void
{
$this->consignesClient = $consignesClient;
}
/**
* @return Collection<int, Recurrence>
*/
public function getRecurrences(): Collection
{
return $this->recurrences;
}
public function addRecurrence(Recurrence $recurrence): self
{
if (!$this->recurrences->contains($recurrence)) {
$this->recurrences[] = $recurrence;
$recurrence->setClient($this);
}
return $this;
}
public function removeRecurrence(Recurrence $recurrence): self
{
if ($this->recurrences->removeElement($recurrence)) {
// set the owning side to null (unless already changed)
if ($recurrence->getClient() === $this) {
$recurrence->setClient(null);
}
}
return $this;
}
/**
* @return bool
*/
public function isHasSignedEasyCollect(): ?bool
{
return $this->hasSignedEasyCollect;
}
/**
* @param bool $hasSignedEasyCollect
*/
public function setHasSignedEasyCollect(bool $hasSignedEasyCollect): void
{
$this->hasSignedEasyCollect = $hasSignedEasyCollect;
}
public function getDaysOfWeek(): ?array
{
return $this->daysOfWeek;
}
public function setDaysOfWeek(array $daysOfWeek): self
{
$this->daysOfWeek = $daysOfWeek;
return $this;
}
public function getAddressFacturation(): ?string
{
if($this->getAddressTuteur() && $this->addressFacturation === null){
return $this->addressTuteur;
}
return $this->addressFacturation;
}
public function setAddressFacturation(?string $addressFacturation): self
{
$this->addressFacturation = $addressFacturation;
return $this;
}
public function getComplementAdresseFacturation(): ?string
{
if($this->getAddressTuteur2() && $this->ComplementAdresseFacturation === null){
return $this->addressTuteur2;
}
return $this->ComplementAdresseFacturation;
}
public function setComplementAdresseFacturation(?string $ComplementAdresseFacturation): self
{
$this->ComplementAdresseFacturation = $ComplementAdresseFacturation;
return $this;
}
public function getCodePostalFacturation(): ?string
{
if($this->getZipcode() && $this->codePostalFacturation === null){
return $this->zipcode;
}
return $this->codePostalFacturation;
}
public function setCodePostalFacturation(?string $codePostalFacturation): self
{
$this->codePostalFacturation = $codePostalFacturation;
return $this;
}
public function getVilleFacturation(): ?string
{
if($this->getCity() && $this->villeFacturation === null){
return $this->city;
}
return $this->villeFacturation;
}
public function setVilleFacturation(?string $villeFacturation): self
{
$this->villeFacturation = $villeFacturation;
return $this;
}
public function getNomFacturation(): ?string
{
if($this->getNomTuteur() && $this->nomFacturation === null){
return $this->nomTuteur;
}
return $this->nomFacturation;
}
public function setNomFacturation(?string $nomFacturation): self
{
$this->nomFacturation = $nomFacturation;
return $this;
}
public function getPrenomFacturation(): ?string
{
if($this->getPrenomTuteur() && $this->prenomFacturation === null){
return $this->prenomTuteur;
}
return $this->prenomFacturation;
}
public function setPrenomFacturation(?string $prenomFacturation): self
{
$this->prenomFacturation = $prenomFacturation;
return $this;
}
public function getCiviliteFacturation(): ?string
{
if($this->getCivilite() && $this->civiliteFacturation === null){
return $this->civilite;
}
return $this->civiliteFacturation;
}
public function setCiviliteFacturation(?string $civiliteFacturation): self
{
$this->civiliteFacturation = $civiliteFacturation;
return $this;
}
}