<?php
namespace App\Entity\Gestiform\Admin;
use App\Entity\AbstractEntity;
use App\Entity\Common\Upload;
use App\Entity\Gestiform\Admin\MasterListe\Masterlistelg;
use App\Entity\Gestiform\Formations\Dossier\HistoriqueComment;
use App\Entity\Gestiform\Formations\Entreprise\Contact;
use App\Entity\Gestiform\Users\Personne;
use App\Repository\Gestiform\Admin\TiersRepository;
use App\Trait\ApiGestiformEntity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=TiersRepository::class)
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="type", type="string")
* @ORM\DiscriminatorMap({
* "tiers" = "Tiers",
* "entreprise" = "App\Entity\Gestiform\Formations\Entreprise\Entreprise",
* "societe" = "App\Entity\Gestiform\Admin\Societe",
* "financeur" = "App\Entity\Gestiform\Formations\Financeur\Financeur",
* "partenaire" = "App\Entity\Gestiform\Admin\Partenaire"
* })
* @UniqueEntity(fields={"raisonSociale"}, message="La raison sociale doit être unique.")
* @UniqueEntity(fields={"siren"}, message="Le SIREN doit être unique.")
*/
class Tiers extends AbstractEntity
{
use ApiGestiformEntity;
/**
* @ORM\Column(type="string", length=255, nullable=true, unique=true)
*/
private ?string $raisonSociale = null;
/**
* @ORM\Column(type="string", length=255, nullable=true, unique=true)
*/
private ?string $siret = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $siteWeb = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $numeroUAI = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $codeApe = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $assurance = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $domaine = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $codeBanque = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $numCompte = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $iban = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $domiciliation = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $email = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $prevoyance = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $numTva = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $description = null;
/**
* @ORM\OneToOne(targetEntity=Upload::class, cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=true)
*/
private ?Upload $logo = null;
/**
* @ORM\ManyToOne(targetEntity=Masterlistelg::class, cascade={"persist"})
* @ORM\JoinColumn(nullable=true)
*/
private ?Masterlistelg $conventionCollective = null;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private ?bool $cfaEntreprise = null;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private ?bool $sousTraitant = null;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private ?bool $prive = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $numActivite = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $mobile = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $fixe = null;
/**
* @ORM\Column(type="string", length=9, unique=true)
* @Assert\NotBlank(message="Le SIREN ne peut pas être vide.")
* @Assert\Regex(
* pattern="/^[0-9]{9}$/",
* message="Le SIREN doit contenir exactement 9 chiffres."
* )
*/
private ?string $siren = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $formeJuridique = null;
/**
* @ORM\ManyToOne(targetEntity=Masterlistelg::class, cascade={"persist"})
* @ORM\JoinColumn(nullable=true)
*/
private ?Masterlistelg $codeTva = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $urssaf = null;
/**
* @ORM\OneToMany(targetEntity=Etablissement::class,mappedBy="tiers", cascade={"persist"})
*/
private Collection $etablissements;
/**
* @ORM\OneToMany(targetEntity=Contact::class,mappedBy="tiers",cascade={"all"})
*/
private Collection $contacts;
/**
* @ORM\ManyToOne(targetEntity=Personne::class,cascade={"persist"})
*/
private ?Personne $personne = null;
/**
* @ORM\OneToMany(targetEntity=HistoriqueComment::class, mappedBy="tiers", cascade={"all"})
*/
private Collection $historiqueComments;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $caisseRetraite = null;
public function __construct()
{
$this->etablissements = new ArrayCollection();
$this->contacts = new ArrayCollection();
$this->historiqueComments = new ArrayCollection();
}
public function getRaisonSociale(): ?string
{
return $this->raisonSociale;
}
public function setRaisonSociale(?string $raisonSociale): self
{
$this->raisonSociale = $raisonSociale;
return $this;
}
public function getSiteWeb(): ?string
{
return $this->siteWeb;
}
public function setSiteWeb(?string $siteWeb): self
{
$this->siteWeb = $siteWeb;
return $this;
}
public function getCodeApe(): ?string
{
return $this->codeApe;
}
public function setCodeApe(?string $codeApe): self
{
$this->codeApe = $codeApe;
return $this;
}
public function getAssurance(): ?string
{
return $this->assurance;
}
public function setAssurance(?string $assurance): self
{
$this->assurance = $assurance;
return $this;
}
public function getCodeBanque(): ?string
{
return $this->codeBanque;
}
public function setCodeBanque(?string $codeBanque): self
{
$this->codeBanque = $codeBanque;
return $this;
}
public function getMobile(): ?string
{
return $this->mobile;
}
public function setMobile(?string $mobile): self
{
$this->mobile = $mobile;
return $this;
}
public function getFixe(): ?string
{
return $this->fixe;
}
public function setFixe(?string $fixe): self
{
$this->fixe = $fixe;
return $this;
}
public function getDomiciliation(): ?string
{
return $this->domiciliation;
}
public function setDomiciliation(?string $domiciliation): self
{
$this->domiciliation = $domiciliation;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getSiret(): ?string
{
return $this->siret;
}
public function setSiret(?string $siret): self
{
$this->siret = $siret;
return $this;
}
public function getNumTva(): ?string
{
return $this->numTva;
}
public function setNumTva(?string $numTva): self
{
$this->numTva = $numTva;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function isCfaEntreprise(): ?bool
{
return $this->cfaEntreprise;
}
public function setCfaEntreprise(?bool $cfaEntreprise): self
{
$this->cfaEntreprise = $cfaEntreprise;
return $this;
}
public function isSousTraitant(): ?bool
{
return $this->sousTraitant;
}
public function setSousTraitant(?bool $soustraitant): self
{
$this->sousTraitant = $soustraitant;
return $this;
}
public function getNumActivite(): ?string
{
return $this->numActivite;
}
public function setNumActivite(?string $numActivite): self
{
$this->numActivite = $numActivite;
return $this;
}
public function getSiren(): ?string
{
return $this->siren;
}
public function setSiren(?string $siren): self
{
$this->siren = $siren;
return $this;
}
public function getFormeJuridique(): ?string
{
return $this->formeJuridique;
}
public function setFormeJuridique(?string $formeJuridique): self
{
$this->formeJuridique = $formeJuridique;
return $this;
}
public function getCodeTva(): ?Masterlistelg
{
return $this->codeTva;
}
public function setCodeTva(?Masterlistelg $codeTva): self
{
$this->codeTva = $codeTva;
return $this;
}
public function getLogo(): ?Upload
{
return $this->logo;
}
public function setLogo(?Upload $logo): self
{
$this->logo = $logo;
return $this;
}
public function getDomaine(): ?string
{
return $this->domaine;
}
public function setDomaine(?string $domaine): self
{
$this->domaine = $domaine;
return $this;
}
public function getPrevoyance(): ?string
{
return $this->prevoyance;
}
public function setPrevoyance(?string $prevoyance): self
{
$this->prevoyance = $prevoyance;
return $this;
}
public function getUrssaf(): ?string
{
return $this->urssaf;
}
public function setUrssaf(?string $urssaf): self
{
$this->urssaf = $urssaf;
return $this;
}
public function getConventionCollective(): ?Masterlistelg
{
return $this->conventionCollective;
}
public function setConventionCollective(?Masterlistelg $conventionCollective): self
{
$this->conventionCollective = $conventionCollective;
return $this;
}
/**
* @return Collection<int, Etablissement>
*/
public function getEtablissements(): Collection
{
return $this->etablissements;
}
public function addEtablissement(Etablissement $etablissement): self
{
if (!$this->etablissements->contains($etablissement)) {
$this->etablissements->add($etablissement);
$etablissement->setTiers($this);
}
return $this;
}
public function removeEtablissement(Etablissement $etablissement): self
{
if ($this->etablissements->removeElement($etablissement)) {
// set the owning side to null (unless already changed)
if ($etablissement->getTiers() === $this) {
$etablissement->setTiers(null);
}
}
return $this;
}
/**
* @return Collection<int, Contact>
*/
public function getContacts(): Collection
{
return $this->contacts;
}
public function addContact(Contact $contact): self
{
if (!$this->contacts->contains($contact)) {
$this->contacts->add($contact);
}
return $this;
}
public function removeContact(Contact $contact): self
{
$this->contacts->removeElement($contact);
return $this;
}
public function getFirstContact()
{
if ($this->getContacts()->first()) {
return $this->getContacts()->first();
}
return null;
}
public function getPersonne(): ?Personne
{
return $this->personne;
}
public function setPersonne(?Personne $personne): self
{
$this->personne = $personne;
return $this;
}
public function getActifEtablissement(): ?Etablissement
{
return $this->etablissements->first() ?: null;
}
public function getIban(): ?string
{
return $this->iban;
}
public function setIban(?string $iban): self
{
$this->iban = $iban;
return $this;
}
/**
* @return Collection<int, HistoriqueComment>
*/
public function getHistoriqueComments(): Collection
{
return $this->historiqueComments;
}
public function addHistoriqueComment(HistoriqueComment $historiqueComment): self
{
if (!$this->historiqueComments->contains($historiqueComment)) {
$this->historiqueComments->add($historiqueComment);
$historiqueComment->setTiers($this);
}
return $this;
}
public function removeHistoriqueComment(HistoriqueComment $historiqueComment): self
{
if ($this->historiqueComments->removeElement($historiqueComment)) {
// set the owning side to null (unless already changed)
if ($historiqueComment->getTiers() === $this) {
$historiqueComment->setTiers(null);
}
}
return $this;
}
public function getPrive(): ?bool
{
return $this->prive;
}
public function setPrive(?bool $prive): self
{
$this->prive = $prive;
return $this;
}
public function getNumeroUAI(): ?string
{
return $this->numeroUAI;
}
public function setNumeroUAI(?string $numeroUAI): self
{
$this->numeroUAI = $numeroUAI;
return $this;
}
public function getCaisseRetraite(): ?string
{
return $this->caisseRetraite;
}
public function setCaisseRetraite(?string $caisseRetraite): self
{
$this->caisseRetraite = $caisseRetraite;
return $this;
}
public function getNomCompletResponsableRh(): string
{
if ($this->getContacts() && !$this->getContacts()->isEmpty()) {
foreach ($this->getContacts() as $contact) {
if ($contact->isResponsableRh()) {
$civilite = $contact->getPersonalInformations()->getCivilite()?->getDesignation();
$fullName = $contact->getPersonalInformations()?->getFullName();
return $civilite . '. ' . $fullName;
}
}
}
return '';
}
public function getNumCompte(): ?string
{
return $this->numCompte;
}
public function setNumCompte(?string $numCompte): self
{
$this->numCompte = $numCompte;
return $this;
}
}