<?php
namespace App\Entity;
use App\Repository\TiersRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=TiersRepository::class)
*/
class Tiers
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $nom_tiers;
/**
* @ORM\Column(type="string", length=255)
*/
private $prenom_tiers;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $tel_fixe_tiers;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $tel_portable_tiers;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email_tiers;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $commentaire_tiers;
/**
* @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
*/
private $date_crea;
/**
* @ORM\Column(type="integer")
*/
private $user_crea;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $date_modif;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $user_modif;
/**
* @ORM\Column(type="boolean", options={"default": 1})
*/
private $is_active;
/**
* 0=dev, 1=salarié, 2=société
* @ORM\Column(type="integer")
*/
private $id_type_tiers;
/**
* @ORM\OneToOne(targetEntity=User::class, mappedBy="tiers", cascade={"persist", "remove"})
*/
private $user;
/**
* @ORM\OneToMany(targetEntity=Adresse::class, mappedBy="tiers")
*/
private $adresses;
/**
* @ORM\OneToOne(targetEntity=InfoSalarie::class, inversedBy="tiers", cascade={"persist", "remove"})
*/
private $info_salarie;
/**
* @ORM\ManyToMany(targetEntity=Societe::class, mappedBy="tiers")
*/
private $societes;
/**
* @ORM\OneToMany(targetEntity=Projet::class, mappedBy="producteur")
*/
private $projet_producteur;
/**
* @ORM\OneToMany(targetEntity=Projet::class, mappedBy="tiers")
*/
private $projet_tiers;
/**
* @ORM\OneToMany(targetEntity=Contrat::class, mappedBy="salarie")
*/
private $contrats;
/**
* @ORM\ManyToMany(targetEntity=Projet::class, mappedBy="salaries")
*/
private $projet_salarie;
/**
* @ORM\ManyToMany(targetEntity=Projet::class, mappedBy="prestataires")
*/
private $projet_presta;
/**
* @ORM\OneToMany(targetEntity=Document::class, mappedBy="salarie")
*/
private $ndf;
public function __construct()
{
$this->adresses = new ArrayCollection();
$this->societes = new ArrayCollection();
$this->projet_producteur = new ArrayCollection();
$this->projet_tiers = new ArrayCollection();
$this->contrats = new ArrayCollection();
$this->projet_salarie = new ArrayCollection();
$this->projet_presta = new ArrayCollection();
$this->ndf = new ArrayCollection();
}
public function clearForJsonResp(){
// $this->adresses = new ArrayCollection();
$this->societes = new ArrayCollection();
$this->projet_producteur = new ArrayCollection();
$this->projet_tiers = new ArrayCollection();
$this->contrats = new ArrayCollection();
$this->projet_salarie = new ArrayCollection();
$this->projet_presta = new ArrayCollection();
$this->ndf = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNomTiers(): ?string
{
return $this->nom_tiers;
}
public function setNomTiers(string $nom_tiers): self
{
$this->nom_tiers = $nom_tiers;
return $this;
}
public function getPrenomTiers(): ?string
{
return $this->prenom_tiers;
}
public function setPrenomTiers(string $prenom_tiers): self
{
$this->prenom_tiers = $prenom_tiers;
return $this;
}
public function getTelFixeTiers(): ?string
{
return $this->tel_fixe_tiers;
}
public function setTelFixeTiers(?string $tel_fixe_tiers): self
{
$this->tel_fixe_tiers = $tel_fixe_tiers;
return $this;
}
public function getTelPortableTiers(): ?string
{
return $this->tel_portable_tiers;
}
public function setTelPortableTiers(?string $tel_portable_tiers): self
{
$this->tel_portable_tiers = $tel_portable_tiers;
return $this;
}
public function getEmailTiers(): ?string
{
return $this->email_tiers;
}
public function setEmailTiers(?string $email_tiers): self
{
$this->email_tiers = $email_tiers;
return $this;
}
public function getCommentaireTiers(): ?string
{
return $this->commentaire_tiers;
}
public function setCommentaireTiers(?string $commentaire_tiers): self
{
$this->commentaire_tiers = $commentaire_tiers;
return $this;
}
public function getDateCrea(): ?\DateTimeInterface
{
return $this->date_crea;
}
public function setDateCrea(\DateTimeInterface $date_crea): self
{
$this->date_crea = $date_crea;
return $this;
}
public function getUserCrea(): ?int
{
return $this->user_crea;
}
public function setUserCrea(int $user_crea): self
{
$this->user_crea = $user_crea;
return $this;
}
public function getDateModif(): ?\DateTimeInterface
{
return $this->date_modif;
}
public function setDateModif(?\DateTimeInterface $date_modif): self
{
$this->date_modif = $date_modif;
return $this;
}
public function getUserModif(): ?int
{
return $this->user_modif;
}
public function setUserModif(?int $user_modif): self
{
$this->user_modif = $user_modif;
return $this;
}
public function getIsActive(): ?bool
{
return $this->is_active;
}
public function setIsActive(bool $is_active): self
{
$this->is_active = $is_active;
return $this;
}
/**
* @return int|null
* 0=dev, 1=salarié, 2=société
*/
public function getIdTypeTiers(): ?int
{
return $this->id_type_tiers;
}
/**
* 0=dev, 1=salarié, 2=société
* @param int $id_type_tiers
* @return $this
*/
public function setIdTypeTiers(int $id_type_tiers): self
{
$this->id_type_tiers = $id_type_tiers;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
// unset the owning side of the relation if necessary
if ($user === null && $this->user !== null) {
$this->user->setTiers(null);
}
// set the owning side of the relation if necessary
if ($user !== null && $user->getTiers() !== $this) {
$user->setTiers($this);
}
$this->user = $user;
return $this;
}
/**
* @return Collection<int, Adresse>
*/
public function getAdresses(): Collection
{
return $this->adresses;
}
public function addAdress(Adresse $adress): self
{
if (!$this->adresses->contains($adress)) {
$this->adresses[] = $adress;
$adress->setTiers($this);
}
return $this;
}
public function removeAdress(Adresse $adress): self
{
if ($this->adresses->removeElement($adress)) {
// set the owning side to null (unless already changed)
if ($adress->getTiers() === $this) {
$adress->setTiers(null);
}
}
return $this;
}
public function serializeAdresse()
{
if(empty($this->adresses)) return array();
$adresseList = array();
foreach ($this->adresses->toArray() as $adresse){
$adresseList[] = array(
'id_adresse' => $adresse->getId(),
'lib_adresse' => $adresse->getLibAdresse(),
'ligne_1' => $adresse->getLigne1(),
'ligne_2' => $adresse->getLigne2(),
'code_postal' => $adresse->getCodePostal(),
'ville' => $adresse->getVille(),
'pays' => $adresse->getPays(),
);
}
return $adresseList;
}
public function getInfoSalarie(): ?InfoSalarie
{
return $this->info_salarie;
}
public function setInfoSalarie(?InfoSalarie $info_salarie): self
{
$this->info_salarie = $info_salarie;
return $this;
}
/**
* @return Collection<int, Societe>
*/
public function getSocietes(): Collection
{
return $this->societes;
}
public function addSociete(Societe $societe): self
{
if (!$this->societes->contains($societe)) {
$this->societes[] = $societe;
$societe->addTier($this);
}
return $this;
}
public function removeSociete(Societe $societe): self
{
if ($this->societes->removeElement($societe)) {
$societe->removeTier($this);
}
return $this;
}
/**
* @return Collection<int, Projet>
*/
public function getProjetProducteur(): Collection
{
return $this->projet_producteur;
}
public function addProjetProducteur(Projet $projetProducteur): self
{
if (!$this->projet_producteur->contains($projetProducteur)) {
$this->projet_producteur[] = $projetProducteur;
$projetProducteur->setProducteur($this);
}
return $this;
}
public function removeProjetProducteur(Projet $projetProducteur): self
{
if ($this->projet_producteur->removeElement($projetProducteur)) {
// set the owning side to null (unless already changed)
if ($projetProducteur->getProducteur() === $this) {
$projetProducteur->setProducteur(null);
}
}
return $this;
}
/**
* @return Collection<int, Projet>
*/
public function getProjetTiers(): Collection
{
return $this->projet_tiers;
}
public function addProjetTier(Projet $projetTier): self
{
if (!$this->projet_tiers->contains($projetTier)) {
$this->projet_tiers[] = $projetTier;
$projetTier->setTiers($this);
}
return $this;
}
public function removeProjetTier(Projet $projetTier): self
{
if ($this->projet_tiers->removeElement($projetTier)) {
// set the owning side to null (unless already changed)
if ($projetTier->getTiers() === $this) {
$projetTier->setTiers(null);
}
}
return $this;
}
/**
* @return Collection<int, Contrat>
*/
public function getContratByIdProjet(int $idProjet): Collection
{
$contratList = new ArrayCollection();
/** @var Contrat $contrat */
foreach ($this->contrats as $contrat){
if($contrat->getIdProjet() === $idProjet) $contratList[] = $contrat;
}
return $contratList;
}
/**
* @return Collection<int, Contrat>
*/
public function getContratTiers(): Collection
{
return $this->contrats;
}
public function addContratTiers(Contrat $contratTiers): self
{
if (!$this->contrats->contains($contratTiers)) {
$this->contrats[] = $contratTiers;
$contratTiers->setSalarie($this);
}
return $this;
}
public function removeContratTiers(Contrat $contratTiers): self
{
if ($this->contrats->removeElement($contratTiers)) {
// set the owning side to null (unless already changed)
if ($contratTiers->getSalarie() === $this) {
$contratTiers->setSalarie(null);
}
}
return $this;
}
/**
* @return Collection<int, Projet>
*/
public function getProjetEmploi(): Collection
{
return $this->projet_salarie;
}
public function addProjetEmploi(Projet $projet): self
{
if (!$this->projet_salarie->contains($projet)) {
$this->projet_salarie[] = $projet;
$projet->addSalary($this);
}
return $this;
}
public function removeProjetEmploi(Projet $projet): self
{
if ($this->projet_salarie->removeElement($projet)) {
$projet->removeSalary($this);
}
return $this;
}
/**
* @return Collection<int, Projet>
*/
public function getProjetPrestataire(): Collection
{
return $this->projet_presta;
}
public function addProjetPrestataire(Projet $projet): self
{
if (!$this->projet_presta->contains($projet)) {
$this->projet_presta[] = $projet;
$projet->addPrestataire($this);
}
return $this;
}
public function removeProjetPrestataire(Projet $projet): self
{
if ($this->projet_presta->removeElement($projet)) {
$projet->removePrestataire($this);
}
return $this;
}
/**
* @return Collection<int, Document>
*/
public function getNdf(): Collection
{
return $this->ndf;
}
public function addNdf(Document $ndf): self
{
if (!$this->ndf->contains($ndf)) {
$this->ndf[] = $ndf;
$ndf->setSalarie($this);
}
return $this;
}
public function removeNdf(Document $ndf): self
{
if ($this->ndf->removeElement($ndf)) {
// set the owning side to null (unless already changed)
if ($ndf->getSalarie() === $this) {
$ndf->setSalarie(null);
}
}
return $this;
}
}