<?php
namespace App\Entity;
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\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
* @UniqueEntity(fields={"username"}, message="There is already an account with this username")
*/
class User implements UserInterface
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $username;
/**
* @ORM\Column(type="string", length=255)
*/
private $password;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $niveau;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true, unique=true)
*/
private $matricule;
/**
* @var array
*
* @ORM\Column(type="array")
*/
private $roles;
/**
* @ORM\OneToMany(targetEntity="App\Entity\PlaceDeMarche", mappedBy="user")
*/
private $placeDeMarches;
/**
* @ORM\OneToMany(targetEntity="App\Entity\TraitementDsDemdDachat", mappedBy="user")
*/
private $traitementDsDemdDachats;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email_pro;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $fonction;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $entry_at;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $prenoms;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\UserStatus", inversedBy="users")
*/
private $status;
/**
* @ORM\OneToMany(targetEntity="App\Entity\AdminDonneurOrdre", mappedBy="lead")
*/
private $adminDonneurOrdres;
/**
* @ORM\OneToMany(targetEntity="App\Entity\AdminDonneurOrdre", mappedBy="suivi_par")
*/
private $adminDonneurOrdres_suivi;
/**
* @ORM\OneToMany(targetEntity="App\Entity\LeveeDeFond", mappedBy="suvi_par")
*/
private $leveeDeFonds;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $date_sortie;
/**
* @ORM\OneToMany(targetEntity="App\Entity\LetterOfIntentToPurchase", mappedBy="agent")
*/
private $letterOfIntentToPurchases;
/**
* @ORM\OneToMany(targetEntity="App\Entity\LetterOfIntentToPurchase", mappedBy="suivipar")
*/
private $suivipars;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Document", mappedBy="redacteur")
*/
private $documents;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Document", mappedBy="approuverPar")
*/
private $documentApprouves;
/**
* @ORM\OneToMany(targetEntity="App\Entity\TraitementDsDemdDachat", mappedBy="agent")
*/
private $agent;
/**
* @ORM\OneToMany(targetEntity="App\Entity\DemandeDeCotation", mappedBy="user")
*/
private $demandeDeCotations;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Prospect", mappedBy="suiviPar")
*/
private $prospects;
/**
* @ORM\OneToMany(targetEntity="App\Entity\RequeteDeFinancement", mappedBy="user")
*/
private $requeteDeFinancements;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Visiteur", mappedBy="user")
*/
private $visiteurs;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Abonne", mappedBy="user")
*/
private $abonnes;
public function __construct()
{
$this->matricule = 'BSCM' . random_int(10, 1000) . date('s');
$this->niveau = "0";
$this->placeDeMarches = new ArrayCollection();
$this->traitementDsDemdDachats = new ArrayCollection();
$this->adminDonneurOrdres = new ArrayCollection();
$this->adminDonneurOrdres_suivi = new ArrayCollection();
$this->leveeDeFonds = new ArrayCollection();
$this->letterOfIntentToPurchases = new ArrayCollection();
$this->agent = new ArrayCollection();
$this->demandeDeCotations = new ArrayCollection();
$this->prospects = new ArrayCollection();
$this->visiteurs = new ArrayCollection();
$this->abonnes = new ArrayCollection();
$this->requeteDeFinancements = new ArrayCollection();
$this->suivipars = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->documentApprouves = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* Returns the roles granted to the user.
*
* public function getRoles()
* {
* return ['ROLE_USER'];
* }
*
* Alternatively, the roles might be stored on a ``roles`` property,
* and populated in any number of different ways when the user object
* is created.
*
* @return (Role|string)[] The user roles
*/
/**
* @return (Role|string)[]
*/
public function getRoles(): array
{
// TODO: Implement getRoles() method.
// return ['ROLE_ADMIN','ROLE_USER','ROLE_SUPER_ADMIN'];
return ['ROLE_USER'];
}
/**
* @param array $roles
* @return User
*/
public function setRoles(array $roles): User
{
$this->roles = $roles;
return $this;
}
/**
* Returns the salt that was originally used to encode the password.
*
* This can return null if the password was not encoded using a salt.
*
* @return string|null The salt
*/
public function getSalt()
{
// TODO: Implement getSalt() method.
return null;
}
/**
* Removes sensitive data from the user.
*
* This is important if, at any given point, sensitive information like
* the plain-text password is stored on this object.
*/
public function eraseCredentials()
{
// TODO: Implement eraseCredentials() method.
}
/**
* String representation of object
* @link http://php.net/manual/en/serializable.serialize.php
* @return string the string representation of the object or null
* @since 5.1.0
*/
public function serialize(): array
{
// TODO: Implement serialize() method.
return serialize([
$this->id,
$this->username,
$this->password,
$this->matricule,
$this->name,
$this->niveau,
$this->roles,
]);
}
/**
* Constructs the object
* @link http://php.net/manual/en/serializable.unserialize.php
* @param string $serialized <p>
* The string representation of the object.
* </p>
* @return void
* @since 5.1.0
*/
public function unserialize($serialized): void
{
// TODO: Implement unserialize() method.
list(
$this->id,
$this->username,
$this->password,
$this->matricule,
$this->name,
$this->niveau,
$this->roles,
) = unserialize($serialized, ['allowed_classes' => false]);
}
public function getNiveau(): ?int
{
return $this->niveau;
}
public function setNiveau(?int $niveau): self
{
$this->niveau = $niveau;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getMatricule(): ?string
{
return $this->matricule;
}
public function setMatricule(?string $matricule): self
{
$this->matricule = $matricule;
return $this;
}
/**
* @return Collection
*/
public function getAbonnes(): Collection{
return $this->abonnes;
}
public function addAbonne(Abonne $abonne): self{
if (!$this->abonnes->contains($abonne)) {
$this->abonnes[] = $abonne;
$abonne->setUser($this);
}
return $this;
}
public function removeAbonne(Abonne $abonne): self{
if ($this->abonnes->contains($abonne)) {
$this->abonnes->removeElement($abonne);
// set the owning side to null (unless already changed)
if ($abonne->getUser() === $this) {
$abonne->setUser(null);
}
}
return $this;
}
/**
* @return Collection
*/
public function getVisiteurs(): Collection
{
return $this->visiteurs;
}
public function addVisiteur(Visiteur $visiteur): self{
if (!$this->visiteurs->contains($visiteur)) {
$this->visiteurs[] = $visiteur;
$visiteur->setUser($this);
}
return $this;
}
public function removeVisiteur(Visiteur $visiteur): self{
if ($this->visiteurs->contains($visiteur)) {
$this->visiteurs->removeElement($visiteur);
// set the owning side to null (unless already changed)
if ($visiteur->getUser() === $this) {
$visiteur->setUser(null);
}
}
return $this;
}
/**
* @return Collection|PlaceDeMarche[]
*/
public function getPlaceDeMarches(): Collection
{
return $this->placeDeMarches;
}
public function addPlaceDeMarch(PlaceDeMarche $placeDeMarch): self
{
if (!$this->placeDeMarches->contains($placeDeMarch)) {
$this->placeDeMarches[] = $placeDeMarch;
$placeDeMarch->setUser($this);
}
return $this;
}
public function removePlaceDeMarch(PlaceDeMarche $placeDeMarch): self
{
if ($this->placeDeMarches->contains($placeDeMarch)) {
$this->placeDeMarches->removeElement($placeDeMarch);
// set the owning side to null (unless already changed)
if ($placeDeMarch->getUser() === $this) {
$placeDeMarch->setUser(null);
}
}
return $this;
}
/**
* @return Collection |RequeteDeFinancement[]
*/
public function getRequeteDeFinancements(): Collection
{
return $this->requeteDeFinancements;
}
public function addRequeteDeFinancement(RequeteDeFinancement $requeteDeFinancement): self
{
if (!$this->requeteDeFinancements->contains($requeteDeFinancement)) {
$this->requeteDeFinancements[] = $requeteDeFinancement;
$requeteDeFinancement->setUser($this);
}
return $this;
}
public function removeRequeteDeFinancement(RequeteDeFinancement $requeteDeFinancement): self
{
if ($this->requeteDeFinancements->contains($requeteDeFinancement)) {
$this->requeteDeFinancements->removeElement($requeteDeFinancement);
// set the owning side to null (unless already changed)
if ($requeteDeFinancement->getUser() === $this) {
$requeteDeFinancement->setUser(null);
}
}
return $this;
}
/**
* @return Collection|TraitementDsDemdDachat[]
*/
public function getTraitementDsDemdDachats(): Collection
{
return $this->traitementDsDemdDachats;
}
public function addTraitementDsDemdDachat(TraitementDsDemdDachat $traitementDsDemdDachat): self
{
if (!$this->traitementDsDemdDachats->contains($traitementDsDemdDachat)) {
$this->traitementDsDemdDachats[] = $traitementDsDemdDachat;
$traitementDsDemdDachat->setUser($this);
}
return $this;
}
public function removeTraitementDsDemdDachat(TraitementDsDemdDachat $traitementDsDemdDachat): self
{
if ($this->traitementDsDemdDachats->contains($traitementDsDemdDachat)) {
$this->traitementDsDemdDachats->removeElement($traitementDsDemdDachat);
// set the owning side to null (unless already changed)
if ($traitementDsDemdDachat->getUser() === $this) {
$traitementDsDemdDachat->setUser(null);
}
}
return $this;
}
public function getEmailPro(): ?string
{
return $this->email_pro;
}
public function setEmailPro(?string $email_pro): self
{
$this->email_pro = $email_pro;
return $this;
}
public function getFonction(): ?string
{
return $this->fonction;
}
public function setFonction(?string $fonction): self
{
$this->fonction = $fonction;
return $this;
}
public function getEntryAt(): ?\DateTimeInterface
{
return $this->entry_at;
}
public function setEntryAt(?\DateTimeInterface $entry_at): self
{
$this->entry_at = $entry_at;
return $this;
}
public function getPrenoms(): ?string
{
return $this->prenoms;
}
public function setPrenoms(?string $prenoms): self
{
$this->prenoms = $prenoms;
return $this;
}
public function getStatus(): ?UserStatus
{
return $this->status;
}
public function setStatus(?UserStatus $status): self
{
$this->status = $status;
return $this;
}
/**
* @return Collection|AdminDonneurOrdre[]
*/
public function getAdminDonneurOrdres(): Collection
{
return $this->adminDonneurOrdres;
}
public function addAdminDonneurOrdre(AdminDonneurOrdre $adminDonneurOrdre): self
{
if (!$this->adminDonneurOrdres->contains($adminDonneurOrdre)) {
$this->adminDonneurOrdres[] = $adminDonneurOrdre;
$adminDonneurOrdre->setLead($this);
}
return $this;
}
public function removeAdminDonneurOrdre(AdminDonneurOrdre $adminDonneurOrdre): self
{
if ($this->adminDonneurOrdres->contains($adminDonneurOrdre)) {
$this->adminDonneurOrdres->removeElement($adminDonneurOrdre);
// set the owning side to null (unless already changed)
if ($adminDonneurOrdre->getLead() === $this) {
$adminDonneurOrdre->setLead(null);
}
}
return $this;
}
/**
* @return Collection|AdminDonneurOrdre[]
*/
public function getAdminDonneurOrdresSuivi(): Collection
{
return $this->adminDonneurOrdres_suivi;
}
public function addAdminDonneurOrdresSuivi(AdminDonneurOrdre $adminDonneurOrdresSuivi): self
{
if (!$this->adminDonneurOrdres_suivi->contains($adminDonneurOrdresSuivi)) {
$this->adminDonneurOrdres_suivi[] = $adminDonneurOrdresSuivi;
$adminDonneurOrdresSuivi->setSuiviPar($this);
}
return $this;
}
public function removeAdminDonneurOrdresSuivi(AdminDonneurOrdre $adminDonneurOrdresSuivi): self
{
if ($this->adminDonneurOrdres_suivi->contains($adminDonneurOrdresSuivi)) {
$this->adminDonneurOrdres_suivi->removeElement($adminDonneurOrdresSuivi);
// set the owning side to null (unless already changed)
if ($adminDonneurOrdresSuivi->getSuiviPar() === $this) {
$adminDonneurOrdresSuivi->setSuiviPar(null);
}
}
return $this;
}
/**
* @return Collection|Document[]
*/
public function getDocuments(): Collection
{
return $this->documents;
}
public function addDocument(Document $documents): self
{
if (!$this->documents->contains($documents)) {
$this->documents[] = $documents;
$documents->setRedacteur($this);
}
return $this;
}
public function removeDocument(Document $documents): self
{
if ($this->documents->contains($documents)) {
$this->documents->removeElement($documents);
// set the owning side to null (unless already changed)
if ($documents->getRedacteur() === $this) {
$documents->setRedacteur(null);
}
}
return $this;
}
/**
* @return Collection|Document[]
*/
public function getDocumentApprouves(): Collection
{
return $this->documentApprouves;
}
public function addDocumentApprouves(Document $documentApprouves): self
{
if (!$this->documentApprouves->contains($documentApprouves)) {
$this->documentApprouves[] = $documentApprouves;
$documentApprouves->setApprouverPar($this);
}
return $this;
}
public function removeDocumentApprouves(Document $documentApprouves): self
{
if ($this->documentApprouves->contains($documentApprouves)) {
$this->documentApprouves->removeElement($documentApprouves);
// set the owning side to null (unless already changed)
if ($documentApprouves->getApprouverPar() === $this) {
$documentApprouves->setApprouverPar(null);
}
}
return $this;
}
/**
* @return Collection|LeveeDeFond[]
*/
public function getLeveeDeFonds(): Collection
{
return $this->leveeDeFonds;
}
public function addLeveeDeFond(LeveeDeFond $leveeDeFond): self
{
if (!$this->leveeDeFonds->contains($leveeDeFond)) {
$this->leveeDeFonds[] = $leveeDeFond;
$leveeDeFond->setSuviPar($this);
}
return $this;
}
public function removeLeveeDeFond(LeveeDeFond $leveeDeFond): self
{
if ($this->leveeDeFonds->contains($leveeDeFond)) {
$this->leveeDeFonds->removeElement($leveeDeFond);
// set the owning side to null (unless already changed)
if ($leveeDeFond->getSuviPar() === $this) {
$leveeDeFond->setSuviPar(null);
}
}
return $this;
}
public function __toString(): string
{
return $this->name;
}
public function getDateSortie(): ?\DateTimeInterface
{
return $this->date_sortie;
}
public function setDateSortie(?\DateTimeInterface $date_sortie): self
{
$this->date_sortie = $date_sortie;
return $this;
}
/**
* @return Collection|LetterOfIntentToPurchase[]
*/
public function getLetterOfIntentToPurchases(): Collection
{
return $this->letterOfIntentToPurchases;
}
public function addLetterOfIntentToPurchase(LetterOfIntentToPurchase $letterOfIntentToPurchase): self
{
if (!$this->letterOfIntentToPurchases->contains($letterOfIntentToPurchase)) {
$this->letterOfIntentToPurchases[] = $letterOfIntentToPurchase;
$letterOfIntentToPurchase->setAgent($this);
}
return $this;
}
public function removeLetterOfIntentToPurchase(LetterOfIntentToPurchase $letterOfIntentToPurchase): self
{
if ($this->letterOfIntentToPurchases->contains($letterOfIntentToPurchase)) {
$this->letterOfIntentToPurchases->removeElement($letterOfIntentToPurchase);
// set the owning side to null (unless already changed)
if ($letterOfIntentToPurchase->getAgent() === $this) {
$letterOfIntentToPurchase->setAgent(null);
}
}
return $this;
}
/**
* @return Collection|LetterOfIntentToPurchase[]
*/
public function getSuivipars(): Collection
{
return $this->suivipars;
}
public function addSuivipar(LetterOfIntentToPurchase $suivipar): self
{
if (!$this->suivipars->contains($suivipar)) {
$this->suivipars[] = $suivipar;
$suivipar->setSuivipar($this);
}
return $this;
}
public function removeSuivipar(LetterOfIntentToPurchase $suivipar): self
{
if ($this->suivipars->contains($suivipar)) {
$this->suivipars->removeElement($suivipar);
// set the owning side to null (unless already changed)
if ($suivipar->getSuivipar() === $this) {
$suivipar->setSuivipar(null);
}
}
return $this;
}
/**
* @return Collection|TraitementDsDemdDachat[]
*/
public function getAgent(): Collection
{
return $this->agent;
}
public function addAgent(TraitementDsDemdDachat $agent): self
{
if (!$this->agent->contains($agent)) {
$this->agent[] = $agent;
$agent->setAgent($this);
}
return $this;
}
public function removeAgent(TraitementDsDemdDachat $agent): self
{
if ($this->agent->contains($agent)) {
$this->agent->removeElement($agent);
// set the owning side to null (unless already changed)
if ($agent->getAgent() === $this) {
$agent->setAgent(null);
}
}
return $this;
}
/**
* @return Collection|DemandeDeCotation[]
*/
public function getDemandeDeCotations(): Collection
{
return $this->demandeDeCotations;
}
public function addDemandeDeCotation(DemandeDeCotation $demandeDeCotation): self
{
if (!$this->demandeDeCotations->contains($demandeDeCotation)) {
$this->demandeDeCotations[] = $demandeDeCotation;
$demandeDeCotation->setUser($this);
}
return $this;
}
public function removeDemandeDeCotation(DemandeDeCotation $demandeDeCotation): self
{
if ($this->demandeDeCotations->contains($demandeDeCotation)) {
$this->demandeDeCotations->removeElement($demandeDeCotation);
// set the owning side to null (unless already changed)
if ($demandeDeCotation->getUser() === $this) {
$demandeDeCotation->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Prospect[]
*/
public function getProspects(): Collection
{
return $this->prospects;
}
public function addProspect(Prospect $prospect): self
{
if (!$this->prospects->contains($prospect)) {
$this->prospects[] = $prospect;
$prospect->setSuiviPar($this);
}
return $this;
}
public function removeProspect(Prospect $prospect): self
{
if ($this->prospects->contains($prospect)) {
$this->prospects->removeElement($prospect);
// set the owning side to null (unless already changed)
if ($prospect->getSuiviPar() === $this) {
$prospect->setSuiviPar(null);
}
}
return $this;
}
}