src/Entity/Gestiform/Admin/Tiers.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gestiform\Admin;
  3. use App\Entity\AbstractEntity;
  4. use App\Entity\Common\Upload;
  5. use App\Entity\Gestiform\Admin\MasterListe\Masterlistelg;
  6. use App\Entity\Gestiform\Formations\Dossier\HistoriqueComment;
  7. use App\Entity\Gestiform\Formations\Entreprise\Contact;
  8. use App\Entity\Gestiform\Users\Personne;
  9. use App\Repository\Gestiform\Admin\TiersRepository;
  10. use App\Trait\ApiGestiformEntity;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16.  
  17. /**
  18.  * @ORM\Entity(repositoryClass=TiersRepository::class)
  19.  * @ORM\InheritanceType("JOINED")
  20.  * @ORM\DiscriminatorColumn(name="type", type="string")
  21.  * @ORM\DiscriminatorMap({
  22.  *     "tiers" = "Tiers",
  23.  *     "entreprise" = "App\Entity\Gestiform\Formations\Entreprise\Entreprise",
  24.  *     "societe" = "App\Entity\Gestiform\Admin\Societe",
  25.  *     "financeur" = "App\Entity\Gestiform\Formations\Financeur\Financeur",
  26.  *     "partenaire" = "App\Entity\Gestiform\Admin\Partenaire"
  27.  * })
  28.  * @UniqueEntity(fields={"raisonSociale"}, message="La raison sociale doit être unique.")
  29.  * @UniqueEntity(fields={"siren"}, message="Le SIREN doit être unique.")
  30.  */
  31. class Tiers extends AbstractEntity
  32. {
  33.     use ApiGestiformEntity;
  34.     /**
  35.      * @ORM\Column(type="string", length=255, nullable=true, unique=true)
  36.      */
  37.     private ?string $raisonSociale null;
  38.     /**
  39.      * @ORM\Column(type="string", length=255, nullable=true, unique=true)
  40.      */
  41.     private ?string $siret null;
  42.     /**
  43.      * @ORM\Column(type="string", length=255, nullable=true)
  44.      */
  45.     private ?string $siteWeb null;
  46.     /**
  47.      * @ORM\Column(type="string", length=255, nullable=true)
  48.      */
  49.     private ?string $numeroUAI null;
  50.     /**
  51.      * @ORM\Column(type="string", length=255, nullable=true)
  52.      */
  53.     private ?string $codeApe null;
  54.     /**
  55.      * @ORM\Column(type="string", length=255, nullable=true)
  56.      */
  57.     private ?string $assurance null;
  58.     /**
  59.      * @ORM\Column(type="string", length=255, nullable=true)
  60.      */
  61.     private ?string $domaine null;
  62.     /**
  63.      * @ORM\Column(type="string", length=255, nullable=true)
  64.      */
  65.     private ?string $codeBanque null;
  66.     /**
  67.      * @ORM\Column(type="string", length=255, nullable=true)
  68.      */
  69.     private ?string $numCompte null;
  70.     /**
  71.      * @ORM\Column(type="string", length=255, nullable=true)
  72.      */
  73.     private ?string $iban null;
  74.     /**
  75.      * @ORM\Column(type="string", length=255, nullable=true)
  76.      */
  77.     private ?string $domiciliation null;
  78.     /**
  79.      * @ORM\Column(type="string", length=255, nullable=true)
  80.      */
  81.     private ?string $email null;
  82.     /**
  83.      * @ORM\Column(type="string", length=255, nullable=true)
  84.      */
  85.     private ?string $prevoyance null;
  86.     /**
  87.      * @ORM\Column(type="string", length=255, nullable=true)
  88.      */
  89.     private ?string $numTva null;
  90.     /**
  91.      * @ORM\Column(type="string", length=255, nullable=true)
  92.      */
  93.     private ?string $description null;
  94.     /**
  95.      * @ORM\OneToOne(targetEntity=Upload::class, cascade={"persist", "remove"})
  96.      * @ORM\JoinColumn(nullable=true)
  97.      */
  98.     private ?Upload $logo null;
  99.     /**
  100.      * @ORM\ManyToOne(targetEntity=Masterlistelg::class, cascade={"persist"})
  101.      * @ORM\JoinColumn(nullable=true)
  102.      */
  103.     private ?Masterlistelg $conventionCollective null;
  104.     /**
  105.      * @ORM\Column(type="boolean", nullable=true)
  106.      */
  107.     private ?bool $cfaEntreprise null;
  108.     /**
  109.      * @ORM\Column(type="boolean", nullable=true)
  110.      */
  111.     private ?bool $sousTraitant null;
  112.     /**
  113.      * @ORM\Column(type="boolean", nullable=true)
  114.      */
  115.     private ?bool $prive null;
  116.     /**
  117.      * @ORM\Column(type="string", length=255, nullable=true)
  118.      */
  119.     private ?string $numActivite null;
  120.     /**
  121.      * @ORM\Column(type="string", length=255, nullable=true)
  122.      */
  123.     private ?string $mobile null;
  124.     /**
  125.      * @ORM\Column(type="string", length=255, nullable=true)
  126.      */
  127.     private ?string $fixe null;
  128.     /**
  129.      * @ORM\Column(type="string", length=9, unique=true)
  130.      * @Assert\NotBlank(message="Le SIREN ne peut pas être vide.")
  131.      * @Assert\Regex(
  132.      * pattern="/^[0-9]{9}$/",
  133.      * message="Le SIREN doit contenir exactement 9 chiffres."
  134.      * )
  135.      */
  136.     private ?string $siren null;
  137.     /**
  138.      * @ORM\Column(type="string", length=255, nullable=true)
  139.      */
  140.     private ?string $formeJuridique null;
  141.     /**
  142.      * @ORM\ManyToOne(targetEntity=Masterlistelg::class, cascade={"persist"})
  143.      * @ORM\JoinColumn(nullable=true)
  144.      */
  145.     private ?Masterlistelg $codeTva null;
  146.     /**
  147.      * @ORM\Column(type="string", length=255, nullable=true)
  148.      */
  149.     private ?string $urssaf null;
  150.     /**
  151.      * @ORM\OneToMany(targetEntity=Etablissement::class,mappedBy="tiers", cascade={"persist"})
  152.      */
  153.     private Collection $etablissements;
  154.     /**
  155.      * @ORM\OneToMany(targetEntity=Contact::class,mappedBy="tiers",cascade={"all"})
  156.      */
  157.     private Collection $contacts;
  158.     /**
  159.      * @ORM\ManyToOne(targetEntity=Personne::class,cascade={"persist"})
  160.      */
  161.     private ?Personne $personne null;
  162.     /**
  163.      * @ORM\OneToMany(targetEntity=HistoriqueComment::class, mappedBy="tiers", cascade={"all"})
  164.      */
  165.     private Collection $historiqueComments;
  166.     /**
  167.      * @ORM\Column(type="string", length=255, nullable=true)
  168.      */
  169.     private ?string $caisseRetraite null;
  170.     public function __construct()
  171.     {
  172.         $this->etablissements = new ArrayCollection();
  173.         $this->contacts = new ArrayCollection();
  174.         $this->historiqueComments = new ArrayCollection();
  175.     }
  176.     public function getRaisonSociale(): ?string
  177.     {
  178.         return $this->raisonSociale;
  179.     }
  180.     public function setRaisonSociale(?string $raisonSociale): self
  181.     {
  182.         $this->raisonSociale $raisonSociale;
  183.         return $this;
  184.     }
  185.     public function getSiteWeb(): ?string
  186.     {
  187.         return $this->siteWeb;
  188.     }
  189.     public function setSiteWeb(?string $siteWeb): self
  190.     {
  191.         $this->siteWeb $siteWeb;
  192.         return $this;
  193.     }
  194.     public function getCodeApe(): ?string
  195.     {
  196.         return $this->codeApe;
  197.     }
  198.     public function setCodeApe(?string $codeApe): self
  199.     {
  200.         $this->codeApe $codeApe;
  201.         return $this;
  202.     }
  203.     public function getAssurance(): ?string
  204.     {
  205.         return $this->assurance;
  206.     }
  207.     public function setAssurance(?string $assurance): self
  208.     {
  209.         $this->assurance $assurance;
  210.         return $this;
  211.     }
  212.     public function getCodeBanque(): ?string
  213.     {
  214.         return $this->codeBanque;
  215.     }
  216.     public function setCodeBanque(?string $codeBanque): self
  217.     {
  218.         $this->codeBanque $codeBanque;
  219.         return $this;
  220.     }
  221.     public function getMobile(): ?string
  222.     {
  223.         return $this->mobile;
  224.     }
  225.     public function setMobile(?string $mobile): self
  226.     {
  227.         $this->mobile $mobile;
  228.         return $this;
  229.     }
  230.     public function getFixe(): ?string
  231.     {
  232.         return $this->fixe;
  233.     }
  234.     public function setFixe(?string $fixe): self
  235.     {
  236.         $this->fixe $fixe;
  237.         return $this;
  238.     }
  239.     public function getDomiciliation(): ?string
  240.     {
  241.         return $this->domiciliation;
  242.     }
  243.     public function setDomiciliation(?string $domiciliation): self
  244.     {
  245.         $this->domiciliation $domiciliation;
  246.         return $this;
  247.     }
  248.     public function getEmail(): ?string
  249.     {
  250.         return $this->email;
  251.     }
  252.     public function setEmail(?string $email): self
  253.     {
  254.         $this->email $email;
  255.         return $this;
  256.     }
  257.     public function getSiret(): ?string
  258.     {
  259.         return $this->siret;
  260.     }
  261.     public function setSiret(?string $siret): self
  262.     {
  263.         $this->siret $siret;
  264.         return $this;
  265.     }
  266.     public function getNumTva(): ?string
  267.     {
  268.         return $this->numTva;
  269.     }
  270.     public function setNumTva(?string $numTva): self
  271.     {
  272.         $this->numTva $numTva;
  273.         return $this;
  274.     }
  275.     public function getDescription(): ?string
  276.     {
  277.         return $this->description;
  278.     }
  279.     public function setDescription(?string $description): self
  280.     {
  281.         $this->description $description;
  282.         return $this;
  283.     }
  284.     public function isCfaEntreprise(): ?bool
  285.     {
  286.         return $this->cfaEntreprise;
  287.     }
  288.     public function setCfaEntreprise(?bool $cfaEntreprise): self
  289.     {
  290.         $this->cfaEntreprise $cfaEntreprise;
  291.         return $this;
  292.     }
  293.     public function isSousTraitant(): ?bool
  294.     {
  295.         return $this->sousTraitant;
  296.     }
  297.     public function setSousTraitant(?bool $soustraitant): self
  298.     {
  299.         $this->sousTraitant $soustraitant;
  300.         return $this;
  301.     }
  302.     public function getNumActivite(): ?string
  303.     {
  304.         return $this->numActivite;
  305.     }
  306.     public function setNumActivite(?string $numActivite): self
  307.     {
  308.         $this->numActivite $numActivite;
  309.         return $this;
  310.     }
  311.     public function getSiren(): ?string
  312.     {
  313.         return $this->siren;
  314.     }
  315.     public function setSiren(?string $siren): self
  316.     {
  317.         $this->siren $siren;
  318.         return $this;
  319.     }
  320.     public function getFormeJuridique(): ?string
  321.     {
  322.         return $this->formeJuridique;
  323.     }
  324.     public function setFormeJuridique(?string $formeJuridique): self
  325.     {
  326.         $this->formeJuridique $formeJuridique;
  327.         return $this;
  328.     }
  329.     public function getCodeTva(): ?Masterlistelg
  330.     {
  331.         return $this->codeTva;
  332.     }
  333.     public function setCodeTva(?Masterlistelg $codeTva): self
  334.     {
  335.         $this->codeTva $codeTva;
  336.         return $this;
  337.     }
  338.     public function getLogo(): ?Upload
  339.     {
  340.         return $this->logo;
  341.     }
  342.     public function setLogo(?Upload $logo): self
  343.     {
  344.         $this->logo $logo;
  345.         return $this;
  346.     }
  347.     public function getDomaine(): ?string
  348.     {
  349.         return $this->domaine;
  350.     }
  351.     public function setDomaine(?string $domaine): self
  352.     {
  353.         $this->domaine $domaine;
  354.         return $this;
  355.     }
  356.     public function getPrevoyance(): ?string
  357.     {
  358.         return $this->prevoyance;
  359.     }
  360.     public function setPrevoyance(?string $prevoyance): self
  361.     {
  362.         $this->prevoyance $prevoyance;
  363.         return $this;
  364.     }
  365.     public function getUrssaf(): ?string
  366.     {
  367.         return $this->urssaf;
  368.     }
  369.     public function setUrssaf(?string $urssaf): self
  370.     {
  371.         $this->urssaf $urssaf;
  372.         return $this;
  373.     }
  374.     public function getConventionCollective(): ?Masterlistelg
  375.     {
  376.         return $this->conventionCollective;
  377.     }
  378.     public function setConventionCollective(?Masterlistelg $conventionCollective): self
  379.     {
  380.         $this->conventionCollective $conventionCollective;
  381.         return $this;
  382.     }
  383.     /**
  384.      * @return Collection<int, Etablissement>
  385.      */
  386.     public function getEtablissements(): Collection
  387.     {
  388.         return $this->etablissements;
  389.     }
  390.     public function addEtablissement(Etablissement $etablissement): self
  391.     {
  392.         if (!$this->etablissements->contains($etablissement)) {
  393.             $this->etablissements->add($etablissement);
  394.             $etablissement->setTiers($this);
  395.         }
  396.         return $this;
  397.     }
  398.     public function removeEtablissement(Etablissement $etablissement): self
  399.     {
  400.         if ($this->etablissements->removeElement($etablissement)) {
  401.             // set the owning side to null (unless already changed)
  402.             if ($etablissement->getTiers() === $this) {
  403.                 $etablissement->setTiers(null);
  404.             }
  405.         }
  406.         return $this;
  407.     }
  408.     /**
  409.      * @return Collection<int, Contact>
  410.      */
  411.     public function getContacts(): Collection
  412.     {
  413.         return $this->contacts;
  414.     }
  415.     public function addContact(Contact $contact): self
  416.     {
  417.         if (!$this->contacts->contains($contact)) {
  418.             $this->contacts->add($contact);
  419.         }
  420.         return $this;
  421.     }
  422.     public function removeContact(Contact $contact): self
  423.     {
  424.         $this->contacts->removeElement($contact);
  425.         return $this;
  426.     }
  427.     public function getFirstContact()
  428.     {
  429.         if ($this->getContacts()->first()) {
  430.             return $this->getContacts()->first();
  431.         }
  432.         return null;
  433.     }
  434.     public function getPersonne(): ?Personne
  435.     {
  436.         return $this->personne;
  437.     }
  438.     public function setPersonne(?Personne $personne): self
  439.     {
  440.         $this->personne $personne;
  441.         return $this;
  442.     }
  443.     public function getActifEtablissement(): ?Etablissement
  444.     {
  445.         return $this->etablissements->first() ?: null;
  446.     }
  447.     public function getIban(): ?string
  448.     {
  449.         return $this->iban;
  450.     }
  451.     public function setIban(?string $iban): self
  452.     {
  453.         $this->iban $iban;
  454.         return $this;
  455.     }
  456.     /**
  457.      * @return Collection<int, HistoriqueComment>
  458.      */
  459.     public function getHistoriqueComments(): Collection
  460.     {
  461.         return $this->historiqueComments;
  462.     }
  463.     public function addHistoriqueComment(HistoriqueComment $historiqueComment): self
  464.     {
  465.         if (!$this->historiqueComments->contains($historiqueComment)) {
  466.             $this->historiqueComments->add($historiqueComment);
  467.             $historiqueComment->setTiers($this);
  468.         }
  469.         return $this;
  470.     }
  471.     public function removeHistoriqueComment(HistoriqueComment $historiqueComment): self
  472.     {
  473.         if ($this->historiqueComments->removeElement($historiqueComment)) {
  474.             // set the owning side to null (unless already changed)
  475.             if ($historiqueComment->getTiers() === $this) {
  476.                 $historiqueComment->setTiers(null);
  477.             }
  478.         }
  479.         return $this;
  480.     }
  481.     public function getPrive(): ?bool
  482.     {
  483.         return $this->prive;
  484.     }
  485.     public function setPrive(?bool $prive): self
  486.     {
  487.         $this->prive $prive;
  488.         return $this;
  489.     }
  490.     public function getNumeroUAI(): ?string
  491.     {
  492.         return $this->numeroUAI;
  493.     }
  494.     public function setNumeroUAI(?string $numeroUAI): self
  495.     {
  496.         $this->numeroUAI $numeroUAI;
  497.         return $this;
  498.     }
  499.     public function getCaisseRetraite(): ?string
  500.     {
  501.         return $this->caisseRetraite;
  502.     }
  503.     public function setCaisseRetraite(?string $caisseRetraite): self
  504.     {
  505.         $this->caisseRetraite $caisseRetraite;
  506.         return $this;
  507.     }
  508.     public function getNomCompletResponsableRh(): string
  509.     {
  510.         if ($this->getContacts() && !$this->getContacts()->isEmpty()) {
  511.             foreach ($this->getContacts() as $contact) {
  512.                 if ($contact->isResponsableRh()) {
  513.                     $civilite $contact->getPersonalInformations()->getCivilite()?->getDesignation();
  514.                     $fullName $contact->getPersonalInformations()?->getFullName();
  515.                         return $civilite '. ' $fullName;
  516.                 }
  517.             }
  518.         }
  519.         return '';
  520.     }
  521.     public function getNumCompte(): ?string
  522.     {
  523.         return $this->numCompte;
  524.     }
  525.     public function setNumCompte(?string $numCompte): self
  526.     {
  527.         $this->numCompte $numCompte;
  528.         return $this;
  529.     }
  530. }